All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] drm: Add plane color matrix on rockchip
@ 2018-02-15  5:32 Daniele Castagna
  2018-02-15  5:32 ` [PATCH 01/10] drm/rockchip: YUV overlays BT.601 color conversion Daniele Castagna
                   ` (10 more replies)
  0 siblings, 11 replies; 44+ messages in thread
From: Daniele Castagna @ 2018-02-15  5:32 UTC (permalink / raw)
  To: dri-devel

Hello,
this patch series adds a per plane color matrix property as well as an
implementation for rockchip.

This patch series builds on and includes previous work done by uma.shankar:
https://lists.freedesktop.org/archives/dri-devel/2017-September/153347.html

The first rockchip patch of this series sets a BT.601 color conversion
matrix for YUV formats and is included because it adds YUV2YUV registers that
the rest of the color matrix rockchip implementation depends upon.

The next patches are the ones originally provided by uma.shankar,
rebased and containing an additional small fix.

The final set of rockchip patches implement, and finally enable, the plane CTM
property on rockchip.

These patches have been rebased on drm-next (80daf42f97b1a0503d029f3c1325),
Unfortunately I haven't been able to test them after rebasing because the
display doesn't come up when I push a kernel built from drm-next on a device.

Daniele Castagna (5):
  drm/rockchip: YUV overlays BT.601 color conversion.
  drm/rockchip: Add yuv2yuv registers to vop_lit
  drm/rockchip: Add R2R registers
  drm/rockchip: Implement drm plane->ctm property.
  drm/rockchip: Enable 'PLANE_CTM' drm property.

uma.shankar at intel.com (Uma Shankar) (5):
  drm: Add Plane Degamma properties
  drm: Add Plane CTM property
  drm: Add Plane Gamma properties
  drm: Define helper function for plane color enabling
  drm: Define helper to set legacy gamma table size

 drivers/gpu/drm/drm_atomic.c                | 30 +++++++
 drivers/gpu/drm/drm_atomic_helper.c         | 14 ++++
 drivers/gpu/drm/drm_color_mgmt.c            | 41 ++++++++++
 drivers/gpu/drm/drm_mode_config.c           | 34 ++++++++
 drivers/gpu/drm/drm_plane.c                 | 48 +++++++++++
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 90 ++++++++++++++++++++-
 drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 16 ++++
 drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 88 +++++++++++++++++++-
 include/drm/drm_color_mgmt.h                |  8 ++
 include/drm/drm_mode_config.h               | 27 +++++++
 include/drm/drm_plane.h                     | 31 +++++++
 11 files changed, 424 insertions(+), 3 deletions(-)

-- 
2.16.1.291.g4437f3f132-goog

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH 01/10] drm/rockchip: YUV overlays BT.601 color conversion.
  2018-02-15  5:32 [PATCH 00/10] drm: Add plane color matrix on rockchip Daniele Castagna
@ 2018-02-15  5:32 ` Daniele Castagna
  2018-02-16 17:55   ` kbuild test robot
                     ` (2 more replies)
  2018-02-15  5:32 ` [PATCH 02/10] drm: Add Plane Degamma properties Daniele Castagna
                   ` (9 subsequent siblings)
  10 siblings, 3 replies; 44+ messages in thread
From: Daniele Castagna @ 2018-02-15  5:32 UTC (permalink / raw)
  To: dri-devel

Currently NV12 hardware overlays scheduled with atomic interface are
converted to RGB using a color space conversion different than BT.601.

The result is that colors of NV12 buffers composited with Mali don't
match colors of YUV hardware overlays.

Running modetest with an NV12 plane also shows colors are incorrect
if compared to an RGB overlay that represents the same color pattern.

This CL adds support for YUV2YUV color space conversion (CSC) module on
rockchip and enables the YUV2RGB part that allows to specify a 4x3
matrix to convert the colors.

The matrix is set to BT.601 coefficients to align to Mali and to what
modetest expects.

TEST=modetest -M rockchip -s 34@30:2400x1600 -P 30:640x480+650+10@NV12 -P 30:640x480+10+10@XR24

Change-Id: Ia5a3b4793229e2c63f79f9f414d1cbe6ccc63fc1
Tested-by: Daniele Castagna <dcastagna@chromium.org>
Reviewed-by: Daniele Castagna <dcastagna@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@chromium.org>
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 40 ++++++++++++++++++++-
 drivers/gpu/drm/rockchip/rockchip_drm_vop.h |  9 +++++
 drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 39 ++++++++++++++++++--
 3 files changed, 85 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index ba7505292b786..ea43ab797f555 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -50,6 +50,10 @@
 		vop_reg_set(vop, &win->phy->scl->ext->name, \
 			    win->base, ~0, v, #name)
 
+#define VOP_YUV2YUV_SET(x, name, v) \
+		if ((x)->data->yuv2yuv) \
+			vop_reg_set(vop, &vop->data->yuv2yuv->name, 0, ~0, v, #name)
+
 #define VOP_INTR_SET_MASK(vop, name, mask, v) \
 		vop_reg_set(vop, &vop->data->intr->name, 0, mask, v, #name)
 
@@ -79,6 +83,18 @@
 #define to_vop(x) container_of(x, struct vop, crtc)
 #define to_vop_win(x) container_of(x, struct vop_win, base)
 
+/*
+ * The coefficients of the following matrix are all fixed points.
+ * The format is S2.10 for the 3x3 part of the matrix, and S9.12 for the offsets.
+ * They are all represented in two's complement.
+ */
+static const uint32_t bt601_yuv2rgb[] = {
+	0x4A8, 0x0,    0x662,
+	0x4A8, 0x1E6F, 0x1CBF,
+	0x4A8, 0x812,  0x0,
+	0x321168, 0x0877CF, 0x2EB127
+};
+
 enum vop_pending {
 	VOP_PENDING_FB_UNREF,
 };
@@ -722,6 +738,9 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
 	uint32_t val;
 	bool rb_swap;
 	int format;
+	int is_yuv = is_yuv_support(fb->format->format);
+	int win_index = VOP_WIN_TO_INDEX(vop_win);
+	int i;
 
 	/*
 	 * can't update plane when vop is disabled.
@@ -762,7 +781,14 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
 	VOP_WIN_SET(vop, win, format, format);
 	VOP_WIN_SET(vop, win, yrgb_vir, DIV_ROUND_UP(fb->pitches[0], 4));
 	VOP_WIN_SET(vop, win, yrgb_mst, dma_addr);
-	if (is_yuv_support(fb->format->format)) {
+
+	if (!win_index) {
+		VOP_YUV2YUV_SET(vop, win0_y2r_en, is_yuv);
+	} else if (win_index == 1) {
+		VOP_YUV2YUV_SET(vop, win1_y2r_en, is_yuv);
+	}
+
+	if (is_yuv) {
 		int hsub = drm_format_horz_chroma_subsampling(fb->format->format);
 		int vsub = drm_format_vert_chroma_subsampling(fb->format->format);
 		int bpp = fb->format->cpp[1];
@@ -776,6 +802,18 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
 		dma_addr = rk_uv_obj->dma_addr + offset + fb->offsets[1];
 		VOP_WIN_SET(vop, win, uv_vir, DIV_ROUND_UP(fb->pitches[1], 4));
 		VOP_WIN_SET(vop, win, uv_mst, dma_addr);
+
+		for (i = 0; i < 12; i++) {
+			if (!win_index) {
+				VOP_YUV2YUV_SET(vop,
+						win0_y2r_coefficients[i],
+						bt601_yuv2rgb[i]);
+			} else {
+				VOP_YUV2YUV_SET(vop,
+						win1_y2r_coefficients[i],
+						bt601_yuv2rgb[i]);
+			}
+		}
 	}
 
 	if (win->phy->scl)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
index 56bbd2e2a8efb..aa8a5d2690376 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
@@ -79,6 +79,14 @@ struct vop_misc {
 	struct vop_reg global_regdone_en;
 };
 
+struct vop_yuv2yuv {
+	struct vop_reg win0_y2r_en;
+	struct vop_reg win0_y2r_coefficients[12];
+
+	struct vop_reg win1_y2r_en;
+	struct vop_reg win1_y2r_coefficients[12];
+};
+
 struct vop_intr {
 	const int *intrs;
 	uint32_t nintrs;
@@ -157,6 +165,7 @@ struct vop_data {
 	const struct vop_misc *misc;
 	const struct vop_modeset *modeset;
 	const struct vop_output *output;
+	const struct vop_yuv2yuv *yuv2yuv;
 	const struct vop_win_data *win;
 	unsigned int win_size;
 
diff --git a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
index 2e4eea3459fe6..be9c414e2e4bc 100644
--- a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
+++ b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
@@ -422,6 +422,40 @@ static const struct vop_output rk3399_output = {
 	.mipi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 15),
 };
 
+static const struct vop_yuv2yuv rk3399_vop_yuv2yuv = {
+	.win0_y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 1),
+	.win0_y2r_coefficients = {
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 0, 0xffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 0, 0xffff, 16),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 4, 0xffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 4, 0xffff, 16),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 8, 0xffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 8, 0xffff, 16),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 12, 0xffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 12, 0xffff, 16),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 16, 0xffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 20, 0xffffffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 24, 0xffffffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 28, 0xffffffff, 0),
+	},
+
+	.win1_y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 9),
+	.win1_y2r_coefficients = {
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 0, 0xffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 0, 0xffff, 16),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 4, 0xffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 4, 0xffff, 16),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 8, 0xffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 8, 0xffff, 16),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 12, 0xffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 12, 0xffff, 16),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 16, 0xffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 20, 0xffffffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 24, 0xffffffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 28, 0xffffffff, 0),
+	},
+};
+
 static const struct vop_data rk3399_vop_big = {
 	.version = VOP_VERSION(3, 5),
 	.feature = VOP_FEATURE_OUTPUT_RGB10,
@@ -430,8 +464,9 @@ static const struct vop_data rk3399_vop_big = {
 	.modeset = &rk3288_modeset,
 	.output = &rk3399_output,
 	.misc = &rk3368_misc,
-	.win = rk3368_vop_win_data,
-	.win_size = ARRAY_SIZE(rk3368_vop_win_data),
+	.yuv2yuv = &rk3399_vop_yuv2yuv,
+	.win = rk3399_vop_win_data,
+	.win_size = ARRAY_SIZE(rk3399_vop_win_data),
 };
 
 static const struct vop_win_data rk3399_vop_lit_win_data[] = {
-- 
2.16.1.291.g4437f3f132-goog

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 02/10] drm: Add Plane Degamma properties
  2018-02-15  5:32 [PATCH 00/10] drm: Add plane color matrix on rockchip Daniele Castagna
  2018-02-15  5:32 ` [PATCH 01/10] drm/rockchip: YUV overlays BT.601 color conversion Daniele Castagna
@ 2018-02-15  5:32 ` Daniele Castagna
  2018-02-16 19:38   ` kbuild test robot
                     ` (2 more replies)
  2018-02-15  5:32 ` [PATCH 03/10] drm: Add Plane CTM property Daniele Castagna
                   ` (8 subsequent siblings)
  10 siblings, 3 replies; 44+ messages in thread
From: Daniele Castagna @ 2018-02-15  5:32 UTC (permalink / raw)
  To: dri-devel

From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>

Add Plane Degamma as a blob property and plane
degamma size as a range property.

(am from https://patchwork.kernel.org/patch/10046515/)

Change-Id: Iaead6f944a8b677227d1be11169f46178de533b1
Signed-off-by: Uma Shankar <uma.shankar at intel.com>
---
 drivers/gpu/drm/drm_atomic.c        | 12 ++++++++++++
 drivers/gpu/drm/drm_atomic_helper.c |  7 +++++++
 drivers/gpu/drm/drm_mode_config.c   | 14 ++++++++++++++
 include/drm/drm_mode_config.h       | 10 ++++++++++
 include/drm/drm_plane.h             | 10 ++++++++++
 5 files changed, 53 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index b76d49218cf1d..4a06ff2fd1a5e 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -717,6 +717,8 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
 {
 	struct drm_device *dev = plane->dev;
 	struct drm_mode_config *config = &dev->mode_config;
+	bool replaced = false;
+	int ret;
 
 	if (property == config->prop_fb_id) {
 		struct drm_framebuffer *fb = drm_framebuffer_lookup(dev, NULL, val);
@@ -762,6 +764,12 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
 	} else if (plane->funcs->atomic_set_property) {
 		return plane->funcs->atomic_set_property(plane, state,
 				property, val);
+	} else if (property == config->plane_degamma_lut_property) {
+		ret = drm_atomic_replace_property_blob_from_id(dev,
+					&state->degamma_lut,
+					val, -1, &replaced);
+		state->color_mgmt_changed |= replaced;
+		return ret;
 	} else {
 		return -EINVAL;
 	}
@@ -820,6 +828,9 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
 		*val = state->zpos;
 	} else if (plane->funcs->atomic_get_property) {
 		return plane->funcs->atomic_get_property(plane, state, property, val);
+	} else if (property == config->plane_degamma_lut_property) {
+		*val = (state->degamma_lut) ?
+			state->degamma_lut->base.id : 0;
 	} else {
 		return -EINVAL;
 	}
@@ -944,6 +955,7 @@ static void drm_atomic_plane_print_state(struct drm_printer *p,
 	drm_printf(p, "\tcrtc-pos=" DRM_RECT_FMT "\n", DRM_RECT_ARG(&dest));
 	drm_printf(p, "\tsrc-pos=" DRM_RECT_FP_FMT "\n", DRM_RECT_FP_ARG(&src));
 	drm_printf(p, "\trotation=%x\n", state->rotation);
+	drm_printf(p, "\tcolor_mgmt_changed=%d\n", state->color_mgmt_changed);
 
 	if (plane->funcs->atomic_print_state)
 		plane->funcs->atomic_print_state(p, state);
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index ab4032167094c..d3eaf4d397681 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -3488,7 +3488,12 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
 		drm_framebuffer_get(state->fb);
 
 	state->fence = NULL;
+
 	state->commit = NULL;
+
+	if (state->degamma_lut)
+		drm_property_reference_blob(state->degamma_lut);
+	state->color_mgmt_changed = false;
 }
 EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state);
 
@@ -3533,6 +3538,8 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)
 
 	if (state->commit)
 		drm_crtc_commit_put(state->commit);
+
+	drm_property_unreference_blob(state->degamma_lut);
 }
 EXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state);
 
diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index e5c653357024d..7d8e74715b565 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -348,6 +348,20 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
 		return -ENOMEM;
 	dev->mode_config.modifiers_property = prop;
 
+	prop = drm_property_create(dev,
+			DRM_MODE_PROP_BLOB,
+			"PLANE_DEGAMMA_LUT", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.plane_degamma_lut_property = prop;
+
+	prop = drm_property_create_range(dev,
+			DRM_MODE_PROP_IMMUTABLE,
+			"PLANE_DEGAMMA_LUT_SIZE", 0, UINT_MAX);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.plane_degamma_lut_size_property = prop;
+
 	return 0;
 }
 
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index 2cb6f02df64ab..dcec93d062b4d 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -724,6 +724,16 @@ struct drm_mode_config {
 	 * the degamma LUT as supported by the driver (read-only).
 	 */
 	struct drm_property *degamma_lut_size_property;
+ 	/**
+	 * @plane_degamma_lut_property: Optional Plane property to set the LUT
+	 * used to convert the framebuffer's colors to linear gamma.
+	 */
+	struct drm_property *plane_degamma_lut_property;
+	/**
+	 * @plane_degamma_lut_size_property: Optional Plane property for the
+	 * size of the degamma LUT as supported by the driver (read-only).
+	 */
+	struct drm_property *plane_degamma_lut_size_property;
 	/**
 	 * @ctm_property: Optional CRTC property to set the
 	 * matrix used to convert colors after the lookup in the
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 8185e3468a231..2f8f5db77a406 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -131,7 +131,17 @@ struct drm_plane_state {
 	 */
 	struct drm_crtc_commit *commit;
 
+	/* @degamma_lut:
+	 *
+	 * Lookup table for converting framebuffer pixel data before apply the
+	 * color conversion matrix @ctm. See drm_plane_enable_color_mgmt(). The
+	 * blob (if not NULL) is an array of &struct drm_color_lut.
+	 */
+	struct drm_property_blob *degamma_lut;
+
 	struct drm_atomic_state *state;
+
+	bool color_mgmt_changed : 1;
 };
 
 static inline struct drm_rect
-- 
2.16.1.291.g4437f3f132-goog

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 03/10] drm: Add Plane CTM property
  2018-02-15  5:32 [PATCH 00/10] drm: Add plane color matrix on rockchip Daniele Castagna
  2018-02-15  5:32 ` [PATCH 01/10] drm/rockchip: YUV overlays BT.601 color conversion Daniele Castagna
  2018-02-15  5:32 ` [PATCH 02/10] drm: Add Plane Degamma properties Daniele Castagna
@ 2018-02-15  5:32 ` Daniele Castagna
  2018-02-27 15:22   ` Sean Paul
  2018-02-15  5:32 ` [PATCH 04/10] drm: Add Plane Gamma properties Daniele Castagna
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 44+ messages in thread
From: Daniele Castagna @ 2018-02-15  5:32 UTC (permalink / raw)
  To: dri-devel

From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>

Add a blob property for plane CSC usage.

(am from https://patchwork.kernel.org/patch/9971339/)

Change-Id: I688ce7c95c20d307cb0aa35c5eba5ce2e1e88314
Signed-off-by: Uma Shankar <uma.shankar at intel.com>
---
 drivers/gpu/drm/drm_atomic.c        | 10 ++++++++++
 drivers/gpu/drm/drm_atomic_helper.c |  3 +++
 drivers/gpu/drm/drm_mode_config.c   |  6 ++++++
 include/drm/drm_mode_config.h       |  6 ++++++
 include/drm/drm_plane.h             |  8 ++++++++
 5 files changed, 33 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 4a06ff2fd1a5e..d4b8c6cc84128 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -770,6 +770,14 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
 					val, -1, &replaced);
 		state->color_mgmt_changed |= replaced;
 		return ret;
+	} else if (property == config->plane_ctm_property) {
+		ret = drm_atomic_replace_property_blob_from_id(dev,
+					&state->ctm,
+					val,
+					sizeof(struct drm_color_ctm),
+					&replaced);
+		state->color_mgmt_changed |= replaced;
+		return ret;
 	} else {
 		return -EINVAL;
 	}
@@ -831,6 +839,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
 	} else if (property == config->plane_degamma_lut_property) {
 		*val = (state->degamma_lut) ?
 			state->degamma_lut->base.id : 0;
+	} else if (property == config->plane_ctm_property) {
+		*val = (state->ctm) ? state->ctm->base.id : 0;
 	} else {
 		return -EINVAL;
 	}
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index d3eaf4d397681..17e137a529a0e 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -3493,6 +3493,8 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
 
 	if (state->degamma_lut)
 		drm_property_reference_blob(state->degamma_lut);
+	if (state->ctm)
+		drm_property_reference_blob(state->ctm);
 	state->color_mgmt_changed = false;
 }
 EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state);
@@ -3540,6 +3542,7 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)
 		drm_crtc_commit_put(state->commit);
 
 	drm_property_unreference_blob(state->degamma_lut);
+	drm_property_unreference_blob(state->ctm);
 }
 EXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state);
 
diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index 7d8e74715b565..c8763977413e7 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -361,6 +361,12 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
 	if (!prop)
 		return -ENOMEM;
 	dev->mode_config.plane_degamma_lut_size_property = prop;
+	prop = drm_property_create(dev,
+			DRM_MODE_PROP_BLOB,
+			"PLANE_CTM", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.plane_ctm_property = prop;
 
 	return 0;
 }
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index dcec93d062b4d..ad7235ced531b 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -734,6 +734,12 @@ struct drm_mode_config {
 	 * size of the degamma LUT as supported by the driver (read-only).
 	 */
 	struct drm_property *plane_degamma_lut_size_property;
+	/**
+	 * @plane_ctm_property: Optional CRTC property to set the
+	 * matrix used to convert colors after the lookup in the
+	 * degamma LUT.
+	 */
+	struct drm_property *plane_ctm_property;
 	/**
 	 * @ctm_property: Optional CRTC property to set the
 	 * matrix used to convert colors after the lookup in the
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 2f8f5db77a406..21aecc9c91a09 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -139,6 +139,14 @@ struct drm_plane_state {
 	 */
 	struct drm_property_blob *degamma_lut;
 
+ 	/**
+	 * @ctm:
+	 *
+	 * Color transformation matrix. See drm_plane_enable_color_mgmt(). The
+	 * blob (if not NULL) is a &struct drm_color_ctm.
+	 */
+	struct drm_property_blob *ctm;
+
 	struct drm_atomic_state *state;
 
 	bool color_mgmt_changed : 1;
-- 
2.16.1.291.g4437f3f132-goog

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 04/10] drm: Add Plane Gamma properties
  2018-02-15  5:32 [PATCH 00/10] drm: Add plane color matrix on rockchip Daniele Castagna
                   ` (2 preceding siblings ...)
  2018-02-15  5:32 ` [PATCH 03/10] drm: Add Plane CTM property Daniele Castagna
@ 2018-02-15  5:32 ` Daniele Castagna
  2018-02-15 19:29   ` Harry Wentland
                     ` (2 more replies)
  2018-02-15  5:32 ` [PATCH 05/10] drm: Define helper function for plane color enabling Daniele Castagna
                   ` (6 subsequent siblings)
  10 siblings, 3 replies; 44+ messages in thread
From: Daniele Castagna @ 2018-02-15  5:32 UTC (permalink / raw)
  To: dri-devel

From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>

Add plane gamma as blob property and size as a
range property.

(am from https://patchwork.kernel.org/patch/9971325/)

Change-Id: I606cd40c9748b136fc2bf4750bea1da285add62d
Signed-off-by: Uma Shankar <uma.shankar at intel.com>
---
 drivers/gpu/drm/drm_atomic.c        |  8 ++++++++
 drivers/gpu/drm/drm_atomic_helper.c |  4 ++++
 drivers/gpu/drm/drm_mode_config.c   | 14 ++++++++++++++
 include/drm/drm_mode_config.h       | 11 +++++++++++
 include/drm/drm_plane.h             |  9 +++++++++
 5 files changed, 46 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index d4b8c6cc84128..f634f6450f415 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -778,6 +778,12 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
 					&replaced);
 		state->color_mgmt_changed |= replaced;
 		return ret;
+	} else if (property == config->plane_gamma_lut_property) {
+		ret = drm_atomic_replace_property_blob_from_id(dev,
+					&state->gamma_lut,
+					val, -1, &replaced);
+		state->color_mgmt_changed |= replaced;
+		return ret;
 	} else {
 		return -EINVAL;
 	}
@@ -841,6 +847,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
 			state->degamma_lut->base.id : 0;
 	} else if (property == config->plane_ctm_property) {
 		*val = (state->ctm) ? state->ctm->base.id : 0;
+	} else if (property == config->plane_gamma_lut_property) {
+		*val = (state->gamma_lut) ? state->gamma_lut->base.id : 0;
 	} else {
 		return -EINVAL;
 	}
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 17e137a529a0e..97dbb36153d14 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -3495,6 +3495,9 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
 		drm_property_reference_blob(state->degamma_lut);
 	if (state->ctm)
 		drm_property_reference_blob(state->ctm);
+	if (state->gamma_lut)
+		drm_property_reference_blob(state->gamma_lut);
+
 	state->color_mgmt_changed = false;
 }
 EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state);
@@ -3543,6 +3546,7 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)
 
 	drm_property_unreference_blob(state->degamma_lut);
 	drm_property_unreference_blob(state->ctm);
+	drm_property_unreference_blob(state->gamma_lut);
 }
 EXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state);
 
diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index c8763977413e7..bc6f8e51c7464 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -368,6 +368,20 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
 		return -ENOMEM;
 	dev->mode_config.plane_ctm_property = prop;
 
+	prop = drm_property_create(dev,
+			DRM_MODE_PROP_BLOB,
+			"PLANE_GAMMA_LUT", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.plane_gamma_lut_property = prop;
+
+	prop = drm_property_create_range(dev,
+			DRM_MODE_PROP_IMMUTABLE,
+			"PLANE_GAMMA_LUT_SIZE", 0, UINT_MAX);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.plane_gamma_lut_size_property = prop;
+
 	return 0;
 }
 
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index ad7235ced531b..3ca3eb3c98950 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -740,6 +740,17 @@ struct drm_mode_config {
 	 * degamma LUT.
 	 */
 	struct drm_property *plane_ctm_property;
+	/**
+	 * @plane_gamma_lut_property: Optional Plane property to set the LUT
+	 * used to convert the colors, after the CTM matrix, to the common
+	 * gamma space chosen for blending.
+	 */
+	struct drm_property *plane_gamma_lut_property;
+	/**
+	 * @plane_gamma_lut_size_property: Optional Plane property for the size
+	 * of the gamma LUT as supported by the driver (read-only).
+	 */
+	struct drm_property *plane_gamma_lut_size_property;
 	/**
 	 * @ctm_property: Optional CRTC property to set the
 	 * matrix used to convert colors after the lookup in the
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 21aecc9c91a09..acabb85009a14 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -147,6 +147,15 @@ struct drm_plane_state {
 	 */
 	struct drm_property_blob *ctm;
 
+	/**
+	 * @gamma_lut:
+	 *
+	 * Lookup table for converting pixel data after the color conversion
+	 * matrix @ctm.  See drm_plane_enable_color_mgmt(). The blob (if not
+	 * NULL) is an array of &struct drm_color_lut.
+	 */
+	struct drm_property_blob *gamma_lut;
+
 	struct drm_atomic_state *state;
 
 	bool color_mgmt_changed : 1;
-- 
2.16.1.291.g4437f3f132-goog

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 05/10] drm: Define helper function for plane color enabling
  2018-02-15  5:32 [PATCH 00/10] drm: Add plane color matrix on rockchip Daniele Castagna
                   ` (3 preceding siblings ...)
  2018-02-15  5:32 ` [PATCH 04/10] drm: Add Plane Gamma properties Daniele Castagna
@ 2018-02-15  5:32 ` Daniele Castagna
  2018-02-27 15:28   ` Sean Paul
  2018-02-15  5:32 ` [PATCH 06/10] drm: Define helper to set legacy gamma table size Daniele Castagna
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 44+ messages in thread
From: Daniele Castagna @ 2018-02-15  5:32 UTC (permalink / raw)
  To: dri-devel

From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>

Define helper function to enable Plane color features
to attach plane color properties to plane structure.

(am from https://patchwork.kernel.org/patch/9971333/)

Change-Id: I0a6647607fe482786e7cdb5f997faf196b2f59a2
Signed-off-by: Uma Shankar <uma.shankar at intel.com>
---
 drivers/gpu/drm/drm_plane.c  | 48 ++++++++++++++++++++++++++++++++++++
 include/drm/drm_color_mgmt.h |  5 ++++
 2 files changed, 53 insertions(+)

diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 2c90519576a3e..bc2fc5e6771ac 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -143,6 +143,54 @@ static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane
 	return 0;
 }
 
+ /**
+ * drm_plane_enable_color_mgmt - enable color management properties
+ * @plane: DRM Plane
+ * @plane_degamma_lut_size: the size of the degamma lut (before CSC)
+ * @plane_has_ctm: whether to attach ctm_property for CSC matrix
+ * @plane_gamma_lut_size: the size of the gamma lut (after CSC)
+ *
+ * This function lets the driver enable the color correction
+ * properties on a plane. This includes 3 degamma, csc and gamma
+ * properties that userspace can set and 2 size properties to inform
+ * the userspace of the lut sizes. Each of the properties are
+ * optional. The gamma and degamma properties are only attached if
+ * their size is not 0 and ctm_property is only attached if has_ctm is
+ * true.
+ *
+ * Drivers should use drm_atomic_helper_legacy_gamma_set() to implement the
+ * legacy &drm_crtc_funcs.gamma_set callback.
+ */
+void drm_plane_enable_color_mgmt(struct drm_plane *plane,
+				uint plane_degamma_lut_size,
+				bool plane_has_ctm,
+				uint plane_gamma_lut_size)
+{
+	struct drm_device *dev = plane->dev;
+	struct drm_mode_config *config = &dev->mode_config;
+
+	if (plane_degamma_lut_size) {
+		drm_object_attach_property(&plane->base,
+				config->plane_degamma_lut_property, 0);
+		drm_object_attach_property(&plane->base,
+				config->plane_degamma_lut_size_property,
+				plane_degamma_lut_size);
+	}
+
+	if (plane_has_ctm)
+		drm_object_attach_property(&plane->base,
+				config->plane_ctm_property, 0);
+
+	if (plane_gamma_lut_size) {
+		drm_object_attach_property(&plane->base,
+				config->plane_gamma_lut_property, 0);
+		drm_object_attach_property(&plane->base,
+				config->plane_gamma_lut_size_property,
+				plane_gamma_lut_size);
+	}
+}
+EXPORT_SYMBOL(drm_plane_enable_color_mgmt);
+
 /**
  * drm_universal_plane_init - Initialize a new universal plane object
  * @dev: DRM device
diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
index 03a59cbce6212..155a9ba38471c 100644
--- a/include/drm/drm_color_mgmt.h
+++ b/include/drm/drm_color_mgmt.h
@@ -37,4 +37,9 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
 int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
 				 int gamma_size);
 
+void drm_plane_enable_color_mgmt(struct drm_plane *plane,
+				 uint plane_degamma_lut_size,
+				 bool plane_has_ctm,
+				 uint plane_gamma_lut_size);
+
 #endif
-- 
2.16.1.291.g4437f3f132-goog

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 06/10] drm: Define helper to set legacy gamma table size
  2018-02-15  5:32 [PATCH 00/10] drm: Add plane color matrix on rockchip Daniele Castagna
                   ` (4 preceding siblings ...)
  2018-02-15  5:32 ` [PATCH 05/10] drm: Define helper function for plane color enabling Daniele Castagna
@ 2018-02-15  5:32 ` Daniele Castagna
  2018-02-16 22:17   ` kbuild test robot
                     ` (2 more replies)
  2018-02-15  5:32 ` [PATCH 07/10] drm/rockchip: Add yuv2yuv registers to vop_lit Daniele Castagna
                   ` (4 subsequent siblings)
  10 siblings, 3 replies; 44+ messages in thread
From: Daniele Castagna @ 2018-02-15  5:32 UTC (permalink / raw)
  To: dri-devel

From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>

Define a helper function to set legacy gamma table
size for planes.

(am from https://patchwork.kernel.org/patch/9971343/)

Change-Id: I3d0c3e71d92300259cdfcebed4349207f64e4083
Signed-off-by: Uma Shankar <uma.shankar at intel.com>
---
 drivers/gpu/drm/drm_color_mgmt.c | 41 ++++++++++++++++++++++++++++++++
 include/drm/drm_color_mgmt.h     |  3 +++
 include/drm/drm_plane.h          |  4 ++++
 3 files changed, 48 insertions(+)

diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index 0d002b045bd26..8f360b3ae0f24 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -203,6 +203,47 @@ int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
 }
 EXPORT_SYMBOL(drm_mode_crtc_set_gamma_size);
 
+/**
+ * drm_mode_plane_set_gamma_size - set the gamma table size
+ * @plane: Plane to set the gamma table size for
+ * @gamma_size: size of the gamma table
+ *
+ * Drivers which support gamma tables should set this to the supported gamma
+ * table size when initializing the Plane. Currently the drm core only supports
+ * a fixed gamma table size.
+ *
+ * Returns:
+ * Zero on success, negative errno on failure.
+ */
+int drm_mode_plane_set_gamma_size(struct drm_plane *plane,
+				int gamma_size)
+{
+	uint16_t *r_base, *g_base, *b_base;
+	int i;
+
+	plane->gamma_size = gamma_size;
+
+	plane->gamma_store = kcalloc(gamma_size, sizeof(uint16_t) * 3,
+			GFP_KERNEL);
+	if (!plane->gamma_store) {
+		plane->gamma_size = 0;
+		return -ENOMEM;
+	}
+
+	r_base = plane->gamma_store;
+	g_base = r_base + gamma_size;
+	b_base = g_base + gamma_size;
+	for (i = 0; i < gamma_size; i++) {
+		r_base[i] = i << 8;
+		g_base[i] = i << 8;
+		b_base[i] = i << 8;
+	}
+
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_mode_plane_set_gamma_size);
+
 /**
  * drm_mode_gamma_set_ioctl - set the gamma table
  * @dev: DRM device
diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
index 155a9ba38471c..2f59c820e148c 100644
--- a/include/drm/drm_color_mgmt.h
+++ b/include/drm/drm_color_mgmt.h
@@ -42,4 +42,7 @@ void drm_plane_enable_color_mgmt(struct drm_plane *plane,
 				 bool plane_has_ctm,
 				 uint plane_gamma_lut_size);
 
+int drm_mode_plane_set_gamma_size(struct drm_plane *plane,
+				  int plane_gamma_size);
+
 #endif
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index acabb85009a14..18d09eacbcd7d 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -585,6 +585,10 @@ struct drm_plane {
 
 	struct drm_property *zpos_property;
 	struct drm_property *rotation_property;
+
+	/* Legacy FB Plane gamma size for reporting to userspace */
+	uint32_t gamma_size;
+	uint16_t *gamma_store;
 };
 
 #define obj_to_plane(x) container_of(x, struct drm_plane, base)
-- 
2.16.1.291.g4437f3f132-goog

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 07/10] drm/rockchip: Add yuv2yuv registers to vop_lit
  2018-02-15  5:32 [PATCH 00/10] drm: Add plane color matrix on rockchip Daniele Castagna
                   ` (5 preceding siblings ...)
  2018-02-15  5:32 ` [PATCH 06/10] drm: Define helper to set legacy gamma table size Daniele Castagna
