linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/11] OMAPDSS: scaling & misc fixes
@ 2015-06-17 12:54 Tomi Valkeinen
  2015-06-17 12:54 ` [PATCH 01/11] OMAPDSS: DISPC: work-around for errata i631 Tomi Valkeinen
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Tomi Valkeinen @ 2015-06-17 12:54 UTC (permalink / raw)
  To: Laurent Pinchart, linux-omap, linux-fbdev; +Cc: Tomi Valkeinen

Hi,

Here are some mostly scaling related fixes for omapdss, forward ported from
TI's kernel (i.e. they've seen quite a bit of testing there).

 Tomi

Tomi Valkeinen (11):
  OMAPDSS: DISPC: work-around for errata i631
  OMAPDSS: DISPC: fix predecimation for YUV modes
  OMAPDSS: DISPC: fix check_horiz_timing_omap3 args
  OMAPDSS: DISPC: add check for scaling limits
  OMAPDSS: DISPC: fix row_inc for OMAP3
  OMAPDSS: DISPC: fix 64 bit issue in 5-tap
  OMAPDSS: DISPC: check if scaling setup failed
  OMAPDSS: DISPC: do only y decimation on OMAP3
  OMAPDSS: DISPC: scaler debug print
  OMAPDSS: HDMI4: fix error handling
  OMAPDSS: HDMI: wait for framedone when stopping video

 drivers/video/fbdev/omap2/dss/dispc.c   | 114 +++++++++++++++++++++++++++-----
 drivers/video/fbdev/omap2/dss/hdmi4.c   |   2 +-
 drivers/video/fbdev/omap2/dss/hdmi_wp.c |  16 +++++
 3 files changed, 116 insertions(+), 16 deletions(-)

-- 
2.1.4


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

* [PATCH 01/11] OMAPDSS: DISPC: work-around for errata i631
  2015-06-17 12:54 [PATCH 00/11] OMAPDSS: scaling & misc fixes Tomi Valkeinen
@ 2015-06-17 12:54 ` Tomi Valkeinen
  2015-06-17 12:54 ` [PATCH 02/11] OMAPDSS: DISPC: fix predecimation for YUV modes Tomi Valkeinen
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Tomi Valkeinen @ 2015-06-17 12:54 UTC (permalink / raw)
  To: Laurent Pinchart, linux-omap, linux-fbdev; +Cc: Tomi Valkeinen

Errata i631 description:

"When in YUV4:2:0 format in 1D burst, the DISPC DMA skips lines when
fetching Chroma sampling."

Workaround:

"If YUV4:2:0-1D burst is required: Set
DISPC_VIDp_ATTRIBUTES[22]DOUBLESTRIDE to 0x0 and
DISPC_VIDp_ATTRIBUTES[13:12]ROTATION to 0x1 or 0x3"

The description is somewhat confusing, but testing has shown that DSS
fetches extra rows from memory when using NV12 format in 1D mode. If the
memory after the framebuffer is inaccessible, this leads to OCP errors.

The driver always uses DOUBLESTRIDE=0 when using 1D mode, so we only
need to handle the ROTATION part.

The issue exist on all OMAP4 and OMAP5 based DSS IPs.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/video/fbdev/omap2/dss/dispc.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/video/fbdev/omap2/dss/dispc.c b/drivers/video/fbdev/omap2/dss/dispc.c
index f4fc77d9d3bf..a074d8b70591 100644
--- a/drivers/video/fbdev/omap2/dss/dispc.c
+++ b/drivers/video/fbdev/omap2/dss/dispc.c
@@ -1741,6 +1741,15 @@ static void dispc_ovl_set_rotation_attrs(enum omap_plane plane, u8 rotation,
 			row_repeat = false;
 	}
 
+	/*
+	 * OMAP4/5 Errata i631:
+	 * NV12 in 1D mode must use ROTATION=1. Otherwise DSS will fetch extra
+	 * rows beyond the framebuffer, which may cause OCP error.
+	 */
+	if (color_mode = OMAP_DSS_COLOR_NV12 &&
+			rotation_type != OMAP_DSS_ROT_TILER)
+		vidrot = 1;
+
 	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), vidrot, 13, 12);
 	if (dss_has_feature(FEAT_ROWREPEATENABLE))
 		REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane),
-- 
2.1.4


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

* [PATCH 02/11] OMAPDSS: DISPC: fix predecimation for YUV modes
  2015-06-17 12:54 [PATCH 00/11] OMAPDSS: scaling & misc fixes Tomi Valkeinen
  2015-06-17 12:54 ` [PATCH 01/11] OMAPDSS: DISPC: work-around for errata i631 Tomi Valkeinen
