Skip to contentSkip to conversation

Couple more DRM plane features on Tegra

PATCH Superseded Dmitry Osipenko 2 participants 10 messages May 4, 2018

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Couple more DRM plane features on Tegra

Hi,

This series improves DRM plane support by supporting zPos on older Tegra's and enabling plane scaling filters (up to Tegra210).

Dmitry Osipenko (3):
drm/tegra: dc: Enable plane scaling filters
drm/tegra: plane: Implement zPos plane property for older Tegra's drm/tegra: dc: Rename supports_blending to has_legacy_blending

 drivers/gpu/drm/tegra/dc.c    | 205 ++++++++++++++++++++++++++--------
 drivers/gpu/drm/tegra/dc.h    |   9 +-
 drivers/gpu/drm/tegra/plane.c | 193 +++++++++++++++++++++++---------
 drivers/gpu/drm/tegra/plane.h |  13 ++-
 4 files changed, 313 insertions(+), 107 deletions(-)
Signature · 1 line
2.17.0
#1 lore raw

PATCH 1/3 drm/tegra: dc: Enable plane scaling filters

Currently resized plane produces a "pixelated" image which doesn't look nice, especially in a case of a video overlay. Enable scaling filters that significantly improve image quality of a scaled overlay.

---
 drivers/gpu/drm/tegra/dc.c | 51 ++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/tegra/dc.h |  7 ++++++
 2 files changed, 58 insertions(+)