@ 2018-02-15  5:32 ` Daniele Castagna
  2018-02-27 15:36   ` Sean Paul
  2018-02-15  5:32 ` [PATCH 08/10] drm/rockchip: Add R2R registers Daniele Castagna
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 44+ messages in thread
From: Daniele Castagna @ 2018-02-15  5:32 UTC (permalink / raw)
  To: dri-devel

rk3399_vop_yuv2yuv registers can be used also by vop_lit (less capable
crtc) to control per-plane color conversion pipeline.

Change-Id: Iaad1efeae7141959c61e976988bd9d699ce3858f
---
 drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
index be9c414e2e4bc..0af95947f22d4 100644
--- a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
+++ b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
@@ -483,6 +483,7 @@ static const struct vop_data rk3399_vop_lit = {
 	.modeset = &rk3288_modeset,
 	.output = &rk3399_output,
 	.misc = &rk3368_misc,
+	.yuv2yuv = &rk3399_vop_yuv2yuv,
 	.win = rk3399_vop_lit_win_data,
 	.win_size = ARRAY_SIZE(rk3399_vop_lit_win_data),
 };
-- 
2.16.1.291.g4437f3f132-goog

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 08/10] drm/rockchip: Add R2R registers
  2018-02-15  5:32 [PATCH 00/10] drm: Add plane color matrix on rockchip Daniele Castagna
                   ` (6 preceding siblings ...)
  2018-02-15  5:32 ` [PATCH 07/10] drm/rockchip: Add yuv2yuv registers to vop_lit Daniele Castagna
@ 2018-02-15  5:32 ` Daniele Castagna
  2018-02-27 15:41   ` Sean Paul
  2018-02-15  5:32 ` [PATCH 09/10] drm/rockchip: Implement drm plane->ctm property Daniele Castagna
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 44+ messages in thread
From: Daniele Castagna @ 2018-02-15  5:32 UTC (permalink / raw)
  To: dri-devel

This patch adds YUV2YUV registers to enable and control per-plane
RGB2RGB colos space conversion matrix.

Change-Id: I8f421222da3587caea6373e2201e918f0c5e2646
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.h |  7 +++
 drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 48 +++++++++++++++++++++
 2 files changed, 55 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
index aa8a5d2690376..fea5a087f4749 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
@@ -80,6 +80,13 @@ struct vop_misc {
 };
 
 struct vop_yuv2yuv {
+	struct vop_reg win0_r2r_en;
+	struct vop_reg win0_r2r_coefficients[12];
+	struct vop_reg win1_r2r_en;
+	struct vop_reg win1_r2r_coefficients[12];
+	struct vop_reg win2_r2r_en;
+	struct vop_reg win2_r2r_coefficients[12];
+
 	struct vop_reg win0_y2r_en;
 	struct vop_reg win0_y2r_coefficients[12];
 
diff --git a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
index 0af95947f22d4..fb7b07aa4fa27 100644
--- a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
+++ b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
@@ -423,6 +423,54 @@ static const struct vop_output rk3399_output = {
 };
 
 static const struct vop_yuv2yuv rk3399_vop_yuv2yuv = {
+	.win0_r2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 0),
+	.win0_r2r_coefficients = {
+		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 0, 0xffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 0, 0xffff, 16),
+		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 4, 0xffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 4, 0xffff, 16),
+		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 8, 0xffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 8, 0xffff, 16),
+		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 12, 0xffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 12, 0xffff, 16),
+		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 16, 0xffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 20, 0xffffffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 24, 0xffffffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 28, 0xffffffff, 0),
+	 },
+
+	.win1_r2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 8),
+	.win1_r2r_coefficients = {
+		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 0, 0xffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 0, 0xffff, 16),
+		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 4, 0xffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 4, 0xffff, 16),
+		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 8, 0xffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 8, 0xffff, 16),
+		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 12, 0xffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 12, 0xffff, 16),
+		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 16, 0xffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 20, 0xffffffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 24, 0xffffffff, 0),
+		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 28, 0xffffffff, 0),
+	 },
+
+	.win2_r2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 16),
+	.win2_r2r_coefficients = {
+		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 0, 0xffff, 0),
+		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 0, 0xffff, 16),
+		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 4, 0xffff, 0),
+		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 4, 0xffff, 16),
+		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 8, 0xffff, 0),
+		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 8, 0xffff, 16),
+		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 12, 0xffff, 0),
+		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 12, 0xffff, 16),
+		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 16, 0xffff, 0),
+		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 20, 0xffffffff, 0),
+		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 24, 0xffffffff, 0),
+		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 28, 0xffffffff, 0),
+	 },
+
 	.win0_y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 1),
 	.win0_y2r_coefficients = {
 		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 0, 0xffff, 0),
-- 
2.16.1.291.g4437f3f132-goog

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 09/10] drm/rockchip: Implement drm plane->ctm property.
  2018-02-15  5:32 [PATCH 00/10] drm: Add plane color matrix on rockchip Daniele Castagna
                   ` (7 preceding siblings ...)
  2018-02-15  5:32 ` [PATCH 08/10] drm/rockchip: Add R2R registers Daniele Castagna
@ 2018-02-15  5:32 ` Daniele Castagna
  2018-02-27 16:09   ` Sean Paul
  2018-02-15  5:33 ` [PATCH 10/10] drm/rockchip: Enable 'PLANE_CTM' drm property Daniele Castagna
  2018-02-19 15:16 ` [PATCH 00/10] drm: Add plane color matrix on rockchip Daniel Vetter
  10 siblings, 1 reply; 44+ messages in thread
From: Daniele Castagna @ 2018-02-15  5:32 UTC (permalink / raw)
  To: dri-devel

Validate drm PLANE_CTM matrix and map it to YUV2YUV registers.

Change-Id: Ib4fe49558c6266bf0c310af121d625cd7b2cedf6
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 45 +++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index ea43ab797f555..8c8118c3db308 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -656,6 +656,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
 	struct drm_framebuffer *fb = state->fb;
 	struct vop_win *vop_win = to_vop_win(plane);
 	const struct vop_win_data *win = vop_win->data;
+	int i;
 	int ret;
 	struct drm_rect clip;
 	int min_scale = win->phy->scl ? FRAC_16_16(1, 8) :
@@ -697,6 +698,25 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
 		return -EINVAL;
 	}
 
+	if (state->ctm) {
+		struct drm_color_ctm* color_ctm = (struct drm_color_ctm*)state->ctm->data;
+		if (state->ctm->length != sizeof(struct drm_color_ctm)) {
+			DRM_ERROR("Invalid PLANE_CTM blob size.\n");
+			return -EINVAL;
+		}
+
+		for (i = 0; i < 9; i++) {
+			/*
+			 * YUV2YUV R2R registers have a signed fixed point S2.10 format.
+			 * The input values, that are in signed fixed point S31.32 format,
+			 * can be converted only if the first 30 MSBs are all 1s or 0s.
+			 */
+			uint32_t msbs = (uint32_t) (color_ctm->matrix[i] >> 34);
+			if (msbs != ~0u && msbs != 0)
+				    return -EOVERFLOW;
+	      }
+	}
+
 	return 0;
 }
 
@@ -816,6 +836,31 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
 		}
 	}
 
+	if (!win_index) {
+		VOP_YUV2YUV_SET(vop, win0_r2r_en, !!state->ctm);
+	} else if (win_index == 1) {
+		VOP_YUV2YUV_SET(vop, win1_r2r_en, !!state->ctm);
+	} else if (win_index == 2) {
+		VOP_YUV2YUV_SET(vop, win2_r2r_en, !!state->ctm);
+	}
+	if (state->ctm) {
+		struct drm_color_ctm* color_ctm = (struct drm_color_ctm*)state->ctm->data;
+                /*
+		 * Convert matrix values from fixed point S31.32 to S2.10, by discarding
+		 * the lowest 22 bits.
+		 */
+		for (i = 0; i < 9; i++) {
+			uint32_t value = (color_ctm->matrix[i] >> 22) & 0x1FFF;
+			if (!win_index) {
+				VOP_YUV2YUV_SET(vop, win0_r2r_coefficients[i], value);
+			 } else if (win_index == 1){
+				VOP_YUV2YUV_SET(vop, win1_r2r_coefficients[i], value);
+			 } else if (win_index == 2) {
+				VOP_YUV2YUV_SET(vop, win2_r2r_coefficients[i], value);
+			 }
+		}
+	}
+
 	if (win->phy->scl)
 		scl_vop_cal_scl_fac(vop, win, actual_w, actual_h,
 				    drm_rect_width(dest), drm_rect_height(dest),
-- 
2.16.1.291.g4437f3f132-goog

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 10/10] drm/rockchip: Enable 'PLANE_CTM' drm property.
  2018-02-15  5:32 [PATCH 00/10] drm: Add plane color matrix on rockchip Daniele Castagna
                   ` (8 preceding siblings ...)
  2018-02-15  5:32 ` [PATCH 09/10] drm/rockchip: Implement drm plane->ctm property Daniele Castagna
@ 2018-02-15  5:33 ` Daniele Castagna
  2018-02-27 16:10   ` Sean Paul
  2018-02-19 15:16 ` [PATCH 00/10] drm: Add plane color matrix on rockchip Daniel Vetter
  10 siblings, 1 reply; 44+ messages in thread
From: Daniele Castagna @ 2018-02-15  5:33 UTC (permalink / raw)
  To: dri-devel

Enable and expose 'PLANE_CTM' matrix on primary and overaly planes.
The property can be use to set a RGB to RGB 3X3 color conversion
matrix that will be applied to planes at scanout.

Change-Id: Ifb7a680ab84c17557b8b3c5aaba1aa3b4eecfcaa
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 8c8118c3db308..4148e2b025b31 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -1352,6 +1352,9 @@ static int vop_create_crtc(struct vop *vop)
 
 	ret = drm_crtc_init_with_planes(drm_dev, crtc, primary, cursor,
 					&vop_crtc_funcs, NULL);
+
+	drm_plane_enable_color_mgmt(primary, 0, true, 0);
+
 	if (ret)
 		goto err_cleanup_planes;
 
@@ -1381,6 +1384,8 @@ static int vop_create_crtc(struct vop *vop)
 			goto err_cleanup_crtc;
 		}
 		drm_plane_helper_add(&vop_win->base, &plane_helper_funcs);
+
+		drm_plane_enable_color_mgmt(&vop_win->base, 0, true, 0);
 	}
 
 	port = of_get_child_by_name(dev->of_node, "port");
-- 
2.16.1.291.g4437f3f132-goog

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* Re: [PATCH 04/10] drm: Add Plane Gamma properties
  2018-02-15  5:32 ` [PATCH 04/10] drm: Add Plane Gamma properties Daniele Castagna
@ 2018-02-15 19:29   ` Harry Wentland
  2018-02-15 19:45     ` Daniele Castagna
  2018-02-19 15:14   ` Daniel Vetter
  2018-02-27 15:26   ` Sean Paul
  2 siblings, 1 reply; 44+ messages in thread
From: Harry Wentland @ 2018-02-15 19:29 UTC (permalink / raw)
  To: Daniele Castagna, dri-devel

On 2018-02-15 12:32 AM, Daniele Castagna wrote:
> From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>
> 
> Add plane gamma as blob property and size as a
> range property.
> 

Plane degamma & CTM make sense to me but I'm not sure why gamma would be on a per-plane basis. That said, HW sometimes has these implemented in odd ways. Do we know of any HW that will currently or in the future need per-plane gamma or are we just trying to cover all potentialities?

Harry

> (am from https://patchwork.kernel.org/patch/9971325/)
> 
> Change-Id: I606cd40c9748b136fc2bf4750bea1da285add62d
> Signed-off-by: Uma Shankar <uma.shankar at intel.com>
> ---
>  drivers/gpu/drm/drm_atomic.c        |  8 ++++++++
>  drivers/gpu/drm/drm_atomic_helper.c |  4 ++++
>  drivers/gpu/drm/drm_mode_config.c   | 14 ++++++++++++++
>  include/drm/drm_mode_config.h       | 11 +++++++++++
>  include/drm/drm_plane.h             |  9 +++++++++
>  5 files changed, 46 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index d4b8c6cc84128..f634f6450f415 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -778,6 +778,12 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
>  					&replaced);
>  		state->color_mgmt_changed |= replaced;
>  		return ret;
> +	} else if (property == config->plane_gamma_lut_property) {
> +		ret = drm_atomic_replace_property_blob_from_id(dev,
> +					&state->gamma_lut,
> +					val, -1, &replaced);
> +		state->color_mgmt_changed |= replaced;
> +		return ret;
>  	} else {
>  		return -EINVAL;
>  	}
> @@ -841,6 +847,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
>  			state->degamma_lut->base.id : 0;
>  	} else if (property == config->plane_ctm_property) {
>  		*val = (state->ctm) ? state->ctm->base.id : 0;
> +	} else if (property == config->plane_gamma_lut_property) {
> +		*val = (state->gamma_lut) ? state->gamma_lut->base.id : 0;
>  	} else {
>  		return -EINVAL;
>  	}
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 17e137a529a0e..97dbb36153d14 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -3495,6 +3495,9 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
>  		drm_property_reference_blob(state->degamma_lut);
>  	if (state->ctm)
>  		drm_property_reference_blob(state->ctm);
> +	if (state->gamma_lut)
> +		drm_property_reference_blob(state->gamma_lut);
> +
>  	state->color_mgmt_changed = false;
>  }
>  EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state);
> @@ -3543,6 +3546,7 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)
>  
>  	drm_property_unreference_blob(state->degamma_lut);
>  	drm_property_unreference_blob(state->ctm);
> +	drm_property_unreference_blob(state->gamma_lut);
>  }
>  EXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state);
>  
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index c8763977413e7..bc6f8e51c7464 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -368,6 +368,20 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>  		return -ENOMEM;
>  	dev->mode_config.plane_ctm_property = prop;
>  
> +	prop = drm_property_create(dev,
> +			DRM_MODE_PROP_BLOB,
> +			"PLANE_GAMMA_LUT", 0);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.plane_gamma_lut_property = prop;
> +
> +	prop = drm_property_create_range(dev,
> +			DRM_MODE_PROP_IMMUTABLE,
> +			"PLANE_GAMMA_LUT_SIZE", 0, UINT_MAX);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.plane_gamma_lut_size_property = prop;
> +
>  	return 0;
>  }
>  
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index ad7235ced531b..3ca3eb3c98950 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -740,6 +740,17 @@ struct drm_mode_config {
>  	 * degamma LUT.
>  	 */
>  	struct drm_property *plane_ctm_property;
> +	/**
> +	 * @plane_gamma_lut_property: Optional Plane property to set the LUT
> +	 * used to convert the colors, after the CTM matrix, to the common
> +	 * gamma space chosen for blending.
> +	 */
> +	struct drm_property *plane_gamma_lut_property;
> +	/**
> +	 * @plane_gamma_lut_size_property: Optional Plane property for the size
> +	 * of the gamma LUT as supported by the driver (read-only).
> +	 */
> +	struct drm_property *plane_gamma_lut_size_property;
>  	/**
>  	 * @ctm_property: Optional CRTC property to set the
>  	 * matrix used to convert colors after the lookup in the
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 21aecc9c91a09..acabb85009a14 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -147,6 +147,15 @@ struct drm_plane_state {
>  	 */
>  	struct drm_property_blob *ctm;
>  
> +	/**
> +	 * @gamma_lut:
> +	 *
> +	 * Lookup table for converting pixel data after the color conversion
> +	 * matrix @ctm.  See drm_plane_enable_color_mgmt(). The blob (if not
> +	 * NULL) is an array of &struct drm_color_lut.
> +	 */
> +	struct drm_property_blob *gamma_lut;
> +
>  	struct drm_atomic_state *state;
>  
>  	bool color_mgmt_changed : 1;
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 04/10] drm: Add Plane Gamma properties
  2018-02-15 19:29   ` Harry Wentland
@ 2018-02-15 19:45     ` Daniele Castagna
  2018-02-16 20:10       ` Ville Syrjälä
  0 siblings, 1 reply; 44+ messages in thread
From: Daniele Castagna @ 2018-02-15 19:45 UTC (permalink / raw)
  To: Harry Wentland; +Cc: uma.shankar, dri-devel

rk3399 has the option of setting per-plane gamma.
The YUV2YUV registers are per-plane. Each plane YUV2YUV pipeline has
at least 3 optional stages, two of those being degamma and gamma, and
they can be configured per-plane.

I'm not sure about Intel HW. I think they might have something similar
planned, considering the original patch was from uma.shankar. CCing
directly in case he knows more.

On Thu, Feb 15, 2018 at 2:29 PM, Harry Wentland <harry.wentland@amd.com> wrote:
> On 2018-02-15 12:32 AM, Daniele Castagna wrote:
>> From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>
>>
>> Add plane gamma as blob property and size as a
>> range property.
>>
>
> Plane degamma & CTM make sense to me but I'm not sure why gamma would be on a per-plane basis. That said, HW sometimes has these implemented in odd ways. Do we know of any HW that will currently or in the future need per-plane gamma or are we just trying to cover all potentialities?
>
> Harry
>
>> (am from https://patchwork.kernel.org/patch/9971325/)
>>
>> Change-Id: I606cd40c9748b136fc2bf4750bea1da285add62d
>> Signed-off-by: Uma Shankar <uma.shankar at intel.com>
>> ---
>>  drivers/gpu/drm/drm_atomic.c        |  8 ++++++++
>>  drivers/gpu/drm/drm_atomic_helper.c |  4 ++++
>>  drivers/gpu/drm/drm_mode_config.c   | 14 ++++++++++++++
>>  include/drm/drm_mode_config.h       | 11 +++++++++++
>>  include/drm/drm_plane.h             |  9 +++++++++
>>  5 files changed, 46 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
>> index d4b8c6cc84128..f634f6450f415 100644
>> --- a/drivers/gpu/drm/drm_atomic.c
>> +++ b/drivers/gpu/drm/drm_atomic.c
>> @@ -778,6 +778,12 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
>>                                       &replaced);
>>               state->color_mgmt_changed |= replaced;
>>               return ret;
>> +     } else if (property == config->plane_gamma_lut_property) {
>> +             ret = drm_atomic_replace_property_blob_from_id(dev,
>> +                                     &state->gamma_lut,
>> +                                     val, -1, &replaced);
>> +             state->color_mgmt_changed |= replaced;
>> +             return ret;
>>       } else {
>>               return -EINVAL;
>>       }
>> @@ -841,6 +847,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
>>                       state->degamma_lut->base.id : 0;
>>       } else if (property == config->plane_ctm_property) {
>>               *val = (state->ctm) ? state->ctm->base.id : 0;
>> +     } else if (property == config->plane_gamma_lut_property) {
>> +             *val = (state->gamma_lut) ? state->gamma_lut->base.id : 0;
>>       } else {
>>               return -EINVAL;
>>       }
>> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
>> index 17e137a529a0e..97dbb36153d14 100644
>> --- a/drivers/gpu/drm/drm_atomic_helper.c
>> +++ b/drivers/gpu/drm/drm_atomic_helper.c
>> @@ -3495,6 +3495,9 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
>>               drm_property_reference_blob(state->degamma_lut);
>>       if (state->ctm)
>>               drm_property_reference_blob(state->ctm);
>> +     if (state->gamma_lut)
>> +             drm_property_reference_blob(state->gamma_lut);
>> +
>>       state->color_mgmt_changed = false;
>>  }
>>  EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state);
>> @@ -3543,6 +3546,7 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)
>>
>>       drm_property_unreference_blob(state->degamma_lut);
>>       drm_property_unreference_blob(state->ctm);
>> +     drm_property_unreference_blob(state->gamma_lut);
>>  }
>>  EXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state);
>>
>> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
>> index c8763977413e7..bc6f8e51c7464 100644
>> --- a/drivers/gpu/drm/drm_mode_config.c
>> +++ b/drivers/gpu/drm/drm_mode_config.c
>> @@ -368,6 +368,20 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>>               return -ENOMEM;
>>       dev->mode_config.plane_ctm_property = prop;
>>
>> +     prop = drm_property_create(dev,
>> +                     DRM_MODE_PROP_BLOB,
>> +                     "PLANE_GAMMA_LUT", 0);
>> +     if (!prop)
>> +             return -ENOMEM;
>> +     dev->mode_config.plane_gamma_lut_property = prop;
>> +
>> +     prop = drm_property_create_range(dev,
>> +                     DRM_MODE_PROP_IMMUTABLE,
>> +                     "PLANE_GAMMA_LUT_SIZE", 0, UINT_MAX);
>> +     if (!prop)
>> +             return -ENOMEM;
>> +     dev->mode_config.plane_gamma_lut_size_property = prop;
>> +
>>       return 0;
>>  }
>>
>> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
>> index ad7235ced531b..3ca3eb3c98950 100644
>> --- a/include/drm/drm_mode_config.h
>> +++ b/include/drm/drm_mode_config.h
>> @@ -740,6 +740,17 @@ struct drm_mode_config {
>>        * degamma LUT.
>>        */
>>       struct drm_property *plane_ctm_property;
>> +     /**
>> +      * @plane_gamma_lut_property: Optional Plane property to set the LUT
>> +      * used to convert the colors, after the CTM matrix, to the common
>> +      * gamma space chosen for blending.
>> +      */
>> +     struct drm_property *plane_gamma_lut_property;
>> +     /**
>> +      * @plane_gamma_lut_size_property: Optional Plane property for the size
>> +      * of the gamma LUT as supported by the driver (read-only).
>> +      */
>> +     struct drm_property *plane_gamma_lut_size_property;
>>       /**
>>        * @ctm_property: Optional CRTC property to set the
>>        * matrix used to convert colors after the lookup in the
>> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
>> index 21aecc9c91a09..acabb85009a14 100644
>> --- a/include/drm/drm_plane.h
>> +++ b/include/drm/drm_plane.h
>> @@ -147,6 +147,15 @@ struct drm_plane_state {
>>        */
>>       struct drm_property_blob *ctm;
>>
>> +     /**
>> +      * @gamma_lut:
>> +      *
>> +      * Lookup table for converting pixel data after the color conversion
>> +      * matrix @ctm.  See drm_plane_enable_color_mgmt(). The blob (if not
>> +      * NULL) is an array of &struct drm_color_lut.
>> +      */
>> +     struct drm_property_blob *gamma_lut;
>> +
>>       struct drm_atomic_state *state;
>>
>>       bool color_mgmt_changed : 1;
>>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 01/10] drm/rockchip: YUV overlays BT.601 color conversion.
  2018-02-15  5:32 ` [PATCH 01/10] drm/rockchip: YUV overlays BT.601 color conversion Daniele Castagna
@ 2018-02-16 17:55   ` kbuild test robot
  2018-02-27 15:03   ` Sean Paul
  2018-12-14 16:29   ` [PATCH v2] drm/rockchip: Fix YUV buffers color rendering Ezequiel Garcia
  2 siblings, 0 replies; 44+ messages in thread
From: kbuild test robot @ 2018-02-16 17:55 UTC (permalink / raw)
  To: Daniele Castagna; +Cc: kbuild-all, dri-devel

[-- Attachment #1: Type: text/plain, Size: 9498 bytes --]

Hi Daniele,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on rockchip/for-next]
[also build test ERROR on v4.16-rc1 next-20180216]
[cannot apply to drm/drm-next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Daniele-Castagna/drm-rockchip-YUV-overlays-BT-601-color-conversion/20180216-233006
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git for-next
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm64 

All error/warnings (new ones prefixed by >>):

   drivers/gpu//drm/rockchip/rockchip_drm_vop.c: In function 'vop_plane_atomic_update':
>> drivers/gpu//drm/rockchip/rockchip_drm_vop.c:742:18: error: implicit declaration of function 'VOP_WIN_TO_INDEX'; did you mean 'CAP_TO_INDEX'? [-Werror=implicit-function-declaration]
     int win_index = VOP_WIN_TO_INDEX(vop_win);
                     ^~~~~~~~~~~~~~~~
                     CAP_TO_INDEX
   cc1: some warnings being treated as errors
--
>> drivers/gpu//drm/rockchip/rockchip_vop_reg.c:468:9: error: 'rk3399_vop_win_data' undeclared here (not in a function); did you mean 'rk3368_vop_win_data'?
     .win = rk3399_vop_win_data,
            ^~~~~~~~~~~~~~~~~~~
            rk3368_vop_win_data
   In file included from arch/arm64/include/asm/sysreg.h:669:0,
                    from arch/arm64/include/asm/cputype.h:116,
                    from arch/arm64/include/asm/cache.h:19,
                    from include/linux/cache.h:6,
                    from include/linux/printk.h:9,
                    from include/linux/kernel.h:14,
                    from include/linux/list.h:9,
                    from include/linux/agp_backend.h:33,
                    from include/drm/drmP.h:35,
                    from drivers/gpu//drm/rockchip/rockchip_vop_reg.c:15:
>> include/linux/build_bug.h:29:45: error: bit-field '<anonymous>' width not an integer constant
    #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
                                                ^
   include/linux/compiler-gcc.h:65:28: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
    #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
                               ^~~~~~~~~~~~~~~~~
   include/linux/kernel.h:71:59: note: in expansion of macro '__must_be_array'
    #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
                                                              ^~~~~~~~~~~~~~~
>> drivers/gpu//drm/rockchip/rockchip_vop_reg.c:469:14: note: in expansion of macro 'ARRAY_SIZE'
     .win_size = ARRAY_SIZE(rk3399_vop_win_data),
                 ^~~~~~~~~~
--
   drivers/gpu/drm/rockchip/rockchip_vop_reg.c:468:9: error: 'rk3399_vop_win_data' undeclared here (not in a function); did you mean 'rk3368_vop_win_data'?
     .win = rk3399_vop_win_data,
            ^~~~~~~~~~~~~~~~~~~
            rk3368_vop_win_data
   In file included from arch/arm64/include/asm/sysreg.h:669:0,
                    from arch/arm64/include/asm/cputype.h:116,
                    from arch/arm64/include/asm/cache.h:19,
                    from include/linux/cache.h:6,
                    from include/linux/printk.h:9,
                    from include/linux/kernel.h:14,
                    from include/linux/list.h:9,
                    from include/linux/agp_backend.h:33,
                    from include/drm/drmP.h:35,
                    from drivers/gpu/drm/rockchip/rockchip_vop_reg.c:15:
>> include/linux/build_bug.h:29:45: error: bit-field '<anonymous>' width not an integer constant
    #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
                                                ^
   include/linux/compiler-gcc.h:65:28: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
    #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
                               ^~~~~~~~~~~~~~~~~
   include/linux/kernel.h:71:59: note: in expansion of macro '__must_be_array'
    #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
                                                              ^~~~~~~~~~~~~~~
   drivers/gpu/drm/rockchip/rockchip_vop_reg.c:469:14: note: in expansion of macro 'ARRAY_SIZE'
     .win_size = ARRAY_SIZE(rk3399_vop_win_data),
                 ^~~~~~~~~~

vim +742 drivers/gpu//drm/rockchip/rockchip_drm_vop.c

   719	
   720	static void vop_plane_atomic_update(struct drm_plane *plane,
   721			struct drm_plane_state *old_state)
   722	{
   723		struct drm_plane_state *state = plane->state;
   724		struct drm_crtc *crtc = state->crtc;
   725		struct vop_win *vop_win = to_vop_win(plane);
   726		const struct vop_win_data *win = vop_win->data;
   727		struct vop *vop = to_vop(state->crtc);
   728		struct drm_framebuffer *fb = state->fb;
   729		unsigned int actual_w, actual_h;
   730		unsigned int dsp_stx, dsp_sty;
   731		uint32_t act_info, dsp_info, dsp_st;
   732		struct drm_rect *src = &state->src;
   733		struct drm_rect *dest = &state->dst;
   734		struct drm_gem_object *obj, *uv_obj;
   735		struct rockchip_gem_object *rk_obj, *rk_uv_obj;
   736		unsigned long offset;
   737		dma_addr_t dma_addr;
   738		uint32_t val;
   739		bool rb_swap;
   740		int format;
   741		int is_yuv = is_yuv_support(fb->format->format);
 > 742		int win_index = VOP_WIN_TO_INDEX(vop_win);
   743		int i;
   744	
   745		/*
   746		 * can't update plane when vop is disabled.
   747		 */
   748		if (WARN_ON(!crtc))
   749			return;
   750	
   751		if (WARN_ON(!vop->is_enabled))
   752			return;
   753	
   754		if (!state->visible) {
   755			vop_plane_atomic_disable(plane, old_state);
   756			return;
   757		}
   758	
   759		obj = rockchip_fb_get_gem_obj(fb, 0);
   760		rk_obj = to_rockchip_obj(obj);
   761	
   762		actual_w = drm_rect_width(src) >> 16;
   763		actual_h = drm_rect_height(src) >> 16;
   764		act_info = (actual_h - 1) << 16 | ((actual_w - 1) & 0xffff);
   765	
   766		dsp_info = (drm_rect_height(dest) - 1) << 16;
   767		dsp_info |= (drm_rect_width(dest) - 1) & 0xffff;
   768	
   769		dsp_stx = dest->x1 + crtc->mode.htotal - crtc->mode.hsync_start;
   770		dsp_sty = dest->y1 + crtc->mode.vtotal - crtc->mode.vsync_start;
   771		dsp_st = dsp_sty << 16 | (dsp_stx & 0xffff);
   772	
   773		offset = (src->x1 >> 16) * fb->format->cpp[0];
   774		offset += (src->y1 >> 16) * fb->pitches[0];
   775		dma_addr = rk_obj->dma_addr + offset + fb->offsets[0];
   776	
   777		format = vop_convert_format(fb->format->format);
   778	
   779		spin_lock(&vop->reg_lock);
   780	
   781		VOP_WIN_SET(vop, win, format, format);
   782		VOP_WIN_SET(vop, win, yrgb_vir, DIV_ROUND_UP(fb->pitches[0], 4));
   783		VOP_WIN_SET(vop, win, yrgb_mst, dma_addr);
   784	
   785		if (!win_index) {
   786			VOP_YUV2YUV_SET(vop, win0_y2r_en, is_yuv);
   787		} else if (win_index == 1) {
   788			VOP_YUV2YUV_SET(vop, win1_y2r_en, is_yuv);
   789		}
   790	
   791		if (is_yuv) {
   792			int hsub = drm_format_horz_chroma_subsampling(fb->format->format);
   793			int vsub = drm_format_vert_chroma_subsampling(fb->format->format);
   794			int bpp = fb->format->cpp[1];
   795	
   796			uv_obj = rockchip_fb_get_gem_obj(fb, 1);
   797			rk_uv_obj = to_rockchip_obj(uv_obj);
   798	
   799			offset = (src->x1 >> 16) * bpp / hsub;
   800			offset += (src->y1 >> 16) * fb->pitches[1] / vsub;
   801	
   802			dma_addr = rk_uv_obj->dma_addr + offset + fb->offsets[1];
   803			VOP_WIN_SET(vop, win, uv_vir, DIV_ROUND_UP(fb->pitches[1], 4));
   804			VOP_WIN_SET(vop, win, uv_mst, dma_addr);
   805	
   806			for (i = 0; i < 12; i++) {
   807				if (!win_index) {
   808					VOP_YUV2YUV_SET(vop,
   809							win0_y2r_coefficients[i],
   810							bt601_yuv2rgb[i]);
   811				} else {
   812					VOP_YUV2YUV_SET(vop,
   813							win1_y2r_coefficients[i],
   814							bt601_yuv2rgb[i]);
   815				}
   816			}
   817		}
   818	
   819		if (win->phy->scl)
   820			scl_vop_cal_scl_fac(vop, win, actual_w, actual_h,
   821					    drm_rect_width(dest), drm_rect_height(dest),
   822					    fb->format->format);
   823	
   824		VOP_WIN_SET(vop, win, act_info, act_info);
   825		VOP_WIN_SET(vop, win, dsp_info, dsp_info);
   826		VOP_WIN_SET(vop, win, dsp_st, dsp_st);
   827	
   828		rb_swap = has_rb_swapped(fb->format->format);
   829		VOP_WIN_SET(vop, win, rb_swap, rb_swap);
   830	
   831		if (is_alpha_support(fb->format->format)) {
   832			VOP_WIN_SET(vop, win, dst_alpha_ctl,
   833				    DST_FACTOR_M0(ALPHA_SRC_INVERSE));
   834			val = SRC_ALPHA_EN(1) | SRC_COLOR_M0(ALPHA_SRC_PRE_MUL) |
   835				SRC_ALPHA_M0(ALPHA_STRAIGHT) |
   836				SRC_BLEND_M0(ALPHA_PER_PIX) |
   837				SRC_ALPHA_CAL_M0(ALPHA_NO_SATURATION) |
   838				SRC_FACTOR_M0(ALPHA_ONE);
   839			VOP_WIN_SET(vop, win, src_alpha_ctl, val);
   840		} else {
   841			VOP_WIN_SET(vop, win, src_alpha_ctl, SRC_ALPHA_EN(0));
   842		}
   843	
   844		VOP_WIN_SET(vop, win, enable, 1);
   845		spin_unlock(&vop->reg_lock);
   846	}
   847	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 37837 bytes --]

[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 02/10] drm: Add Plane Degamma properties
  2018-02-15  5:32 ` [PATCH 02/10] drm: Add Plane Degamma properties Daniele Castagna