@ 2015-06-17 12:54 ` Tomi Valkeinen
  2015-06-17 12:54 ` [PATCH 03/11] OMAPDSS: DISPC: fix check_horiz_timing_omap3 args Tomi Valkeinen
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Tomi Valkeinen @ 2015-06-17 12:54 UTC (permalink / raw)
  To: Laurent Pinchart, linux-omap, linux-fbdev; +Cc: Tomi Valkeinen

DISPC needs even input buffer width for YUV modes. The DISPC driver
doesn't check this at the moment (although omapdrm does), but worse,
when DISPC driver does x predecimation the result may be uneven. This
causes sometimes sync losts, underflows, or just visual errors.

This patch makes DISPC driver return an error if the user gives uneven
input width for a YUV buffer. It also makes the input width even in case
of predecimation.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/video/fbdev/omap2/dss/dispc.c | 36 +++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/drivers/video/fbdev/omap2/dss/dispc.c b/drivers/video/fbdev/omap2/dss/dispc.c
index a074d8b70591..db60aa98f661 100644
--- a/drivers/video/fbdev/omap2/dss/dispc.c
+++ b/drivers/video/fbdev/omap2/dss/dispc.c
@@ -2542,6 +2542,21 @@ static int dispc_ovl_setup_common(enum omap_plane plane,
 	if (paddr = 0 && rotation_type != OMAP_DSS_ROT_TILER)
 		return -EINVAL;
 
+	switch (color_mode) {
+	case OMAP_DSS_COLOR_YUV2:
+	case OMAP_DSS_COLOR_UYVY:
+	case OMAP_DSS_COLOR_NV12:
+		if (in_width & 1) {
+			DSSERR("input width %d is not even for YUV format\n",
+				in_width);
+			return -EINVAL;
+		}
+		break;
+
+	default:
+		break;
+	}
+
 	out_width = out_width = 0 ? width : out_width;
 	out_height = out_height = 0 ? height : out_height;
 
@@ -2572,6 +2587,27 @@ static int dispc_ovl_setup_common(enum omap_plane plane,
 	in_width = in_width / x_predecim;
 	in_height = in_height / y_predecim;
 
+	if (x_predecim > 1 || y_predecim > 1)
+		DSSDBG("predecimation %d x %x, new input size %d x %d\n",
+			x_predecim, y_predecim, in_width, in_height);
+
+	switch (color_mode) {
+	case OMAP_DSS_COLOR_YUV2:
+	case OMAP_DSS_COLOR_UYVY:
+	case OMAP_DSS_COLOR_NV12:
+		if (in_width & 1) {
+			DSSDBG("predecimated input width is not even for YUV format\n");
+			DSSDBG("adjusting input width %d -> %d\n",
+				in_width, in_width & ~1);
+
+			in_width &= ~1;
+		}
+		break;
+
+	default:
+		break;
+	}
+
 	if (color_mode = OMAP_DSS_COLOR_YUV2 ||
 			color_mode = OMAP_DSS_COLOR_UYVY ||
 			color_mode = OMAP_DSS_COLOR_NV12)
-- 
2.1.4


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

* [PATCH 03/11] OMAPDSS: DISPC: fix check_horiz_timing_omap3 args
  2015-06-17 12:54 [PATCH 00/11] OMAPDSS: scaling & misc fixes Tomi Valkeinen
  2015-06-17 12:54 ` [PATCH 01/11] OMAPDSS: DISPC: work-around for errata i631 Tomi Valkeinen
  2015-06-17 12:54 ` [PATCH 02/11] OMAPDSS: DISPC: fix predecimation for YUV modes Tomi Valkeinen
@ 2015-06-17 12:54 ` Tomi Valkeinen
  2015-06-17 12:54 ` [PATCH 04/11] OMAPDSS: DISPC: add check for scaling limits Tomi Valkeinen
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Tomi Valkeinen @ 2015-06-17 12:54 UTC (permalink / raw)
  To: Laurent Pinchart, linux-omap, linux-fbdev; +Cc: Tomi Valkeinen

After calculating the required decimation for scaling, the dispc driver
checks once more if the resulting configuration is valid by calling
check_horiz_timing_omap3().

Earlier calls to this function have correctly used in_width and
in_height as parameters, but the last call uses width and height. This
causes the driver to possibly reject scaling that would work.

This patch fixes the parameters.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/video/fbdev/omap2/dss/dispc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/omap2/dss/dispc.c b/drivers/video/fbdev/omap2/dss/dispc.c
index db60aa98f661..cc61513afdb4 100644
--- a/drivers/video/fbdev/omap2/dss/dispc.c
+++ b/drivers/video/fbdev/omap2/dss/dispc.c
@@ -2338,8 +2338,8 @@ again:
 		}
 	} while (*decim_x <= *x_predecim && *decim_y <= *y_predecim && error);
 