drivers/gpu/drm/tegra/dc.c +51 -0
index 9f83a65b5ea9..2e81142281c3 100644
@@ -361,6 +361,47 @@ static void tegra_dc_setup_window(struct tegra_plane *plane,
 	if (window->bottom_up)
 		value |= V_DIRECTION;
 
+	if (!(dc->soc->has_win_a_without_filter && plane->index == 0) &&
+	    !(window->src.w == window->dst.w)) {
+		/*
+		 * Enable horizontal 6-tap filter and set filtering
+		 * coefficients to the default values defined in TRM.
+		 */
+		tegra_plane_writel(plane, 0x00008000, DC_WIN_H_FILTER_P(0));
+		tegra_plane_writel(plane, 0x3e087ce1, DC_WIN_H_FILTER_P(1));
+		tegra_plane_writel(plane, 0x3b117ac1, DC_WIN_H_FILTER_P(2));
+		tegra_plane_writel(plane, 0x591b73aa, DC_WIN_H_FILTER_P(3));
+		tegra_plane_writel(plane, 0x57256d9a, DC_WIN_H_FILTER_P(4));
+		tegra_plane_writel(plane, 0x552f668b, DC_WIN_H_FILTER_P(5));
+		tegra_plane_writel(plane, 0x73385e8b, DC_WIN_H_FILTER_P(6));
+		tegra_plane_writel(plane, 0x72435583, DC_WIN_H_FILTER_P(7));
+		tegra_plane_writel(plane, 0x714c4c8b, DC_WIN_H_FILTER_P(8));
+		tegra_plane_writel(plane, 0x70554393, DC_WIN_H_FILTER_P(9));
+		tegra_plane_writel(plane, 0x715e389b, DC_WIN_H_FILTER_P(10));
+		tegra_plane_writel(plane, 0x71662faa, DC_WIN_H_FILTER_P(11));
+		tegra_plane_writel(plane, 0x536d25ba, DC_WIN_H_FILTER_P(12));
+		tegra_plane_writel(plane, 0x55731bca, DC_WIN_H_FILTER_P(13));
+		tegra_plane_writel(plane, 0x387a11d9, DC_WIN_H_FILTER_P(14));
+		tegra_plane_writel(plane, 0x3c7c08f1, DC_WIN_H_FILTER_P(15));
+
+		value |= H_FILTER;
+	}
+
+	if (!(dc->soc->has_win_a_without_filter && plane->index == 0) &&
+	    !(dc->soc->has_win_c_without_vert_filter && plane->index == 2) &&
+	    !(window->src.h == window->dst.h)) {
+		unsigned int i, k;
+
+		/*
+		 * Enable vertical 2-tap filter and set filtering
+		 * coefficients to the default values defined in TRM.
+		 */
+		for (i = 0, k = 128; i < 16; i++, k -= 8)
+			tegra_plane_writel(plane, k, DC_WIN_V_FILTER_P(i));
+
+		value |= V_FILTER;
+	}
+
 	tegra_plane_writel(plane, value, DC_WIN_WIN_OPTIONS);
 
 	if (dc->soc->supports_blending)
@@ -1978,6 +2019,8 @@ static const struct tegra_dc_soc_info tegra20_dc_soc_info = {
 	.num_overlay_formats = ARRAY_SIZE(tegra20_overlay_formats),
 	.overlay_formats = tegra20_overlay_formats,
 	.modifiers = tegra20_modifiers,
+	.has_win_a_without_filter = true,
+	.has_win_c_without_vert_filter = true,
 };
 
 static const struct tegra_dc_soc_info tegra30_dc_soc_info = {
@@ -1995,6 +2038,8 @@ static const struct tegra_dc_soc_info tegra30_dc_soc_info = {
 	.num_overlay_formats = ARRAY_SIZE(tegra20_overlay_formats),
 	.overlay_formats = tegra20_overlay_formats,
 	.modifiers = tegra20_modifiers,
+	.has_win_a_without_filter = false,
+	.has_win_c_without_vert_filter = false,
 };
 
 static const struct tegra_dc_soc_info tegra114_dc_soc_info = {
@@ -2012,6 +2057,8 @@ static const struct tegra_dc_soc_info tegra114_dc_soc_info = {
 	.num_overlay_formats = ARRAY_SIZE(tegra114_overlay_formats),
 	.overlay_formats = tegra114_overlay_formats,
 	.modifiers = tegra20_modifiers,
+	.has_win_a_without_filter = false,
+	.has_win_c_without_vert_filter = false,
 };
 
 static const struct tegra_dc_soc_info tegra124_dc_soc_info = {
@@ -2029,6 +2076,8 @@ static const struct tegra_dc_soc_info tegra124_dc_soc_info = {
 	.num_overlay_formats = ARRAY_SIZE(tegra124_overlay_formats),
 	.overlay_formats = tegra124_overlay_formats,
 	.modifiers = tegra124_modifiers,
+	.has_win_a_without_filter = false,
+	.has_win_c_without_vert_filter = false,
 };
 
 static const struct tegra_dc_soc_info tegra210_dc_soc_info = {
@@ -2046,6 +2095,8 @@ static const struct tegra_dc_soc_info tegra210_dc_soc_info = {
 	.num_overlay_formats = ARRAY_SIZE(tegra114_overlay_formats),
 	.overlay_formats = tegra114_overlay_formats,
 	.modifiers = tegra124_modifiers,
+	.has_win_a_without_filter = false,
+	.has_win_c_without_vert_filter = false,
 };
 
 static const struct tegra_windowgroup_soc tegra186_dc_wgrps[] = {
drivers/gpu/drm/tegra/dc.h +7 -0
index d2b50d32de4d..5c3d1d6faa3b 100644
@@ -67,6 +67,8 @@ struct tegra_dc_soc_info {
 	const u32 *overlay_formats;
 	unsigned int num_overlay_formats;
 	const u64 *modifiers;
+	bool has_win_a_without_filter;
+	bool has_win_c_without_vert_filter;
 };
 
 struct tegra_dc {
@@ -553,6 +555,9 @@ int tegra_dc_rgb_exit(struct tegra_dc *dc);
 #define  THREAD_NUM(x) (((x) & 0x1f) << 1)
 #define  THREAD_GROUP_ENABLE (1 << 0)
 
+#define DC_WIN_H_FILTER_P(p)			(0x601 + p)
+#define DC_WIN_V_FILTER_P(p)			(0x619 + p)
+
 #define DC_WIN_CSC_YOF				0x611
 #define DC_WIN_CSC_KYRGB			0x612
 #define DC_WIN_CSC_KUR				0x613
@@ -566,6 +571,8 @@ int tegra_dc_rgb_exit(struct tegra_dc *dc);
 #define H_DIRECTION  (1 <<  0)
 #define V_DIRECTION  (1 <<  2)
 #define COLOR_EXPAND (1 <<  6)
+#define H_FILTER     (1 <<  8)
+#define V_FILTER     (1 << 10)
 #define CSC_ENABLE   (1 << 18)
 #define WIN_ENABLE   (1 << 30)
 
Signature · 1 line
2.17.0
#5 lore raw

PATCH 2/3 drm/tegra: plane: Implement zPos plane property for older Tegra's

In reply to Dmitry Osipenko

Older Tegra's do not support planes z position handling in hardware, but HW provides knobs for zPos implementation in software.

---
 drivers/gpu/drm/tegra/dc.c    | 134 ++++++++++++++++-------
 drivers/gpu/drm/tegra/plane.c | 193 ++++++++++++++++++++++++----------
 drivers/gpu/drm/tegra/plane.h |  13 ++-
 3 files changed, 244 insertions(+), 96 deletions(-)
drivers/gpu/drm/tegra/dc.c +97 -37
index 2e81142281c3..ba5481cd470d 100644
@@ -162,29 +162,90 @@ static void tegra_plane_setup_blending_legacy(struct tegra_plane *plane)
 	u32 foreground = BLEND_WEIGHT1(255) | BLEND_WEIGHT0(255) |
 			 BLEND_COLOR_KEY_NONE;
 	u32 blendnokey = BLEND_WEIGHT1(255) | BLEND_WEIGHT0(255);
+	u32 blending[2];
 	struct tegra_plane_state *state;
 	unsigned int i;
 
+	/* disable blending for non-overlapping case */
+	tegra_plane_writel(plane, blendnokey, DC_WIN_BLEND_NOKEY);
+	tegra_plane_writel(plane, foreground, DC_WIN_BLEND_1WIN);
+
 	state = to_tegra_plane_state(plane->base.state);
 
-	/* alpha contribution is 1 minus sum of overlapping windows */
-	for (i = 0; i < 3; i++) {
-		if (state->dependent[i])
-			background[i] |= BLEND_CONTROL_DEPENDENT;
-	}
+	if (state->opaque) {
+		/*
+		 * Since custom fix-weight blending isn't utilized and weight
+		 * of top window is set to max, we can enforce dependent
+		 * blending which in this case results in transparent bottom
+		 * window if top window is opaque and if top window enables
+		 * alpha blending, then bottom window is getting alpha value
+		 * of 1 minus the sum of alpha components of the overlapping
+		 * plane.
+		 */
+		background[0] |= BLEND_CONTROL_DEPENDENT;
+		background[1] |= BLEND_CONTROL_DEPENDENT;
 
-	/* enable alpha blending if pixel format has an alpha component */
-	if (!state->opaque)
+		/*
+		 * The region where three windows overlap is the intersection
+		 * of the two regions where two windows overlap. It contributes
+		 * to the area if all of the windows on top of it have an alpha
+		 * component.
+		 */
+		switch (state->base.normalized_zpos) {
+		case 0:
+			if (state->blending[0].alpha &&
+			    state->blending[1].alpha)
+				background[2] |= BLEND_CONTROL_DEPENDENT;
+			break;
+
+		case 1:
+			background[2] |= BLEND_CONTROL_DEPENDENT;
+			break;
+		}
+	} else {
+		/*
+		 * Enable alpha blending if pixel format has an alpha
+		 * component.
+		 */
 		foreground |= BLEND_CONTROL_ALPHA;
 
-	/*
-	 * Disable blending and assume Window A is the bottom-most window,
-	 * Window C is the top-most window and Window B is in the middle.
-	 */
-	tegra_plane_writel(plane, blendnokey, DC_WIN_BLEND_NOKEY);
-	tegra_plane_writel(plane, foreground, DC_WIN_BLEND_1WIN);
+		/*
+		 * If any of the windows on top of this window is opaque, it
+		 * will completely conceal this window within that area. If
+		 * top window has an alpha component, it is blended over the
+		 * bottom window.
+		 */
+		for (i = 0; i < 2; i++) {
+			if (state->blending[i].alpha &&
+			    state->blending[i].top)
+				background[i] |= BLEND_CONTROL_DEPENDENT;
+		}
+
+		switch (state->base.normalized_zpos) {
+		case 0:
+			if (state->blending[0].alpha &&
+			    state->blending[1].alpha)
+				background[2] |= BLEND_CONTROL_DEPENDENT;
+			break;
+
+		case 1:
+			/*
+			 * When both middle and topmost windows have an alpha,
+			 * these windows a mixed together and then the result
+			 * is blended over the bottom window.
+			 */
+			if ((state->blending[0].alpha &&
+			     state->blending[0].top))
+				background[2] |= BLEND_CONTROL_ALPHA;
 
-	switch (plane->index) {
+			if (state->blending[1].alpha &&
+			    state->blending[1].top)
+				background[2] |= BLEND_CONTROL_ALPHA;
+			break;
+		}
+	}
+
+	switch (state->base.normalized_zpos) {
 	case 0:
 		tegra_plane_writel(plane, background[0], DC_WIN_BLEND_2WIN_X);
 		tegra_plane_writel(plane, background[1], DC_WIN_BLEND_2WIN_Y);
@@ -192,8 +253,21 @@ static void tegra_plane_setup_blending_legacy(struct tegra_plane *plane)
 		break;
 
 	case 1:
-		tegra_plane_writel(plane, foreground, DC_WIN_BLEND_2WIN_X);
-		tegra_plane_writel(plane, background[1], DC_WIN_BLEND_2WIN_Y);
+		/*
+		 * If window B / C is topmost, then X / Y registers are
+		 * matching the order of blending[...] state indices,
+		 * otherwise a swap is required.
+		 */
+		if (!state->blending[0].top && state->blending[1].top) {
+			blending[0] = foreground;
+			blending[1] = background[1];
+		} else {
+			blending[0] = background[0];
+			blending[1] = foreground;
+		}
+
+		tegra_plane_writel(plane, blending[0], DC_WIN_BLEND_2WIN_X);
+		tegra_plane_writel(plane, blending[1], DC_WIN_BLEND_2WIN_Y);
 		tegra_plane_writel(plane, background[2], DC_WIN_BLEND_3WIN_XY);
 		break;
 
@@ -495,14 +569,14 @@ static int tegra_plane_atomic_check(struct drm_plane *plane,
 	struct tegra_bo_tiling *tiling = &plane_state->tiling;
 	struct tegra_plane *tegra = to_tegra_plane(plane);
 	struct tegra_dc *dc = to_tegra_dc(state->crtc);
-	unsigned int format;
 	int err;
 
 	/* no need for further checks if the plane is being disabled */
 	if (!state->crtc)
 		return 0;
 
-	err = tegra_plane_format(state->fb->format->format, &format,
+	err = tegra_plane_format(state->fb->format->format,
+				 &plane_state->format,
 				 &plane_state->swap);
 	if (err < 0)
 		return err;
@@ -514,21 +588,11 @@ static int tegra_plane_atomic_check(struct drm_plane *plane,
 	 * be emulated by disabling alpha blending for the plane.
 	 */
 	if (!dc->soc->supports_blending) {
-		if (!tegra_plane_format_has_alpha(format)) {
-			err = tegra_plane_format_get_alpha(format, &format);
-			if (err < 0)
-				return err;
-
-			plane_state->opaque = true;
-		} else {
-			plane_state->opaque = false;
-		}
-
-		tegra_plane_check_dependent(tegra, plane_state);
+		err = tegra_plane_setup_legacy_state(tegra, plane_state);
+		if (err < 0)
+			return err;
 	}
 
-	plane_state->format = format;
-
 	err = tegra_fb_get_tiling(state->fb, tiling);
 	if (err < 0)
 		return err;
@@ -680,9 +744,7 @@ static struct drm_plane *tegra_primary_plane_create(struct drm_device *drm,
 	}
 
 	drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs);
-
-	if (dc->soc->supports_blending)
-		drm_plane_create_zpos_property(&plane->base, 0, 0, 255);
+	drm_plane_create_zpos_property(&plane->base, plane->index, 0, 255);
 
 	return &plane->base;
 }
@@ -959,9 +1021,7 @@ static struct drm_plane *tegra_dc_overlay_plane_create(struct drm_device *drm,
 	}
 
 	drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs);
-
-	if (dc->soc->supports_blending)
-		drm_plane_create_zpos_property(&plane->base, 0, 0, 255);
+	drm_plane_create_zpos_property(&plane->base, plane->index, 0, 255);
 
 	return &plane->base;
 }
drivers/gpu/drm/tegra/plane.c +139 -54

250 lines not on this page · raw message

drivers/gpu/drm/tegra/plane.h +8 -5
index 6938719e7e5d..7360ddfafee8 100644
@@ -34,6 +34,11 @@ static inline struct tegra_plane *to_tegra_plane(struct drm_plane *plane)
 	return container_of(plane, struct tegra_plane, base);
 }
 
+struct tegra_plane_legacy_blending_state {
+	bool alpha;
+	bool top;
+};
+
 struct tegra_plane_state {
 	struct drm_plane_state base;
 
@@ -42,8 +47,8 @@ struct tegra_plane_state {
 	u32 swap;
 
 	/* used for legacy blending support only */
+	struct tegra_plane_legacy_blending_state blending[2];
 	bool opaque;
-	bool dependent[3];
 };
 
 static inline struct tegra_plane_state *
@@ -62,9 +67,7 @@ int tegra_plane_state_add(struct tegra_plane *plane,
 
 int tegra_plane_format(u32 fourcc, u32 *format, u32 *swap);
 bool tegra_plane_format_is_yuv(unsigned int format, bool *planar);
-bool tegra_plane_format_has_alpha(unsigned int format);
-int tegra_plane_format_get_alpha(unsigned int opaque, unsigned int *alpha);
-void tegra_plane_check_dependent(struct tegra_plane *tegra,
-				 struct tegra_plane_state *state);
+int tegra_plane_setup_legacy_state(struct tegra_plane *tegra,
+				   struct tegra_plane_state *state);
 
 #endif /* TEGRA_PLANE_H */
Signature · 1 line
2.17.0
#8 lore raw

PATCH 3/3 drm/tegra: dc: Rename supports_blending to has_legacy_blending

In reply to Dmitry Osipenko

Older Tegra's support blending. Rename SoC info entry supports_blending to has_legacy_blending to eliminate confusion.

---
 drivers/gpu/drm/tegra/dc.c | 20 ++++++++++----------
 drivers/gpu/drm/tegra/dc.h |  2 +-
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/gpu/drm/tegra/dc.c +10 -10
index ba5481cd470d..fe00b3250f6a 100644
@@ -478,10 +478,10 @@ static void tegra_dc_setup_window(struct tegra_plane *plane,
 
 	tegra_plane_writel(plane, value, DC_WIN_WIN_OPTIONS);
 
-	if (dc->soc->supports_blending)
-		tegra_plane_setup_blending(plane, window);
-	else
+	if (dc->soc->has_legacy_blending)
 		tegra_plane_setup_blending_legacy(plane);
+	else
+		tegra_plane_setup_blending(plane, window);
 }
 
 static const u32 tegra20_primary_formats[] = {
@@ -587,7 +587,7 @@ static int tegra_plane_atomic_check(struct drm_plane *plane,
 	 * the corresponding opaque formats. However, the opaque formats can
 	 * be emulated by disabling alpha blending for the plane.
 	 */
-	if (!dc->soc->supports_blending) {
+	if (dc->soc->has_legacy_blending) {
 		err = tegra_plane_setup_legacy_state(tegra, plane_state);
 		if (err < 0)
 			return err;
@@ -2069,7 +2069,7 @@ static const struct tegra_dc_soc_info tegra20_dc_soc_info = {
 	.supports_interlacing = false,
 	.supports_cursor = false,
 	.supports_block_linear = false,
-	.supports_blending = false,
+	.has_legacy_blending = true,
 	.pitch_align = 8,
 	.has_powergate = false,
 	.coupled_pm = true,
@@ -2088,7 +2088,7 @@ static const struct tegra_dc_soc_info tegra30_dc_soc_info = {
 	.supports_interlacing = false,
 	.supports_cursor = false,
 	.supports_block_linear = false,
-	.supports_blending = false,
+	.has_legacy_blending = true,
 	.pitch_align = 8,
 	.has_powergate = false,
 	.coupled_pm = false,
@@ -2107,7 +2107,7 @@ static const struct tegra_dc_soc_info tegra114_dc_soc_info = {
 	.supports_interlacing = false,
 	.supports_cursor = false,
 	.supports_block_linear = false,
-	.supports_blending = false,
+	.has_legacy_blending = true,
 	.pitch_align = 64,
 	.has_powergate = true,
 	.coupled_pm = false,
@@ -2126,7 +2126,7 @@ static const struct tegra_dc_soc_info tegra124_dc_soc_info = {
 	.supports_interlacing = true,
 	.supports_cursor = true,
 	.supports_block_linear = true,
-	.supports_blending = true,
+	.has_legacy_blending = false,
 	.pitch_align = 64,
 	.has_powergate = true,
 	.coupled_pm = false,
@@ -2145,7 +2145,7 @@ static const struct tegra_dc_soc_info tegra210_dc_soc_info = {
 	.supports_interlacing = true,
 	.supports_cursor = true,
 	.supports_block_linear = true,
-	.supports_blending = true,
+	.has_legacy_blending = false,
 	.pitch_align = 64,
 	.has_powergate = true,
 	.coupled_pm = false,
@@ -2198,7 +2198,7 @@ static const struct tegra_dc_soc_info tegra186_dc_soc_info = {
 	.supports_interlacing = true,
 	.supports_cursor = true,
 	.supports_block_linear = true,
-	.supports_blending = true,
+	.has_legacy_blending = false,
 	.pitch_align = 64,
 	.has_powergate = false,
 	.coupled_pm = false,
drivers/gpu/drm/tegra/dc.h +1 -1
index 5c3d1d6faa3b..ca5cac6bf8ea 100644
@@ -55,7 +55,7 @@ struct tegra_dc_soc_info {
 	bool supports_interlacing;
 	bool supports_cursor;
 	bool supports_block_linear;
-	bool supports_blending;
+	bool has_legacy_blending;
 	unsigned int pitch_align;
 	bool has_powergate;
 	bool coupled_pm;
Signature · 1 line
2.17.0
#2 lore raw

Re: [PATCH v1 1/3] drm/tegra: dc: Enable plane scaling filters

In reply to Dmitry Osipenko
Quoted 15 lines · Dmitry Osipenko

Currently resized plane produces a "pixelated" image which doesn't look nice, especially in a case of a video overlay. Enable scaling filters that significantly improve image quality of a scaled overlay.

---
 drivers/gpu/drm/tegra/dc.c | 51 ++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/tegra/dc.h |  7 ++++++
 2 files changed, 58 insertions(+)
drivers/gpu/drm/tegra/dc.c +0 -0
index 9f83a65b5ea9..2e81142281c3 100644

drivers/gpu/drm/tegra/dc.c static void tegra_dc_setup_window(struct tegra_plane *plane, · line 365

Quoted 5 lines
drivers/gpu/drm/tegra/dc.c +2 -0
@@ -361,6 +361,47 @@ static void tegra_dc_setup_window(struct tegra_plane *plane,
 	if (window->bottom_up)
 		value |= V_DIRECTION;
 
+	if (!(dc->soc->has_win_a_without_filter && plane->index == 0) &&
+	    !(window->src.w == window->dst.w)) {

I don't know about you, but I get dizzy trying to parse the above. How about we move this into helpers:

	static bool tegra_plane_has_horizontal_filter(struct tegra_plane *plane)
	{
		struct tegra_dc *dc = plane->dc;

		/* this function should never be called on inactive planes */
		if (WARN_ON(!dc))
			return false;

		if (plane->index == 0 && dc->soc->has_win_a_without_filter)
			return false;

		return true;
	}

Then the above becomes:

	bool scale_x = window->dst.w != window->src.w;

	if (scale_x && tegra_plane_has_horizontal_filter(plane)) {
Quoted 17 lines
drivers/gpu/drm/tegra/dc.c +17 -0
+		/*
+		 * Enable horizontal 6-tap filter and set filtering
+		 * coefficients to the default values defined in TRM.
+		 */
+		tegra_plane_writel(plane, 0x00008000, DC_WIN_H_FILTER_P(0));
+		tegra_plane_writel(plane, 0x3e087ce1, DC_WIN_H_FILTER_P(1));
+		tegra_plane_writel(plane, 0x3b117ac1, DC_WIN_H_FILTER_P(2));
+		tegra_plane_writel(plane, 0x591b73aa, DC_WIN_H_FILTER_P(3));
+		tegra_plane_writel(plane, 0x57256d9a, DC_WIN_H_FILTER_P(4));
+		tegra_plane_writel(plane, 0x552f668b, DC_WIN_H_FILTER_P(5));
+		tegra_plane_writel(plane, 0x73385e8b, DC_WIN_H_FILTER_P(6));
+		tegra_plane_writel(plane, 0x72435583, DC_WIN_H_FILTER_P(7));
+		tegra_plane_writel(plane, 0x714c4c8b, DC_WIN_H_FILTER_P(8));
+		tegra_plane_writel(plane, 0x70554393, DC_WIN_H_FILTER_P(9));
+		tegra_plane_writel(plane, 0x715e389b, DC_WIN_H_FILTER_P(10));
+		tegra_plane_writel(plane, 0x71662faa, DC_WIN_H_FILTER_P(11));
+		tegra_plane_writel(plane, 0x536d25ba, DC_WIN_H_FILTER_P(12));

drivers/gpu/drm/tegra/dc.c static void tegra_dc_setup_window(struct tegra_plane *plane, · line 392

Quoted 10 lines
drivers/gpu/drm/tegra/dc.c +10 -0
+		tegra_plane_writel(plane, 0x55731bca, DC_WIN_H_FILTER_P(13));
+		tegra_plane_writel(plane, 0x387a11d9, DC_WIN_H_FILTER_P(14));
+		tegra_plane_writel(plane, 0x3c7c08f1, DC_WIN_H_FILTER_P(15));
+
+		value |= H_FILTER;
+	}
+
+	if (!(dc->soc->has_win_a_without_filter && plane->index == 0) &&
+	    !(dc->soc->has_win_c_without_vert_filter && plane->index == 2) &&
+	    !(window->src.h == window->dst.h)) {
	static bool tegra_plane_has_vertical_filter(struct tegra_plane *plane)
	{
		struct tegra_dc *dc = plane->dc;

		/* this function should never be called on inactive planes */
		if (WARN_ON(!dc))
			return false;

		if (plane->index == 0 && dc->soc->has_win_a_without_filter)
			return false;

		if (plane->index == 2 && dc->soc->has_win_c_without_vert_filter)
			return false;

		return true;
	}

And the above becomes:

	bool scale_y = window->dst.h != window->src.h;

	if (scale_y && tegra_plane_has_vertical_filter(plane)) {

Thierry

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

Re: [PATCH v1 1/3] drm/tegra: dc: Enable plane scaling filters

Quoted 19 lines · Thierry Reding
Quoted 18 lines · Dmitry Osipenko

Currently resized plane produces a "pixelated" image which doesn't look nice, especially in a case of a video overlay. Enable scaling filters that significantly improve image quality of a scaled overlay.

---
 drivers/gpu/drm/tegra/dc.c | 51 ++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/tegra/dc.h |  7 ++++++
 2 files changed, 58 insertions(+)
drivers/gpu/drm/tegra/dc.c +0 -0
index 9f83a65b5ea9..2e81142281c3 100644
@@ -361,6 +361,47 @@ static void tegra_dc_setup_window(struct tegra_plane *plane,
 	if (window->bottom_up)
 		value |= V_DIRECTION;
 
Quoted 5 lines

drivers/gpu/drm/tegra/dc.c static void tegra_dc_setup_window(struct tegra_plane *plane, · line 365

Quoted 2 lines
drivers/gpu/drm/tegra/dc.c +2 -0
+	if (!(dc->soc->has_win_a_without_filter && plane->index == 0) &&
+	    !(window->src.w == window->dst.w)) {

I don't know about you, but I get dizzy trying to parse the above. How about we move this into helpers:

+1

Quoted 65 lines
	static bool tegra_plane_has_horizontal_filter(struct tegra_plane *plane)
	{
		struct tegra_dc *dc = plane->dc;

		/* this function should never be called on inactive planes */
		if (WARN_ON(!dc))
			return false;

		if (plane->index == 0 && dc->soc->has_win_a_without_filter)
			return false;

		return true;
	}

Then the above becomes:

	bool scale_x = window->dst.w != window->src.w;

	if (scale_x && tegra_plane_has_horizontal_filter(plane)) {
Quoted 17 lines
drivers/gpu/drm/tegra/dc.c +17 -0
+		/*
+		 * Enable horizontal 6-tap filter and set filtering
+		 * coefficients to the default values defined in TRM.
+		 */
+		tegra_plane_writel(plane, 0x00008000, DC_WIN_H_FILTER_P(0));
+		tegra_plane_writel(plane, 0x3e087ce1, DC_WIN_H_FILTER_P(1));
+		tegra_plane_writel(plane, 0x3b117ac1, DC_WIN_H_FILTER_P(2));
+		tegra_plane_writel(plane, 0x591b73aa, DC_WIN_H_FILTER_P(3));
+		tegra_plane_writel(plane, 0x57256d9a, DC_WIN_H_FILTER_P(4));
+		tegra_plane_writel(plane, 0x552f668b, DC_WIN_H_FILTER_P(5));
+		tegra_plane_writel(plane, 0x73385e8b, DC_WIN_H_FILTER_P(6));
+		tegra_plane_writel(plane, 0x72435583, DC_WIN_H_FILTER_P(7));
+		tegra_plane_writel(plane, 0x714c4c8b, DC_WIN_H_FILTER_P(8));
+		tegra_plane_writel(plane, 0x70554393, DC_WIN_H_FILTER_P(9));
+		tegra_plane_writel(plane, 0x715e389b, DC_WIN_H_FILTER_P(10));
+		tegra_plane_writel(plane, 0x71662faa, DC_WIN_H_FILTER_P(11));
+		tegra_plane_writel(plane, 0x536d25ba, DC_WIN_H_FILTER_P(12));

drivers/gpu/drm/tegra/dc.c static void tegra_dc_setup_window(struct tegra_plane *plane, · line 392

Quoted 10 lines
drivers/gpu/drm/tegra/dc.c +10 -0
+		tegra_plane_writel(plane, 0x55731bca, DC_WIN_H_FILTER_P(13));
+		tegra_plane_writel(plane, 0x387a11d9, DC_WIN_H_FILTER_P(14));
+		tegra_plane_writel(plane, 0x3c7c08f1, DC_WIN_H_FILTER_P(15));
+
+		value |= H_FILTER;
+	}
+
+	if (!(dc->soc->has_win_a_without_filter && plane->index == 0) &&
+	    !(dc->soc->has_win_c_without_vert_filter && plane->index == 2) &&
+	    !(window->src.h == window->dst.h)) {
	static bool tegra_plane_has_vertical_filter(struct tegra_plane *plane)
	{
		struct tegra_dc *dc = plane->dc;

		/* this function should never be called on inactive planes */
		if (WARN_ON(!dc))
			return false;

		if (plane->index == 0 && dc->soc->has_win_a_without_filter)
			return false;

		if (plane->index == 2 && dc->soc->has_win_c_without_vert_filter)
			return false;

		return true;
	}
Quoted 5 lines

And the above becomes:

	bool scale_y = window->dst.h != window->src.h;

	if (scale_y && tegra_plane_has_vertical_filter(plane)) {

I'll adjust this patch, thanks.

Maybe it also worth to factor filtering out into a custom DRM property? For example in a case of libvdpau-tegra we perform the exact same filtering on blitting YUV to RGB surface (shown as overlay) by GR2D for displaying video players interface on top of video, this results in a double filtering that has no visual effect and probably wastes memory bandwidth a tad.

Though I'm not very keen anymore on trying to add custom plane properties after being previously NAK'ed. We can wrap filtering into a property later if will be desired, should be good to just have it enabled by default for now.

#4 lore raw

Re: [PATCH v1 1/3] drm/tegra: dc: Enable plane scaling filters

Quoted 107 lines · Dmitry Osipenko
Quoted 19 lines · Thierry Reding
Quoted 18 lines · Dmitry Osipenko

Currently resized plane produces a "pixelated" image which doesn't look nice, especially in a case of a video overlay. Enable scaling filters that significantly improve image quality of a scaled overlay.

---
 drivers/gpu/drm/tegra/dc.c | 51 ++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/tegra/dc.h |  7 ++++++
 2 files changed, 58 insertions(+)
drivers/gpu/drm/tegra/dc.c +0 -0
index 9f83a65b5ea9..2e81142281c3 100644
@@ -361,6 +361,47 @@ static void tegra_dc_setup_window(struct tegra_plane *plane,
 	if (window->bottom_up)
 		value |= V_DIRECTION;
 
Quoted 5 lines

drivers/gpu/drm/tegra/dc.c static void tegra_dc_setup_window(struct tegra_plane *plane, · line 365

Quoted 2 lines
drivers/gpu/drm/tegra/dc.c +2 -0
+	if (!(dc->soc->has_win_a_without_filter && plane->index == 0) &&
+	    !(window->src.w == window->dst.w)) {

I don't know about you, but I get dizzy trying to parse the above. How about we move this into helpers:

+1

Quoted 65 lines
	static bool tegra_plane_has_horizontal_filter(struct tegra_plane *plane)
	{
		struct tegra_dc *dc = plane->dc;

		/* this function should never be called on inactive planes */
		if (WARN_ON(!dc))
			return false;

		if (plane->index == 0 && dc->soc->has_win_a_without_filter)
			return false;

		return true;
	}

Then the above becomes:

	bool scale_x = window->dst.w != window->src.w;

	if (scale_x && tegra_plane_has_horizontal_filter(plane)) {
Quoted 17 lines
drivers/gpu/drm/tegra/dc.c +17 -0
+		/*
+		 * Enable horizontal 6-tap filter and set filtering
+		 * coefficients to the default values defined in TRM.
+		 */
+		tegra_plane_writel(plane, 0x00008000, DC_WIN_H_FILTER_P(0));
+		tegra_plane_writel(plane, 0x3e087ce1, DC_WIN_H_FILTER_P(1));
+		tegra_plane_writel(plane, 0x3b117ac1, DC_WIN_H_FILTER_P(2));
+		tegra_plane_writel(plane, 0x591b73aa, DC_WIN_H_FILTER_P(3));
+		tegra_plane_writel(plane, 0x57256d9a, DC_WIN_H_FILTER_P(4));
+		tegra_plane_writel(plane, 0x552f668b, DC_WIN_H_FILTER_P(5));
+		tegra_plane_writel(plane, 0x73385e8b, DC_WIN_H_FILTER_P(6));
+		tegra_plane_writel(plane, 0x72435583, DC_WIN_H_FILTER_P(7));
+		tegra_plane_writel(plane, 0x714c4c8b, DC_WIN_H_FILTER_P(8));
+		tegra_plane_writel(plane, 0x70554393, DC_WIN_H_FILTER_P(9));
+		tegra_plane_writel(plane, 0x715e389b, DC_WIN_H_FILTER_P(10));
+		tegra_plane_writel(plane, 0x71662faa, DC_WIN_H_FILTER_P(11));
+		tegra_plane_writel(plane, 0x536d25ba, DC_WIN_H_FILTER_P(12));

drivers/gpu/drm/tegra/dc.c static void tegra_dc_setup_window(struct tegra_plane *plane, · line 392

Quoted 10 lines
drivers/gpu/drm/tegra/dc.c +10 -0
+		tegra_plane_writel(plane, 0x55731bca, DC_WIN_H_FILTER_P(13));
+		tegra_plane_writel(plane, 0x387a11d9, DC_WIN_H_FILTER_P(14));
+		tegra_plane_writel(plane, 0x3c7c08f1, DC_WIN_H_FILTER_P(15));
+
+		value |= H_FILTER;
+	}
+
+	if (!(dc->soc->has_win_a_without_filter && plane->index == 0) &&
+	    !(dc->soc->has_win_c_without_vert_filter && plane->index == 2) &&
+	    !(window->src.h == window->dst.h)) {
	static bool tegra_plane_has_vertical_filter(struct tegra_plane *plane)
	{
		struct tegra_dc *dc = plane->dc;

		/* this function should never be called on inactive planes */
		if (WARN_ON(!dc))
			return false;

		if (plane->index == 0 && dc->soc->has_win_a_without_filter)
			return false;

		if (plane->index == 2 && dc->soc->has_win_c_without_vert_filter)
			return false;

		return true;
	}
Quoted 5 lines

And the above becomes:

	bool scale_y = window->dst.h != window->src.h;

	if (scale_y && tegra_plane_has_vertical_filter(plane)) {

I'll adjust this patch, thanks.

Maybe it also worth to factor filtering out into a custom DRM property? For example in a case of libvdpau-tegra we perform the exact same filtering on blitting YUV to RGB surface (shown as overlay) by GR2D for displaying video players interface on top of video, this results in a double filtering that has no visual effect and probably wastes memory bandwidth a tad.

Quoted 3 lines

Though I'm not very keen anymore on trying to add custom plane properties after being previously NAK'ed. We can wrap filtering into a property later if will be desired, should be good to just have it enabled by default for now.

Agreed. Let's keep this enabled by default and then address the corner cases separately.

Thierry

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

Re: [PATCH v1 2/3] drm/tegra: plane: Implement zPos plane property for older Tegra's

In reply to Dmitry Osipenko
Quoted 9 lines · Dmitry Osipenko

Older Tegra's do not support planes z position handling in hardware, but HW provides knobs for zPos implementation in software.

---
 drivers/gpu/drm/tegra/dc.c    | 134 ++++++++++++++++-------
 drivers/gpu/drm/tegra/plane.c | 193 ++++++++++++++++++++++++----------
 drivers/gpu/drm/tegra/plane.h |  13 ++-
 3 files changed, 244 insertions(+), 96 deletions(-)

This is obviously a lot to review, but it looks pretty good. On minor comment below.

Quoted 5 lines
drivers/gpu/drm/tegra/dc.c +0 -0
index 2e81142281c3..ba5481cd470d 100644
@@ -162,29 +162,90 @@ static void tegra_plane_setup_blending_legacy(struct tegra_plane *plane)

[...]

drivers/gpu/drm/tegra/dc.c static void tegra_plane_setup_blending_legacy(struct tegra_plane *plane) · line 238

Quoted 8 lines
drivers/gpu/drm/tegra/dc.c +8 -0
+		case 1:
+			/*
+			 * When both middle and topmost windows have an alpha,
+			 * these windows a mixed together and then the result
+			 * is blended over the bottom window.
+			 */
+			if ((state->blending[0].alpha &&
+			     state->blending[0].top))

There seems to be one pair of parentheses too much here.

Thierry

#9 lore raw

Re: [PATCH v1 3/3] drm/tegra: dc: Rename supports_blending to has_legacy_blending

In reply to Dmitry Osipenko
Quoted 8 lines · Dmitry Osipenko

Older Tegra's support blending. Rename SoC info entry supports_blending to has_legacy_blending to eliminate confusion.

---
 drivers/gpu/drm/tegra/dc.c | 20 ++++++++++----------
 drivers/gpu/drm/tegra/dc.h |  2 +-
 2 files changed, 11 insertions(+), 11 deletions(-)

Looks good to me.

Thierry

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw

Re: [PATCH v1 2/3] drm/tegra: plane: Implement zPos plane property for older Tegra's

In reply to Thierry Reding
Quoted 20 lines · Thierry Reding
Quoted 9 lines · Dmitry Osipenko

Older Tegra's do not support planes z position handling in hardware, but HW provides knobs for zPos implementation in software.

---
 drivers/gpu/drm/tegra/dc.c    | 134 ++++++++++++++++-------
 drivers/gpu/drm/tegra/plane.c | 193 ++++++++++++++++++++++++----------
 drivers/gpu/drm/tegra/plane.h |  13 ++-
 3 files changed, 244 insertions(+), 96 deletions(-)

This is obviously a lot to review, but it looks pretty good. On minor comment below.

Quoted 5 lines
drivers/gpu/drm/tegra/dc.c +0 -0
index 2e81142281c3..ba5481cd470d 100644
@@ -162,29 +162,90 @@ static void tegra_plane_setup_blending_legacy(struct tegra_plane *plane)

[...]

Quoted 10 lines

drivers/gpu/drm/tegra/dc.c static void tegra_plane_setup_blending_legacy(struct tegra_plane *plane) · line 238

Quoted 8 lines
drivers/gpu/drm/tegra/dc.c +8 -0
+		case 1:
+			/*
+			 * When both middle and topmost windows have an alpha,
+			 * these windows a mixed together and then the result
+			 * is blended over the bottom window.
+			 */
+			if ((state->blending[0].alpha &&
+			     state->blending[0].top))

There seems to be one pair of parentheses too much here.

Good catch ;)