@ 2018-02-16 19:38   ` kbuild test robot
  2018-02-19 15:15   ` Daniel Vetter
  2018-02-27 15:13   ` Sean Paul
  2 siblings, 0 replies; 44+ messages in thread
From: kbuild test robot @ 2018-02-16 19:38 UTC (permalink / raw)
  To: Daniele Castagna; +Cc: kbuild-all, dri-devel

[-- Attachment #1: Type: text/plain, Size: 22693 bytes --]

Hi uma.shankar,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on rockchip/for-next]
[also build test WARNING on v4.16-rc1 next-20180216]
[cannot apply to drm/drm-next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Daniele-Castagna/drm-rockchip-YUV-overlays-BT-601-color-conversion/20180216-233006
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git for-next
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

   include/linux/crypto.h:477: warning: Function parameter or member 'cra_u.blkcipher' not described in 'crypto_alg'
   include/linux/crypto.h:477: warning: Function parameter or member 'cra_u.cipher' not described in 'crypto_alg'
   include/linux/crypto.h:477: warning: Function parameter or member 'cra_u.compress' not described in 'crypto_alg'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.ibss' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.connect' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.keys' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.ie' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.ie_len' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.bssid' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.prev_bssid' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.ssid' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.default_key' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.default_mgmt_key' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.prev_bssid_valid' not described in 'wireless_dev'
   include/net/mac80211.h:2259: warning: Function parameter or member 'radiotap_timestamp.units_pos' not described in 'ieee80211_hw'
   include/net/mac80211.h:2259: warning: Function parameter or member 'radiotap_timestamp.accuracy' not described in 'ieee80211_hw'
   include/net/mac80211.h:950: warning: Function parameter or member 'rates' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'control.rts_cts_rate_idx' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'control.use_rts' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'control.use_cts_prot' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'control.short_preamble' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'control.skip_table' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'control.jiffies' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'control.vif' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'control.hw_key' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'control.flags' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'control.enqueue_time' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'ack' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'ack.cookie' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'status.rates' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'status.ack_signal' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'status.ampdu_ack_len' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'status.ampdu_len' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'status.antenna' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'status.tx_time' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'status_driver_data' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'driver_rates' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'pad' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'rate_driver_data' not described in 'ieee80211_tx_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'rx_stats_avg' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'rx_stats_avg.signal' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'rx_stats_avg.chain_signal' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'status_stats.filtered' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'status_stats.retry_failed' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'status_stats.retry_count' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'status_stats.lost_packets' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'status_stats.last_tdls_pkt_time' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'msdu_retries' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'msdu_failed' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'status_stats.last_ack' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'tx_stats.packets' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'tx_stats.bytes' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'tx_stats.last_rate' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'msdu' not described in 'sta_info'
   include/linux/dma-buf.h:307: warning: Function parameter or member 'cb_excl.cb' not described in 'dma_buf'
   include/linux/dma-buf.h:307: warning: Function parameter or member 'cb_excl.poll' not described in 'dma_buf'
   include/linux/dma-buf.h:307: warning: Function parameter or member 'cb_excl.active' not described in 'dma_buf'
   include/linux/dma-buf.h:307: warning: Function parameter or member 'cb_shared.cb' not described in 'dma_buf'
   include/linux/dma-buf.h:307: warning: Function parameter or member 'cb_shared.poll' not described in 'dma_buf'
   include/linux/dma-buf.h:307: warning: Function parameter or member 'cb_shared.active' not described in 'dma_buf'
   include/linux/dma-fence-array.h:54: warning: Function parameter or member 'work' not described in 'dma_fence_array'
   include/linux/gpio/driver.h:142: warning: Function parameter or member 'request_key' not described in 'gpio_irq_chip'
   include/linux/iio/iio.h:270: warning: Function parameter or member 'scan_type.sign' not described in 'iio_chan_spec'
   include/linux/iio/iio.h:270: warning: Function parameter or member 'scan_type.realbits' not described in 'iio_chan_spec'
   include/linux/iio/iio.h:270: warning: Function parameter or member 'scan_type.storagebits' not described in 'iio_chan_spec'
   include/linux/iio/iio.h:270: warning: Function parameter or member 'scan_type.shift' not described in 'iio_chan_spec'
   include/linux/iio/iio.h:270: warning: Function parameter or member 'scan_type.repeat' not described in 'iio_chan_spec'
   include/linux/iio/iio.h:270: warning: Function parameter or member 'scan_type.endianness' not described in 'iio_chan_spec'
   include/linux/iio/hw-consumer.h:1: warning: no structured comments found
   include/linux/device.h:294: warning: Function parameter or member 'coredump' not described in 'device_driver'
   include/linux/input/sparse-keymap.h:46: warning: Function parameter or member 'sw' not described in 'key_entry'
   include/linux/mtd/rawnand.h:709: warning: Function parameter or member 'timings.sdr' not described in 'nand_data_interface'
   include/linux/mtd/rawnand.h:774: warning: Function parameter or member 'buf' not described in 'nand_op_data_instr'
   include/linux/mtd/rawnand.h:774: warning: Function parameter or member 'buf.in' not described in 'nand_op_data_instr'
   include/linux/mtd/rawnand.h:774: warning: Function parameter or member 'buf.out' not described in 'nand_op_data_instr'
   include/linux/mtd/rawnand.h:820: warning: Function parameter or member 'ctx' not described in 'nand_op_instr'
   include/linux/mtd/rawnand.h:820: warning: Function parameter or member 'ctx.cmd' not described in 'nand_op_instr'
   include/linux/mtd/rawnand.h:820: warning: Function parameter or member 'ctx.addr' not described in 'nand_op_instr'
   include/linux/mtd/rawnand.h:820: warning: Function parameter or member 'ctx.data' not described in 'nand_op_instr'
   include/linux/mtd/rawnand.h:820: warning: Function parameter or member 'ctx.waitrdy' not described in 'nand_op_instr'
   include/linux/mtd/rawnand.h:967: warning: Function parameter or member 'ctx' not described in 'nand_op_parser_pattern_elem'
   include/linux/mtd/rawnand.h:967: warning: Function parameter or member 'ctx.addr' not described in 'nand_op_parser_pattern_elem'
   include/linux/mtd/rawnand.h:967: warning: Function parameter or member 'ctx.data' not described in 'nand_op_parser_pattern_elem'
   include/linux/mtd/rawnand.h:1281: warning: Function parameter or member 'manufacturer.desc' not described in 'nand_chip'
   include/linux/mtd/rawnand.h:1281: warning: Function parameter or member 'manufacturer.priv' not described in 'nand_chip'
   include/linux/regulator/driver.h:221: warning: Function parameter or member 'resume_early' not described in 'regulator_ops'
   drivers/regulator/core.c:4299: warning: Excess function parameter 'state' description in 'regulator_suspend_late'
   arch/s390/include/asm/cio.h:245: warning: Function parameter or member 'esw.esw0' not described in 'irb'
   arch/s390/include/asm/cio.h:245: warning: Function parameter or member 'esw.esw1' not described in 'irb'
   arch/s390/include/asm/cio.h:245: warning: Function parameter or member 'esw.esw2' not described in 'irb'
   arch/s390/include/asm/cio.h:245: warning: Function parameter or member 'esw.esw3' not described in 'irb'
   arch/s390/include/asm/cio.h:245: warning: Function parameter or member 'esw.eadm' not described in 'irb'
   include/drm/drm_drv.h:609: warning: Function parameter or member 'gem_prime_pin' not described in 'drm_driver'
   include/drm/drm_drv.h:609: warning: Function parameter or member 'gem_prime_unpin' not described in 'drm_driver'
   include/drm/drm_drv.h:609: warning: Function parameter or member 'gem_prime_res_obj' not described in 'drm_driver'
   include/drm/drm_drv.h:609: warning: Function parameter or member 'gem_prime_get_sg_table' not described in 'drm_driver'
   include/drm/drm_drv.h:609: warning: Function parameter or member 'gem_prime_import_sg_table' not described in 'drm_driver'
   include/drm/drm_drv.h:609: warning: Function parameter or member 'gem_prime_vmap' not described in 'drm_driver'
   include/drm/drm_drv.h:609: warning: Function parameter or member 'gem_prime_vunmap' not described in 'drm_driver'
   include/drm/drm_drv.h:609: warning: Function parameter or member 'gem_prime_mmap' not described in 'drm_driver'
>> include/drm/drm_plane.h:146: warning: Function parameter or member 'degamma_lut' not described in 'drm_plane_state'
>> include/drm/drm_plane.h:146: warning: Function parameter or member 'color_mgmt_changed' not described in 'drm_plane_state'
   include/drm/drm_connector.h:370: warning: Function parameter or member 'margins.left' not described in 'drm_tv_connector_state'
   include/drm/drm_connector.h:370: warning: Function parameter or member 'margins.right' not described in 'drm_tv_connector_state'
   include/drm/drm_connector.h:370: warning: Function parameter or member 'margins.top' not described in 'drm_tv_connector_state'
   include/drm/drm_connector.h:370: warning: Function parameter or member 'margins.bottom' not described in 'drm_tv_connector_state'
   include/drm/drm_vblank.h:63: warning: Function parameter or member 'event.base' not described in 'drm_pending_vblank_event'
   include/drm/drm_vblank.h:63: warning: Function parameter or member 'event.vbl' not described in 'drm_pending_vblank_event'
   include/drm/drm_vblank.h:63: warning: Function parameter or member 'event.seq' not described in 'drm_pending_vblank_event'
   drivers/gpu/drm/tve200/tve200_drv.c:1: warning: no structured comments found
   include/linux/skbuff.h:846: warning: Function parameter or member 'dev_scratch' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'skb_mstamp' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member '__cloned_offset' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'head_frag' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member '__unused' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member '__pkt_type_offset' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'pfmemalloc' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'encapsulation' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'encap_hdr_csum' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'csum_valid' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'csum_complete_sw' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'csum_level' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'inner_protocol_type' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'remcsum_offload' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'offload_fwd_mark' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'offload_mr_fwd_mark' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'sender_cpu' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'reserved_tailroom' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'inner_ipproto' not described in 'sk_buff'
   include/net/sock.h:234: warning: Function parameter or member 'skc_addrpair' not described in 'sock_common'
   include/net/sock.h:234: warning: Function parameter or member 'skc_portpair' not described in 'sock_common'
   include/net/sock.h:234: warning: Function parameter or member 'skc_ipv6only' not described in 'sock_common'
   include/net/sock.h:234: warning: Function parameter or member 'skc_net_refcnt' not described in 'sock_common'
   include/net/sock.h:234: warning: Function parameter or member 'skc_v6_daddr' not described in 'sock_common'
   include/net/sock.h:234: warning: Function parameter or member 'skc_v6_rcv_saddr' not described in 'sock_common'
   include/net/sock.h:234: warning: Function parameter or member 'skc_cookie' not described in 'sock_common'
   include/net/sock.h:234: warning: Function parameter or member 'skc_listener' not described in 'sock_common'
   include/net/sock.h:234: warning: Function parameter or member 'skc_tw_dr' not described in 'sock_common'
   include/net/sock.h:234: warning: Function parameter or member 'skc_rcv_wnd' not described in 'sock_common'
   include/net/sock.h:234: warning: Function parameter or member 'skc_tw_rcv_nxt' not described in 'sock_common'
   include/net/sock.h:487: warning: Function parameter or member 'sk_backlog.rmem_alloc' not described in 'sock'
   include/net/sock.h:487: warning: Function parameter or member 'sk_backlog.len' not described in 'sock'
   include/net/sock.h:487: warning: Function parameter or member 'sk_backlog.head' not described in 'sock'
   include/net/sock.h:487: warning: Function parameter or member 'sk_backlog.tail' not described in 'sock'
   include/net/sock.h:487: warning: Function parameter or member 'sk_wq_raw' not described in 'sock'
   include/net/sock.h:487: warning: Function parameter or member 'tcp_rtx_queue' not described in 'sock'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'adj_list.upper' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'adj_list.lower' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'gso_partial_features' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'switchdev_ops' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'l3mdev_ops' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'xfrmdev_ops' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'name_assign_type' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'ieee802154_ptr' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'mpls_ptr' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'xdp_prog' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'gro_flush_timeout' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'nf_hooks_ingress' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member '____cacheline_aligned_in_smp' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'qdisc_hash' not described in 'net_device'
   include/linux/phylink.h:56: warning: Function parameter or member '__ETHTOOL_DECLARE_LINK_MODE_MASK(advertising' not described in 'phylink_link_state'
   include/linux/phylink.h:56: warning: Function parameter or member '__ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising' not described in 'phylink_link_state'
   include/linux/rcupdate.h:570: ERROR: Unexpected indentation.
   include/linux/rcupdate.h:574: ERROR: Unexpected indentation.
   include/linux/rcupdate.h:578: WARNING: Block quote ends without a blank line; unexpected unindent.
   include/linux/rcupdate.h:580: WARNING: Block quote ends without a blank line; unexpected unindent.
   include/linux/rcupdate.h:580: WARNING: Inline literal start-string without end-string.
   kernel/time/timer.c:1259: ERROR: Unexpected indentation.
   kernel/time/timer.c:1261: ERROR: Unexpected indentation.
   kernel/time/timer.c:1262: WARNING: Block quote ends without a blank line; unexpected unindent.
   include/linux/wait.h:110: WARNING: Block quote ends without a blank line; unexpected unindent.
   include/linux/wait.h:113: ERROR: Unexpected indentation.
   include/linux/wait.h:115: WARNING: Block quote ends without a blank line; unexpected unindent.
   kernel/time/hrtimer.c:1113: WARNING: Block quote ends without a blank line; unexpected unindent.
   kernel/signal.c:327: WARNING: Inline literal start-string without end-string.
   drivers/video/fbdev/core/modedb.c:647: WARNING: Inline strong start-string without end-string.
   drivers/video/fbdev/core/modedb.c:647: WARNING: Inline strong start-string without end-string.
   drivers/video/fbdev/core/modedb.c:647: WARNING: Inline strong start-string without end-string.
   drivers/video/fbdev/core/modedb.c:647: WARNING: Inline strong start-string without end-string.
   include/linux/iio/iio.h:191: ERROR: Unexpected indentation.
   include/linux/iio/iio.h:192: WARNING: Block quote ends without a blank line; unexpected unindent.
   include/linux/iio/iio.h:198: WARNING: Definition list ends without a blank line; unexpected unindent.
   drivers/ata/libata-core.c:5920: ERROR: Unknown target name: "hw".
   drivers/message/fusion/mptbase.c:5052: WARNING: Definition list ends without a blank line; unexpected unindent.
   drivers/tty/serial/serial_core.c:1901: WARNING: Definition list ends without a blank line; unexpected unindent.
   include/linux/mtd/rawnand.h:805: ERROR: Unexpected indentation.
   include/linux/mtd/rawnand.h:1391: WARNING: Inline strong start-string without end-string.
   include/linux/mtd/rawnand.h:1393: WARNING: Inline strong start-string without end-string.
   include/linux/regulator/driver.h:273: ERROR: Unknown target name: "regulator_regmap_x_voltage".
   Documentation/driver-api/slimbus.rst:93: WARNING: Title underline too short.

vim +146 include/drm/drm_plane.h

43968d7b Daniel Vetter 2016-09-21 @146  

:::::: The code at line 146 was first introduced by commit
:::::: 43968d7b806d7a7e021261294c583a216fddf0e5 drm: Extract drm_plane.[hc]

:::::: TO: Daniel Vetter <daniel.vetter@ffwll.ch>
:::::: CC: Sean Paul <seanpaul@chromium.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 6812 bytes --]

[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 04/10] drm: Add Plane Gamma properties
  2018-02-15 19:45     ` Daniele Castagna
@ 2018-02-16 20:10       ` Ville Syrjälä
  2018-02-16 21:36         ` Harry Wentland
  0 siblings, 1 reply; 44+ messages in thread
From: Ville Syrjälä @ 2018-02-16 20:10 UTC (permalink / raw)
  To: Daniele Castagna; +Cc: uma.shankar, dri-devel

On Thu, Feb 15, 2018 at 02:45:29PM -0500, Daniele Castagna wrote:
> rk3399 has the option of setting per-plane gamma.
> The YUV2YUV registers are per-plane. Each plane YUV2YUV pipeline has
> at least 3 optional stages, two of those being degamma and gamma, and
> they can be configured per-plane.
> 
> I'm not sure about Intel HW. I think they might have something similar
> planned, considering the original patch was from uma.shankar. CCing
> directly in case he knows more.

IIRC some of out upcoming stuff will have a pipeline like
'csc->degamma->csc->gamma->blender'. I don't really know what the point
of the post csc gamma is though. Normally you would not want to reapply
any gamma prior to blending.

The only use case I can think of would be if you don't have a gamma lut
in the crtc for post blend gamma. In that case I suppose you might consider
doing the gamma before blending and accepting the slightly incorrect
blending results. But at least on our hardware we always have a gamma
lut in the crtc as well.

So yeah, I don't really have any reason why we'd need to actually to
expose the per-plane gamma. Some "crazy" artistic use case perhaps?

I'm totally fine not exposing it until someone comes up with an actual
use for it.

Does rk3399 have a dedicated csc for yuv->rgb before degamma? Or are you
supposed to use the same csc for that as you'd use for ctm? In that case
I can understand why the hw would have a gamm lut on each side of the
csc. But it would also means that you can't do yuv->rgb and ctm at the
same time unless you're fine with doing it wrong.

> 
> On Thu, Feb 15, 2018 at 2:29 PM, Harry Wentland <harry.wentland@amd.com> wrote:
> > On 2018-02-15 12:32 AM, Daniele Castagna wrote:
> >> From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>
> >>
> >> Add plane gamma as blob property and size as a
> >> range property.
> >>
> >
> > Plane degamma & CTM make sense to me but I'm not sure why gamma would be on a per-plane basis. That said, HW sometimes has these implemented in odd ways. Do we know of any HW that will currently or in the future need per-plane gamma or are we just trying to cover all potentialities?
> >
> > Harry
> >
> >> (am from https://patchwork.kernel.org/patch/9971325/)
> >>
> >> Change-Id: I606cd40c9748b136fc2bf4750bea1da285add62d
> >> Signed-off-by: Uma Shankar <uma.shankar at intel.com>
> >> ---
> >>  drivers/gpu/drm/drm_atomic.c        |  8 ++++++++
> >>  drivers/gpu/drm/drm_atomic_helper.c |  4 ++++
> >>  drivers/gpu/drm/drm_mode_config.c   | 14 ++++++++++++++
> >>  include/drm/drm_mode_config.h       | 11 +++++++++++
> >>  include/drm/drm_plane.h             |  9 +++++++++
> >>  5 files changed, 46 insertions(+)
> >>
> >> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> >> index d4b8c6cc84128..f634f6450f415 100644
> >> --- a/drivers/gpu/drm/drm_atomic.c
> >> +++ b/drivers/gpu/drm/drm_atomic.c
> >> @@ -778,6 +778,12 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
> >>                                       &replaced);
> >>               state->color_mgmt_changed |= replaced;
> >>               return ret;
> >> +     } else if (property == config->plane_gamma_lut_property) {
> >> +             ret = drm_atomic_replace_property_blob_from_id(dev,
> >> +                                     &state->gamma_lut,
> >> +                                     val, -1, &replaced);
> >> +             state->color_mgmt_changed |= replaced;
> >> +             return ret;
> >>       } else {
> >>               return -EINVAL;
> >>       }
> >> @@ -841,6 +847,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
> >>                       state->degamma_lut->base.id : 0;
> >>       } else if (property == config->plane_ctm_property) {
> >>               *val = (state->ctm) ? state->ctm->base.id : 0;
> >> +     } else if (property == config->plane_gamma_lut_property) {
> >> +             *val = (state->gamma_lut) ? state->gamma_lut->base.id : 0;
> >>       } else {
> >>               return -EINVAL;
> >>       }
> >> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> >> index 17e137a529a0e..97dbb36153d14 100644
> >> --- a/drivers/gpu/drm/drm_atomic_helper.c
> >> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> >> @@ -3495,6 +3495,9 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
> >>               drm_property_reference_blob(state->degamma_lut);
> >>       if (state->ctm)
> >>               drm_property_reference_blob(state->ctm);
> >> +     if (state->gamma_lut)
> >> +             drm_property_reference_blob(state->gamma_lut);
> >> +
> >>       state->color_mgmt_changed = false;
> >>  }
> >>  EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state);
> >> @@ -3543,6 +3546,7 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)
> >>
> >>       drm_property_unreference_blob(state->degamma_lut);
> >>       drm_property_unreference_blob(state->ctm);
> >> +     drm_property_unreference_blob(state->gamma_lut);
> >>  }
> >>  EXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state);
> >>
> >> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> >> index c8763977413e7..bc6f8e51c7464 100644
> >> --- a/drivers/gpu/drm/drm_mode_config.c
> >> +++ b/drivers/gpu/drm/drm_mode_config.c
> >> @@ -368,6 +368,20 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> >>               return -ENOMEM;
> >>       dev->mode_config.plane_ctm_property = prop;
> >>
> >> +     prop = drm_property_create(dev,
> >> +                     DRM_MODE_PROP_BLOB,
> >> +                     "PLANE_GAMMA_LUT", 0);
> >> +     if (!prop)
> >> +             return -ENOMEM;
> >> +     dev->mode_config.plane_gamma_lut_property = prop;
> >> +
> >> +     prop = drm_property_create_range(dev,
> >> +                     DRM_MODE_PROP_IMMUTABLE,
> >> +                     "PLANE_GAMMA_LUT_SIZE", 0, UINT_MAX);
> >> +     if (!prop)
> >> +             return -ENOMEM;
> >> +     dev->mode_config.plane_gamma_lut_size_property = prop;
> >> +
> >>       return 0;
> >>  }
> >>
> >> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> >> index ad7235ced531b..3ca3eb3c98950 100644
> >> --- a/include/drm/drm_mode_config.h
> >> +++ b/include/drm/drm_mode_config.h
> >> @@ -740,6 +740,17 @@ struct drm_mode_config {
> >>        * degamma LUT.
> >>        */
> >>       struct drm_property *plane_ctm_property;
> >> +     /**
> >> +      * @plane_gamma_lut_property: Optional Plane property to set the LUT
> >> +      * used to convert the colors, after the CTM matrix, to the common
> >> +      * gamma space chosen for blending.
> >> +      */
> >> +     struct drm_property *plane_gamma_lut_property;
> >> +     /**
> >> +      * @plane_gamma_lut_size_property: Optional Plane property for the size
> >> +      * of the gamma LUT as supported by the driver (read-only).
> >> +      */
> >> +     struct drm_property *plane_gamma_lut_size_property;
> >>       /**
> >>        * @ctm_property: Optional CRTC property to set the
> >>        * matrix used to convert colors after the lookup in the
> >> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> >> index 21aecc9c91a09..acabb85009a14 100644
> >> --- a/include/drm/drm_plane.h
> >> +++ b/include/drm/drm_plane.h
> >> @@ -147,6 +147,15 @@ struct drm_plane_state {
> >>        */
> >>       struct drm_property_blob *ctm;
> >>
> >> +     /**
> >> +      * @gamma_lut:
> >> +      *
> >> +      * Lookup table for converting pixel data after the color conversion
> >> +      * matrix @ctm.  See drm_plane_enable_color_mgmt(). The blob (if not
> >> +      * NULL) is an array of &struct drm_color_lut.
> >> +      */
> >> +     struct drm_property_blob *gamma_lut;
> >> +
> >>       struct drm_atomic_state *state;
> >>
> >>       bool color_mgmt_changed : 1;
> >>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 04/10] drm: Add Plane Gamma properties
  2018-02-16 20:10       ` Ville Syrjälä
@ 2018-02-16 21:36         ` Harry Wentland
  2018-02-18  6:43           ` Shankar, Uma
  0 siblings, 1 reply; 44+ messages in thread
From: Harry Wentland @ 2018-02-16 21:36 UTC (permalink / raw)
  To: Ville Syrjälä, Daniele Castagna; +Cc: uma.shankar, dri-devel

On 2018-02-16 03:10 PM, Ville Syrjälä wrote:
> On Thu, Feb 15, 2018 at 02:45:29PM -0500, Daniele Castagna wrote:
>> rk3399 has the option of setting per-plane gamma.
>> The YUV2YUV registers are per-plane. Each plane YUV2YUV pipeline has
>> at least 3 optional stages, two of those being degamma and gamma, and
>> they can be configured per-plane.
>>

I don't mind having a per-plane gamma, especially since rk3399 has it in
HW. It just seemed a bit curious to me and I'd rather avoid properties
that would never be used by any driver.

>> I'm not sure about Intel HW. I think they might have something similar
>> planned, considering the original patch was from uma.shankar. CCing
>> directly in case he knows more.
> 
> IIRC some of out upcoming stuff will have a pipeline like
> 'csc->degamma->csc->gamma->blender'. I don't really know what the point
> of the post csc gamma is though. Normally you would not want to reapply
> any gamma prior to blending.
> 
> The only use case I can think of would be if you don't have a gamma lut
> in the crtc for post blend gamma. In that case I suppose you might consider
> doing the gamma before blending and accepting the slightly incorrect
> blending results. But at least on our hardware we always have a gamma
> lut in the crtc as well.

That's what I was thinking of as the only possible use-case as well.

Harry

> 
> So yeah, I don't really have any reason why we'd need to actually to
> expose the per-plane gamma. Some "crazy" artistic use case perhaps?
> 
> I'm totally fine not exposing it until someone comes up with an actual
> use for it.
> 
> Does rk3399 have a dedicated csc for yuv->rgb before degamma? Or are you
> supposed to use the same csc for that as you'd use for ctm? In that case
> I can understand why the hw would have a gamm lut on each side of the
> csc. But it would also means that you can't do yuv->rgb and ctm at the
> same time unless you're fine with doing it wrong.
> 
>>
>> On Thu, Feb 15, 2018 at 2:29 PM, Harry Wentland <harry.wentland@amd.com> wrote:
>>> On 2018-02-15 12:32 AM, Daniele Castagna wrote:
>>>> From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>
>>>>
>>>> Add plane gamma as blob property and size as a
>>>> range property.
>>>>
>>>
>>> Plane degamma & CTM make sense to me but I'm not sure why gamma would be on a per-plane basis. That said, HW sometimes has these implemented in odd ways. Do we know of any HW that will currently or in the future need per-plane gamma or are we just trying to cover all potentialities?
>>>
>>> Harry
>>>
>>>> (am from https://patchwork.kernel.org/patch/9971325/)
>>>>
>>>> Change-Id: I606cd40c9748b136fc2bf4750bea1da285add62d
>>>> Signed-off-by: Uma Shankar <uma.shankar at intel.com>
>>>> ---
>>>>  drivers/gpu/drm/drm_atomic.c        |  8 ++++++++
>>>>  drivers/gpu/drm/drm_atomic_helper.c |  4 ++++
>>>>  drivers/gpu/drm/drm_mode_config.c   | 14 ++++++++++++++
>>>>  include/drm/drm_mode_config.h       | 11 +++++++++++
>>>>  include/drm/drm_plane.h             |  9 +++++++++
>>>>  5 files changed, 46 insertions(+)
>>>>
>>>> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
>>>> index d4b8c6cc84128..f634f6450f415 100644
>>>> --- a/drivers/gpu/drm/drm_atomic.c
>>>> +++ b/drivers/gpu/drm/drm_atomic.c
>>>> @@ -778,6 +778,12 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
>>>>                                       &replaced);
>>>>               state->color_mgmt_changed |= replaced;
>>>>               return ret;
>>>> +     } else if (property == config->plane_gamma_lut_property) {
>>>> +             ret = drm_atomic_replace_property_blob_from_id(dev,
>>>> +                                     &state->gamma_lut,
>>>> +                                     val, -1, &replaced);
>>>> +             state->color_mgmt_changed |= replaced;
>>>> +             return ret;
>>>>       } else {
>>>>               return -EINVAL;
>>>>       }
>>>> @@ -841,6 +847,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
>>>>                       state->degamma_lut->base.id : 0;
>>>>       } else if (property == config->plane_ctm_property) {
>>>>               *val = (state->ctm) ? state->ctm->base.id : 0;
>>>> +     } else if (property == config->plane_gamma_lut_property) {
>>>> +             *val = (state->gamma_lut) ? state->gamma_lut->base.id : 0;
>>>>       } else {
>>>>               return -EINVAL;
>>>>       }
>>>> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
>>>> index 17e137a529a0e..97dbb36153d14 100644
>>>> --- a/drivers/gpu/drm/drm_atomic_helper.c
>>>> +++ b/drivers/gpu/drm/drm_atomic_helper.c
>>>> @@ -3495,6 +3495,9 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
>>>>               drm_property_reference_blob(state->degamma_lut);
>>>>       if (state->ctm)
>>>>               drm_property_reference_blob(state->ctm);
>>>> +     if (state->gamma_lut)
>>>> +             drm_property_reference_blob(state->gamma_lut);
>>>> +
>>>>       state->color_mgmt_changed = false;
>>>>  }
>>>>  EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state);
>>>> @@ -3543,6 +3546,7 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)
>>>>
>>>>       drm_property_unreference_blob(state->degamma_lut);
>>>>       drm_property_unreference_blob(state->ctm);
>>>> +     drm_property_unreference_blob(state->gamma_lut);
>>>>  }
>>>>  EXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state);
>>>>
>>>> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
>>>> index c8763977413e7..bc6f8e51c7464 100644
>>>> --- a/drivers/gpu/drm/drm_mode_config.c
>>>> +++ b/drivers/gpu/drm/drm_mode_config.c
>>>> @@ -368,6 +368,20 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>>>>               return -ENOMEM;
>>>>       dev->mode_config.plane_ctm_property = prop;
>>>>
>>>> +     prop = drm_property_create(dev,
>>>> +                     DRM_MODE_PROP_BLOB,
>>>> +                     "PLANE_GAMMA_LUT", 0);
>>>> +     if (!prop)
>>>> +             return -ENOMEM;
>>>> +     dev->mode_config.plane_gamma_lut_property = prop;
>>>> +
>>>> +     prop = drm_property_create_range(dev,
>>>> +                     DRM_MODE_PROP_IMMUTABLE,
>>>> +                     "PLANE_GAMMA_LUT_SIZE", 0, UINT_MAX);
>>>> +     if (!prop)
>>>> +             return -ENOMEM;
>>>> +     dev->mode_config.plane_gamma_lut_size_property = prop;
>>>> +
>>>>       return 0;
>>>>  }
>>>>
>>>> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
>>>> index ad7235ced531b..3ca3eb3c98950 100644
>>>> --- a/include/drm/drm_mode_config.h
>>>> +++ b/include/drm/drm_mode_config.h
>>>> @@ -740,6 +740,17 @@ struct drm_mode_config {
>>>>        * degamma LUT.
>>>>        */
>>>>       struct drm_property *plane_ctm_property;
>>>> +     /**
>>>> +      * @plane_gamma_lut_property: Optional Plane property to set the LUT
>>>> +      * used to convert the colors, after the CTM matrix, to the common
>>>> +      * gamma space chosen for blending.
>>>> +      */
>>>> +     struct drm_property *plane_gamma_lut_property;
>>>> +     /**
>>>> +      * @plane_gamma_lut_size_property: Optional Plane property for the size
>>>> +      * of the gamma LUT as supported by the driver (read-only).
>>>> +      */
>>>> +     struct drm_property *plane_gamma_lut_size_property;
>>>>       /**
>>>>        * @ctm_property: Optional CRTC property to set the
>>>>        * matrix used to convert colors after the lookup in the
>>>> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
>>>> index 21aecc9c91a09..acabb85009a14 100644
>>>> --- a/include/drm/drm_plane.h
>>>> +++ b/include/drm/drm_plane.h
>>>> @@ -147,6 +147,15 @@ struct drm_plane_state {
>>>>        */
>>>>       struct drm_property_blob *ctm;
>>>>
>>>> +     /**
>>>> +      * @gamma_lut:
>>>> +      *
>>>> +      * Lookup table for converting pixel data after the color conversion
>>>> +      * matrix @ctm.  See drm_plane_enable_color_mgmt(). The blob (if not
>>>> +      * NULL) is an array of &struct drm_color_lut.
>>>> +      */
>>>> +     struct drm_property_blob *gamma_lut;
>>>> +
>>>>       struct drm_atomic_state *state;
>>>>
>>>>       bool color_mgmt_changed : 1;
>>>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 06/10] drm: Define helper to set legacy gamma table size
  2018-02-15  5:32 ` [PATCH 06/10] drm: Define helper to set legacy gamma table size Daniele Castagna