-	if (check_horiz_timing_omap3(pclk, lclk, mgr_timings, pos_x, width,
-				height, out_width, out_height, *five_taps)) {
+	if (check_horiz_timing_omap3(pclk, lclk, mgr_timings, pos_x, in_width,
+				in_height, out_width, out_height, *five_taps)) {
 			DSSERR("horizontal timing too tight\n");
 			return -EINVAL;
 	}
-- 
2.1.4


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

* [PATCH 04/11] OMAPDSS: DISPC: add check for scaling limits
  2015-06-17 12:54 [PATCH 00/11] OMAPDSS: scaling & misc fixes Tomi Valkeinen
                   ` (2 preceding siblings ...)
  2015-06-17 12:54 ` [PATCH 03/11] OMAPDSS: DISPC: fix check_horiz_timing_omap3 args Tomi Valkeinen
@ 2015-06-17 12:54 ` Tomi Valkeinen
  2015-06-17 12:54 ` [PATCH 05/11] OMAPDSS: DISPC: fix row_inc for OMAP3 Tomi Valkeinen
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Tomi Valkeinen @ 2015-06-17 12:54 UTC (permalink / raw)
  To: Laurent Pinchart, linux-omap, linux-fbdev; +Cc: Tomi Valkeinen

On OMAP3/AM43xx some scaling factors cause underflows/synclosts. After
studying this, I found that sometimes the driver uses three-tap scaling
with downscaling factor smaller than x0.5. This causes issues, as x0.5
is the limit for three-tap scaling.

The driver has FEAT_PARAM_DOWNSCALE parameter, but that seems to be for
five-tap scaling, which allows scaling down to x0.25.

This patch adds checks for both horizontal and vertical scaling. For
horizontal the HW always uses 5 taps, so the limit is x0.25.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/video/fbdev/omap2/dss/dispc.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/video/fbdev/omap2/dss/dispc.c b/drivers/video/fbdev/omap2/dss/dispc.c
index cc61513afdb4..ddce8fcfc5c1 100644
--- a/drivers/video/fbdev/omap2/dss/dispc.c
+++ b/drivers/video/fbdev/omap2/dss/dispc.c
@@ -2326,6 +2326,21 @@ again:
 		error = (error || in_width > maxsinglelinewidth * 2 ||
 			(in_width > maxsinglelinewidth && *five_taps) ||
 			!*core_clk || *core_clk > dispc_core_clk_rate());
+
+		if (!error) {
+			/* verify that we're inside the limits of scaler */
+			if (in_width / 4 > out_width)
+					error = 1;
+
+			if (*five_taps) {
+				if (in_height / 4 > out_height)
+					error = 1;
+			} else {
+				if (in_height / 2 > out_height)
+					error = 1;
+			}
+		}
+
 		if (error) {
 			if (*decim_x = *decim_y) {
 				*decim_x = min_factor;
-- 
2.1.4


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

* [PATCH 05/11] OMAPDSS: DISPC: fix row_inc for OMAP3
  2015-06-17 12:54 [PATCH 00/11] OMAPDSS: scaling & misc fixes Tomi Valkeinen
                   ` (3 preceding siblings ...)
  2015-06-17 12:54 ` [PATCH 04/11] OMAPDSS: DISPC: add check for scaling limits Tomi Valkeinen
@ 2015-06-17 12:54 ` Tomi Valkeinen
  2015-06-17 12:54 ` [PATCH 06/11] OMAPDSS: DISPC: fix 64 bit issue in 5-tap Tomi Valkeinen
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Tomi Valkeinen @ 2015-06-17 12:54 UTC (permalink / raw)
  To: Laurent Pinchart, linux-omap, linux-fbdev; +Cc: Tomi Valkeinen

pixel_inc and row_inc work differently on OMAP2/3 and OMAP4+ DSS. On
OMAP2/3 DSS, the pixel_inc is _not_ added by the HW at the end of the
line, after the last pixel, whereas on OMAP4+ it is.

The driver currently works for OMAP4+, but does not handle OMAP2/3
correctly, which leads to tilted image when row_inc is used.

This patch adds a flag to DISPC driver so that the pixel_inc is added
when required.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/video/fbdev/omap2/dss/dispc.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/video/fbdev/omap2/dss/dispc.c b/drivers/video/fbdev/omap2/dss/dispc.c
index ddce8fcfc5c1..4488d9367bd3 100644
--- a/drivers/video/fbdev/omap2/dss/dispc.c
+++ b/drivers/video/fbdev/omap2/dss/dispc.c
@@ -95,6 +95,9 @@ struct dispc_features {
 	bool mstandby_workaround:1;
 
 	bool set_max_preload:1;
+
+	/* PIXEL_INC is not added to the last pixel of a line */
+	bool last_pixel_inc_missing:1;
 };
 
 #define DISPC_MAX_NR_FIFOS 5
@@ -2692,6 +2695,9 @@ static int dispc_ovl_setup_common(enum omap_plane plane,
 		dispc_ovl_set_ba1_uv(plane, p_uv_addr + offset1);
 	}
 
+	if (dispc.feat->last_pixel_inc_missing)
+		row_inc += pix_inc - 1;
+
 	dispc_ovl_set_row_inc(plane, row_inc);
 	dispc_ovl_set_pix_inc(plane, pix_inc);
 
@@ -3769,6 +3775,7 @@ static const struct dispc_features omap24xx_dispc_feats __initconst = {
 	.num_fifos		=	3,
 	.no_framedone_tv	=	true,
 	.set_max_preload	=	false,
+	.last_pixel_inc_missing	=	true,
 };
 
 static const struct dispc_features omap34xx_rev1_0_dispc_feats __initconst = {
@@ -3789,6 +3796,7 @@ static const struct dispc_features omap34xx_rev1_0_dispc_feats __initconst = {
 	.num_fifos		=	3,
 	.no_framedone_tv	=	true,
 	.set_max_preload	=	false,
+	.last_pixel_inc_missing	=	true,
 };
 
 static const struct dispc_features omap34xx_rev3_0_dispc_feats __initconst = {
@@ -3809,6 +3817,7 @@ static const struct dispc_features omap34xx_rev3_0_dispc_feats __initconst = {
 	.num_fifos		=	3,
 	.no_framedone_tv	=	true,
 	.set_max_preload	=	false,
+	.last_pixel_inc_missing	=	true,
 };
 
 static const struct dispc_features omap44xx_dispc_feats __initconst = {
-- 
2.1.4


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

* [PATCH 06/11] OMAPDSS: DISPC: fix 64 bit issue in 5-tap
  2015-06-17 12:54 [PATCH 00/11] OMAPDSS: scaling & misc fixes Tomi Valkeinen
                   ` (4 preceding siblings ...)
  2015-06-17 12:54 ` [PATCH 05/11] OMAPDSS: DISPC: fix row_inc for OMAP3 Tomi Valkeinen
@ 2015-06-17 12:54 ` Tomi Valkeinen
  2015-06-17 12:54 ` [PATCH 07/11] OMAPDSS: DISPC: check if scaling setup failed Tomi Valkeinen
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Tomi Valkeinen @ 2015-06-17 12:54 UTC (permalink / raw)
  To: Laurent Pinchart, linux-omap, linux-fbdev; +Cc: Tomi Valkeinen

The DISPC driver uses 64 bit arithmetic to calculate the required clock
rate for scaling. The code does not seem to work correctly, and instead
calculates with 32 bit numbers, giving wrong result.

Fix the code by typecasting values to u64 first, so that the
calculations do happen in 64 bits.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/video/fbdev/omap2/dss/dispc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/video/fbdev/omap2/dss/dispc.c b/drivers/video/fbdev/omap2/dss/dispc.c
index 4488d9367bd3..2db1c986e989 100644
--- a/drivers/video/fbdev/omap2/dss/dispc.c
+++ b/drivers/video/fbdev/omap2/dss/dispc.c
@@ -2166,7 +2166,7 @@ static unsigned long calc_core_clk_five_taps(unsigned long pclk,
 	if (height > out_height) {
 		unsigned int ppl = mgr_timings->x_res;
 
-		tmp = pclk * height * out_width;
+		tmp = (u64)pclk * height * out_width;
 		do_div(tmp, 2 * out_height * ppl);
 		core_clk = tmp;
 
@@ -2174,14 +2174,14 @@ static unsigned long calc_core_clk_five_taps(unsigned long pclk,
 			if (ppl = out_width)
 				return 0;
 
-			tmp = pclk * (height - 2 * out_height) * out_width;
+			tmp = (u64)pclk * (height - 2 * out_height) * out_width;
 			do_div(tmp, 2 * out_height * (ppl - out_width));
 			core_clk = max_t(u32, core_clk, tmp);
 		}
 	}
 
 	if (width > out_width) {
-		tmp = pclk * width;
+		tmp = (u64)pclk * width;
 		do_div(tmp, out_width);
 		core_clk = max_t(u32, core_clk, tmp);
 
-- 
2.1.4


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

* [PATCH 07/11] OMAPDSS: DISPC: check if scaling setup failed
  2015-06-17 12:54 [PATCH 00/11] OMAPDSS: scaling & misc fixes Tomi Valkeinen
                   ` (5 preceding siblings ...)
  2015-06-17 12:54 ` [PATCH 06/11] OMAPDSS: DISPC: fix 64 bit issue in 5-tap Tomi Valkeinen
@ 2015-06-17 12:54 ` Tomi Valkeinen
  2015-06-17 12:54 ` [PATCH 08/11] OMAPDSS: DISPC: do only y decimation on OMAP3 Tomi Valkeinen
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Tomi Valkeinen @ 2015-06-17 12:54 UTC (permalink / raw)
  To: Laurent Pinchart, linux-omap, linux-fbdev; +Cc: Tomi Valkeinen

The DISPC's scaling code seems to presume that decimation always
succeeds, and so we always do find a suitable downscaling setup.
However, this is not the case, and the algorithm can fail.

When that happens, the code just proceeds with wrong results, causing
issues later.

Add the necessary checks to bail out if the scaling algorithm failed.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/video/fbdev/omap2/dss/dispc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/video/fbdev/omap2/dss/dispc.c b/drivers/video/fbdev/omap2/dss/dispc.c
index 2db1c986e989..0bdb587cb48c 100644
--- a/drivers/video/fbdev/omap2/dss/dispc.c
+++ b/drivers/video/fbdev/omap2/dss/dispc.c
@@ -2279,6 +2279,11 @@ static int dispc_ovl_calc_scaling_24xx(unsigned long pclk, unsigned long lclk,
 		}
 	} while (*decim_x <= *x_predecim && *decim_y <= *y_predecim && error);
 
+	if (error) {
+		DSSERR("failed to find scaling settings\n");
+		return -EINVAL;
+	}
+
 	if (in_width > maxsinglelinewidth) {
 		DSSERR("Cannot scale max input width exceeded");
 		return -EINVAL;
@@ -2356,6 +2361,11 @@ again:
 		}
 	} while (*decim_x <= *x_predecim && *decim_y <= *y_predecim && error);
 
+	if (error) {
+		DSSERR("failed to find scaling settings\n");
+		return -EINVAL;
+	}
+
 	if (check_horiz_timing_omap3(pclk, lclk, mgr_timings, pos_x, in_width,
 				in_height, out_width, out_height, *five_taps)) {
 			DSSERR("horizontal timing too tight\n");
-- 
2.1.4


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

* [PATCH 08/11] OMAPDSS: DISPC: do only y decimation on OMAP3
  2015-06-17 12:54 [PATCH 00/11] OMAPDSS: scaling & misc fixes Tomi Valkeinen
                   ` (6 preceding siblings ...)
  2015-06-17 12:54 ` [PATCH 07/11] OMAPDSS: DISPC: check if scaling setup failed Tomi Valkeinen
@ 2015-06-17 12:54 ` Tomi Valkeinen
  2015-06-17 12:54 ` [PATCH 09/11] OMAPDSS: DISPC: scaler debug print Tomi Valkeinen
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Tomi Valkeinen @ 2015-06-17 12:54 UTC (permalink / raw)
  To: Laurent Pinchart, linux-omap, linux-fbdev; +Cc: Tomi Valkeinen

The current driver does both x and y decimation on OMAP3 DSS. Testing
shows that x decimation rarely works, leading to underflows.

The exact reason for this is unclear, as the underflows seem to happen
even with low pixel clock rates, and I would presume that if the DSS can
manage a display with 140MHz pixel clock, it could manage x decimation
with factor 2 with a low pixel clock (~30MHz).

So it is possible that there is a problem somewhere else, in memory
management, or DSS DMA, or similar. I have not found anything that would
help this.

So, to fix the downscaling scaling, this patch removes x decimation for
OMAP3. This will limit some of the more demanding downscaling scenarios,
but one could argue that using DSS to downscale such a large amount is
insane in the first place, as the produced image is rather bad quality.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/video/fbdev/omap2/dss/dispc.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/video/fbdev/omap2/dss/dispc.c b/drivers/video/fbdev/omap2/dss/dispc.c
index 0bdb587cb48c..646d94a71a79 100644
--- a/drivers/video/fbdev/omap2/dss/dispc.c
+++ b/drivers/video/fbdev/omap2/dss/dispc.c
@@ -2300,7 +2300,6 @@ static int dispc_ovl_calc_scaling_34xx(unsigned long pclk, unsigned long lclk,
 {
 	int error;
 	u16 in_width, in_height;
-	int min_factor = min(*decim_x, *decim_y);
 	const int maxsinglelinewidth  			dss_feat_get_param_max(FEAT_PARAM_LINEWIDTH);
 
@@ -2349,16 +2348,8 @@ again:
 			}
 		}
 
-		if (error) {
-			if (*decim_x = *decim_y) {
-				*decim_x = min_factor;
-				++*decim_y;
-			} else {
-				swap(*decim_x, *decim_y);
-				if (*decim_x < *decim_y)
-					++*decim_x;
-			}
-		}
+		if (error)
+			++*decim_y;
 	} while (*decim_x <= *x_predecim && *decim_y <= *y_predecim && error);
 
 	if (error) {
-- 
2.1.4


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

* [PATCH 09/11] OMAPDSS: DISPC: scaler debug print
  2015-06-17 12:54 [PATCH 00/11] OMAPDSS: scaling & misc fixes Tomi Valkeinen
                   ` (7 preceding siblings ...)
  2015-06-17 12:54 ` [PATCH 08/11] OMAPDSS: DISPC: do only y decimation on OMAP3 Tomi Valkeinen
@ 2015-06-17 12:54 ` Tomi Valkeinen
  2015-06-17 12:54 ` [PATCH 10/11] OMAPDSS: HDMI4: fix error handling Tomi Valkeinen
  2015-06-17 12:54 ` [PATCH 11/11] OMAPDSS: HDMI: wait for framedone when stopping video Tomi Valkeinen
  10 siblings, 0 replies; 12+ messages in thread
From: Tomi Valkeinen @ 2015-06-17 12:54 UTC (permalink / raw)
  To: Laurent Pinchart, linux-omap, linux-fbdev; +Cc: Tomi Valkeinen

Improve the DISPC debug print for scaling.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/video/fbdev/omap2/dss/dispc.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/omap2/dss/dispc.c b/drivers/video/fbdev/omap2/dss/dispc.c
index 646d94a71a79..f8c9115cdb4b 100644
--- a/drivers/video/fbdev/omap2/dss/dispc.c
+++ b/drivers/video/fbdev/omap2/dss/dispc.c
@@ -2418,6 +2418,9 @@ static int dispc_ovl_calc_scaling_44xx(unsigned long pclk, unsigned long lclk,
 	return 0;
 }
 
+#define DIV_FRAC(dividend, divisor) \
+	((dividend) * 100 / (divisor) - ((dividend) / (divisor) * 100))
+
 static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk,
 		enum omap_overlay_caps caps,
 		const struct omap_video_timings *mgr_timings,
@@ -2477,8 +2480,19 @@ static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk,
 	if (ret)
 		return ret;
 
-	DSSDBG("required core clk rate = %lu Hz\n", core_clk);
-	DSSDBG("current core clk rate = %lu Hz\n", dispc_core_clk_rate());
+	DSSDBG("%dx%d -> %dx%d (%d.%02d x %d.%02d), decim %dx%d %dx%d (%d.%02d x %d.%02d), taps %d, req clk %lu, cur clk %lu\n",
+		width, height,
+		out_width, out_height,
+		out_width / width, DIV_FRAC(out_width, width),
+		out_height / height, DIV_FRAC(out_height, height),
+
+		decim_x, decim_y,
+		width / decim_x, height / decim_y,
+		out_width / (width / decim_x), DIV_FRAC(out_width, width / decim_x),
+		out_height / (height / decim_y), DIV_FRAC(out_height, height / decim_y),
+
+		*five_taps ? 5 : 3,
+		core_clk, dispc_core_clk_rate());
 
 	if (!core_clk || core_clk > dispc_core_clk_rate()) {
 		DSSERR("failed to set up scaling, "
-- 
2.1.4


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

* [PATCH 10/11] OMAPDSS: HDMI4: fix error handling
  2015-06-17 12:54 [PATCH 00/11] OMAPDSS: scaling & misc fixes Tomi Valkeinen
                   ` (8 preceding siblings ...)
  2015-06-17 12:54 ` [PATCH 09/11] OMAPDSS: DISPC: scaler debug print Tomi Valkeinen
@ 2015-06-17 12:54 ` Tomi Valkeinen
  2015-06-17 12:54 ` [PATCH 11/11] OMAPDSS: HDMI: wait for framedone when stopping video Tomi Valkeinen
  10 siblings, 0 replies; 12+ messages in thread
From: Tomi Valkeinen @ 2015-06-17 12:54 UTC (permalink / raw)
  To: Laurent Pinchart, linux-omap, linux-fbdev; +Cc: Tomi Valkeinen

Error handling in hdmi_power_on_full() is not correct, and could leave
resources unfreed.

Fix this by arranging the error labels correctly.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/video/fbdev/omap2/dss/hdmi4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/omap2/dss/hdmi4.c b/drivers/video/fbdev/omap2/dss/hdmi4.c
index 916d47978f41..e1345abd41bb 100644
--- a/drivers/video/fbdev/omap2/dss/hdmi4.c
+++ b/drivers/video/fbdev/omap2/dss/hdmi4.c
@@ -229,9 +229,9 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
 err_mgr_enable:
 	hdmi_wp_video_stop(&hdmi.wp);
 err_vid_enable:
-err_phy_cfg:
 	hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF);
 err_phy_pwr:
+err_phy_cfg:
 err_pll_cfg:
 	dss_pll_disable(&hdmi.pll.pll);
 err_pll_enable:
-- 
2.1.4


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

* [PATCH 11/11] OMAPDSS: HDMI: wait for framedone when stopping video
  2015-06-17 12:54 [PATCH 00/11] OMAPDSS: scaling & misc fixes Tomi Valkeinen
                   ` (9 preceding siblings ...)
  2015-06-17 12:54 ` [PATCH 10/11] OMAPDSS: HDMI4: fix error handling Tomi Valkeinen
@ 2015-06-17 12:54 ` Tomi Valkeinen
  10 siblings, 0 replies; 12+ messages in thread
From: Tomi Valkeinen @ 2015-06-17 12:54 UTC (permalink / raw)
  To: Laurent Pinchart, linux-omap, linux-fbdev; +Cc: Tomi Valkeinen

At the moment when HDMI video output is stopped, we just clear the
enable bit and return. While it's unclear if this can cause any issues,
I think it's still better to wait for FRAMEDONE interrupt after clearing
the enable bit so that we're sure the HDMI IP has finished.

As we don't have any ready-made irq handling for HDMI, and this only
needs to be done when disabling the HDMI output, this patch implements a
simple loop with sleep, polling the FRAMEDONE bit.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/video/fbdev/omap2/dss/hdmi_wp.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/video/fbdev/omap2/dss/hdmi_wp.c b/drivers/video/fbdev/omap2/dss/hdmi_wp.c
index c15377e242cc..7c544bc56fb5 100644
--- a/drivers/video/fbdev/omap2/dss/hdmi_wp.c
+++ b/drivers/video/fbdev/omap2/dss/hdmi_wp.c
@@ -110,7 +110,23 @@ int hdmi_wp_video_start(struct hdmi_wp_data *wp)
 
 void hdmi_wp_video_stop(struct hdmi_wp_data *wp)
 {
+	int i;
+
+	hdmi_write_reg(wp->base, HDMI_WP_IRQSTATUS, HDMI_IRQ_VIDEO_FRAME_DONE);
+
 	REG_FLD_MOD(wp->base, HDMI_WP_VIDEO_CFG, false, 31, 31);
+
+	for (i = 0; i < 50; ++i) {
+		u32 v;
+
+		msleep(20);
+
+		v = hdmi_read_reg(wp->base, HDMI_WP_IRQSTATUS_RAW);
+		if (v & HDMI_IRQ_VIDEO_FRAME_DONE)
+			return;
+	}
+
+	DSSERR("no HDMI FRAMEDONE when disabling output\n");
 }
 
 void hdmi_wp_video_config_format(struct hdmi_wp_data *wp,
-- 
2.1.4


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

end of thread, other threads:[~2015-06-17 12:54 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-17 12:54 [PATCH 00/11] OMAPDSS: scaling & misc fixes Tomi Valkeinen
2015-06-17 12:54 ` [PATCH 01/11] OMAPDSS: DISPC: work-around for errata i631 Tomi Valkeinen
2015-06-17 12:54 ` [PATCH 02/11] OMAPDSS: DISPC: fix predecimation for YUV modes Tomi Valkeinen
2015-06-17 12:54 ` [PATCH 03/11] OMAPDSS: DISPC: fix check_horiz_timing_omap3 args Tomi Valkeinen
2015-06-17 12:54 ` [PATCH 04/11] OMAPDSS: DISPC: add check for scaling limits Tomi Valkeinen
2015-06-17 12:54 ` [PATCH 05/11] OMAPDSS: DISPC: fix row_inc for OMAP3 Tomi Valkeinen
2015-06-17 12:54 ` [PATCH 06/11] OMAPDSS: DISPC: fix 64 bit issue in 5-tap Tomi Valkeinen
2015-06-17 12:54 ` [PATCH 07/11] OMAPDSS: DISPC: check if scaling setup failed Tomi Valkeinen
2015-06-17 12:54 ` [PATCH 08/11] OMAPDSS: DISPC: do only y decimation on OMAP3 Tomi Valkeinen
2015-06-17 12:54 ` [PATCH 09/11] OMAPDSS: DISPC: scaler debug print Tomi Valkeinen
2015-06-17 12:54 ` [PATCH 10/11] OMAPDSS: HDMI4: fix error handling Tomi Valkeinen
2015-06-17 12:54 ` [PATCH 11/11] OMAPDSS: HDMI: wait for framedone when stopping video Tomi Valkeinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).