@ 2018-02-16 22:17   ` kbuild test robot
  2018-02-27 15:35   ` Sean Paul
  2018-02-27 16:20   ` Emil Velikov
  2 siblings, 0 replies; 44+ messages in thread
From: kbuild test robot @ 2018-02-16 22:17 UTC (permalink / raw)
  To: Daniele Castagna; +Cc: kbuild-all, dri-devel

[-- Attachment #1: Type: text/plain, Size: 22687 bytes --]

Hi uma.shankar,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on rockchip/for-next]
[also build test WARNING on v4.16-rc1 next-20180216]
[cannot apply to drm/drm-next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Daniele-Castagna/drm-rockchip-YUV-overlays-BT-601-color-conversion/20180216-233006
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git for-next
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

   include/linux/crypto.h:477: warning: Function parameter or member 'cra_u.compress' not described in 'crypto_alg'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.ibss' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.connect' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.keys' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.ie' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.ie_len' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.bssid' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.prev_bssid' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.ssid' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.default_key' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.default_mgmt_key' not described in 'wireless_dev'
   include/net/cfg80211.h:4129: warning: Function parameter or member 'wext.prev_bssid_valid' not described in 'wireless_dev'
   include/net/mac80211.h:2259: warning: Function parameter or member 'radiotap_timestamp.units_pos' not described in 'ieee80211_hw'
   include/net/mac80211.h:2259: warning: Function parameter or member 'radiotap_timestamp.accuracy' not described in 'ieee80211_hw'
   include/net/mac80211.h:950: warning: Function parameter or member 'rates' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'control.rts_cts_rate_idx' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'control.use_rts' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'control.use_cts_prot' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'control.short_preamble' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'control.skip_table' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'control.jiffies' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'control.vif' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'control.hw_key' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'control.flags' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'control.enqueue_time' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'ack' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'ack.cookie' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'status.rates' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'status.ack_signal' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'status.ampdu_ack_len' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'status.ampdu_len' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'status.antenna' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'status.tx_time' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'status_driver_data' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'driver_rates' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'pad' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:950: warning: Function parameter or member 'rate_driver_data' not described in 'ieee80211_tx_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'rx_stats_avg' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'rx_stats_avg.signal' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'rx_stats_avg.chain_signal' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'status_stats.filtered' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'status_stats.retry_failed' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'status_stats.retry_count' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'status_stats.lost_packets' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'status_stats.last_tdls_pkt_time' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'msdu_retries' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'msdu_failed' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'status_stats.last_ack' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'tx_stats.packets' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'tx_stats.bytes' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'tx_stats.last_rate' not described in 'sta_info'
   net/mac80211/sta_info.h:584: warning: Function parameter or member 'msdu' not described in 'sta_info'
   include/linux/dma-buf.h:307: warning: Function parameter or member 'cb_excl.cb' not described in 'dma_buf'
   include/linux/dma-buf.h:307: warning: Function parameter or member 'cb_excl.poll' not described in 'dma_buf'
   include/linux/dma-buf.h:307: warning: Function parameter or member 'cb_excl.active' not described in 'dma_buf'
   include/linux/dma-buf.h:307: warning: Function parameter or member 'cb_shared.cb' not described in 'dma_buf'
   include/linux/dma-buf.h:307: warning: Function parameter or member 'cb_shared.poll' not described in 'dma_buf'
   include/linux/dma-buf.h:307: warning: Function parameter or member 'cb_shared.active' not described in 'dma_buf'
   include/linux/dma-fence-array.h:54: warning: Function parameter or member 'work' not described in 'dma_fence_array'
   include/linux/gpio/driver.h:142: warning: Function parameter or member 'request_key' not described in 'gpio_irq_chip'
   include/linux/iio/iio.h:270: warning: Function parameter or member 'scan_type.sign' not described in 'iio_chan_spec'
   include/linux/iio/iio.h:270: warning: Function parameter or member 'scan_type.realbits' not described in 'iio_chan_spec'
   include/linux/iio/iio.h:270: warning: Function parameter or member 'scan_type.storagebits' not described in 'iio_chan_spec'
   include/linux/iio/iio.h:270: warning: Function parameter or member 'scan_type.shift' not described in 'iio_chan_spec'
   include/linux/iio/iio.h:270: warning: Function parameter or member 'scan_type.repeat' not described in 'iio_chan_spec'
   include/linux/iio/iio.h:270: warning: Function parameter or member 'scan_type.endianness' not described in 'iio_chan_spec'
   include/linux/iio/hw-consumer.h:1: warning: no structured comments found
   include/linux/device.h:294: warning: Function parameter or member 'coredump' not described in 'device_driver'
   include/linux/input/sparse-keymap.h:46: warning: Function parameter or member 'sw' not described in 'key_entry'
   include/linux/mtd/rawnand.h:709: warning: Function parameter or member 'timings.sdr' not described in 'nand_data_interface'
   include/linux/mtd/rawnand.h:774: warning: Function parameter or member 'buf' not described in 'nand_op_data_instr'
   include/linux/mtd/rawnand.h:774: warning: Function parameter or member 'buf.in' not described in 'nand_op_data_instr'
   include/linux/mtd/rawnand.h:774: warning: Function parameter or member 'buf.out' not described in 'nand_op_data_instr'
   include/linux/mtd/rawnand.h:820: warning: Function parameter or member 'ctx' not described in 'nand_op_instr'
   include/linux/mtd/rawnand.h:820: warning: Function parameter or member 'ctx.cmd' not described in 'nand_op_instr'
   include/linux/mtd/rawnand.h:820: warning: Function parameter or member 'ctx.addr' not described in 'nand_op_instr'
   include/linux/mtd/rawnand.h:820: warning: Function parameter or member 'ctx.data' not described in 'nand_op_instr'
   include/linux/mtd/rawnand.h:820: warning: Function parameter or member 'ctx.waitrdy' not described in 'nand_op_instr'
   include/linux/mtd/rawnand.h:967: warning: Function parameter or member 'ctx' not described in 'nand_op_parser_pattern_elem'
   include/linux/mtd/rawnand.h:967: warning: Function parameter or member 'ctx.addr' not described in 'nand_op_parser_pattern_elem'
   include/linux/mtd/rawnand.h:967: warning: Function parameter or member 'ctx.data' not described in 'nand_op_parser_pattern_elem'
   include/linux/mtd/rawnand.h:1281: warning: Function parameter or member 'manufacturer.desc' not described in 'nand_chip'
   include/linux/mtd/rawnand.h:1281: warning: Function parameter or member 'manufacturer.priv' not described in 'nand_chip'
   include/linux/regulator/driver.h:221: warning: Function parameter or member 'resume_early' not described in 'regulator_ops'
   drivers/regulator/core.c:4299: warning: Excess function parameter 'state' description in 'regulator_suspend_late'
   arch/s390/include/asm/cio.h:245: warning: Function parameter or member 'esw.esw0' not described in 'irb'
   arch/s390/include/asm/cio.h:245: warning: Function parameter or member 'esw.esw1' not described in 'irb'
   arch/s390/include/asm/cio.h:245: warning: Function parameter or member 'esw.esw2' not described in 'irb'
   arch/s390/include/asm/cio.h:245: warning: Function parameter or member 'esw.esw3' not described in 'irb'
   arch/s390/include/asm/cio.h:245: warning: Function parameter or member 'esw.eadm' not described in 'irb'
   include/drm/drm_drv.h:609: warning: Function parameter or member 'gem_prime_pin' not described in 'drm_driver'
   include/drm/drm_drv.h:609: warning: Function parameter or member 'gem_prime_unpin' not described in 'drm_driver'
   include/drm/drm_drv.h:609: warning: Function parameter or member 'gem_prime_res_obj' not described in 'drm_driver'
   include/drm/drm_drv.h:609: warning: Function parameter or member 'gem_prime_get_sg_table' not described in 'drm_driver'
   include/drm/drm_drv.h:609: warning: Function parameter or member 'gem_prime_import_sg_table' not described in 'drm_driver'
   include/drm/drm_drv.h:609: warning: Function parameter or member 'gem_prime_vmap' not described in 'drm_driver'
   include/drm/drm_drv.h:609: warning: Function parameter or member 'gem_prime_vunmap' not described in 'drm_driver'
   include/drm/drm_drv.h:609: warning: Function parameter or member 'gem_prime_mmap' not described in 'drm_driver'
   include/drm/drm_plane.h:163: warning: Function parameter or member 'degamma_lut' not described in 'drm_plane_state'
   include/drm/drm_plane.h:163: warning: Function parameter or member 'color_mgmt_changed' not described in 'drm_plane_state'
>> include/drm/drm_plane.h:593: warning: Function parameter or member 'gamma_size' not described in 'drm_plane'
>> include/drm/drm_plane.h:593: warning: Function parameter or member 'gamma_store' not described in 'drm_plane'
   include/drm/drm_connector.h:370: warning: Function parameter or member 'margins.left' not described in 'drm_tv_connector_state'
   include/drm/drm_connector.h:370: warning: Function parameter or member 'margins.right' not described in 'drm_tv_connector_state'
   include/drm/drm_connector.h:370: warning: Function parameter or member 'margins.top' not described in 'drm_tv_connector_state'
   include/drm/drm_connector.h:370: warning: Function parameter or member 'margins.bottom' not described in 'drm_tv_connector_state'
   include/drm/drm_vblank.h:63: warning: Function parameter or member 'event.base' not described in 'drm_pending_vblank_event'
   include/drm/drm_vblank.h:63: warning: Function parameter or member 'event.vbl' not described in 'drm_pending_vblank_event'
   include/drm/drm_vblank.h:63: warning: Function parameter or member 'event.seq' not described in 'drm_pending_vblank_event'
   drivers/gpu/drm/tve200/tve200_drv.c:1: warning: no structured comments found
   include/linux/skbuff.h:846: warning: Function parameter or member 'dev_scratch' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'skb_mstamp' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member '__cloned_offset' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'head_frag' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member '__unused' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member '__pkt_type_offset' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'pfmemalloc' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'encapsulation' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'encap_hdr_csum' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'csum_valid' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'csum_complete_sw' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'csum_level' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'inner_protocol_type' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'remcsum_offload' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'offload_fwd_mark' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'offload_mr_fwd_mark' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'sender_cpu' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'reserved_tailroom' not described in 'sk_buff'
   include/linux/skbuff.h:846: warning: Function parameter or member 'inner_ipproto' not described in 'sk_buff'
   include/net/sock.h:234: warning: Function parameter or member 'skc_addrpair' not described in 'sock_common'
   include/net/sock.h:234: warning: Function parameter or member 'skc_portpair' not described in 'sock_common'
   include/net/sock.h:234: warning: Function parameter or member 'skc_ipv6only' not described in 'sock_common'
   include/net/sock.h:234: warning: Function parameter or member 'skc_net_refcnt' not described in 'sock_common'
   include/net/sock.h:234: warning: Function parameter or member 'skc_v6_daddr' not described in 'sock_common'
   include/net/sock.h:234: warning: Function parameter or member 'skc_v6_rcv_saddr' not described in 'sock_common'
   include/net/sock.h:234: warning: Function parameter or member 'skc_cookie' not described in 'sock_common'
   include/net/sock.h:234: warning: Function parameter or member 'skc_listener' not described in 'sock_common'
   include/net/sock.h:234: warning: Function parameter or member 'skc_tw_dr' not described in 'sock_common'
   include/net/sock.h:234: warning: Function parameter or member 'skc_rcv_wnd' not described in 'sock_common'
   include/net/sock.h:234: warning: Function parameter or member 'skc_tw_rcv_nxt' not described in 'sock_common'
   include/net/sock.h:487: warning: Function parameter or member 'sk_backlog.rmem_alloc' not described in 'sock'
   include/net/sock.h:487: warning: Function parameter or member 'sk_backlog.len' not described in 'sock'
   include/net/sock.h:487: warning: Function parameter or member 'sk_backlog.head' not described in 'sock'
   include/net/sock.h:487: warning: Function parameter or member 'sk_backlog.tail' not described in 'sock'
   include/net/sock.h:487: warning: Function parameter or member 'sk_wq_raw' not described in 'sock'
   include/net/sock.h:487: warning: Function parameter or member 'tcp_rtx_queue' not described in 'sock'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'adj_list.upper' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'adj_list.lower' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'gso_partial_features' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'switchdev_ops' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'l3mdev_ops' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'xfrmdev_ops' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'name_assign_type' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'ieee802154_ptr' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'mpls_ptr' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'xdp_prog' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'gro_flush_timeout' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'nf_hooks_ingress' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member '____cacheline_aligned_in_smp' not described in 'net_device'
   include/linux/netdevice.h:1940: warning: Function parameter or member 'qdisc_hash' not described in 'net_device'
   include/linux/phylink.h:56: warning: Function parameter or member '__ETHTOOL_DECLARE_LINK_MODE_MASK(advertising' not described in 'phylink_link_state'
   include/linux/phylink.h:56: warning: Function parameter or member '__ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising' not described in 'phylink_link_state'
   include/linux/rcupdate.h:570: ERROR: Unexpected indentation.
   include/linux/rcupdate.h:574: ERROR: Unexpected indentation.
   include/linux/rcupdate.h:578: WARNING: Block quote ends without a blank line; unexpected unindent.
   include/linux/rcupdate.h:580: WARNING: Block quote ends without a blank line; unexpected unindent.
   include/linux/rcupdate.h:580: WARNING: Inline literal start-string without end-string.
   kernel/time/timer.c:1259: ERROR: Unexpected indentation.
   kernel/time/timer.c:1261: ERROR: Unexpected indentation.
   kernel/time/timer.c:1262: WARNING: Block quote ends without a blank line; unexpected unindent.
   include/linux/wait.h:110: WARNING: Block quote ends without a blank line; unexpected unindent.
   include/linux/wait.h:113: ERROR: Unexpected indentation.
   include/linux/wait.h:115: WARNING: Block quote ends without a blank line; unexpected unindent.
   kernel/time/hrtimer.c:1113: WARNING: Block quote ends without a blank line; unexpected unindent.
   kernel/signal.c:327: WARNING: Inline literal start-string without end-string.
   drivers/video/fbdev/core/modedb.c:647: WARNING: Inline strong start-string without end-string.
   drivers/video/fbdev/core/modedb.c:647: WARNING: Inline strong start-string without end-string.
   drivers/video/fbdev/core/modedb.c:647: WARNING: Inline strong start-string without end-string.
   drivers/video/fbdev/core/modedb.c:647: WARNING: Inline strong start-string without end-string.
   include/linux/iio/iio.h:191: ERROR: Unexpected indentation.
   include/linux/iio/iio.h:192: WARNING: Block quote ends without a blank line; unexpected unindent.
   include/linux/iio/iio.h:198: WARNING: Definition list ends without a blank line; unexpected unindent.
   drivers/ata/libata-core.c:5920: ERROR: Unknown target name: "hw".
   drivers/message/fusion/mptbase.c:5052: WARNING: Definition list ends without a blank line; unexpected unindent.
   drivers/tty/serial/serial_core.c:1901: WARNING: Definition list ends without a blank line; unexpected unindent.
   include/linux/mtd/rawnand.h:805: ERROR: Unexpected indentation.
   include/linux/mtd/rawnand.h:1391: WARNING: Inline strong start-string without end-string.
   include/linux/mtd/rawnand.h:1393: WARNING: Inline strong start-string without end-string.
   include/linux/regulator/driver.h:273: ERROR: Unknown target name: "regulator_regmap_x_voltage".
   Documentation/driver-api/slimbus.rst:93: WARNING: Title underline too short.

vim +593 include/drm/drm_plane.h

43968d7b Daniel Vetter 2016-09-21 @593  

:::::: The code at line 593 was first introduced by commit
:::::: 43968d7b806d7a7e021261294c583a216fddf0e5 drm: Extract drm_plane.[hc]

:::::: TO: Daniel Vetter <daniel.vetter@ffwll.ch>
:::::: CC: Sean Paul <seanpaul@chromium.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 6812 bytes --]

[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* RE: [PATCH 04/10] drm: Add Plane Gamma properties
  2018-02-16 21:36         ` Harry Wentland
@ 2018-02-18  6:43           ` Shankar, Uma
  0 siblings, 0 replies; 44+ messages in thread
From: Shankar, Uma @ 2018-02-18  6:43 UTC (permalink / raw)
  To: Harry Wentland, Ville Syrjälä, Daniele Castagna; +Cc: dri-devel



>-----Original Message-----
>From: Harry Wentland [mailto:harry.wentland@amd.com]
>Sent: Saturday, February 17, 2018 3:07 AM
>To: Ville Syrjälä <ville.syrjala@linux.intel.com>; Daniele Castagna
><dcastagna@google.com>
>Cc: Shankar, Uma <uma.shankar@intel.com>; dri-devel@lists.freedesktop.org
>Subject: Re: [PATCH 04/10] drm: Add Plane Gamma properties
>
>On 2018-02-16 03:10 PM, Ville Syrjälä wrote:
>> On Thu, Feb 15, 2018 at 02:45:29PM -0500, Daniele Castagna wrote:
>>> rk3399 has the option of setting per-plane gamma.
>>> The YUV2YUV registers are per-plane. Each plane YUV2YUV pipeline has
>>> at least 3 optional stages, two of those being degamma and gamma, and
>>> they can be configured per-plane.
>>>
>
>I don't mind having a per-plane gamma, especially since rk3399 has it in HW. It
>just seemed a bit curious to me and I'd rather avoid properties that would never
>be used by any driver.
>
>>> I'm not sure about Intel HW. I think they might have something
>>> similar planned, considering the original patch was from uma.shankar.
>>> CCing directly in case he knows more.
>>
>> IIRC some of out upcoming stuff will have a pipeline like
>> 'csc->degamma->csc->gamma->blender'. I don't really know what the
>> point of the post csc gamma is though. Normally you would not want to
>> reapply any gamma prior to blending.
>>
>> The only use case I can think of would be if you don't have a gamma
>> lut in the crtc for post blend gamma. In that case I suppose you might
>> consider doing the gamma before blending and accepting the slightly
>> incorrect blending results. But at least on our hardware we always
>> have a gamma lut in the crtc as well.
>
>That's what I was thinking of as the only possible use-case as well.
>

The primary use case of the post CSC plane gamma LUT will be to do tone
mapping in case of HDR data. Again the accuracy of it will depend on the
number of LUT samples and precision. It could be used, if for some strange
use case we want non-linear blending. I believe Android was using non-linear
blending by design (not sure if it changed in recent variants). Also as Ville
mentioned, if we lack gamma at pipe level on certain hardware, this may be
required. But tone mapping is the primary use case.

Regards,
Uma Shankar

>Harry
>
>>
>> So yeah, I don't really have any reason why we'd need to actually to
>> expose the per-plane gamma. Some "crazy" artistic use case perhaps?
>>
>> I'm totally fine not exposing it until someone comes up with an actual
>> use for it.
>>
>> Does rk3399 have a dedicated csc for yuv->rgb before degamma? Or are
>> you supposed to use the same csc for that as you'd use for ctm? In
>> that case I can understand why the hw would have a gamm lut on each
>> side of the csc. But it would also means that you can't do yuv->rgb
>> and ctm at the same time unless you're fine with doing it wrong.
>>
>>>
>>> On Thu, Feb 15, 2018 at 2:29 PM, Harry Wentland
><harry.wentland@amd.com> wrote:
>>>> On 2018-02-15 12:32 AM, Daniele Castagna wrote:
>>>>> From: "uma.shankar at intel.com (Uma Shankar)"
>>>>> <uma.shankar@intel.com>
>>>>>
>>>>> Add plane gamma as blob property and size as a range property.
>>>>>
>>>>
>>>> Plane degamma & CTM make sense to me but I'm not sure why gamma
>would be on a per-plane basis. That said, HW sometimes has these implemented
>in odd ways. Do we know of any HW that will currently or in the future need per-
>plane gamma or are we just trying to cover all potentialities?
>>>>
>>>> Harry
>>>>
>>>>> (am from https://patchwork.kernel.org/patch/9971325/)
>>>>>
>>>>> Change-Id: I606cd40c9748b136fc2bf4750bea1da285add62d
>>>>> Signed-off-by: Uma Shankar <uma.shankar at intel.com>
>>>>> ---
>>>>>  drivers/gpu/drm/drm_atomic.c        |  8 ++++++++
>>>>>  drivers/gpu/drm/drm_atomic_helper.c |  4 ++++
>>>>>  drivers/gpu/drm/drm_mode_config.c   | 14 ++++++++++++++
>>>>>  include/drm/drm_mode_config.h       | 11 +++++++++++
>>>>>  include/drm/drm_plane.h             |  9 +++++++++
>>>>>  5 files changed, 46 insertions(+)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/drm_atomic.c
>>>>> b/drivers/gpu/drm/drm_atomic.c index d4b8c6cc84128..f634f6450f415
>>>>> 100644
>>>>> --- a/drivers/gpu/drm/drm_atomic.c
>>>>> +++ b/drivers/gpu/drm/drm_atomic.c
>>>>> @@ -778,6 +778,12 @@ static int drm_atomic_plane_set_property(struct
>drm_plane *plane,
>>>>>                                       &replaced);
>>>>>               state->color_mgmt_changed |= replaced;
>>>>>               return ret;
>>>>> +     } else if (property == config->plane_gamma_lut_property) {
>>>>> +             ret = drm_atomic_replace_property_blob_from_id(dev,
>>>>> +                                     &state->gamma_lut,
>>>>> +                                     val, -1, &replaced);
>>>>> +             state->color_mgmt_changed |= replaced;
>>>>> +             return ret;
>>>>>       } else {
>>>>>               return -EINVAL;
>>>>>       }
>>>>> @@ -841,6 +847,8 @@ drm_atomic_plane_get_property(struct drm_plane
>*plane,
>>>>>                       state->degamma_lut->base.id : 0;
>>>>>       } else if (property == config->plane_ctm_property) {
>>>>>               *val = (state->ctm) ? state->ctm->base.id : 0;
>>>>> +     } else if (property == config->plane_gamma_lut_property) {
>>>>> +             *val = (state->gamma_lut) ? state->gamma_lut->base.id
>>>>> + : 0;
>>>>>       } else {
>>>>>               return -EINVAL;
>>>>>       }
>>>>> diff --git a/drivers/gpu/drm/drm_atomic_helper.c
>>>>> b/drivers/gpu/drm/drm_atomic_helper.c
>>>>> index 17e137a529a0e..97dbb36153d14 100644
>>>>> --- a/drivers/gpu/drm/drm_atomic_helper.c
>>>>> +++ b/drivers/gpu/drm/drm_atomic_helper.c
>>>>> @@ -3495,6 +3495,9 @@ void
>__drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
>>>>>               drm_property_reference_blob(state->degamma_lut);
>>>>>       if (state->ctm)
>>>>>               drm_property_reference_blob(state->ctm);
>>>>> +     if (state->gamma_lut)
>>>>> +             drm_property_reference_blob(state->gamma_lut);
>>>>> +
>>>>>       state->color_mgmt_changed = false;  }
>>>>> EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state);
>>>>> @@ -3543,6 +3546,7 @@ void
>>>>> __drm_atomic_helper_plane_destroy_state(struct drm_plane_state
>>>>> *state)
>>>>>
>>>>>       drm_property_unreference_blob(state->degamma_lut);
>>>>>       drm_property_unreference_blob(state->ctm);
>>>>> +     drm_property_unreference_blob(state->gamma_lut);
>>>>>  }
>>>>>  EXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state);
>>>>>
>>>>> diff --git a/drivers/gpu/drm/drm_mode_config.c
>>>>> b/drivers/gpu/drm/drm_mode_config.c
>>>>> index c8763977413e7..bc6f8e51c7464 100644
>>>>> --- a/drivers/gpu/drm/drm_mode_config.c
>>>>> +++ b/drivers/gpu/drm/drm_mode_config.c
>>>>> @@ -368,6 +368,20 @@ static int
>drm_mode_create_standard_properties(struct drm_device *dev)
>>>>>               return -ENOMEM;
>>>>>       dev->mode_config.plane_ctm_property = prop;
>>>>>
>>>>> +     prop = drm_property_create(dev,
>>>>> +                     DRM_MODE_PROP_BLOB,
>>>>> +                     "PLANE_GAMMA_LUT", 0);
>>>>> +     if (!prop)
>>>>> +             return -ENOMEM;
>>>>> +     dev->mode_config.plane_gamma_lut_property = prop;
>>>>> +
>>>>> +     prop = drm_property_create_range(dev,
>>>>> +                     DRM_MODE_PROP_IMMUTABLE,
>>>>> +                     "PLANE_GAMMA_LUT_SIZE", 0, UINT_MAX);
>>>>> +     if (!prop)
>>>>> +             return -ENOMEM;
>>>>> +     dev->mode_config.plane_gamma_lut_size_property = prop;
>>>>> +
>>>>>       return 0;
>>>>>  }
>>>>>
>>>>> diff --git a/include/drm/drm_mode_config.h
>>>>> b/include/drm/drm_mode_config.h index ad7235ced531b..3ca3eb3c98950
>>>>> 100644
>>>>> --- a/include/drm/drm_mode_config.h
>>>>> +++ b/include/drm/drm_mode_config.h
>>>>> @@ -740,6 +740,17 @@ struct drm_mode_config {
>>>>>        * degamma LUT.
>>>>>        */
>>>>>       struct drm_property *plane_ctm_property;
>>>>> +     /**
>>>>> +      * @plane_gamma_lut_property: Optional Plane property to set the LUT
>>>>> +      * used to convert the colors, after the CTM matrix, to the common
>>>>> +      * gamma space chosen for blending.
>>>>> +      */
>>>>> +     struct drm_property *plane_gamma_lut_property;
>>>>> +     /**
>>>>> +      * @plane_gamma_lut_size_property: Optional Plane property for the
>size
>>>>> +      * of the gamma LUT as supported by the driver (read-only).
>>>>> +      */
>>>>> +     struct drm_property *plane_gamma_lut_size_property;
>>>>>       /**
>>>>>        * @ctm_property: Optional CRTC property to set the
>>>>>        * matrix used to convert colors after the lookup in the diff
>>>>> --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h index
>>>>> 21aecc9c91a09..acabb85009a14 100644
>>>>> --- a/include/drm/drm_plane.h
>>>>> +++ b/include/drm/drm_plane.h
>>>>> @@ -147,6 +147,15 @@ struct drm_plane_state {
>>>>>        */
>>>>>       struct drm_property_blob *ctm;
>>>>>
>>>>> +     /**
>>>>> +      * @gamma_lut:
>>>>> +      *
>>>>> +      * Lookup table for converting pixel data after the color conversion
>>>>> +      * matrix @ctm.  See drm_plane_enable_color_mgmt(). The blob (if not
>>>>> +      * NULL) is an array of &struct drm_color_lut.
>>>>> +      */
>>>>> +     struct drm_property_blob *gamma_lut;
>>>>> +
>>>>>       struct drm_atomic_state *state;
>>>>>
>>>>>       bool color_mgmt_changed : 1;
>>>>>
>>> _______________________________________________
>>> dri-devel mailing list
>>> dri-devel@lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 04/10] drm: Add Plane Gamma properties
  2018-02-15  5:32 ` [PATCH 04/10] drm: Add Plane Gamma properties Daniele Castagna
  2018-02-15 19:29   ` Harry Wentland
@ 2018-02-19 15:14   ` Daniel Vetter
  2018-02-27 15:26   ` Sean Paul
  2 siblings, 0 replies; 44+ messages in thread
From: Daniel Vetter @ 2018-02-19 15:14 UTC (permalink / raw)
  To: Daniele Castagna; +Cc: dri-devel

On Thu, Feb 15, 2018 at 12:32:54AM -0500, Daniele Castagna wrote:
> From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>
> 
> Add plane gamma as blob property and size as a
> range property.
> 
> (am from https://patchwork.kernel.org/patch/9971325/)
> 
> Change-Id: I606cd40c9748b136fc2bf4750bea1da285add62d
> Signed-off-by: Uma Shankar <uma.shankar at intel.com>

Please also add kerneldoc for the properties itself, see

https://dri.freedesktop.org/docs/drm/gpu/drm-kms.html#color-management-properties

That means we need a bunch of rewording, now that we're adding planes.

I also think a small diagram that shows the full pipeline (which probably
no hw ever implements) would be really good. See the various inlined dot
files we have in the KMS documentation already.

Thanks, Daniel

> ---
>  drivers/gpu/drm/drm_atomic.c        |  8 ++++++++
>  drivers/gpu/drm/drm_atomic_helper.c |  4 ++++
>  drivers/gpu/drm/drm_mode_config.c   | 14 ++++++++++++++
>  include/drm/drm_mode_config.h       | 11 +++++++++++
>  include/drm/drm_plane.h             |  9 +++++++++
>  5 files changed, 46 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index d4b8c6cc84128..f634f6450f415 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -778,6 +778,12 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
>  					&replaced);
>  		state->color_mgmt_changed |= replaced;
>  		return ret;
> +	} else if (property == config->plane_gamma_lut_property) {
> +		ret = drm_atomic_replace_property_blob_from_id(dev,
> +					&state->gamma_lut,
> +					val, -1, &replaced);
> +		state->color_mgmt_changed |= replaced;
> +		return ret;
>  	} else {
>  		return -EINVAL;
>  	}
> @@ -841,6 +847,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
>  			state->degamma_lut->base.id : 0;
>  	} else if (property == config->plane_ctm_property) {
>  		*val = (state->ctm) ? state->ctm->base.id : 0;
> +	} else if (property == config->plane_gamma_lut_property) {
> +		*val = (state->gamma_lut) ? state->gamma_lut->base.id : 0;
>  	} else {
>  		return -EINVAL;
>  	}
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 17e137a529a0e..97dbb36153d14 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -3495,6 +3495,9 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
>  		drm_property_reference_blob(state->degamma_lut);
>  	if (state->ctm)
>  		drm_property_reference_blob(state->ctm);
> +	if (state->gamma_lut)
> +		drm_property_reference_blob(state->gamma_lut);
> +
>  	state->color_mgmt_changed = false;
>  }
>  EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state);
> @@ -3543,6 +3546,7 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)
>  
>  	drm_property_unreference_blob(state->degamma_lut);
>  	drm_property_unreference_blob(state->ctm);
> +	drm_property_unreference_blob(state->gamma_lut);
>  }
>  EXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state);
>  
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index c8763977413e7..bc6f8e51c7464 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -368,6 +368,20 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>  		return -ENOMEM;
>  	dev->mode_config.plane_ctm_property = prop;
>  
> +	prop = drm_property_create(dev,
> +			DRM_MODE_PROP_BLOB,
> +			"PLANE_GAMMA_LUT", 0);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.plane_gamma_lut_property = prop;
> +
> +	prop = drm_property_create_range(dev,
> +			DRM_MODE_PROP_IMMUTABLE,
> +			"PLANE_GAMMA_LUT_SIZE", 0, UINT_MAX);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.plane_gamma_lut_size_property = prop;
> +
>  	return 0;
>  }
>  
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index ad7235ced531b..3ca3eb3c98950 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -740,6 +740,17 @@ struct drm_mode_config {
>  	 * degamma LUT.
>  	 */
>  	struct drm_property *plane_ctm_property;
> +	/**
> +	 * @plane_gamma_lut_property: Optional Plane property to set the LUT
> +	 * used to convert the colors, after the CTM matrix, to the common
> +	 * gamma space chosen for blending.
> +	 */
> +	struct drm_property *plane_gamma_lut_property;
> +	/**
> +	 * @plane_gamma_lut_size_property: Optional Plane property for the size
> +	 * of the gamma LUT as supported by the driver (read-only).
> +	 */
> +	struct drm_property *plane_gamma_lut_size_property;
>  	/**
>  	 * @ctm_property: Optional CRTC property to set the
>  	 * matrix used to convert colors after the lookup in the
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 21aecc9c91a09..acabb85009a14 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -147,6 +147,15 @@ struct drm_plane_state {
>  	 */
>  	struct drm_property_blob *ctm;
>  
> +	/**
> +	 * @gamma_lut:
> +	 *
> +	 * Lookup table for converting pixel data after the color conversion
> +	 * matrix @ctm.  See drm_plane_enable_color_mgmt(). The blob (if not
> +	 * NULL) is an array of &struct drm_color_lut.
> +	 */
> +	struct drm_property_blob *gamma_lut;
> +
>  	struct drm_atomic_state *state;
>  
>  	bool color_mgmt_changed : 1;
> -- 
> 2.16.1.291.g4437f3f132-goog
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 02/10] drm: Add Plane Degamma properties
  2018-02-15  5:32 ` [PATCH 02/10] drm: Add Plane Degamma properties Daniele Castagna
  2018-02-16 19:38   ` kbuild test robot
@ 2018-02-19 15:15   ` Daniel Vetter
  2018-02-27 15:13   ` Sean Paul
  2 siblings, 0 replies; 44+ messages in thread
From: Daniel Vetter @ 2018-02-19 15:15 UTC (permalink / raw)
  To: Daniele Castagna; +Cc: dri-devel

On Thu, Feb 15, 2018 at 12:32:52AM -0500, Daniele Castagna wrote:
> From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>
> 
> Add Plane Degamma as a blob property and plane
> degamma size as a range property.
> 
> (am from https://patchwork.kernel.org/patch/10046515/)
> 
> Change-Id: Iaead6f944a8b677227d1be11169f46178de533b1
> Signed-off-by: Uma Shankar <uma.shankar at intel.com>
> ---
>  drivers/gpu/drm/drm_atomic.c        | 12 ++++++++++++
>  drivers/gpu/drm/drm_atomic_helper.c |  7 +++++++
>  drivers/gpu/drm/drm_mode_config.c   | 14 ++++++++++++++
>  include/drm/drm_mode_config.h       | 10 ++++++++++
>  include/drm/drm_plane.h             | 10 ++++++++++
>  5 files changed, 53 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index b76d49218cf1d..4a06ff2fd1a5e 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -717,6 +717,8 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
>  {
>  	struct drm_device *dev = plane->dev;
>  	struct drm_mode_config *config = &dev->mode_config;
> +	bool replaced = false;
> +	int ret;
>  
>  	if (property == config->prop_fb_id) {
>  		struct drm_framebuffer *fb = drm_framebuffer_lookup(dev, NULL, val);
> @@ -762,6 +764,12 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
>  	} else if (plane->funcs->atomic_set_property) {
>  		return plane->funcs->atomic_set_property(plane, state,
>  				property, val);
> +	} else if (property == config->plane_degamma_lut_property) {
> +		ret = drm_atomic_replace_property_blob_from_id(dev,
> +					&state->degamma_lut,
> +					val, -1, &replaced);
> +		state->color_mgmt_changed |= replaced;
> +		return ret;
>  	} else {
>  		return -EINVAL;
>  	}
> @@ -820,6 +828,9 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
>  		*val = state->zpos;
>  	} else if (plane->funcs->atomic_get_property) {
>  		return plane->funcs->atomic_get_property(plane, state, property, val);
> +	} else if (property == config->plane_degamma_lut_property) {
> +		*val = (state->degamma_lut) ?
> +			state->degamma_lut->base.id : 0;
>  	} else {
>  		return -EINVAL;
>  	}
> @@ -944,6 +955,7 @@ static void drm_atomic_plane_print_state(struct drm_printer *p,
>  	drm_printf(p, "\tcrtc-pos=" DRM_RECT_FMT "\n", DRM_RECT_ARG(&dest));
>  	drm_printf(p, "\tsrc-pos=" DRM_RECT_FP_FMT "\n", DRM_RECT_FP_ARG(&src));
>  	drm_printf(p, "\trotation=%x\n", state->rotation);
> +	drm_printf(p, "\tcolor_mgmt_changed=%d\n", state->color_mgmt_changed);
>  
>  	if (plane->funcs->atomic_print_state)
>  		plane->funcs->atomic_print_state(p, state);
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index ab4032167094c..d3eaf4d397681 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -3488,7 +3488,12 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
>  		drm_framebuffer_get(state->fb);
>  
>  	state->fence = NULL;
> +
>  	state->commit = NULL;
> +
> +	if (state->degamma_lut)
> +		drm_property_reference_blob(state->degamma_lut);
> +	state->color_mgmt_changed = false;
>  }
>  EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state);
>  
> @@ -3533,6 +3538,8 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)
>  
>  	if (state->commit)
>  		drm_crtc_commit_put(state->commit);
> +
> +	drm_property_unreference_blob(state->degamma_lut);
>  }
>  EXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state);
>  
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index e5c653357024d..7d8e74715b565 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -348,6 +348,20 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>  		return -ENOMEM;
>  	dev->mode_config.modifiers_property = prop;
>  
> +	prop = drm_property_create(dev,
> +			DRM_MODE_PROP_BLOB,
> +			"PLANE_DEGAMMA_LUT", 0);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.plane_degamma_lut_property = prop;
> +
> +	prop = drm_property_create_range(dev,
> +			DRM_MODE_PROP_IMMUTABLE,
> +			"PLANE_DEGAMMA_LUT_SIZE", 0, UINT_MAX);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.plane_degamma_lut_size_property = prop;
> +
>  	return 0;
>  }
>  
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index 2cb6f02df64ab..dcec93d062b4d 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -724,6 +724,16 @@ struct drm_mode_config {
>  	 * the degamma LUT as supported by the driver (read-only).
>  	 */
>  	struct drm_property *degamma_lut_size_property;
> + 	/**
> +	 * @plane_degamma_lut_property: Optional Plane property to set the LUT
> +	 * used to convert the framebuffer's colors to linear gamma.
> +	 */
> +	struct drm_property *plane_degamma_lut_property;
> +	/**
> +	 * @plane_degamma_lut_size_property: Optional Plane property for the
> +	 * size of the degamma LUT as supported by the driver (read-only).
> +	 */
> +	struct drm_property *plane_degamma_lut_size_property;
>  	/**
>  	 * @ctm_property: Optional CRTC property to set the
>  	 * matrix used to convert colors after the lookup in the
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 8185e3468a231..2f8f5db77a406 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -131,7 +131,17 @@ struct drm_plane_state {
>  	 */
>  	struct drm_crtc_commit *commit;
>  
> +	/* @degamma_lut:

This isn't kerneldoc. Please build the docs using

$ make htmldocs

and make sure it's warning-free (for the files you're touching) and that
the end result looks correct and has all the hyperlinks working and
linking to the right places.

Thanks, Daniel

> +	 *
> +	 * Lookup table for converting framebuffer pixel data before apply the
> +	 * color conversion matrix @ctm. See drm_plane_enable_color_mgmt(). The
> +	 * blob (if not NULL) is an array of &struct drm_color_lut.
> +	 */
> +	struct drm_property_blob *degamma_lut;
> +
>  	struct drm_atomic_state *state;
> +
> +	bool color_mgmt_changed : 1;
>  };
>  
>  static inline struct drm_rect
> -- 
> 2.16.1.291.g4437f3f132-goog
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 00/10] drm: Add plane color matrix on rockchip
  2018-02-15  5:32 [PATCH 00/10] drm: Add plane color matrix on rockchip Daniele Castagna
                   ` (9 preceding siblings ...)
  2018-02-15  5:33 ` [PATCH 10/10] drm/rockchip: Enable 'PLANE_CTM' drm property Daniele Castagna
@ 2018-02-19 15:16 ` Daniel Vetter
  10 siblings, 0 replies; 44+ messages in thread
From: Daniel Vetter @ 2018-02-19 15:16 UTC (permalink / raw)
  To: Daniele Castagna; +Cc: dri-devel

On Thu, Feb 15, 2018 at 12:32:50AM -0500, Daniele Castagna wrote:
> Hello,
> this patch series adds a per plane color matrix property as well as an
> implementation for rockchip.
> 
> This patch series builds on and includes previous work done by uma.shankar:
> https://lists.freedesktop.org/archives/dri-devel/2017-September/153347.html
> 
> The first rockchip patch of this series sets a BT.601 color conversion
> matrix for YUV formats and is included because it adds YUV2YUV registers that
> the rest of the color matrix rockchip implementation depends upon.
> 
> The next patches are the ones originally provided by uma.shankar,
> rebased and containing an additional small fix.
> 
> The final set of rockchip patches implement, and finally enable, the plane CTM
> property on rockchip.
> 
> These patches have been rebased on drm-next (80daf42f97b1a0503d029f3c1325),
> Unfortunately I haven't been able to test them after rebasing because the
> display doesn't come up when I push a kernel built from drm-next on a device.

Link to the open source userspace making use of these new properties is
missing. See

https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements

-Daniel

> 
> Daniele Castagna (5):
>   drm/rockchip: YUV overlays BT.601 color conversion.
>   drm/rockchip: Add yuv2yuv registers to vop_lit
>   drm/rockchip: Add R2R registers
>   drm/rockchip: Implement drm plane->ctm property.
>   drm/rockchip: Enable 'PLANE_CTM' drm property.
> 
> uma.shankar at intel.com (Uma Shankar) (5):
>   drm: Add Plane Degamma properties
>   drm: Add Plane CTM property
>   drm: Add Plane Gamma properties
>   drm: Define helper function for plane color enabling
>   drm: Define helper to set legacy gamma table size
> 
>  drivers/gpu/drm/drm_atomic.c                | 30 +++++++
>  drivers/gpu/drm/drm_atomic_helper.c         | 14 ++++
>  drivers/gpu/drm/drm_color_mgmt.c            | 41 ++++++++++
>  drivers/gpu/drm/drm_mode_config.c           | 34 ++++++++
>  drivers/gpu/drm/drm_plane.c                 | 48 +++++++++++
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 90 ++++++++++++++++++++-
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 16 ++++
>  drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 88 +++++++++++++++++++-
>  include/drm/drm_color_mgmt.h                |  8 ++
>  include/drm/drm_mode_config.h               | 27 +++++++
>  include/drm/drm_plane.h                     | 31 +++++++
>  11 files changed, 424 insertions(+), 3 deletions(-)
> 
> -- 
> 2.16.1.291.g4437f3f132-goog
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 01/10] drm/rockchip: YUV overlays BT.601 color conversion.
  2018-02-15  5:32 ` [PATCH 01/10] drm/rockchip: YUV overlays BT.601 color conversion Daniele Castagna
  2018-02-16 17:55   ` kbuild test robot
@ 2018-02-27 15:03   ` Sean Paul
  2018-12-14 16:29   ` [PATCH v2] drm/rockchip: Fix YUV buffers color rendering Ezequiel Garcia
  2 siblings, 0 replies; 44+ messages in thread
From: Sean Paul @ 2018-02-27 15:03 UTC (permalink / raw)
  To: Daniele Castagna; +Cc: dri-devel

On Thu, Feb 15, 2018 at 12:32:51AM -0500, Daniele Castagna wrote:
> Currently NV12 hardware overlays scheduled with atomic interface are
> converted to RGB using a color space conversion different than BT.601.
> 
> The result is that colors of NV12 buffers composited with Mali don't
> match colors of YUV hardware overlays.
> 
> Running modetest with an NV12 plane also shows colors are incorrect
> if compared to an RGB overlay that represents the same color pattern.
> 
> This CL adds support for YUV2YUV color space conversion (CSC) module on
> rockchip and enables the YUV2RGB part that allows to specify a 4x3
> matrix to convert the colors.
> 
> The matrix is set to BT.601 coefficients to align to Mali and to what
> modetest expects.

Hey Daniele,
Apologies for missing this set. 

> 
> TEST=modetest -M rockchip -s 34@30:2400x1600 -P 30:640x480+650+10@NV12 -P 30:640x480+10+10@XR24
> 
> Change-Id: Ia5a3b4793229e2c63f79f9f414d1cbe6ccc63fc1

It's usually good form to strip out the gerrit Change-Id from the commit
message.

> Tested-by: Daniele Castagna <dcastagna@chromium.org>
> Reviewed-by: Daniele Castagna <dcastagna@chromium.org>
> Reviewed-by: Kristian H. Kristensen <hoegsberg@chromium.org>
> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 40 ++++++++++++++++++++-
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.h |  9 +++++
>  drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 39 ++++++++++++++++++--
>  3 files changed, 85 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> index ba7505292b786..ea43ab797f555 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> @@ -50,6 +50,10 @@
>  		vop_reg_set(vop, &win->phy->scl->ext->name, \
>  			    win->base, ~0, v, #name)
>  
> +#define VOP_YUV2YUV_SET(x, name, v) \
> +		if ((x)->data->yuv2yuv) \
> +			vop_reg_set(vop, &vop->data->yuv2yuv->name, 0, ~0, v, #name)
> +
>  #define VOP_INTR_SET_MASK(vop, name, mask, v) \
>  		vop_reg_set(vop, &vop->data->intr->name, 0, mask, v, #name)
>  
> @@ -79,6 +83,18 @@
>  #define to_vop(x) container_of(x, struct vop, crtc)
>  #define to_vop_win(x) container_of(x, struct vop_win, base)
>  
> +/*
> + * The coefficients of the following matrix are all fixed points.
> + * The format is S2.10 for the 3x3 part of the matrix, and S9.12 for the offsets.
> + * They are all represented in two's complement.
> + */
> +static const uint32_t bt601_yuv2rgb[] = {
> +	0x4A8, 0x0,    0x662,
> +	0x4A8, 0x1E6F, 0x1CBF,
> +	0x4A8, 0x812,  0x0,
> +	0x321168, 0x0877CF, 0x2EB127
> +};
> +
>  enum vop_pending {
>  	VOP_PENDING_FB_UNREF,
>  };
> @@ -722,6 +738,9 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
>  	uint32_t val;
>  	bool rb_swap;
>  	int format;
> +	int is_yuv = is_yuv_support(fb->format->format);
> +	int win_index = VOP_WIN_TO_INDEX(vop_win);
> +	int i;
>  
>  	/*
>  	 * can't update plane when vop is disabled.
> @@ -762,7 +781,14 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
>  	VOP_WIN_SET(vop, win, format, format);
>  	VOP_WIN_SET(vop, win, yrgb_vir, DIV_ROUND_UP(fb->pitches[0], 4));
>  	VOP_WIN_SET(vop, win, yrgb_mst, dma_addr);
> -	if (is_yuv_support(fb->format->format)) {
> +
> +	if (!win_index) {
> +		VOP_YUV2YUV_SET(vop, win0_y2r_en, is_yuv);
> +	} else if (win_index == 1) {
> +		VOP_YUV2YUV_SET(vop, win1_y2r_en, is_yuv);
> +	}
> +
> +	if (is_yuv) {
>  		int hsub = drm_format_horz_chroma_subsampling(fb->format->format);
>  		int vsub = drm_format_vert_chroma_subsampling(fb->format->format);
>  		int bpp = fb->format->cpp[1];
> @@ -776,6 +802,18 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
>  		dma_addr = rk_uv_obj->dma_addr + offset + fb->offsets[1];
>  		VOP_WIN_SET(vop, win, uv_vir, DIV_ROUND_UP(fb->pitches[1], 4));
>  		VOP_WIN_SET(vop, win, uv_mst, dma_addr);
> +
> +		for (i = 0; i < 12; i++) {
> +			if (!win_index) {
> +				VOP_YUV2YUV_SET(vop,
> +						win0_y2r_coefficients[i],
> +						bt601_yuv2rgb[i]);
> +			} else {
> +				VOP_YUV2YUV_SET(vop,
> +						win1_y2r_coefficients[i],
> +						bt601_yuv2rgb[i]);
> +			}
> +		}
>  	}
>  
>  	if (win->phy->scl)
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
> index 56bbd2e2a8efb..aa8a5d2690376 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
> @@ -79,6 +79,14 @@ struct vop_misc {
>  	struct vop_reg global_regdone_en;
>  };
>  
> +struct vop_yuv2yuv {
> +	struct vop_reg win0_y2r_en;
> +	struct vop_reg win0_y2r_coefficients[12];
> +
> +	struct vop_reg win1_y2r_en;
> +	struct vop_reg win1_y2r_coefficients[12];
> +};

struct vop_yuv2yuv {
        struct {
                struct vop_reg y2r_en;
                struct vop_reg y2r_coefficients[12];
        } regs[2];
};

Then add win_index to the macro above and you can avoid the if (!win_index)
checks everywhere.

Bonus points if you #define the '2' and '12' as something more meaningful

> +
>  struct vop_intr {
>  	const int *intrs;
>  	uint32_t nintrs;
> @@ -157,6 +165,7 @@ struct vop_data {
>  	const struct vop_misc *misc;
>  	const struct vop_modeset *modeset;
>  	const struct vop_output *output;
> +	const struct vop_yuv2yuv *yuv2yuv;
>  	const struct vop_win_data *win;
>  	unsigned int win_size;
>  
> diff --git a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> index 2e4eea3459fe6..be9c414e2e4bc 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> @@ -422,6 +422,40 @@ static const struct vop_output rk3399_output = {
>  	.mipi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 15),
>  };
>  
> +static const struct vop_yuv2yuv rk3399_vop_yuv2yuv = {
> +	.win0_y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 1),
> +	.win0_y2r_coefficients = {
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 0, 0xffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 0, 0xffff, 16),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 4, 0xffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 4, 0xffff, 16),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 8, 0xffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 8, 0xffff, 16),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 12, 0xffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 12, 0xffff, 16),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 16, 0xffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 20, 0xffffffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 24, 0xffffffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 28, 0xffffffff, 0),
> +	},
> +
> +	.win1_y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 9),
> +	.win1_y2r_coefficients = {
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 0, 0xffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 0, 0xffff, 16),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 4, 0xffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 4, 0xffff, 16),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 8, 0xffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 8, 0xffff, 16),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 12, 0xffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 12, 0xffff, 16),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 16, 0xffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 20, 0xffffffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 24, 0xffffffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 28, 0xffffffff, 0),
> +	},
> +};
> +
>  static const struct vop_data rk3399_vop_big = {
>  	.version = VOP_VERSION(3, 5),
>  	.feature = VOP_FEATURE_OUTPUT_RGB10,
> @@ -430,8 +464,9 @@ static const struct vop_data rk3399_vop_big = {
>  	.modeset = &rk3288_modeset,
>  	.output = &rk3399_output,
>  	.misc = &rk3368_misc,
> -	.win = rk3368_vop_win_data,
> -	.win_size = ARRAY_SIZE(rk3368_vop_win_data),
> +	.yuv2yuv = &rk3399_vop_yuv2yuv,
> +	.win = rk3399_vop_win_data,
> +	.win_size = ARRAY_SIZE(rk3399_vop_win_data),
>  };
>  
>  static const struct vop_win_data rk3399_vop_lit_win_data[] = {
> -- 
> 2.16.1.291.g4437f3f132-goog
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 02/10] drm: Add Plane Degamma properties
  2018-02-15  5:32 ` [PATCH 02/10] drm: Add Plane Degamma properties Daniele Castagna
  2018-02-16 19:38   ` kbuild test robot
  2018-02-19 15:15   ` Daniel Vetter
@ 2018-02-27 15:13   ` Sean Paul
  2018-02-28 14:54     ` Shankar, Uma
  2 siblings, 1 reply; 44+ messages in thread
From: Sean Paul @ 2018-02-27 15:13 UTC (permalink / raw)
  To: Daniele Castagna; +Cc: uma.shankar, dri-devel

On Thu, Feb 15, 2018 at 12:32:52AM -0500, Daniele Castagna wrote:
> From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>
> 
> Add Plane Degamma as a blob property and plane
> degamma size as a range property.
> 
> (am from https://patchwork.kernel.org/patch/10046515/)

The discussion on this previous version has some feedback on using 32-bit values
in the gamma lut instead of 16-bit. Have you considered this?

> 
> Change-Id: Iaead6f944a8b677227d1be11169f46178de533b1
> Signed-off-by: Uma Shankar <uma.shankar at intel.com>
> ---
>  drivers/gpu/drm/drm_atomic.c        | 12 ++++++++++++
>  drivers/gpu/drm/drm_atomic_helper.c |  7 +++++++
>  drivers/gpu/drm/drm_mode_config.c   | 14 ++++++++++++++
>  include/drm/drm_mode_config.h       | 10 ++++++++++
>  include/drm/drm_plane.h             | 10 ++++++++++
>  5 files changed, 53 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index b76d49218cf1d..4a06ff2fd1a5e 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -717,6 +717,8 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
>  {
>  	struct drm_device *dev = plane->dev;
>  	struct drm_mode_config *config = &dev->mode_config;
> +	bool replaced = false;
> +	int ret;
>  
>  	if (property == config->prop_fb_id) {
>  		struct drm_framebuffer *fb = drm_framebuffer_lookup(dev, NULL, val);
> @@ -762,6 +764,12 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
>  	} else if (plane->funcs->atomic_set_property) {
>  		return plane->funcs->atomic_set_property(plane, state,
>  				property, val);
> +	} else if (property == config->plane_degamma_lut_property) {
> +		ret = drm_atomic_replace_property_blob_from_id(dev,
> +					&state->degamma_lut,
> +					val, -1, &replaced);
> +		state->color_mgmt_changed |= replaced;
> +		return ret;
>  	} else {
>  		return -EINVAL;
>  	}
> @@ -820,6 +828,9 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
>  		*val = state->zpos;
>  	} else if (plane->funcs->atomic_get_property) {
>  		return plane->funcs->atomic_get_property(plane, state, property, val);
> +	} else if (property == config->plane_degamma_lut_property) {
> +		*val = (state->degamma_lut) ?
> +			state->degamma_lut->base.id : 0;
>  	} else {
>  		return -EINVAL;
>  	}
> @@ -944,6 +955,7 @@ static void drm_atomic_plane_print_state(struct drm_printer *p,
>  	drm_printf(p, "\tcrtc-pos=" DRM_RECT_FMT "\n", DRM_RECT_ARG(&dest));
>  	drm_printf(p, "\tsrc-pos=" DRM_RECT_FP_FMT "\n", DRM_RECT_FP_ARG(&src));
>  	drm_printf(p, "\trotation=%x\n", state->rotation);
> +	drm_printf(p, "\tcolor_mgmt_changed=%d\n", state->color_mgmt_changed);
>  
>  	if (plane->funcs->atomic_print_state)
>  		plane->funcs->atomic_print_state(p, state);
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index ab4032167094c..d3eaf4d397681 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -3488,7 +3488,12 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
>  		drm_framebuffer_get(state->fb);
>  
>  	state->fence = NULL;
> +

Extra line snuck in here

>  	state->commit = NULL;
> +
> +	if (state->degamma_lut)
> +		drm_property_reference_blob(state->degamma_lut);
> +	state->color_mgmt_changed = false;
>  }
>  EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state);
>  
> @@ -3533,6 +3538,8 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)
>  
>  	if (state->commit)
>  		drm_crtc_commit_put(state->commit);
> +
> +	drm_property_unreference_blob(state->degamma_lut);
>  }
>  EXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state);
>  
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index e5c653357024d..7d8e74715b565 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -348,6 +348,20 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>  		return -ENOMEM;
>  	dev->mode_config.modifiers_property = prop;
>  
> +	prop = drm_property_create(dev,
> +			DRM_MODE_PROP_BLOB,
> +			"PLANE_DEGAMMA_LUT", 0);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.plane_degamma_lut_property = prop;
> +
> +	prop = drm_property_create_range(dev,
> +			DRM_MODE_PROP_IMMUTABLE,
> +			"PLANE_DEGAMMA_LUT_SIZE", 0, UINT_MAX);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.plane_degamma_lut_size_property = prop;

Since these are optional, we probably want a helper for them which is only called if
a plane wants to use them instead of always instantiating them.

> +
>  	return 0;
>  }
>  
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index 2cb6f02df64ab..dcec93d062b4d 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -724,6 +724,16 @@ struct drm_mode_config {
>  	 * the degamma LUT as supported by the driver (read-only).
>  	 */
>  	struct drm_property *degamma_lut_size_property;
> + 	/**
> +	 * @plane_degamma_lut_property: Optional Plane property to set the LUT
> +	 * used to convert the framebuffer's colors to linear gamma.
> +	 */
> +	struct drm_property *plane_degamma_lut_property;
> +	/**
> +	 * @plane_degamma_lut_size_property: Optional Plane property for the
> +	 * size of the degamma LUT as supported by the driver (read-only).
> +	 */
> +	struct drm_property *plane_degamma_lut_size_property;

Can we put these in drm_plane instead? If we do, we don't need the "plane_"
prefix.

>  	/**
>  	 * @ctm_property: Optional CRTC property to set the
>  	 * matrix used to convert colors after the lookup in the
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 8185e3468a231..2f8f5db77a406 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -131,7 +131,17 @@ struct drm_plane_state {
>  	 */
>  	struct drm_crtc_commit *commit;
>  
> +	/* @degamma_lut:
> +	 *
> +	 * Lookup table for converting framebuffer pixel data before apply the
> +	 * color conversion matrix @ctm. See drm_plane_enable_color_mgmt(). The
> +	 * blob (if not NULL) is an array of &struct drm_color_lut.
> +	 */
> +	struct drm_property_blob *degamma_lut;
> +
>  	struct drm_atomic_state *state;
> +
> +	bool color_mgmt_changed : 1;
>  };
>  
>  static inline struct drm_rect
> -- 
> 2.16.1.291.g4437f3f132-goog
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 03/10] drm: Add Plane CTM property
  2018-02-15  5:32 ` [PATCH 03/10] drm: Add Plane CTM property Daniele Castagna
@ 2018-02-27 15:22   ` Sean Paul
  2018-02-28 14:55     ` Shankar, Uma
  0 siblings, 1 reply; 44+ messages in thread
From: Sean Paul @ 2018-02-27 15:22 UTC (permalink / raw)
  To: Daniele Castagna; +Cc: dri-devel

On Thu, Feb 15, 2018 at 12:32:53AM -0500, Daniele Castagna wrote:
> From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>
> 
> Add a blob property for plane CSC usage.
> 
> (am from https://patchwork.kernel.org/patch/9971339/)
> 
> Change-Id: I688ce7c95c20d307cb0aa35c5eba5ce2e1e88314
> Signed-off-by: Uma Shankar <uma.shankar at intel.com>
> ---
>  drivers/gpu/drm/drm_atomic.c        | 10 ++++++++++
>  drivers/gpu/drm/drm_atomic_helper.c |  3 +++
>  drivers/gpu/drm/drm_mode_config.c   |  6 ++++++
>  include/drm/drm_mode_config.h       |  6 ++++++
>  include/drm/drm_plane.h             |  8 ++++++++
>  5 files changed, 33 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 4a06ff2fd1a5e..d4b8c6cc84128 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -770,6 +770,14 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
>  					val, -1, &replaced);
>  		state->color_mgmt_changed |= replaced;
>  		return ret;
> +	} else if (property == config->plane_ctm_property) {
> +		ret = drm_atomic_replace_property_blob_from_id(dev,
> +					&state->ctm,
> +					val,
> +					sizeof(struct drm_color_ctm),
> +					&replaced);
> +		state->color_mgmt_changed |= replaced;
> +		return ret;
>  	} else {
>  		return -EINVAL;
>  	}
> @@ -831,6 +839,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
>  	} else if (property == config->plane_degamma_lut_property) {
>  		*val = (state->degamma_lut) ?
>  			state->degamma_lut->base.id : 0;
> +	} else if (property == config->plane_ctm_property) {
> +		*val = (state->ctm) ? state->ctm->base.id : 0;
>  	} else {
>  		return -EINVAL;
>  	}
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index d3eaf4d397681..17e137a529a0e 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -3493,6 +3493,8 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
>  
>  	if (state->degamma_lut)
>  		drm_property_reference_blob(state->degamma_lut);
> +	if (state->ctm)
> +		drm_property_reference_blob(state->ctm);
>  	state->color_mgmt_changed = false;
>  }
>  EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state);
> @@ -3540,6 +3542,7 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)
>  		drm_crtc_commit_put(state->commit);
>  
>  	drm_property_unreference_blob(state->degamma_lut);
> +	drm_property_unreference_blob(state->ctm);
>  }
>  EXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state);
>  
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index 7d8e74715b565..c8763977413e7 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -361,6 +361,12 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>  	if (!prop)
>  		return -ENOMEM;
>  	dev->mode_config.plane_degamma_lut_size_property = prop;
> +	prop = drm_property_create(dev,
> +			DRM_MODE_PROP_BLOB,
> +			"PLANE_CTM", 0);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.plane_ctm_property = prop;
>  
>  	return 0;
>  }
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index dcec93d062b4d..ad7235ced531b 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -734,6 +734,12 @@ struct drm_mode_config {
>  	 * size of the degamma LUT as supported by the driver (read-only).
>  	 */
>  	struct drm_property *plane_degamma_lut_size_property;
> +	/**
> +	 * @plane_ctm_property: Optional CRTC property to set the
> +	 * matrix used to convert colors after the lookup in the
> +	 * degamma LUT.
> +	 */
> +	struct drm_property *plane_ctm_property;

Same comments re: puttting the property in drm_plane and adding a helper to
create it.

Sean

>  	/**
>  	 * @ctm_property: Optional CRTC property to set the
>  	 * matrix used to convert colors after the lookup in the
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 2f8f5db77a406..21aecc9c91a09 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -139,6 +139,14 @@ struct drm_plane_state {
>  	 */
>  	struct drm_property_blob *degamma_lut;
>  
> + 	/**
> +	 * @ctm:
> +	 *
> +	 * Color transformation matrix. See drm_plane_enable_color_mgmt(). The
> +	 * blob (if not NULL) is a &struct drm_color_ctm.
> +	 */
> +	struct drm_property_blob *ctm;
> +
>  	struct drm_atomic_state *state;
>  
>  	bool color_mgmt_changed : 1;
> -- 
> 2.16.1.291.g4437f3f132-goog
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 04/10] drm: Add Plane Gamma properties
  2018-02-15  5:32 ` [PATCH 04/10] drm: Add Plane Gamma properties Daniele Castagna
  2018-02-15 19:29   ` Harry Wentland
  2018-02-19 15:14   ` Daniel Vetter
@ 2018-02-27 15:26   ` Sean Paul
  2018-02-27 16:52     ` Ville Syrjälä
  2 siblings, 1 reply; 44+ messages in thread
From: Sean Paul @ 2018-02-27 15:26 UTC (permalink / raw)
  To: Daniele Castagna; +Cc: dri-devel

On Thu, Feb 15, 2018 at 12:32:54AM -0500, Daniele Castagna wrote:
> From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>
> 
> Add plane gamma as blob property and size as a
> range property.
> 
> (am from https://patchwork.kernel.org/patch/9971325/)
> 
> Change-Id: I606cd40c9748b136fc2bf4750bea1da285add62d
> Signed-off-by: Uma Shankar <uma.shankar at intel.com>
> ---
>  drivers/gpu/drm/drm_atomic.c        |  8 ++++++++
>  drivers/gpu/drm/drm_atomic_helper.c |  4 ++++
>  drivers/gpu/drm/drm_mode_config.c   | 14 ++++++++++++++
>  include/drm/drm_mode_config.h       | 11 +++++++++++
>  include/drm/drm_plane.h             |  9 +++++++++
>  5 files changed, 46 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index d4b8c6cc84128..f634f6450f415 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -778,6 +778,12 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
>  					&replaced);
>  		state->color_mgmt_changed |= replaced;
>  		return ret;
> +	} else if (property == config->plane_gamma_lut_property) {
> +		ret = drm_atomic_replace_property_blob_from_id(dev,
> +					&state->gamma_lut,
> +					val, -1, &replaced);
> +		state->color_mgmt_changed |= replaced;
> +		return ret;
>  	} else {
>  		return -EINVAL;
>  	}
> @@ -841,6 +847,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
>  			state->degamma_lut->base.id : 0;
>  	} else if (property == config->plane_ctm_property) {
>  		*val = (state->ctm) ? state->ctm->base.id : 0;
> +	} else if (property == config->plane_gamma_lut_property) {
> +		*val = (state->gamma_lut) ? state->gamma_lut->base.id : 0;
>  	} else {
>  		return -EINVAL;
>  	}
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 17e137a529a0e..97dbb36153d14 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -3495,6 +3495,9 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
>  		drm_property_reference_blob(state->degamma_lut);
>  	if (state->ctm)
>  		drm_property_reference_blob(state->ctm);
> +	if (state->gamma_lut)
> +		drm_property_reference_blob(state->gamma_lut);
> +
>  	state->color_mgmt_changed = false;
>  }
>  EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state);
> @@ -3543,6 +3546,7 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)
>  
>  	drm_property_unreference_blob(state->degamma_lut);
>  	drm_property_unreference_blob(state->ctm);
> +	drm_property_unreference_blob(state->gamma_lut);
>  }
>  EXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state);
>  
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index c8763977413e7..bc6f8e51c7464 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -368,6 +368,20 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>  		return -ENOMEM;
>  	dev->mode_config.plane_ctm_property = prop;
>  
> +	prop = drm_property_create(dev,
> +			DRM_MODE_PROP_BLOB,
> +			"PLANE_GAMMA_LUT", 0);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.plane_gamma_lut_property = prop;
> +
> +	prop = drm_property_create_range(dev,
> +			DRM_MODE_PROP_IMMUTABLE,
> +			"PLANE_GAMMA_LUT_SIZE", 0, UINT_MAX);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.plane_gamma_lut_size_property = prop;
> +
>  	return 0;
>  }
>  
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index ad7235ced531b..3ca3eb3c98950 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -740,6 +740,17 @@ struct drm_mode_config {
>  	 * degamma LUT.
>  	 */
>  	struct drm_property *plane_ctm_property;
> +	/**
> +	 * @plane_gamma_lut_property: Optional Plane property to set the LUT
> +	 * used to convert the colors, after the CTM matrix, to the common
> +	 * gamma space chosen for blending.
> +	 */
> +	struct drm_property *plane_gamma_lut_property;
> +	/**
> +	 * @plane_gamma_lut_size_property: Optional Plane property for the size
> +	 * of the gamma LUT as supported by the driver (read-only).
> +	 */
> +	struct drm_property *plane_gamma_lut_size_property;

Same comments here about drm_property location.

>  	/**
>  	 * @ctm_property: Optional CRTC property to set the
>  	 * matrix used to convert colors after the lookup in the
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 21aecc9c91a09..acabb85009a14 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -147,6 +147,15 @@ struct drm_plane_state {
>  	 */
>  	struct drm_property_blob *ctm;
>  
> +	/**
> +	 * @gamma_lut:
> +	 *
> +	 * Lookup table for converting pixel data after the color conversion
> +	 * matrix @ctm.  See drm_plane_enable_color_mgmt(). The blob (if not
> +	 * NULL) is an array of &struct drm_color_lut.
> +	 */
> +	struct drm_property_blob *gamma_lut;

Will 16-bit be sufficient here as well, or will we want to use the 32-bit variant
that is required for degamma?

Sean

> +
>  	struct drm_atomic_state *state;
>  
>  	bool color_mgmt_changed : 1;
> -- 
> 2.16.1.291.g4437f3f132-goog
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 05/10] drm: Define helper function for plane color enabling
  2018-02-15  5:32 ` [PATCH 05/10] drm: Define helper function for plane color enabling Daniele Castagna
@ 2018-02-27 15:28   ` Sean Paul
  2018-02-28 14:57     ` Shankar, Uma
  0 siblings, 1 reply; 44+ messages in thread
From: Sean Paul @ 2018-02-27 15:28 UTC (permalink / raw)
  To: Daniele Castagna; +Cc: dri-devel

On Thu, Feb 15, 2018 at 12:32:55AM -0500, Daniele Castagna wrote:
> From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>
> 
> Define helper function to enable Plane color features
> to attach plane color properties to plane structure.
> 
> (am from https://patchwork.kernel.org/patch/9971333/)
> 
> Change-Id: I0a6647607fe482786e7cdb5f997faf196b2f59a2
> Signed-off-by: Uma Shankar <uma.shankar at intel.com>
> ---
>  drivers/gpu/drm/drm_plane.c  | 48 ++++++++++++++++++++++++++++++++++++
>  include/drm/drm_color_mgmt.h |  5 ++++
>  2 files changed, 53 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index 2c90519576a3e..bc2fc5e6771ac 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -143,6 +143,54 @@ static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane
>  	return 0;
>  }
>  
> + /**
> + * drm_plane_enable_color_mgmt - enable color management properties
> + * @plane: DRM Plane
> + * @plane_degamma_lut_size: the size of the degamma lut (before CSC)
> + * @plane_has_ctm: whether to attach ctm_property for CSC matrix
> + * @plane_gamma_lut_size: the size of the gamma lut (after CSC)
> + *
> + * This function lets the driver enable the color correction
> + * properties on a plane. This includes 3 degamma, csc and gamma
> + * properties that userspace can set and 2 size properties to inform
> + * the userspace of the lut sizes. Each of the properties are
> + * optional. The gamma and degamma properties are only attached if
> + * their size is not 0 and ctm_property is only attached if has_ctm is
> + * true.
> + *
> + * Drivers should use drm_atomic_helper_legacy_gamma_set() to implement the
> + * legacy &drm_crtc_funcs.gamma_set callback.
> + */
> +void drm_plane_enable_color_mgmt(struct drm_plane *plane,
> +				uint plane_degamma_lut_size,
> +				bool plane_has_ctm,
> +				uint plane_gamma_lut_size)
> +{

This seems like a good place to create the properties once they're located in
drm_plane.

> +	struct drm_device *dev = plane->dev;
> +	struct drm_mode_config *config = &dev->mode_config;
> +
> +	if (plane_degamma_lut_size) {
> +		drm_object_attach_property(&plane->base,
> +				config->plane_degamma_lut_property, 0);
> +		drm_object_attach_property(&plane->base,
> +				config->plane_degamma_lut_size_property,
> +				plane_degamma_lut_size);
> +	}
> +
> +	if (plane_has_ctm)
> +		drm_object_attach_property(&plane->base,
> +				config->plane_ctm_property, 0);
> +
> +	if (plane_gamma_lut_size) {
> +		drm_object_attach_property(&plane->base,
> +				config->plane_gamma_lut_property, 0);
> +		drm_object_attach_property(&plane->base,
> +				config->plane_gamma_lut_size_property,
> +				plane_gamma_lut_size);
> +	}
> +}
> +EXPORT_SYMBOL(drm_plane_enable_color_mgmt);
> +
>  /**
>   * drm_universal_plane_init - Initialize a new universal plane object
>   * @dev: DRM device
> diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
> index 03a59cbce6212..155a9ba38471c 100644
> --- a/include/drm/drm_color_mgmt.h
> +++ b/include/drm/drm_color_mgmt.h
> @@ -37,4 +37,9 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
>  int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
>  				 int gamma_size);
>  
> +void drm_plane_enable_color_mgmt(struct drm_plane *plane,
> +				 uint plane_degamma_lut_size,
> +				 bool plane_has_ctm,
> +				 uint plane_gamma_lut_size);
> +
>  #endif
> -- 
> 2.16.1.291.g4437f3f132-goog
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 06/10] drm: Define helper to set legacy gamma table size
  2018-02-15  5:32 ` [PATCH 06/10] drm: Define helper to set legacy gamma table size Daniele Castagna
  2018-02-16 22:17   ` kbuild test robot
@ 2018-02-27 15:35   ` Sean Paul
  2018-02-27 16:20   ` Emil Velikov
  2 siblings, 0 replies; 44+ messages in thread
From: Sean Paul @ 2018-02-27 15:35 UTC (permalink / raw)
  To: Daniele Castagna; +Cc: dri-devel

On Thu, Feb 15, 2018 at 12:32:56AM -0500, Daniele Castagna wrote:
> From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>
> 
> Define a helper function to set legacy gamma table
> size for planes.
> 
> (am from https://patchwork.kernel.org/patch/9971343/)

I don't see this used in the rest of the series. When it was originally
introduced, it was accompanied by drm/i915: Enable plane color features, which
seems to have been dropped.

Sean

> 
> Change-Id: I3d0c3e71d92300259cdfcebed4349207f64e4083
> Signed-off-by: Uma Shankar <uma.shankar at intel.com>
> ---
>  drivers/gpu/drm/drm_color_mgmt.c | 41 ++++++++++++++++++++++++++++++++
>  include/drm/drm_color_mgmt.h     |  3 +++
>  include/drm/drm_plane.h          |  4 ++++
>  3 files changed, 48 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
> index 0d002b045bd26..8f360b3ae0f24 100644
> --- a/drivers/gpu/drm/drm_color_mgmt.c
> +++ b/drivers/gpu/drm/drm_color_mgmt.c
> @@ -203,6 +203,47 @@ int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
>  }
>  EXPORT_SYMBOL(drm_mode_crtc_set_gamma_size);
>  
> +/**
> + * drm_mode_plane_set_gamma_size - set the gamma table size
> + * @plane: Plane to set the gamma table size for
> + * @gamma_size: size of the gamma table
> + *
> + * Drivers which support gamma tables should set this to the supported gamma
> + * table size when initializing the Plane. Currently the drm core only supports
> + * a fixed gamma table size.
> + *
> + * Returns:
> + * Zero on success, negative errno on failure.
> + */
> +int drm_mode_plane_set_gamma_size(struct drm_plane *plane,
> +				int gamma_size)
> +{
> +	uint16_t *r_base, *g_base, *b_base;
> +	int i;
> +
> +	plane->gamma_size = gamma_size;
> +
> +	plane->gamma_store = kcalloc(gamma_size, sizeof(uint16_t) * 3,
> +			GFP_KERNEL);
> +	if (!plane->gamma_store) {
> +		plane->gamma_size = 0;
> +		return -ENOMEM;
> +	}
> +
> +	r_base = plane->gamma_store;
> +	g_base = r_base + gamma_size;
> +	b_base = g_base + gamma_size;
> +	for (i = 0; i < gamma_size; i++) {
> +		r_base[i] = i << 8;
> +		g_base[i] = i << 8;
> +		b_base[i] = i << 8;
> +	}
> +
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_mode_plane_set_gamma_size);
> +
>  /**
>   * drm_mode_gamma_set_ioctl - set the gamma table
>   * @dev: DRM device
> diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
> index 155a9ba38471c..2f59c820e148c 100644
> --- a/include/drm/drm_color_mgmt.h
> +++ b/include/drm/drm_color_mgmt.h
> @@ -42,4 +42,7 @@ void drm_plane_enable_color_mgmt(struct drm_plane *plane,
>  				 bool plane_has_ctm,
>  				 uint plane_gamma_lut_size);
>  
> +int drm_mode_plane_set_gamma_size(struct drm_plane *plane,
> +				  int plane_gamma_size);
> +
>  #endif
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index acabb85009a14..18d09eacbcd7d 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -585,6 +585,10 @@ struct drm_plane {
>  
>  	struct drm_property *zpos_property;
>  	struct drm_property *rotation_property;
> +
> +	/* Legacy FB Plane gamma size for reporting to userspace */
> +	uint32_t gamma_size;
> +	uint16_t *gamma_store;
>  };
>  
>  #define obj_to_plane(x) container_of(x, struct drm_plane, base)
> -- 
> 2.16.1.291.g4437f3f132-goog
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 07/10] drm/rockchip: Add yuv2yuv registers to vop_lit
  2018-02-15  5:32 ` [PATCH 07/10] drm/rockchip: Add yuv2yuv registers to vop_lit Daniele Castagna
@ 2018-02-27 15:36   ` Sean Paul
  0 siblings, 0 replies; 44+ messages in thread
From: Sean Paul @ 2018-02-27 15:36 UTC (permalink / raw)
  To: Daniele Castagna; +Cc: dri-devel

On Thu, Feb 15, 2018 at 12:32:57AM -0500, Daniele Castagna wrote:
> rk3399_vop_yuv2yuv registers can be used also by vop_lit (less capable
> crtc) to control per-plane color conversion pipeline.
> 
> Change-Id: Iaad1efeae7141959c61e976988bd9d699ce3858f

Missing Signed-off-by, but this can probably get squashed into the earlier patch where
the structure is introduced.

Sean

> ---
>  drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> index be9c414e2e4bc..0af95947f22d4 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> @@ -483,6 +483,7 @@ static const struct vop_data rk3399_vop_lit = {
>  	.modeset = &rk3288_modeset,
>  	.output = &rk3399_output,
>  	.misc = &rk3368_misc,
> +	.yuv2yuv = &rk3399_vop_yuv2yuv,
>  	.win = rk3399_vop_lit_win_data,
>  	.win_size = ARRAY_SIZE(rk3399_vop_lit_win_data),
>  };
> -- 
> 2.16.1.291.g4437f3f132-goog
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 08/10] drm/rockchip: Add R2R registers
  2018-02-15  5:32 ` [PATCH 08/10] drm/rockchip: Add R2R registers Daniele Castagna
@ 2018-02-27 15:41   ` Sean Paul
  0 siblings, 0 replies; 44+ messages in thread
From: Sean Paul @ 2018-02-27 15:41 UTC (permalink / raw)
  To: Daniele Castagna; +Cc: dri-devel

On Thu, Feb 15, 2018 at 12:32:58AM -0500, Daniele Castagna wrote:
> This patch adds YUV2YUV registers to enable and control per-plane
> RGB2RGB colos space conversion matrix.
> 
> Change-Id: I8f421222da3587caea6373e2201e918f0c5e2646

Missing Signed-off-by, I think you can squash this into "drm/rockchip: Implement
drm plane->ctm property" as well.

> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.h |  7 +++
>  drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 48 +++++++++++++++++++++
>  2 files changed, 55 insertions(+)
> 
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
> index aa8a5d2690376..fea5a087f4749 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
> @@ -80,6 +80,13 @@ struct vop_misc {
>  };
>  
>  struct vop_yuv2yuv {
> +	struct vop_reg win0_r2r_en;
> +	struct vop_reg win0_r2r_coefficients[12];
> +	struct vop_reg win1_r2r_en;
> +	struct vop_reg win1_r2r_coefficients[12];
> +	struct vop_reg win2_r2r_en;
> +	struct vop_reg win2_r2r_coefficients[12];
> +
>  	struct vop_reg win0_y2r_en;
>  	struct vop_reg win0_y2r_coefficients[12];

I'll revise my earlier feedback and propose:

#define NUM_CSC_COEFFICIENTS    12
#define NUM_R2R_WINDOWS         3
#define NUM_Y2R_WINDOWS         2

struct vop_csc_reg {
        struct vop_reg en;
        struct vop_reg coefficients[NUM_CSC_COEFFICIENTS];
};

struct vop_csc {
        struct vop_csc_reg r2r[NUM_R2R_WINDOWS];
        struct vop_csc_reg y2r[NUM_Y2R_WINDOWS];
};


>  
> diff --git a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> index 0af95947f22d4..fb7b07aa4fa27 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> @@ -423,6 +423,54 @@ static const struct vop_output rk3399_output = {
>  };
>  
>  static const struct vop_yuv2yuv rk3399_vop_yuv2yuv = {
> +	.win0_r2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 0),
> +	.win0_r2r_coefficients = {
> +		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 0, 0xffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 0, 0xffff, 16),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 4, 0xffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 4, 0xffff, 16),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 8, 0xffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 8, 0xffff, 16),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 12, 0xffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 12, 0xffff, 16),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 16, 0xffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 20, 0xffffffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 24, 0xffffffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_3X3 + 28, 0xffffffff, 0),
> +	 },
> +
> +	.win1_r2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 8),
> +	.win1_r2r_coefficients = {
> +		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 0, 0xffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 0, 0xffff, 16),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 4, 0xffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 4, 0xffff, 16),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 8, 0xffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 8, 0xffff, 16),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 12, 0xffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 12, 0xffff, 16),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 16, 0xffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 20, 0xffffffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 24, 0xffffffff, 0),
> +		VOP_REG(RK3399_WIN1_YUV2YUV_3X3 + 28, 0xffffffff, 0),
> +	 },
> +
> +	.win2_r2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 16),
> +	.win2_r2r_coefficients = {
> +		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 0, 0xffff, 0),
> +		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 0, 0xffff, 16),
> +		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 4, 0xffff, 0),
> +		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 4, 0xffff, 16),
> +		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 8, 0xffff, 0),
> +		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 8, 0xffff, 16),
> +		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 12, 0xffff, 0),
> +		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 12, 0xffff, 16),
> +		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 16, 0xffff, 0),
> +		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 20, 0xffffffff, 0),
> +		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 24, 0xffffffff, 0),
> +		VOP_REG(RK3399_WIN2_YUV2YUV_3X3 + 28, 0xffffffff, 0),
> +	 },
> +
>  	.win0_y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 1),
>  	.win0_y2r_coefficients = {
>  		VOP_REG(RK3399_WIN1_YUV2YUV_Y2R + 0, 0xffff, 0),
> -- 
> 2.16.1.291.g4437f3f132-goog
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 09/10] drm/rockchip: Implement drm plane->ctm property.
  2018-02-15  5:32 ` [PATCH 09/10] drm/rockchip: Implement drm plane->ctm property Daniele Castagna
@ 2018-02-27 16:09   ` Sean Paul
  0 siblings, 0 replies; 44+ messages in thread
From: Sean Paul @ 2018-02-27 16:09 UTC (permalink / raw)
  To: Daniele Castagna; +Cc: dri-devel

On Thu, Feb 15, 2018 at 12:32:59AM -0500, Daniele Castagna wrote:
> Validate drm PLANE_CTM matrix and map it to YUV2YUV registers.
> 
> Change-Id: Ib4fe49558c6266bf0c310af121d625cd7b2cedf6

Missing Signed-off-by

> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 45 +++++++++++++++++++++
>  1 file changed, 45 insertions(+)
> 
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> index ea43ab797f555..8c8118c3db308 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> @@ -656,6 +656,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
>  	struct drm_framebuffer *fb = state->fb;
>  	struct vop_win *vop_win = to_vop_win(plane);
>  	const struct vop_win_data *win = vop_win->data;
> +	int i;
>  	int ret;
>  	struct drm_rect clip;
>  	int min_scale = win->phy->scl ? FRAC_16_16(1, 8) :
> @@ -697,6 +698,25 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
>  		return -EINVAL;
>  	}
>  
> +	if (state->ctm) {
> +		struct drm_color_ctm* color_ctm = (struct drm_color_ctm*)state->ctm->data;
> +		if (state->ctm->length != sizeof(struct drm_color_ctm)) {
> +			DRM_ERROR("Invalid PLANE_CTM blob size.\n");
> +			return -EINVAL;
> +		}
> +
> +		for (i = 0; i < 9; i++) {

s/9/ARRAY_SIZE(color_ctm->matrix)/

> +			/*
> +			 * YUV2YUV R2R registers have a signed fixed point S2.10 format.
> +			 * The input values, that are in signed fixed point S31.32 format,
> +			 * can be converted only if the first 30 MSBs are all 1s or 0s.
> +			 */
> +			uint32_t msbs = (uint32_t) (color_ctm->matrix[i] >> 34);

The behavior of a negative value shift is implementation-defined, so probably
best not to use it.

You could do:

uint64_t mask = GENMASK_ULL(63, 34);
uint64_t msbs = (uint64_t)color_ctm->matrix[i] & mask;

if (msbs == 0 || msbs == mask)

> +			if (msbs != ~0u && msbs != 0)
> +				    return -EOVERFLOW;

Indent is off here.

> +	      }
> +	}
> +
>  	return 0;
>  }
>  
> @@ -816,6 +836,31 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
>  		}
>  	}
>  
> +	if (!win_index) {
> +		VOP_YUV2YUV_SET(vop, win0_r2r_en, !!state->ctm);
> +	} else if (win_index == 1) {
> +		VOP_YUV2YUV_SET(vop, win1_r2r_en, !!state->ctm);
> +	} else if (win_index == 2) {
> +		VOP_YUV2YUV_SET(vop, win2_r2r_en, !!state->ctm);
> +	}
> +	if (state->ctm) {
> +		struct drm_color_ctm* color_ctm = (struct drm_color_ctm*)state->ctm->data;
> +                /*

Indent is messed up here too

> +		 * Convert matrix values from fixed point S31.32 to S2.10, by discarding
> +		 * the lowest 22 bits.
> +		 */
> +		for (i = 0; i < 9; i++) {
> +			uint32_t value = (color_ctm->matrix[i] >> 22) & 0x1FFF;

Same comment regarding the shift here, best to cast and mask before shifting.

> +			if (!win_index) {
> +				VOP_YUV2YUV_SET(vop, win0_r2r_coefficients[i], value);
> +			 } else if (win_index == 1){
> +				VOP_YUV2YUV_SET(vop, win1_r2r_coefficients[i], value);
> +			 } else if (win_index == 2) {
> +				VOP_YUV2YUV_SET(vop, win2_r2r_coefficients[i], value);
> +			 }
> +		}
> +	}
> +
>  	if (win->phy->scl)
>  		scl_vop_cal_scl_fac(vop, win, actual_w, actual_h,
>  				    drm_rect_width(dest), drm_rect_height(dest),
> -- 
> 2.16.1.291.g4437f3f132-goog
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 10/10] drm/rockchip: Enable 'PLANE_CTM' drm property.
  2018-02-15  5:33 ` [PATCH 10/10] drm/rockchip: Enable 'PLANE_CTM' drm property Daniele Castagna
@ 2018-02-27 16:10   ` Sean Paul
  0 siblings, 0 replies; 44+ messages in thread
From: Sean Paul @ 2018-02-27 16:10 UTC (permalink / raw)
  To: Daniele Castagna; +Cc: dri-devel

On Thu, Feb 15, 2018 at 12:33:00AM -0500, Daniele Castagna wrote:
> Enable and expose 'PLANE_CTM' matrix on primary and overaly planes.
> The property can be use to set a RGB to RGB 3X3 color conversion
> matrix that will be applied to planes at scanout.
> 
> Change-Id: Ifb7a680ab84c17557b8b3c5aaba1aa3b4eecfcaa

Once you add the missing SoB,

Reviewed-by: Sean Paul <seanpaul@chromium.org>

> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> index 8c8118c3db308..4148e2b025b31 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> @@ -1352,6 +1352,9 @@ static int vop_create_crtc(struct vop *vop)
>  
>  	ret = drm_crtc_init_with_planes(drm_dev, crtc, primary, cursor,
>  					&vop_crtc_funcs, NULL);
> +
> +	drm_plane_enable_color_mgmt(primary, 0, true, 0);
> +
>  	if (ret)
>  		goto err_cleanup_planes;
>  
> @@ -1381,6 +1384,8 @@ static int vop_create_crtc(struct vop *vop)
>  			goto err_cleanup_crtc;
>  		}
>  		drm_plane_helper_add(&vop_win->base, &plane_helper_funcs);
> +
> +		drm_plane_enable_color_mgmt(&vop_win->base, 0, true, 0);
>  	}
>  
>  	port = of_get_child_by_name(dev->of_node, "port");
> -- 
> 2.16.1.291.g4437f3f132-goog
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 06/10] drm: Define helper to set legacy gamma table size
  2018-02-15  5:32 ` [PATCH 06/10] drm: Define helper to set legacy gamma table size Daniele Castagna
  2018-02-16 22:17   ` kbuild test robot
  2018-02-27 15:35   ` Sean Paul
@ 2018-02-27 16:20   ` Emil Velikov
  2 siblings, 0 replies; 44+ messages in thread
From: Emil Velikov @ 2018-02-27 16:20 UTC (permalink / raw)
  To: Daniele Castagna; +Cc: ML dri-devel

Hi Daniele,

On 15 February 2018 at 05:32, Daniele Castagna <dcastagna@chromium.org> wrote:
> From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>
>
> Define a helper function to set legacy gamma table
> size for planes.
>
> (am from https://patchwork.kernel.org/patch/9971343/)
>
> Change-Id: I3d0c3e71d92300259cdfcebed4349207f64e4083
> Signed-off-by: Uma Shankar <uma.shankar at intel.com>
> ---
Daniel V has made a very good point in the cover letter. With that
resolved there's a few small suggestions:

 - please correct Uma's email - something has gone very wrong
 - drop the "am from ..." and Change-Id lines - they're not applicable
in upstream development, AFAICT
 - include your s-o-b when submitting patches - see the documentation
for details [1]

HTH
Emil

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v4.16-rc3#n429
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 04/10] drm: Add Plane Gamma properties
  2018-02-27 15:26   ` Sean Paul
@ 2018-02-27 16:52     ` Ville Syrjälä
  0 siblings, 0 replies; 44+ messages in thread
From: Ville Syrjälä @ 2018-02-27 16:52 UTC (permalink / raw)
  To: Sean Paul; +Cc: Daniele Castagna, dri-devel

On Tue, Feb 27, 2018 at 10:26:30AM -0500, Sean Paul wrote:
> On Thu, Feb 15, 2018 at 12:32:54AM -0500, Daniele Castagna wrote:
> > From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>
> > 
> > Add plane gamma as blob property and size as a
> > range property.
> > 
> > (am from https://patchwork.kernel.org/patch/9971325/)
> > 
> > Change-Id: I606cd40c9748b136fc2bf4750bea1da285add62d
> > Signed-off-by: Uma Shankar <uma.shankar at intel.com>
> > ---
> >  drivers/gpu/drm/drm_atomic.c        |  8 ++++++++
> >  drivers/gpu/drm/drm_atomic_helper.c |  4 ++++
> >  drivers/gpu/drm/drm_mode_config.c   | 14 ++++++++++++++
> >  include/drm/drm_mode_config.h       | 11 +++++++++++
> >  include/drm/drm_plane.h             |  9 +++++++++
> >  5 files changed, 46 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> > index d4b8c6cc84128..f634f6450f415 100644
> > --- a/drivers/gpu/drm/drm_atomic.c
> > +++ b/drivers/gpu/drm/drm_atomic.c
> > @@ -778,6 +778,12 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
> >  					&replaced);
> >  		state->color_mgmt_changed |= replaced;
> >  		return ret;
> > +	} else if (property == config->plane_gamma_lut_property) {
> > +		ret = drm_atomic_replace_property_blob_from_id(dev,
> > +					&state->gamma_lut,
> > +					val, -1, &replaced);
> > +		state->color_mgmt_changed |= replaced;
> > +		return ret;
> >  	} else {
> >  		return -EINVAL;
> >  	}
> > @@ -841,6 +847,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
> >  			state->degamma_lut->base.id : 0;
> >  	} else if (property == config->plane_ctm_property) {
> >  		*val = (state->ctm) ? state->ctm->base.id : 0;
> > +	} else if (property == config->plane_gamma_lut_property) {
> > +		*val = (state->gamma_lut) ? state->gamma_lut->base.id : 0;
> >  	} else {
> >  		return -EINVAL;
> >  	}
> > diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> > index 17e137a529a0e..97dbb36153d14 100644
> > --- a/drivers/gpu/drm/drm_atomic_helper.c
> > +++ b/drivers/gpu/drm/drm_atomic_helper.c
> > @@ -3495,6 +3495,9 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
> >  		drm_property_reference_blob(state->degamma_lut);
> >  	if (state->ctm)
> >  		drm_property_reference_blob(state->ctm);
> > +	if (state->gamma_lut)
> > +		drm_property_reference_blob(state->gamma_lut);
> > +
> >  	state->color_mgmt_changed = false;
> >  }
> >  EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state);
> > @@ -3543,6 +3546,7 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)
> >  
> >  	drm_property_unreference_blob(state->degamma_lut);
> >  	drm_property_unreference_blob(state->ctm);
> > +	drm_property_unreference_blob(state->gamma_lut);
> >  }
> >  EXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state);
> >  
> > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > index c8763977413e7..bc6f8e51c7464 100644
> > --- a/drivers/gpu/drm/drm_mode_config.c
> > +++ b/drivers/gpu/drm/drm_mode_config.c
> > @@ -368,6 +368,20 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> >  		return -ENOMEM;
> >  	dev->mode_config.plane_ctm_property = prop;
> >  
> > +	prop = drm_property_create(dev,
> > +			DRM_MODE_PROP_BLOB,
> > +			"PLANE_GAMMA_LUT", 0);
> > +	if (!prop)
> > +		return -ENOMEM;
> > +	dev->mode_config.plane_gamma_lut_property = prop;
> > +
> > +	prop = drm_property_create_range(dev,
> > +			DRM_MODE_PROP_IMMUTABLE,
> > +			"PLANE_GAMMA_LUT_SIZE", 0, UINT_MAX);
> > +	if (!prop)
> > +		return -ENOMEM;
> > +	dev->mode_config.plane_gamma_lut_size_property = prop;
> > +
> >  	return 0;
> >  }
> >  
> > diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> > index ad7235ced531b..3ca3eb3c98950 100644
> > --- a/include/drm/drm_mode_config.h
> > +++ b/include/drm/drm_mode_config.h
> > @@ -740,6 +740,17 @@ struct drm_mode_config {
> >  	 * degamma LUT.
> >  	 */
> >  	struct drm_property *plane_ctm_property;
> > +	/**
> > +	 * @plane_gamma_lut_property: Optional Plane property to set the LUT
> > +	 * used to convert the colors, after the CTM matrix, to the common
> > +	 * gamma space chosen for blending.
> > +	 */
> > +	struct drm_property *plane_gamma_lut_property;
> > +	/**
> > +	 * @plane_gamma_lut_size_property: Optional Plane property for the size
> > +	 * of the gamma LUT as supported by the driver (read-only).
> > +	 */
> > +	struct drm_property *plane_gamma_lut_size_property;
> 
> Same comments here about drm_property location.
> 
> >  	/**
> >  	 * @ctm_property: Optional CRTC property to set the
> >  	 * matrix used to convert colors after the lookup in the
> > diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> > index 21aecc9c91a09..acabb85009a14 100644
> > --- a/include/drm/drm_plane.h
> > +++ b/include/drm/drm_plane.h
> > @@ -147,6 +147,15 @@ struct drm_plane_state {
> >  	 */
> >  	struct drm_property_blob *ctm;
> >  
> > +	/**
> > +	 * @gamma_lut:
> > +	 *
> > +	 * Lookup table for converting pixel data after the color conversion
> > +	 * matrix @ctm.  See drm_plane_enable_color_mgmt(). The blob (if not
> > +	 * NULL) is an array of &struct drm_color_lut.
> > +	 */
> > +	struct drm_property_blob *gamma_lut;
> 
> Will 16-bit be sufficient here as well, or will we want to use the 32-bit variant
> that is required for degamma?

Someone proposing expanding the luts beying u0.16? I have been recently
thinking about making the luts support values outside the [0.0,1.0) interval
by stealing bits from the 'u16 reserved' have in drm_color_lut. At least
modern intel hw can do up to [0.0,8.0) (and it also mirrors the values
across the origin for negative inputs). Now, I don't have an immediate
use for that but I think some xvYCC type of stuff with out of gamut
values is one potential use case. There are potentially 5 bits per
component to use, so s5.16 might be the thing I'd consider. That would
cover the capabilities of intel hw. But if people are thinking that the
.16 is not enough then I supposer we might have to consider a totally
new property with higher precision lut entries, in which case extending
the current thing doesn't make much sense.

Another thing I've been sketching out in my head is some kind of enum
property that actually describes the diffrent modes the luts/ctm support. 
This would allow the client to eg. select between modes with a proper LUT
with lower precision vs. an interpolated curve with higher precision. At
least on intel hw the crtc luts support several different modes. My
current plan is that each mode would consist of a set of intervals,
where each interval a small structure which describes how the hardware
operates on input values in that range. Each set of intervals
would be exposed as a blob, and the blobs would be exposed via an enum
property. Such a blob enum property wouldn't allow the user to provide
and arbitrary blob and instead the blob id must match one of the enum
values.

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* RE: [PATCH 02/10] drm: Add Plane Degamma properties
  2018-02-27 15:13   ` Sean Paul
@ 2018-02-28 14:54     ` Shankar, Uma
  0 siblings, 0 replies; 44+ messages in thread
From: Shankar, Uma @ 2018-02-28 14:54 UTC (permalink / raw)
  To: Sean Paul, Daniele Castagna; +Cc: dri-devel



>-----Original Message-----
>From: Sean Paul [mailto:seanpaul@chromium.org]
>Sent: Tuesday, February 27, 2018 8:44 PM
>To: Daniele Castagna <dcastagna@chromium.org>
>Cc: dri-devel@lists.freedesktop.org; brian.starkey@arm.com; Shankar, Uma
><uma.shankar@intel.com>
>Subject: Re: [PATCH 02/10] drm: Add Plane Degamma properties
>
>On Thu, Feb 15, 2018 at 12:32:52AM -0500, Daniele Castagna wrote:
>> From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>
>>
>> Add Plane Degamma as a blob property and plane degamma size as a range
>> property.
>>
>> (am from https://patchwork.kernel.org/patch/10046515/)
>
>The discussion on this previous version has some feedback on using 32-bit values
>in the gamma lut instead of 16-bit. Have you considered this?
>

This needs to be modified. Will address this and send a next version.
Kept it on hold since was trying to get a userspace implementation done.
But, it's good to refresh the series addressing all the review comments.
Thanks for the review Sean Paul.

>>
>> Change-Id: Iaead6f944a8b677227d1be11169f46178de533b1
>> Signed-off-by: Uma Shankar <uma.shankar at intel.com>
>> ---
>>  drivers/gpu/drm/drm_atomic.c        | 12 ++++++++++++
>>  drivers/gpu/drm/drm_atomic_helper.c |  7 +++++++
>>  drivers/gpu/drm/drm_mode_config.c   | 14 ++++++++++++++
>>  include/drm/drm_mode_config.h       | 10 ++++++++++
>>  include/drm/drm_plane.h             | 10 ++++++++++
>>  5 files changed, 53 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_atomic.c
>> b/drivers/gpu/drm/drm_atomic.c index b76d49218cf1d..4a06ff2fd1a5e
>> 100644
>> --- a/drivers/gpu/drm/drm_atomic.c
>> +++ b/drivers/gpu/drm/drm_atomic.c
>> @@ -717,6 +717,8 @@ static int drm_atomic_plane_set_property(struct
>> drm_plane *plane,  {
>>  	struct drm_device *dev = plane->dev;
>>  	struct drm_mode_config *config = &dev->mode_config;
>> +	bool replaced = false;
>> +	int ret;
>>
>>  	if (property == config->prop_fb_id) {
>>  		struct drm_framebuffer *fb = drm_framebuffer_lookup(dev,
>NULL,
>> val); @@ -762,6 +764,12 @@ static int drm_atomic_plane_set_property(struct
>drm_plane *plane,
>>  	} else if (plane->funcs->atomic_set_property) {
>>  		return plane->funcs->atomic_set_property(plane, state,
>>  				property, val);
>> +	} else if (property == config->plane_degamma_lut_property) {
>> +		ret = drm_atomic_replace_property_blob_from_id(dev,
>> +					&state->degamma_lut,
>> +					val, -1, &replaced);
>> +		state->color_mgmt_changed |= replaced;
>> +		return ret;
>>  	} else {
>>  		return -EINVAL;
>>  	}
>> @@ -820,6 +828,9 @@ drm_atomic_plane_get_property(struct drm_plane
>*plane,
>>  		*val = state->zpos;
>>  	} else if (plane->funcs->atomic_get_property) {
>>  		return plane->funcs->atomic_get_property(plane, state,
>property,
>> val);
>> +	} else if (property == config->plane_degamma_lut_property) {
>> +		*val = (state->degamma_lut) ?
>> +			state->degamma_lut->base.id : 0;
>>  	} else {
>>  		return -EINVAL;
>>  	}
>> @@ -944,6 +955,7 @@ static void drm_atomic_plane_print_state(struct
>drm_printer *p,
>>  	drm_printf(p, "\tcrtc-pos=" DRM_RECT_FMT "\n",
>DRM_RECT_ARG(&dest));
>>  	drm_printf(p, "\tsrc-pos=" DRM_RECT_FP_FMT "\n",
>DRM_RECT_FP_ARG(&src));
>>  	drm_printf(p, "\trotation=%x\n", state->rotation);
>> +	drm_printf(p, "\tcolor_mgmt_changed=%d\n",
>> +state->color_mgmt_changed);
>>
>>  	if (plane->funcs->atomic_print_state)
>>  		plane->funcs->atomic_print_state(p, state); diff --git
>> a/drivers/gpu/drm/drm_atomic_helper.c
>> b/drivers/gpu/drm/drm_atomic_helper.c
>> index ab4032167094c..d3eaf4d397681 100644
>> --- a/drivers/gpu/drm/drm_atomic_helper.c
>> +++ b/drivers/gpu/drm/drm_atomic_helper.c
>> @@ -3488,7 +3488,12 @@ void
>__drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
>>  		drm_framebuffer_get(state->fb);
>>
>>  	state->fence = NULL;
>> +
>
>Extra line snuck in here
>

Will rectify this.

>>  	state->commit = NULL;
>> +
>> +	if (state->degamma_lut)
>> +		drm_property_reference_blob(state->degamma_lut);
>> +	state->color_mgmt_changed = false;
>>  }
>>  EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state);
>>
>> @@ -3533,6 +3538,8 @@ void
>> __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)
>>
>>  	if (state->commit)
>>  		drm_crtc_commit_put(state->commit);
>> +
>> +	drm_property_unreference_blob(state->degamma_lut);
>>  }
>>  EXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state);
>>
>> diff --git a/drivers/gpu/drm/drm_mode_config.c
>> b/drivers/gpu/drm/drm_mode_config.c
>> index e5c653357024d..7d8e74715b565 100644
>> --- a/drivers/gpu/drm/drm_mode_config.c
>> +++ b/drivers/gpu/drm/drm_mode_config.c
>> @@ -348,6 +348,20 @@ static int
>drm_mode_create_standard_properties(struct drm_device *dev)
>>  		return -ENOMEM;
>>  	dev->mode_config.modifiers_property = prop;
>>
>> +	prop = drm_property_create(dev,
>> +			DRM_MODE_PROP_BLOB,
>> +			"PLANE_DEGAMMA_LUT", 0);
>> +	if (!prop)
>> +		return -ENOMEM;
>> +	dev->mode_config.plane_degamma_lut_property = prop;
>> +
>> +	prop = drm_property_create_range(dev,
>> +			DRM_MODE_PROP_IMMUTABLE,
>> +			"PLANE_DEGAMMA_LUT_SIZE", 0, UINT_MAX);
>> +	if (!prop)
>> +		return -ENOMEM;
>> +	dev->mode_config.plane_degamma_lut_size_property = prop;
>
>Since these are optional, we probably want a helper for them which is only called
>if a plane wants to use them instead of always instantiating them.
>

Ok, will update this.

>> +
>>  	return 0;
>>  }
>>
>> diff --git a/include/drm/drm_mode_config.h
>> b/include/drm/drm_mode_config.h index 2cb6f02df64ab..dcec93d062b4d
>> 100644
>> --- a/include/drm/drm_mode_config.h
>> +++ b/include/drm/drm_mode_config.h
>> @@ -724,6 +724,16 @@ struct drm_mode_config {
>>  	 * the degamma LUT as supported by the driver (read-only).
>>  	 */
>>  	struct drm_property *degamma_lut_size_property;
>> + 	/**
>> +	 * @plane_degamma_lut_property: Optional Plane property to set the
>LUT
>> +	 * used to convert the framebuffer's colors to linear gamma.
>> +	 */
>> +	struct drm_property *plane_degamma_lut_property;
>> +	/**
>> +	 * @plane_degamma_lut_size_property: Optional Plane property for the
>> +	 * size of the degamma LUT as supported by the driver (read-only).
>> +	 */
>> +	struct drm_property *plane_degamma_lut_size_property;
>
>Can we put these in drm_plane instead? If we do, we don't need the "plane_"
>prefix.
>

Yeah, will do that.

>>  	/**
>>  	 * @ctm_property: Optional CRTC property to set the
>>  	 * matrix used to convert colors after the lookup in the diff --git
>> a/include/drm/drm_plane.h b/include/drm/drm_plane.h index
>> 8185e3468a231..2f8f5db77a406 100644
>> --- a/include/drm/drm_plane.h
>> +++ b/include/drm/drm_plane.h
>> @@ -131,7 +131,17 @@ struct drm_plane_state {
>>  	 */
>>  	struct drm_crtc_commit *commit;
>>
>> +	/* @degamma_lut:
>> +	 *
>> +	 * Lookup table for converting framebuffer pixel data before apply the
>> +	 * color conversion matrix @ctm. See drm_plane_enable_color_mgmt().
>The
>> +	 * blob (if not NULL) is an array of &struct drm_color_lut.
>> +	 */
>> +	struct drm_property_blob *degamma_lut;
>> +
>>  	struct drm_atomic_state *state;
>> +
>> +	bool color_mgmt_changed : 1;
>>  };
>>
>>  static inline struct drm_rect
>> --
>> 2.16.1.291.g4437f3f132-goog
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
>--
>Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* RE: [PATCH 03/10] drm: Add Plane CTM property
  2018-02-27 15:22   ` Sean Paul
@ 2018-02-28 14:55     ` Shankar, Uma
  0 siblings, 0 replies; 44+ messages in thread
From: Shankar, Uma @ 2018-02-28 14:55 UTC (permalink / raw)
  To: Sean Paul, Daniele Castagna; +Cc: dri-devel



>-----Original Message-----
>From: dri-devel [mailto:dri-devel-bounces@lists.freedesktop.org] On Behalf Of
>Sean Paul
>Sent: Tuesday, February 27, 2018 8:53 PM
>To: Daniele Castagna <dcastagna@chromium.org>
>Cc: dri-devel@lists.freedesktop.org
>Subject: Re: [PATCH 03/10] drm: Add Plane CTM property
>
>On Thu, Feb 15, 2018 at 12:32:53AM -0500, Daniele Castagna wrote:
>> From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>
>>
>> Add a blob property for plane CSC usage.
>>
>> (am from https://patchwork.kernel.org/patch/9971339/)
>>
>> Change-Id: I688ce7c95c20d307cb0aa35c5eba5ce2e1e88314
>> Signed-off-by: Uma Shankar <uma.shankar at intel.com>
>> ---
>>  drivers/gpu/drm/drm_atomic.c        | 10 ++++++++++
>>  drivers/gpu/drm/drm_atomic_helper.c |  3 +++
>>  drivers/gpu/drm/drm_mode_config.c   |  6 ++++++
>>  include/drm/drm_mode_config.h       |  6 ++++++
>>  include/drm/drm_plane.h             |  8 ++++++++
>>  5 files changed, 33 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_atomic.c
>> b/drivers/gpu/drm/drm_atomic.c index 4a06ff2fd1a5e..d4b8c6cc84128
>> 100644
>> --- a/drivers/gpu/drm/drm_atomic.c
>> +++ b/drivers/gpu/drm/drm_atomic.c
>> @@ -770,6 +770,14 @@ static int drm_atomic_plane_set_property(struct
>drm_plane *plane,
>>  					val, -1, &replaced);
>>  		state->color_mgmt_changed |= replaced;
>>  		return ret;
>> +	} else if (property == config->plane_ctm_property) {
>> +		ret = drm_atomic_replace_property_blob_from_id(dev,
>> +					&state->ctm,
>> +					val,
>> +					sizeof(struct drm_color_ctm),
>> +					&replaced);
>> +		state->color_mgmt_changed |= replaced;
>> +		return ret;
>>  	} else {
>>  		return -EINVAL;
>>  	}
>> @@ -831,6 +839,8 @@ drm_atomic_plane_get_property(struct drm_plane
>*plane,
>>  	} else if (property == config->plane_degamma_lut_property) {
>>  		*val = (state->degamma_lut) ?
>>  			state->degamma_lut->base.id : 0;
>> +	} else if (property == config->plane_ctm_property) {
>> +		*val = (state->ctm) ? state->ctm->base.id : 0;
>>  	} else {
>>  		return -EINVAL;
>>  	}
>> diff --git a/drivers/gpu/drm/drm_atomic_helper.c
>> b/drivers/gpu/drm/drm_atomic_helper.c
>> index d3eaf4d397681..17e137a529a0e 100644
>> --- a/drivers/gpu/drm/drm_atomic_helper.c
>> +++ b/drivers/gpu/drm/drm_atomic_helper.c
>> @@ -3493,6 +3493,8 @@ void
>> __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
>>
>>  	if (state->degamma_lut)
>>  		drm_property_reference_blob(state->degamma_lut);
>> +	if (state->ctm)
>> +		drm_property_reference_blob(state->ctm);
>>  	state->color_mgmt_changed = false;
>>  }
>>  EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state);
>> @@ -3540,6 +3542,7 @@ void
>__drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)
>>  		drm_crtc_commit_put(state->commit);
>>
>>  	drm_property_unreference_blob(state->degamma_lut);
>> +	drm_property_unreference_blob(state->ctm);
>>  }
>>  EXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state);
>>
>> diff --git a/drivers/gpu/drm/drm_mode_config.c
>> b/drivers/gpu/drm/drm_mode_config.c
>> index 7d8e74715b565..c8763977413e7 100644
>> --- a/drivers/gpu/drm/drm_mode_config.c
>> +++ b/drivers/gpu/drm/drm_mode_config.c
>> @@ -361,6 +361,12 @@ static int
>drm_mode_create_standard_properties(struct drm_device *dev)
>>  	if (!prop)
>>  		return -ENOMEM;
>>  	dev->mode_config.plane_degamma_lut_size_property = prop;
>> +	prop = drm_property_create(dev,
>> +			DRM_MODE_PROP_BLOB,
>> +			"PLANE_CTM", 0);
>> +	if (!prop)
>> +		return -ENOMEM;
>> +	dev->mode_config.plane_ctm_property = prop;
>>
>>  	return 0;
>>  }
>> diff --git a/include/drm/drm_mode_config.h
>> b/include/drm/drm_mode_config.h index dcec93d062b4d..ad7235ced531b
>> 100644
>> --- a/include/drm/drm_mode_config.h
>> +++ b/include/drm/drm_mode_config.h
>> @@ -734,6 +734,12 @@ struct drm_mode_config {
>>  	 * size of the degamma LUT as supported by the driver (read-only).
>>  	 */
>>  	struct drm_property *plane_degamma_lut_size_property;
>> +	/**
>> +	 * @plane_ctm_property: Optional CRTC property to set the
>> +	 * matrix used to convert colors after the lookup in the
>> +	 * degamma LUT.
>> +	 */
>> +	struct drm_property *plane_ctm_property;
>
>Same comments re: puttting the property in drm_plane and adding a helper to
>create it.
>

Sure, will update this.

Regards,
Uma Shankar

>Sean
>
>>  	/**
>>  	 * @ctm_property: Optional CRTC property to set the
>>  	 * matrix used to convert colors after the lookup in the diff --git
>> a/include/drm/drm_plane.h b/include/drm/drm_plane.h index
>> 2f8f5db77a406..21aecc9c91a09 100644
>> --- a/include/drm/drm_plane.h
>> +++ b/include/drm/drm_plane.h
>> @@ -139,6 +139,14 @@ struct drm_plane_state {
>>  	 */
>>  	struct drm_property_blob *degamma_lut;
>>
>> + 	/**
>> +	 * @ctm:
>> +	 *
>> +	 * Color transformation matrix. See drm_plane_enable_color_mgmt().
>The
>> +	 * blob (if not NULL) is a &struct drm_color_ctm.
>> +	 */
>> +	struct drm_property_blob *ctm;
>> +
>>  	struct drm_atomic_state *state;
>>
>>  	bool color_mgmt_changed : 1;
>> --
>> 2.16.1.291.g4437f3f132-goog
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
>--
>Sean Paul, Software Engineer, Google / Chromium OS
>_______________________________________________
>dri-devel mailing list
>dri-devel@lists.freedesktop.org
>https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* RE: [PATCH 05/10] drm: Define helper function for plane color enabling
  2018-02-27 15:28   ` Sean Paul
@ 2018-02-28 14:57     ` Shankar, Uma
  0 siblings, 0 replies; 44+ messages in thread
From: Shankar, Uma @ 2018-02-28 14:57 UTC (permalink / raw)
  To: Sean Paul, Daniele Castagna; +Cc: dri-devel



>-----Original Message-----
>From: dri-devel [mailto:dri-devel-bounces@lists.freedesktop.org] On Behalf Of
>Sean Paul
>Sent: Tuesday, February 27, 2018 8:59 PM
>To: Daniele Castagna <dcastagna@chromium.org>
>Cc: dri-devel@lists.freedesktop.org
>Subject: Re: [PATCH 05/10] drm: Define helper function for plane color enabling
>
>On Thu, Feb 15, 2018 at 12:32:55AM -0500, Daniele Castagna wrote:
>> From: "uma.shankar at intel.com (Uma Shankar)" <uma.shankar@intel.com>
>>
>> Define helper function to enable Plane color features to attach plane
>> color properties to plane structure.
>>
>> (am from https://patchwork.kernel.org/patch/9971333/)
>>
>> Change-Id: I0a6647607fe482786e7cdb5f997faf196b2f59a2
>> Signed-off-by: Uma Shankar <uma.shankar at intel.com>
>> ---
>>  drivers/gpu/drm/drm_plane.c  | 48
>> ++++++++++++++++++++++++++++++++++++
>>  include/drm/drm_color_mgmt.h |  5 ++++
>>  2 files changed, 53 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
>> index 2c90519576a3e..bc2fc5e6771ac 100644
>> --- a/drivers/gpu/drm/drm_plane.c
>> +++ b/drivers/gpu/drm/drm_plane.c
>> @@ -143,6 +143,54 @@ static int create_in_format_blob(struct drm_device
>*dev, struct drm_plane *plane
>>  	return 0;
>>  }
>>
>> + /**
>> + * drm_plane_enable_color_mgmt - enable color management properties
>> + * @plane: DRM Plane
>> + * @plane_degamma_lut_size: the size of the degamma lut (before CSC)
>> + * @plane_has_ctm: whether to attach ctm_property for CSC matrix
>> + * @plane_gamma_lut_size: the size of the gamma lut (after CSC)
>> + *
>> + * This function lets the driver enable the color correction
>> + * properties on a plane. This includes 3 degamma, csc and gamma
>> + * properties that userspace can set and 2 size properties to inform
>> + * the userspace of the lut sizes. Each of the properties are
>> + * optional. The gamma and degamma properties are only attached if
>> + * their size is not 0 and ctm_property is only attached if has_ctm
>> +is
>> + * true.
>> + *
>> + * Drivers should use drm_atomic_helper_legacy_gamma_set() to
>> +implement the
>> + * legacy &drm_crtc_funcs.gamma_set callback.
>> + */
>> +void drm_plane_enable_color_mgmt(struct drm_plane *plane,
>> +				uint plane_degamma_lut_size,
>> +				bool plane_has_ctm,
>> +				uint plane_gamma_lut_size)
>> +{
>
>This seems like a good place to create the properties once they're located in
>drm_plane.
>

Yeah, I agree. Will update the series.

Regards,
Uma Shankar

>> +	struct drm_device *dev = plane->dev;
>> +	struct drm_mode_config *config = &dev->mode_config;
>> +
>> +	if (plane_degamma_lut_size) {
>> +		drm_object_attach_property(&plane->base,
>> +				config->plane_degamma_lut_property, 0);
>> +		drm_object_attach_property(&plane->base,
>> +				config->plane_degamma_lut_size_property,
>> +				plane_degamma_lut_size);
>> +	}
>> +
>> +	if (plane_has_ctm)
>> +		drm_object_attach_property(&plane->base,
>> +				config->plane_ctm_property, 0);
>> +
>> +	if (plane_gamma_lut_size) {
>> +		drm_object_attach_property(&plane->base,
>> +				config->plane_gamma_lut_property, 0);
>> +		drm_object_attach_property(&plane->base,
>> +				config->plane_gamma_lut_size_property,
>> +				plane_gamma_lut_size);
>> +	}
>> +}
>> +EXPORT_SYMBOL(drm_plane_enable_color_mgmt);
>> +
>>  /**
>>   * drm_universal_plane_init - Initialize a new universal plane object
>>   * @dev: DRM device
>> diff --git a/include/drm/drm_color_mgmt.h
>> b/include/drm/drm_color_mgmt.h index 03a59cbce6212..155a9ba38471c
>> 100644
>> --- a/include/drm/drm_color_mgmt.h
>> +++ b/include/drm/drm_color_mgmt.h
>> @@ -37,4 +37,9 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc
>> *crtc,  int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
>>  				 int gamma_size);
>>
>> +void drm_plane_enable_color_mgmt(struct drm_plane *plane,
>> +				 uint plane_degamma_lut_size,
>> +				 bool plane_has_ctm,
>> +				 uint plane_gamma_lut_size);
>> +
>>  #endif
>> --
>> 2.16.1.291.g4437f3f132-goog
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
>--
>Sean Paul, Software Engineer, Google / Chromium OS
>_______________________________________________
>dri-devel mailing list
>dri-devel@lists.freedesktop.org
>https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2] drm/rockchip: Fix YUV buffers color rendering
  2018-02-15  5:32 ` [PATCH 01/10] drm/rockchip: YUV overlays BT.601 color conversion Daniele Castagna
  2018-02-16 17:55   ` kbuild test robot
  2018-02-27 15:03   ` Sean Paul
@ 2018-12-14 16:29   ` Ezequiel Garcia
  2019-01-03 16:28     ` Ezequiel Garcia
                       ` (2 more replies)
  2 siblings, 3 replies; 44+ messages in thread
From: Ezequiel Garcia @ 2018-12-14 16:29 UTC (permalink / raw)
  To: dri-devel
  Cc: Daniele Castagna, Tomasz Figa, linux-rockchip, Sean Paul, kernel,
	Ezequiel Garcia

From: Daniele Castagna <dcastagna@chromium.org>

Currently, YUV hardware overlays are converted to RGB using
a color space conversion different than BT.601.

The result is that colors of e.g. NV12 buffers don't match
colors of YUV hardware overlays.

In order to fix this, enable YUV2YUV and set appropriate coefficients
for formats such as NV12 to be displayed correctly.

This commit was tested using modetest, gstreamer and chromeos (hardware
accelerated video playback). Before the commit, tests rendering
with NV12 format resulted in colors not displayed correctly.

Test examples (RK3399 Ficus board connected to HDMI monitor):

  $ modetest 39@32:1920x1080@NV12
  $ gst-launch-1.0 videotestrc ! video/x-raw,format=NV12 ! kmssink

Signed-off-by: Daniele Castagna <dcastagna@chromium.org>
[ezequiel: rebase on linux-next and massage commit log]
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
---
v2:
  * Addressed feedback from Sean Paul
  * Rebased on linux-next

 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 41 ++++++++++++++++++++-
 drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 13 +++++++
 drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 36 ++++++++++++++++++
 3 files changed, 89 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index fb70fb486fbf..78c7f63a60c0 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -52,6 +52,18 @@
 		vop_reg_set(vop, &win->phy->scl->ext->name, \
 			    win->base, ~0, v, #name)
 
+#define VOP_WIN_YUV2YUV_SET(x, win_yuv2yuv, name, v) \
+	do { \
+		if (win_yuv2yuv->name.mask) \
+			vop_reg_set(vop, &win_yuv2yuv->name, 0, ~0, v, #name); \
+	} while (0)
+
+#define VOP_WIN_YUV2YUV_COEFFICIENT_SET(x, win_yuv2yuv, name, v) \
+	do { \
+		if (win_yuv2yuv->phy->name.mask) \
+			vop_reg_set(vop, &win_yuv2yuv->phy->name, win_yuv2yuv->base, ~0, v, #name); \
+	} while (0)
+
 #define VOP_INTR_SET_MASK(vop, name, mask, v) \
 		vop_reg_set(vop, &vop->data->intr->name, 0, mask, v, #name)
 
@@ -84,6 +96,18 @@
 #define to_vop(x) container_of(x, struct vop, crtc)
 #define to_vop_win(x) container_of(x, struct vop_win, base)
 
+/*
+ * The coefficients of the following matrix are all fixed points.
+ * The format is S2.10 for the 3x3 part of the matrix, and S9.12 for the offsets.
+ * They are all represented in two's complement.
+ */
+static const uint32_t rockchip_bt601_yuv2rgb[] = {
+	0x000004a8, 0x00000000, 0x00000662,
+	0x000004a8, 0x00001e6f, 0x00001cbf,
+	0x000004a8, 0x00000812, 0x00000000,
+	0x00321168, 0x000877cf, 0x002eb127
+};
+
 enum vop_pending {
 	VOP_PENDING_FB_UNREF,
 };
@@ -91,6 +115,7 @@ enum vop_pending {
 struct vop_win {
 	struct drm_plane base;
 	const struct vop_win_data *data;
+	const struct vop_win_yuv2yuv_data *yuv2yuv_data;
 	struct vop *vop;
 };
 
@@ -712,6 +737,7 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
 	struct drm_crtc *crtc = state->crtc;
 	struct vop_win *vop_win = to_vop_win(plane);
 	const struct vop_win_data *win = vop_win->data;
+	const struct vop_win_yuv2yuv_data *win_yuv2yuv = vop_win->yuv2yuv_data;
 	struct vop *vop = to_vop(state->crtc);
 	struct drm_framebuffer *fb = state->fb;
 	unsigned int actual_w, actual_h;
@@ -727,6 +753,8 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
 	bool rb_swap;
 	int win_index = VOP_WIN_TO_INDEX(vop_win);
 	int format;
+	int is_yuv = fb->format->is_yuv;
+	int i;
 
 	/*
 	 * can't update plane when vop is disabled.
@@ -767,7 +795,10 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
 	VOP_WIN_SET(vop, win, format, format);
 	VOP_WIN_SET(vop, win, yrgb_vir, DIV_ROUND_UP(fb->pitches[0], 4));
 	VOP_WIN_SET(vop, win, yrgb_mst, dma_addr);
-	if (fb->format->is_yuv) {
+
+	VOP_WIN_YUV2YUV_SET(vop, win_yuv2yuv, y2r_en, is_yuv);
+
+	if (is_yuv) {
 		int hsub = drm_format_horz_chroma_subsampling(fb->format->format);
 		int vsub = drm_format_vert_chroma_subsampling(fb->format->format);
 		int bpp = fb->format->cpp[1];
@@ -781,6 +812,13 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
 		dma_addr = rk_uv_obj->dma_addr + offset + fb->offsets[1];
 		VOP_WIN_SET(vop, win, uv_vir, DIV_ROUND_UP(fb->pitches[1], 4));
 		VOP_WIN_SET(vop, win, uv_mst, dma_addr);
+
+		for (i = 0; i < NUM_YUV2YUV_COEFFICIENTS; i++) {
+			VOP_WIN_YUV2YUV_COEFFICIENT_SET(vop,
+							win_yuv2yuv,
+							y2r_coefficients[i],
+							rockchip_bt601_yuv2rgb[i]);
+		}
 	}
 
 	if (win->phy->scl)
@@ -1529,6 +1567,7 @@ static void vop_win_init(struct vop *vop)
 
 		vop_win->data = win_data;
 		vop_win->vop = vop;
+		vop_win->yuv2yuv_data = &vop_data->win_yuv2yuv[i];
 	}
 }
 
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
index 0fe40e1983d9..aed467cd81b9 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
@@ -23,6 +23,8 @@
 #define VOP_MAJOR(version)		((version) >> 8)
 #define VOP_MINOR(version)		((version) & 0xff)
 
+#define NUM_YUV2YUV_COEFFICIENTS 12
+
 enum vop_data_format {
 	VOP_FMT_ARGB8888 = 0,
 	VOP_FMT_RGB888,
@@ -124,6 +126,10 @@ struct vop_scl_regs {
 	struct vop_reg scale_cbcr_y;
 };
 
+struct vop_yuv2yuv_phy {
+	struct vop_reg y2r_coefficients[NUM_YUV2YUV_COEFFICIENTS];
+};
+
 struct vop_win_phy {
 	const struct vop_scl_regs *scl;
 	const uint32_t *data_formats;
@@ -146,6 +152,12 @@ struct vop_win_phy {
 	struct vop_reg channel;
 };
 
+struct vop_win_yuv2yuv_data {
+	uint32_t base;
+	const struct vop_yuv2yuv_phy *phy;
+	struct vop_reg y2r_en;
+};
+
 struct vop_win_data {
 	uint32_t base;
 	const struct vop_win_phy *phy;
@@ -159,6 +171,7 @@ struct vop_data {
 	const struct vop_misc *misc;
 	const struct vop_modeset *modeset;
 	const struct vop_output *output;
+	const struct vop_win_yuv2yuv_data *win_yuv2yuv;
 	const struct vop_win_data *win;
 	unsigned int win_size;
 
diff --git a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
index 08fc40af52c8..fe752df4e038 100644
--- a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
+++ b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
@@ -637,6 +637,34 @@ static const struct vop_output rk3399_output = {
 	.mipi_dual_channel_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 3),
 };
 
+static const struct vop_yuv2yuv_phy rk3399_yuv2yuv_win01_data = {
+	.y2r_coefficients = {
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 0, 0xffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 0, 0xffff, 16),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 4, 0xffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 4, 0xffff, 16),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 8, 0xffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 8, 0xffff, 16),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 12, 0xffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 12, 0xffff, 16),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 16, 0xffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 20, 0xffffffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 24, 0xffffffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 28, 0xffffffff, 0),
+	},
+};
+
+static const struct vop_yuv2yuv_phy rk3399_yuv2yuv_win23_data = { };
+
+static const struct vop_win_yuv2yuv_data rk3399_vop_big_win_yuv2yuv_data[] = {
+	{ .base = 0x00, .phy = &rk3399_yuv2yuv_win01_data,
+	  .y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 1) },
+	{ .base = 0x60, .phy = &rk3399_yuv2yuv_win01_data,
+	  .y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 9) },
+	{ .base = 0xC0, .phy = &rk3399_yuv2yuv_win23_data },
+	{ .base = 0x120, .phy = &rk3399_yuv2yuv_win23_data },
+};
+
 static const struct vop_data rk3399_vop_big = {
 	.version = VOP_VERSION(3, 5),
 	.feature = VOP_FEATURE_OUTPUT_RGB10,
@@ -647,6 +675,7 @@ static const struct vop_data rk3399_vop_big = {
 	.misc = &rk3368_misc,
 	.win = rk3368_vop_win_data,
 	.win_size = ARRAY_SIZE(rk3368_vop_win_data),
+	.win_yuv2yuv = rk3399_vop_big_win_yuv2yuv_data,
 };
 
 static const struct vop_win_data rk3399_vop_lit_win_data[] = {
@@ -656,6 +685,12 @@ static const struct vop_win_data rk3399_vop_lit_win_data[] = {
 	  .type = DRM_PLANE_TYPE_CURSOR},
 };
 
+static const struct vop_win_yuv2yuv_data rk3399_vop_lit_win_yuv2yuv_data[] = {
+	{ .base = 0x00, .phy = &rk3399_yuv2yuv_win01_data,
+	  .y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 1)},
+	{ .base = 0x60, .phy = &rk3399_yuv2yuv_win23_data },
+};
+
 static const struct vop_data rk3399_vop_lit = {
 	.version = VOP_VERSION(3, 6),
 	.intr = &rk3366_vop_intr,
@@ -665,6 +700,7 @@ static const struct vop_data rk3399_vop_lit = {
 	.misc = &rk3368_misc,
 	.win = rk3399_vop_lit_win_data,
 	.win_size = ARRAY_SIZE(rk3399_vop_lit_win_data),
+	.win_yuv2yuv = rk3399_vop_lit_win_yuv2yuv_data,
 };
 
 static const struct vop_win_data rk3228_vop_win_data[] = {
-- 
2.20.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* Re: [PATCH v2] drm/rockchip: Fix YUV buffers color rendering
  2018-12-14 16:29   ` [PATCH v2] drm/rockchip: Fix YUV buffers color rendering Ezequiel Garcia
@ 2019-01-03 16:28     ` Ezequiel Garcia
  2019-01-07 13:26     ` Heiko Stuebner
  2019-01-08 21:46     ` [PATCH v3] " Ezequiel Garcia
  2 siblings, 0 replies; 44+ messages in thread
From: Ezequiel Garcia @ 2019-01-03 16:28 UTC (permalink / raw)
  To: dri-devel
  Cc: Daniele Castagna, Tomasz Figa, linux-rockchip, Sean Paul, kernel

On Fri, 2018-12-14 at 13:29 -0300, Ezequiel Garcia wrote:
> From: Daniele Castagna <dcastagna@chromium.org>
> 
> Currently, YUV hardware overlays are converted to RGB using
> a color space conversion different than BT.601.
> 
> The result is that colors of e.g. NV12 buffers don't match
> colors of YUV hardware overlays.
> 
> In order to fix this, enable YUV2YUV and set appropriate coefficients
> for formats such as NV12 to be displayed correctly.
> 
> This commit was tested using modetest, gstreamer and chromeos (hardware
> accelerated video playback). Before the commit, tests rendering
> with NV12 format resulted in colors not displayed correctly.
> 
> Test examples (RK3399 Ficus board connected to HDMI monitor):
> 
>   $ modetest 39@32:1920x1080@NV12
>   $ gst-launch-1.0 videotestrc ! video/x-raw,format=NV12 ! kmssink
> 
> Signed-off-by: Daniele Castagna <dcastagna@chromium.org>
> [ezequiel: rebase on linux-next and massage commit log]
> Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
> ---
> v2:
>   * Addressed feedback from Sean Paul
>   * Rebased on linux-next
> 

Any feedback on this one?

Thanks!
Ezequiel

>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 41 ++++++++++++++++++++-
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 13 +++++++
>  drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 36 ++++++++++++++++++
>  3 files changed, 89 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> index fb70fb486fbf..78c7f63a60c0 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> @@ -52,6 +52,18 @@
>  		vop_reg_set(vop, &win->phy->scl->ext->name, \
>  			    win->base, ~0, v, #name)
>  
> +#define VOP_WIN_YUV2YUV_SET(x, win_yuv2yuv, name, v) \
> +	do { \
> +		if (win_yuv2yuv->name.mask) \
> +			vop_reg_set(vop, &win_yuv2yuv->name, 0, ~0, v, #name); \
> +	} while (0)
> +
> +#define VOP_WIN_YUV2YUV_COEFFICIENT_SET(x, win_yuv2yuv, name, v) \
> +	do { \
> +		if (win_yuv2yuv->phy->name.mask) \
> +			vop_reg_set(vop, &win_yuv2yuv->phy->name, win_yuv2yuv->base, ~0, v, #name); \
> +	} while (0)
> +
>  #define VOP_INTR_SET_MASK(vop, name, mask, v) \
>  		vop_reg_set(vop, &vop->data->intr->name, 0, mask, v, #name)
>  
> @@ -84,6 +96,18 @@
>  #define to_vop(x) container_of(x, struct vop, crtc)
>  #define to_vop_win(x) container_of(x, struct vop_win, base)
>  
> +/*
> + * The coefficients of the following matrix are all fixed points.
> + * The format is S2.10 for the 3x3 part of the matrix, and S9.12 for the offsets.
> + * They are all represented in two's complement.
> + */
> +static const uint32_t rockchip_bt601_yuv2rgb[] = {
> +	0x000004a8, 0x00000000, 0x00000662,
> +	0x000004a8, 0x00001e6f, 0x00001cbf,
> +	0x000004a8, 0x00000812, 0x00000000,
> +	0x00321168, 0x000877cf, 0x002eb127
> +};
> +
>  enum vop_pending {
>  	VOP_PENDING_FB_UNREF,
>  };
> @@ -91,6 +115,7 @@ enum vop_pending {
>  struct vop_win {
>  	struct drm_plane base;
>  	const struct vop_win_data *data;
> +	const struct vop_win_yuv2yuv_data *yuv2yuv_data;
>  	struct vop *vop;
>  };
>  
> @@ -712,6 +737,7 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
>  	struct drm_crtc *crtc = state->crtc;
>  	struct vop_win *vop_win = to_vop_win(plane);
>  	const struct vop_win_data *win = vop_win->data;
> +	const struct vop_win_yuv2yuv_data *win_yuv2yuv = vop_win->yuv2yuv_data;
>  	struct vop *vop = to_vop(state->crtc);
>  	struct drm_framebuffer *fb = state->fb;
>  	unsigned int actual_w, actual_h;
> @@ -727,6 +753,8 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
>  	bool rb_swap;
>  	int win_index = VOP_WIN_TO_INDEX(vop_win);
>  	int format;
> +	int is_yuv = fb->format->is_yuv;
> +	int i;
>  
>  	/*
>  	 * can't update plane when vop is disabled.
> @@ -767,7 +795,10 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
>  	VOP_WIN_SET(vop, win, format, format);
>  	VOP_WIN_SET(vop, win, yrgb_vir, DIV_ROUND_UP(fb->pitches[0], 4));
>  	VOP_WIN_SET(vop, win, yrgb_mst, dma_addr);
> -	if (fb->format->is_yuv) {
> +
> +	VOP_WIN_YUV2YUV_SET(vop, win_yuv2yuv, y2r_en, is_yuv);
> +
> +	if (is_yuv) {
>  		int hsub = drm_format_horz_chroma_subsampling(fb->format->format);
>  		int vsub = drm_format_vert_chroma_subsampling(fb->format->format);
>  		int bpp = fb->format->cpp[1];
> @@ -781,6 +812,13 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
>  		dma_addr = rk_uv_obj->dma_addr + offset + fb->offsets[1];
>  		VOP_WIN_SET(vop, win, uv_vir, DIV_ROUND_UP(fb->pitches[1], 4));
>  		VOP_WIN_SET(vop, win, uv_mst, dma_addr);
> +
> +		for (i = 0; i < NUM_YUV2YUV_COEFFICIENTS; i++) {
> +			VOP_WIN_YUV2YUV_COEFFICIENT_SET(vop,
> +							win_yuv2yuv,
> +							y2r_coefficients[i],
> +							rockchip_bt601_yuv2rgb[i]);
> +		}
>  	}
>  
>  	if (win->phy->scl)
> @@ -1529,6 +1567,7 @@ static void vop_win_init(struct vop *vop)
>  
>  		vop_win->data = win_data;
>  		vop_win->vop = vop;
> +		vop_win->yuv2yuv_data = &vop_data->win_yuv2yuv[i];
>  	}
>  }
>  
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
> index 0fe40e1983d9..aed467cd81b9 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
> @@ -23,6 +23,8 @@
>  #define VOP_MAJOR(version)		((version) >> 8)
>  #define VOP_MINOR(version)		((version) & 0xff)
>  
> +#define NUM_YUV2YUV_COEFFICIENTS 12
> +
>  enum vop_data_format {
>  	VOP_FMT_ARGB8888 = 0,
>  	VOP_FMT_RGB888,
> @@ -124,6 +126,10 @@ struct vop_scl_regs {
>  	struct vop_reg scale_cbcr_y;
>  };
>  
> +struct vop_yuv2yuv_phy {
> +	struct vop_reg y2r_coefficients[NUM_YUV2YUV_COEFFICIENTS];
> +};
> +
>  struct vop_win_phy {
>  	const struct vop_scl_regs *scl;
>  	const uint32_t *data_formats;
> @@ -146,6 +152,12 @@ struct vop_win_phy {
>  	struct vop_reg channel;
>  };
>  
> +struct vop_win_yuv2yuv_data {
> +	uint32_t base;
> +	const struct vop_yuv2yuv_phy *phy;
> +	struct vop_reg y2r_en;
> +};
> +
>  struct vop_win_data {
>  	uint32_t base;
>  	const struct vop_win_phy *phy;
> @@ -159,6 +171,7 @@ struct vop_data {
>  	const struct vop_misc *misc;
>  	const struct vop_modeset *modeset;
>  	const struct vop_output *output;
> +	const struct vop_win_yuv2yuv_data *win_yuv2yuv;
>  	const struct vop_win_data *win;
>  	unsigned int win_size;
>  
> diff --git a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> index 08fc40af52c8..fe752df4e038 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> @@ -637,6 +637,34 @@ static const struct vop_output rk3399_output = {
>  	.mipi_dual_channel_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 3),
>  };
>  
> +static const struct vop_yuv2yuv_phy rk3399_yuv2yuv_win01_data = {
> +	.y2r_coefficients = {
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 0, 0xffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 0, 0xffff, 16),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 4, 0xffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 4, 0xffff, 16),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 8, 0xffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 8, 0xffff, 16),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 12, 0xffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 12, 0xffff, 16),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 16, 0xffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 20, 0xffffffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 24, 0xffffffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 28, 0xffffffff, 0),
> +	},
> +};
> +
> +static const struct vop_yuv2yuv_phy rk3399_yuv2yuv_win23_data = { };
> +
> +static const struct vop_win_yuv2yuv_data rk3399_vop_big_win_yuv2yuv_data[] = {
> +	{ .base = 0x00, .phy = &rk3399_yuv2yuv_win01_data,
> +	  .y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 1) },
> +	{ .base = 0x60, .phy = &rk3399_yuv2yuv_win01_data,
> +	  .y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 9) },
> +	{ .base = 0xC0, .phy = &rk3399_yuv2yuv_win23_data },
> +	{ .base = 0x120, .phy = &rk3399_yuv2yuv_win23_data },
> +};
> +
>  static const struct vop_data rk3399_vop_big = {
>  	.version = VOP_VERSION(3, 5),
>  	.feature = VOP_FEATURE_OUTPUT_RGB10,
> @@ -647,6 +675,7 @@ static const struct vop_data rk3399_vop_big = {
>  	.misc = &rk3368_misc,
>  	.win = rk3368_vop_win_data,
>  	.win_size = ARRAY_SIZE(rk3368_vop_win_data),
> +	.win_yuv2yuv = rk3399_vop_big_win_yuv2yuv_data,
>  };
>  
>  static const struct vop_win_data rk3399_vop_lit_win_data[] = {
> @@ -656,6 +685,12 @@ static const struct vop_win_data rk3399_vop_lit_win_data[] = {
>  	  .type = DRM_PLANE_TYPE_CURSOR},
>  };
>  
> +static const struct vop_win_yuv2yuv_data rk3399_vop_lit_win_yuv2yuv_data[] = {
> +	{ .base = 0x00, .phy = &rk3399_yuv2yuv_win01_data,
> +	  .y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 1)},
> +	{ .base = 0x60, .phy = &rk3399_yuv2yuv_win23_data },
> +};
> +
>  static const struct vop_data rk3399_vop_lit = {
>  	.version = VOP_VERSION(3, 6),
>  	.intr = &rk3366_vop_intr,
> @@ -665,6 +700,7 @@ static const struct vop_data rk3399_vop_lit = {
>  	.misc = &rk3368_misc,
>  	.win = rk3399_vop_lit_win_data,
>  	.win_size = ARRAY_SIZE(rk3399_vop_lit_win_data),
> +	.win_yuv2yuv = rk3399_vop_lit_win_yuv2yuv_data,
>  };
>  
>  static const struct vop_win_data rk3228_vop_win_data[] = {


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2] drm/rockchip: Fix YUV buffers color rendering
  2018-12-14 16:29   ` [PATCH v2] drm/rockchip: Fix YUV buffers color rendering Ezequiel Garcia
  2019-01-03 16:28     ` Ezequiel Garcia
@ 2019-01-07 13:26     ` Heiko Stuebner
  2019-01-07 20:07       ` Ezequiel Garcia
  2019-01-08 21:46     ` [PATCH v3] " Ezequiel Garcia
  2 siblings, 1 reply; 44+ messages in thread
From: Heiko Stuebner @ 2019-01-07 13:26 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: Daniele Castagna, dri-devel, Tomasz Figa, linux-rockchip,
	Sean Paul, kernel

Hi,

sorry, only now got to test this on actual hardware,

Am Freitag, 14. Dezember 2018, 17:29:20 CET schrieb Ezequiel Garcia:
> From: Daniele Castagna <dcastagna@chromium.org>
> 
> Currently, YUV hardware overlays are converted to RGB using
> a color space conversion different than BT.601.
> 
> The result is that colors of e.g. NV12 buffers don't match
> colors of YUV hardware overlays.
> 
> In order to fix this, enable YUV2YUV and set appropriate coefficients
> for formats such as NV12 to be displayed correctly.
> 
> This commit was tested using modetest, gstreamer and chromeos (hardware
> accelerated video playback). Before the commit, tests rendering
> with NV12 format resulted in colors not displayed correctly.
> 
> Test examples (RK3399 Ficus board connected to HDMI monitor):
> 
>   $ modetest 39@32:1920x1080@NV12
>   $ gst-launch-1.0 videotestrc ! video/x-raw,format=NV12 ! kmssink
> 
> Signed-off-by: Daniele Castagna <dcastagna@chromium.org>
> [ezequiel: rebase on linux-next and massage commit log]
> Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
> ---
> v2:
>   * Addressed feedback from Sean Paul
>   * Rebased on linux-next
> 
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 41 ++++++++++++++++++++-
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 13 +++++++
>  drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 36 ++++++++++++++++++
>  3 files changed, 89 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> index fb70fb486fbf..78c7f63a60c0 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> @@ -52,6 +52,18 @@
>  		vop_reg_set(vop, &win->phy->scl->ext->name, \
>  			    win->base, ~0, v, #name)
>  
> +#define VOP_WIN_YUV2YUV_SET(x, win_yuv2yuv, name, v) \
> +	do { \
> +		if (win_yuv2yuv->name.mask) \
> +			vop_reg_set(vop, &win_yuv2yuv->name, 0, ~0, v, #name); \
> +	} while (0)
> +
> +#define VOP_WIN_YUV2YUV_COEFFICIENT_SET(x, win_yuv2yuv, name, v) \
> +	do { \
> +		if (win_yuv2yuv->phy->name.mask) \
> +			vop_reg_set(vop, &win_yuv2yuv->phy->name, win_yuv2yuv->base, ~0, v, #name); \
> +	} while (0)
> +

While this seems to work on rk3399, it hangs both my rk3328 (rock64)
and rk3288 (google-pinky) during rockchip-drm probe.

Making this something like

	if (win_yuv2yuv && win_yuv2yuv->phy->name.mask) \

aka testing for existence of win_yuv2yuv first, makes them boot again,
so I guess I ran into a (for whatever reason) silent null-ptr-dereference.


> diff --git a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> index 08fc40af52c8..fe752df4e038 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> @@ -637,6 +637,34 @@ static const struct vop_output rk3399_output = {
>  	.mipi_dual_channel_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 3),
>  };
>  
> +static const struct vop_yuv2yuv_phy rk3399_yuv2yuv_win01_data = {
> +	.y2r_coefficients = {
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 0, 0xffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 0, 0xffff, 16),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 4, 0xffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 4, 0xffff, 16),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 8, 0xffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 8, 0xffff, 16),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 12, 0xffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 12, 0xffff, 16),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 16, 0xffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 20, 0xffffffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 24, 0xffffffff, 0),
> +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 28, 0xffffffff, 0),
> +	},
> +};
> +
> +static const struct vop_yuv2yuv_phy rk3399_yuv2yuv_win23_data = { };

looking at the rk3399 TRM it seems that win2+3 also have yuv2rgb
coefficient registers. I didn't check in depth but are they so different
that they cannot be supported?

Aka what is the difference between win0/1 and win2/3 ?


Heiko


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2] drm/rockchip: Fix YUV buffers color rendering
  2019-01-07 13:26     ` Heiko Stuebner
@ 2019-01-07 20:07       ` Ezequiel Garcia
  2019-01-08 17:17         ` Ezequiel Garcia
  0 siblings, 1 reply; 44+ messages in thread
From: Ezequiel Garcia @ 2019-01-07 20:07 UTC (permalink / raw)
  To: Heiko Stuebner, Sandy Huang
  Cc: Daniele Castagna, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	Tomasz Figa, linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	Sean Paul, kernel-ZGY8ohtN/8qB+jHODAdFcQ

On Mon, 2019-01-07 at 14:26 +0100, Heiko Stuebner wrote:
> Hi,
> 
> sorry, only now got to test this on actual hardware,
> 
> Am Freitag, 14. Dezember 2018, 17:29:20 CET schrieb Ezequiel Garcia:
> > From: Daniele Castagna <dcastagna-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> > 
> > Currently, YUV hardware overlays are converted to RGB using
> > a color space conversion different than BT.601.
> > 
> > The result is that colors of e.g. NV12 buffers don't match
> > colors of YUV hardware overlays.
> > 
> > In order to fix this, enable YUV2YUV and set appropriate coefficients
> > for formats such as NV12 to be displayed correctly.
> > 
> > This commit was tested using modetest, gstreamer and chromeos (hardware
> > accelerated video playback). Before the commit, tests rendering
> > with NV12 format resulted in colors not displayed correctly.
> > 
> > Test examples (RK3399 Ficus board connected to HDMI monitor):
> > 
> >   $ modetest 39@32:1920x1080@NV12
> >   $ gst-launch-1.0 videotestrc ! video/x-raw,format=NV12 ! kmssink
> > 
> > Signed-off-by: Daniele Castagna <dcastagna-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> > [ezequiel: rebase on linux-next and massage commit log]
> > Signed-off-by: Ezequiel Garcia <ezequiel-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
> > ---
> > v2:
> >   * Addressed feedback from Sean Paul
> >   * Rebased on linux-next
> > 
> >  drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 41 ++++++++++++++++++++-
> >  drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 13 +++++++
> >  drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 36 ++++++++++++++++++
> >  3 files changed, 89 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> > index fb70fb486fbf..78c7f63a60c0 100644
> > --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> > @@ -52,6 +52,18 @@
> >  		vop_reg_set(vop, &win->phy->scl->ext->name, \
> >  			    win->base, ~0, v, #name)
> >  
> > +#define VOP_WIN_YUV2YUV_SET(x, win_yuv2yuv, name, v) \
> > +	do { \
> > +		if (win_yuv2yuv->name.mask) \
> > +			vop_reg_set(vop, &win_yuv2yuv->name, 0, ~0, v, #name); \
> > +	} while (0)
> > +
> > +#define VOP_WIN_YUV2YUV_COEFFICIENT_SET(x, win_yuv2yuv, name, v) \
> > +	do { \
> > +		if (win_yuv2yuv->phy->name.mask) \
> > +			vop_reg_set(vop, &win_yuv2yuv->phy->name, win_yuv2yuv->base, ~0, v, #name); \
> > +	} while (0)
> > +
> 
> While this seems to work on rk3399, it hangs both my rk3328 (rock64)
> and rk3288 (google-pinky) during rockchip-drm probe.
> 

Oh, shame on me, I should've done that.

> Making this something like
> 
> 	if (win_yuv2yuv && win_yuv2yuv->phy->name.mask) \
> 
> aka testing for existence of win_yuv2yuv first, makes them boot again,
> so I guess I ran into a (for whatever reason) silent null-ptr-dereference.
> 

Sounds good. I'll post a v3.

> 
> > diff --git a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> > index 08fc40af52c8..fe752df4e038 100644
> > --- a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> > +++ b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> > @@ -637,6 +637,34 @@ static const struct vop_output rk3399_output = {
> >  	.mipi_dual_channel_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 3),
> >  };
> >  
> > +static const struct vop_yuv2yuv_phy rk3399_yuv2yuv_win01_data = {
> > +	.y2r_coefficients = {
> > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 0, 0xffff, 0),
> > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 0, 0xffff, 16),
> > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 4, 0xffff, 0),
> > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 4, 0xffff, 16),
> > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 8, 0xffff, 0),
> > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 8, 0xffff, 16),
> > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 12, 0xffff, 0),
> > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 12, 0xffff, 16),
> > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 16, 0xffff, 0),
> > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 20, 0xffffffff, 0),
> > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 24, 0xffffffff, 0),
> > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 28, 0xffffffff, 0),
> > +	},
> > +};
> > +
> > +static const struct vop_yuv2yuv_phy rk3399_yuv2yuv_win23_data = { };
> 
> looking at the rk3399 TRM it seems that win2+3 also have yuv2rgb
> coefficient registers. I didn't check in depth but are they so different
> that they cannot be supported?
> 
> Aka what is the difference between win0/1 and win2/3 ?
> 
> 

I think Sandy is the best to answer this. I can't say I'm an expert
on the details of this hardware.

Thanks,
Eze

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2] drm/rockchip: Fix YUV buffers color rendering
  2019-01-07 20:07       ` Ezequiel Garcia
@ 2019-01-08 17:17         ` Ezequiel Garcia
  0 siblings, 0 replies; 44+ messages in thread
From: Ezequiel Garcia @ 2019-01-08 17:17 UTC (permalink / raw)
  To: Heiko Stuebner, Sandy Huang
  Cc: Daniele Castagna, dri-devel, Tomasz Figa, linux-rockchip,
	Sean Paul, kernel

On Mon, 2019-01-07 at 17:07 -0300, Ezequiel Garcia wrote:
> On Mon, 2019-01-07 at 14:26 +0100, Heiko Stuebner wrote:
> > Hi,
> > 
> > sorry, only now got to test this on actual hardware,
> > 
> > Am Freitag, 14. Dezember 2018, 17:29:20 CET schrieb Ezequiel Garcia:
> > > From: Daniele Castagna <dcastagna@chromium.org>
> > > 
> > > Currently, YUV hardware overlays are converted to RGB using
> > > a color space conversion different than BT.601.
> > > 
> > > The result is that colors of e.g. NV12 buffers don't match
> > > colors of YUV hardware overlays.
> > > 
> > > In order to fix this, enable YUV2YUV and set appropriate coefficients
> > > for formats such as NV12 to be displayed correctly.
> > > 
> > > This commit was tested using modetest, gstreamer and chromeos (hardware
> > > accelerated video playback). Before the commit, tests rendering
> > > with NV12 format resulted in colors not displayed correctly.
> > > 
> > > Test examples (RK3399 Ficus board connected to HDMI monitor):
> > > 
> > >   $ modetest 39@32:1920x1080@NV12
> > >   $ gst-launch-1.0 videotestrc ! video/x-raw,format=NV12 ! kmssink
> > > 
> > > Signed-off-by: Daniele Castagna <dcastagna@chromium.org>
> > > [ezequiel: rebase on linux-next and massage commit log]
> > > Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
> > > ---
> > > v2:
> > >   * Addressed feedback from Sean Paul
> > >   * Rebased on linux-next
> > > 
> > >  drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 41 ++++++++++++++++++++-
> > >  drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 13 +++++++
> > >  drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 36 ++++++++++++++++++
> > >  3 files changed, 89 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> > > index fb70fb486fbf..78c7f63a60c0 100644
> > > --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> > > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> > > @@ -52,6 +52,18 @@
> > >  		vop_reg_set(vop, &win->phy->scl->ext->name, \
> > >  			    win->base, ~0, v, #name)
> > >  
> > > +#define VOP_WIN_YUV2YUV_SET(x, win_yuv2yuv, name, v) \
> > > +	do { \
> > > +		if (win_yuv2yuv->name.mask) \
> > > +			vop_reg_set(vop, &win_yuv2yuv->name, 0, ~0, v, #name); \
> > > +	} while (0)
> > > +
> > > +#define VOP_WIN_YUV2YUV_COEFFICIENT_SET(x, win_yuv2yuv, name, v) \
> > > +	do { \
> > > +		if (win_yuv2yuv->phy->name.mask) \
> > > +			vop_reg_set(vop, &win_yuv2yuv->phy->name, win_yuv2yuv->base, ~0, v, #name); \
> > > +	} while (0)
> > > +
> > 
> > While this seems to work on rk3399, it hangs both my rk3328 (rock64)
> > and rk3288 (google-pinky) during rockchip-drm probe.
> > 
> 
> Oh, shame on me, I should've done that.
> 
> > Making this something like
> > 
> > 	if (win_yuv2yuv && win_yuv2yuv->phy->name.mask) \
> > 
> > aka testing for existence of win_yuv2yuv first, makes them boot again,
> > so I guess I ran into a (for whatever reason) silent null-ptr-dereference.
> > 
> 
> Sounds good. I'll post a v3.
> 
> > > diff --git a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> > > index 08fc40af52c8..fe752df4e038 100644
> > > --- a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> > > +++ b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
> > > @@ -637,6 +637,34 @@ static const struct vop_output rk3399_output = {
> > >  	.mipi_dual_channel_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 3),
> > >  };
> > >  
> > > +static const struct vop_yuv2yuv_phy rk3399_yuv2yuv_win01_data = {
> > > +	.y2r_coefficients = {
> > > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 0, 0xffff, 0),
> > > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 0, 0xffff, 16),
> > > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 4, 0xffff, 0),
> > > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 4, 0xffff, 16),
> > > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 8, 0xffff, 0),
> > > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 8, 0xffff, 16),
> > > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 12, 0xffff, 0),
> > > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 12, 0xffff, 16),
> > > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 16, 0xffff, 0),
> > > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 20, 0xffffffff, 0),
> > > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 24, 0xffffffff, 0),
> > > +		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 28, 0xffffffff, 0),
> > > +	},
> > > +};
> > > +
> > > +static const struct vop_yuv2yuv_phy rk3399_yuv2yuv_win23_data = { };
> > 
> > looking at the rk3399 TRM it seems that win2+3 also have yuv2rgb
> > coefficient registers. I didn't check in depth but are they so different
> > that they cannot be supported?
> > 
> > Aka what is the difference between win0/1 and win2/3 ?
> > 
> > 
> 
> I think Sandy is the best to answer this. I can't say I'm an expert
> on the details of this hardware.
> 

Reading thru the spec, I see what wins 2 and 3 don't support YUV formats,
so the feature (whatever it's purpose) is not needed, as there's
no YUV colorspace issue.

Like I said, I don't have specific knowledge on the hardware.

Thanks,
Eze

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v3] drm/rockchip: Fix YUV buffers color rendering
  2018-12-14 16:29   ` [PATCH v2] drm/rockchip: Fix YUV buffers color rendering Ezequiel Garcia
  2019-01-03 16:28     ` Ezequiel Garcia
  2019-01-07 13:26     ` Heiko Stuebner
@ 2019-01-08 21:46     ` Ezequiel Garcia
  2019-01-10 22:55       ` Heiko Stuebner
  2 siblings, 1 reply; 44+ messages in thread
From: Ezequiel Garcia @ 2019-01-08 21:46 UTC (permalink / raw)
  To: dri-devel
  Cc: Daniele Castagna, Tomasz Figa, linux-rockchip, Sean Paul, kernel,
	Ezequiel Garcia

From: Daniele Castagna <dcastagna@chromium.org>

Currently, YUV hardware overlays are converted to RGB using
a color space conversion different than BT.601.

The result is that colors of e.g. NV12 buffers don't match
colors of YUV hardware overlays.

In order to fix this, enable YUV2YUV and set appropriate coefficients
for formats such as NV12 to be displayed correctly.

This commit was tested using modetest, gstreamer and chromeos (hardware
accelerated video playback). Before the commit, tests rendering
with NV12 format resulted in colors not displayed correctly.

Test examples (Tested on RK3399 and RK3288 boards connected to HDMI monitor):

  $ modetest 39@32:1920x1080@NV12
  $ gst-launch-1.0 videotestrc ! video/x-raw,format=NV12 ! kmssink

Signed-off-by: Daniele Castagna <dcastagna@chromium.org>
[ezequiel: rebase on linux-next and massage commit log]
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
---
v3: Add a check for non-null win_yuv2yuv as suggested by Heiko.

 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 40 ++++++++++++++++++++-
 drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 13 +++++++
 drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 36 +++++++++++++++++++
 3 files changed, 88 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index db8358e6d230..7ad9067b3110 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -53,6 +53,18 @@
 		vop_reg_set(vop, &win->phy->scl->ext->name, \
 			    win->base, ~0, v, #name)
 
+#define VOP_WIN_YUV2YUV_SET(x, win_yuv2yuv, name, v) \
+	do { \
+		if (win_yuv2yuv && win_yuv2yuv->name.mask) \
+			vop_reg_set(vop, &win_yuv2yuv->name, 0, ~0, v, #name); \
+	} while (0)
+
+#define VOP_WIN_YUV2YUV_COEFFICIENT_SET(x, win_yuv2yuv, name, v) \
+	do { \
+		if (win_yuv2yuv && win_yuv2yuv->phy->name.mask) \
+			vop_reg_set(vop, &win_yuv2yuv->phy->name, win_yuv2yuv->base, ~0, v, #name); \
+	} while (0)
+
 #define VOP_INTR_SET_MASK(vop, name, mask, v) \
 		vop_reg_set(vop, &vop->data->intr->name, 0, mask, v, #name)
 
@@ -85,6 +97,18 @@
 #define to_vop(x) container_of(x, struct vop, crtc)
 #define to_vop_win(x) container_of(x, struct vop_win, base)
 
+/*
+ * The coefficients of the following matrix are all fixed points.
+ * The format is S2.10 for the 3x3 part of the matrix, and S9.12 for the offsets.
+ * They are all represented in two's complement.
+ */
+static const uint32_t bt601_yuv2rgb[] = {
+	0x4A8, 0x0,    0x662,
+	0x4A8, 0x1E6F, 0x1CBF,
+	0x4A8, 0x812,  0x0,
+	0x321168, 0x0877CF, 0x2EB127
+};
+
 enum vop_pending {
 	VOP_PENDING_FB_UNREF,
 };
@@ -92,6 +116,7 @@ enum vop_pending {
 struct vop_win {
 	struct drm_plane base;
 	const struct vop_win_data *data;
+	const struct vop_win_yuv2yuv_data *yuv2yuv_data;
 	struct vop *vop;
 };
 
@@ -713,6 +738,7 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
 	struct drm_crtc *crtc = state->crtc;
 	struct vop_win *vop_win = to_vop_win(plane);
 	const struct vop_win_data *win = vop_win->data;
+	const struct vop_win_yuv2yuv_data *win_yuv2yuv = vop_win->yuv2yuv_data;
 	struct vop *vop = to_vop(state->crtc);
 	struct drm_framebuffer *fb = state->fb;
 	unsigned int actual_w, actual_h;
@@ -728,6 +754,8 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
 	bool rb_swap;
 	int win_index = VOP_WIN_TO_INDEX(vop_win);
 	int format;
+	int is_yuv = fb->format->is_yuv;
+	int i;
 
 	/*
 	 * can't update plane when vop is disabled.
@@ -768,7 +796,9 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
 	VOP_WIN_SET(vop, win, format, format);
 	VOP_WIN_SET(vop, win, yrgb_vir, DIV_ROUND_UP(fb->pitches[0], 4));
 	VOP_WIN_SET(vop, win, yrgb_mst, dma_addr);
-	if (fb->format->is_yuv) {
+	VOP_WIN_YUV2YUV_SET(vop, win_yuv2yuv, y2r_en, is_yuv);
+
+	if (is_yuv) {
 		int hsub = drm_format_horz_chroma_subsampling(fb->format->format);
 		int vsub = drm_format_vert_chroma_subsampling(fb->format->format);
 		int bpp = fb->format->cpp[1];
@@ -782,6 +812,13 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
 		dma_addr = rk_uv_obj->dma_addr + offset + fb->offsets[1];
 		VOP_WIN_SET(vop, win, uv_vir, DIV_ROUND_UP(fb->pitches[1], 4));
 		VOP_WIN_SET(vop, win, uv_mst, dma_addr);
+
+		for (i = 0; i < NUM_YUV2YUV_COEFFICIENTS; i++) {
+			VOP_WIN_YUV2YUV_COEFFICIENT_SET(vop,
+							win_yuv2yuv,
+							y2r_coefficients[i],
+							bt601_yuv2rgb[i]);
+		}
 	}
 
 	if (win->phy->scl)
@@ -1531,6 +1568,7 @@ static void vop_win_init(struct vop *vop)
 
 		vop_win->data = win_data;
 		vop_win->vop = vop;
+		vop_win->yuv2yuv_data = &vop_data->win_yuv2yuv[i];
 	}
 }
 
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
index 0fe40e1983d9..aed467cd81b9 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
@@ -23,6 +23,8 @@
 #define VOP_MAJOR(version)		((version) >> 8)
 #define VOP_MINOR(version)		((version) & 0xff)
 
+#define NUM_YUV2YUV_COEFFICIENTS 12
+
 enum vop_data_format {
 	VOP_FMT_ARGB8888 = 0,
 	VOP_FMT_RGB888,
@@ -124,6 +126,10 @@ struct vop_scl_regs {
 	struct vop_reg scale_cbcr_y;
 };
 
+struct vop_yuv2yuv_phy {
+	struct vop_reg y2r_coefficients[NUM_YUV2YUV_COEFFICIENTS];
+};
+
 struct vop_win_phy {
 	const struct vop_scl_regs *scl;
 	const uint32_t *data_formats;
@@ -146,6 +152,12 @@ struct vop_win_phy {
 	struct vop_reg channel;
 };
 
+struct vop_win_yuv2yuv_data {
+	uint32_t base;
+	const struct vop_yuv2yuv_phy *phy;
+	struct vop_reg y2r_en;
+};
+
 struct vop_win_data {
 	uint32_t base;
 	const struct vop_win_phy *phy;
@@ -159,6 +171,7 @@ struct vop_data {
 	const struct vop_misc *misc;
 	const struct vop_modeset *modeset;
 	const struct vop_output *output;
+	const struct vop_win_yuv2yuv_data *win_yuv2yuv;
 	const struct vop_win_data *win;
 	unsigned int win_size;
 
diff --git a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
index 08fc40af52c8..fe752df4e038 100644
--- a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
+++ b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c
@@ -637,6 +637,34 @@ static const struct vop_output rk3399_output = {
 	.mipi_dual_channel_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 3),
 };
 
+static const struct vop_yuv2yuv_phy rk3399_yuv2yuv_win01_data = {
+	.y2r_coefficients = {
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 0, 0xffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 0, 0xffff, 16),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 4, 0xffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 4, 0xffff, 16),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 8, 0xffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 8, 0xffff, 16),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 12, 0xffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 12, 0xffff, 16),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 16, 0xffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 20, 0xffffffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 24, 0xffffffff, 0),
+		VOP_REG(RK3399_WIN0_YUV2YUV_Y2R + 28, 0xffffffff, 0),
+	},
+};
+
+static const struct vop_yuv2yuv_phy rk3399_yuv2yuv_win23_data = { };
+
+static const struct vop_win_yuv2yuv_data rk3399_vop_big_win_yuv2yuv_data[] = {
+	{ .base = 0x00, .phy = &rk3399_yuv2yuv_win01_data,
+	  .y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 1) },
+	{ .base = 0x60, .phy = &rk3399_yuv2yuv_win01_data,
+	  .y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 9) },
+	{ .base = 0xC0, .phy = &rk3399_yuv2yuv_win23_data },
+	{ .base = 0x120, .phy = &rk3399_yuv2yuv_win23_data },
+};
+
 static const struct vop_data rk3399_vop_big = {
 	.version = VOP_VERSION(3, 5),
 	.feature = VOP_FEATURE_OUTPUT_RGB10,
@@ -647,6 +675,7 @@ static const struct vop_data rk3399_vop_big = {
 	.misc = &rk3368_misc,
 	.win = rk3368_vop_win_data,
 	.win_size = ARRAY_SIZE(rk3368_vop_win_data),
+	.win_yuv2yuv = rk3399_vop_big_win_yuv2yuv_data,
 };
 
 static const struct vop_win_data rk3399_vop_lit_win_data[] = {
@@ -656,6 +685,12 @@ static const struct vop_win_data rk3399_vop_lit_win_data[] = {
 	  .type = DRM_PLANE_TYPE_CURSOR},
 };
 
+static const struct vop_win_yuv2yuv_data rk3399_vop_lit_win_yuv2yuv_data[] = {
+	{ .base = 0x00, .phy = &rk3399_yuv2yuv_win01_data,
+	  .y2r_en = VOP_REG(RK3399_YUV2YUV_WIN, 0x1, 1)},
+	{ .base = 0x60, .phy = &rk3399_yuv2yuv_win23_data },
+};
+
 static const struct vop_data rk3399_vop_lit = {
 	.version = VOP_VERSION(3, 6),
 	.intr = &rk3366_vop_intr,
@@ -665,6 +700,7 @@ static const struct vop_data rk3399_vop_lit = {
 	.misc = &rk3368_misc,
 	.win = rk3399_vop_lit_win_data,
 	.win_size = ARRAY_SIZE(rk3399_vop_lit_win_data),
+	.win_yuv2yuv = rk3399_vop_lit_win_yuv2yuv_data,
 };
 
 static const struct vop_win_data rk3228_vop_win_data[] = {
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* Re: [PATCH v3] drm/rockchip: Fix YUV buffers color rendering
  2019-01-08 21:46     ` [PATCH v3] " Ezequiel Garcia
@ 2019-01-10 22:55       ` Heiko Stuebner
  0 siblings, 0 replies; 44+ messages in thread
From: Heiko Stuebner @ 2019-01-10 22:55 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: Daniele Castagna, dri-devel, Tomasz Figa, linux-rockchip,
	Sean Paul, kernel

Am Dienstag, 8. Januar 2019, 22:46:59 CET schrieb Ezequiel Garcia:
> From: Daniele Castagna <dcastagna@chromium.org>
> 
> Currently, YUV hardware overlays are converted to RGB using
> a color space conversion different than BT.601.
> 
> The result is that colors of e.g. NV12 buffers don't match
> colors of YUV hardware overlays.
> 
> In order to fix this, enable YUV2YUV and set appropriate coefficients
> for formats such as NV12 to be displayed correctly.
> 
> This commit was tested using modetest, gstreamer and chromeos (hardware
> accelerated video playback). Before the commit, tests rendering
> with NV12 format resulted in colors not displayed correctly.
> 
> Test examples (Tested on RK3399 and RK3288 boards connected to HDMI monitor):
> 
>   $ modetest 39@32:1920x1080@NV12
>   $ gst-launch-1.0 videotestrc ! video/x-raw,format=NV12 ! kmssink
> 
> Signed-off-by: Daniele Castagna <dcastagna@chromium.org>
> [ezequiel: rebase on linux-next and massage commit log]
> Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
> ---
> v3: Add a check for non-null win_yuv2yuv as suggested by Heiko.

applied to drm-misc-next after making sure that display keeps
working on all rockchip socs now

Thanks
Heiko


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2019-01-10 22:55 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-15  5:32 [PATCH 00/10] drm: Add plane color matrix on rockchip Daniele Castagna
2018-02-15  5:32 ` [PATCH 01/10] drm/rockchip: YUV overlays BT.601 color conversion Daniele Castagna
2018-02-16 17:55   ` kbuild test robot
2018-02-27 15:03   ` Sean Paul
2018-12-14 16:29   ` [PATCH v2] drm/rockchip: Fix YUV buffers color rendering Ezequiel Garcia
2019-01-03 16:28     ` Ezequiel Garcia
2019-01-07 13:26     ` Heiko Stuebner
2019-01-07 20:07       ` Ezequiel Garcia
2019-01-08 17:17         ` Ezequiel Garcia
2019-01-08 21:46     ` [PATCH v3] " Ezequiel Garcia
2019-01-10 22:55       ` Heiko Stuebner
2018-02-15  5:32 ` [PATCH 02/10] drm: Add Plane Degamma properties Daniele Castagna
2018-02-16 19:38   ` kbuild test robot
2018-02-19 15:15   ` Daniel Vetter
2018-02-27 15:13   ` Sean Paul
2018-02-28 14:54     ` Shankar, Uma
2018-02-15  5:32 ` [PATCH 03/10] drm: Add Plane CTM property Daniele Castagna
2018-02-27 15:22   ` Sean Paul
2018-02-28 14:55     ` Shankar, Uma
2018-02-15  5:32 ` [PATCH 04/10] drm: Add Plane Gamma properties Daniele Castagna
2018-02-15 19:29   ` Harry Wentland
2018-02-15 19:45     ` Daniele Castagna
2018-02-16 20:10       ` Ville Syrjälä
2018-02-16 21:36         ` Harry Wentland
2018-02-18  6:43           ` Shankar, Uma
2018-02-19 15:14   ` Daniel Vetter
2018-02-27 15:26   ` Sean Paul
2018-02-27 16:52     ` Ville Syrjälä
2018-02-15  5:32 ` [PATCH 05/10] drm: Define helper function for plane color enabling Daniele Castagna
2018-02-27 15:28   ` Sean Paul
2018-02-28 14:57     ` Shankar, Uma
2018-02-15  5:32 ` [PATCH 06/10] drm: Define helper to set legacy gamma table size Daniele Castagna
2018-02-16 22:17   ` kbuild test robot
2018-02-27 15:35   ` Sean Paul
2018-02-27 16:20   ` Emil Velikov
2018-02-15  5:32 ` [PATCH 07/10] drm/rockchip: Add yuv2yuv registers to vop_lit Daniele Castagna
2018-02-27 15:36   ` Sean Paul
2018-02-15  5:32 ` [PATCH 08/10] drm/rockchip: Add R2R registers Daniele Castagna
2018-02-27 15:41   ` Sean Paul
2018-02-15  5:32 ` [PATCH 09/10] drm/rockchip: Implement drm plane->ctm property Daniele Castagna
2018-02-27 16:09   ` Sean Paul
2018-02-15  5:33 ` [PATCH 10/10] drm/rockchip: Enable 'PLANE_CTM' drm property Daniele Castagna
2018-02-27 16:10   ` Sean Paul
2018-02-19 15:16 ` [PATCH 00/10] drm: Add plane color matrix on rockchip Daniel Vetter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.