linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <syrjala@sci.fi>
To: Chandrabhanu Mahapatra <cmahapatra@ti.com>
Cc: tomi.valkeinen@ti.com, linux-omap@vger.kernel.org,
	linux-fbdev@vger.kernel.org
Subject: Re: [PATCH 2/2] OMAPDSS: DISPC: Handle synclost errors in OMAP3
Date: Thu, 15 Mar 2012 23:04:46 +0000	[thread overview]
Message-ID: <20120315230446.GO17132@sci.fi> (raw)
In-Reply-To: <1331812132-9814-1-git-send-email-cmahapatra@ti.com>

On Thu, Mar 15, 2012 at 05:18:52PM +0530, Chandrabhanu Mahapatra wrote:
> In OMAP3 DISPC video overlays suffer from some undocumented horizontal position
> and timing related limitations leading to SYNCLOST errors. Whenever the image
> window is moved towards the right of the screen SYNCLOST errors become
> frequent. Checks have been implemented to see that DISPC driver rejects
> configuration exceeding above limitations.
> 
> This code was successfully tested on OMAP3. This code is written based on code
> written by Ville Syrjälä <ville.syrjala@nokia.com> in Linux OMAP kernel. Ville
> Syrjälä <ville.syrjala@nokia.com> had added checks for video overlay horizontal
> timing and DISPC horizontal blanking length limitations.
> 
> Signed-off-by: Chandrabhanu Mahapatra <cmahapatra@ti.com>
> ---
>  drivers/video/omap2/dss/dispc.c |   67 +++++++++++++++++++++++++++++++++++++--
>  1 files changed, 64 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/video/omap2/dss/dispc.c b/drivers/video/omap2/dss/dispc.c
> index 5a1963e..ebfa613 100644
> --- a/drivers/video/omap2/dss/dispc.c
> +++ b/drivers/video/omap2/dss/dispc.c
> @@ -1622,6 +1622,58 @@ static void calc_dma_rotation_offset(u8 rotation, bool mirror,
>  	}
>  }
>  
> +static int check_horiz_timing(enum omap_channel channel, u16 pos_x,
> +		u16 width, u16 height, u16 out_width, u16 out_height)
> +{
> +	int DS = DIV_ROUND_UP(height, out_height);
> +	struct omap_dss_device *dssdev = dispc_mgr_get_device(channel);
> +	struct omap_video_timings t = dssdev->panel.timings;
> +	int pcd = REG_GET(DISPC_DIVISORo(channel), 7, 0);

pcd doesn't exist for TV out, which is the reason why you see
'lclk/pclk' ratio used instead in the harmattan kernel.

Another thing which still seems to be wrong in the upstream code is the
use of fclk in the scaling checks. It should be checking lclk instead.

> +	unsigned long nonactive, val, blank;
> +	static const u8 limits[3] = { 8, 10, 20 };
> +	int i;
> +
> +	nonactive = t.x_res + t.hfp + t.hsw + t.hbp - out_width;
> +
> +	/*
> +	 * Atleast DS-2 lines must have already been fetched
> +	 * before the display active video period starts.
> +	 */
> +	val = (nonactive - pos_x) * pcd;
> +	DSSDBG("(nonactive - pos_x) * pcd = %lu,"
> +		" max(0, DS - 2) * width = %d\n",
> +		val, max(0, DS - 2) * width);
> +	if (val < max(0, DS - 2) * width)
> +		return -EINVAL;
> +
> +	/*
> +	 * Only one line can be fetched during the overlay active
> +	 * period, the rest have to be fetched during the inactive
> +	 * period.
> +	 */
> +	val = nonactive * pcd;
> +	DSSDBG("nonactive * pcd  = %lu, max(0, DS - 1) * width = %d\n",
> +		val, max(0, DS - 1) * width);
> +	if (val < max(0, DS - 1) * width)
> +		return -EINVAL;
> +
> +	/*
> +	 * Atleast Ceil(DS) lines should have been loaded during
> +	 * PPL (screen width) + blanking period.
> +	 */
> +	i = 0;
> +	if (out_height < height)
> +		i++;
> +	if (out_width < width)
> +		i++;
> +	blank = (t.hbp + t.hsw + t.hfp) * pcd;
> +	DSSDBG("blanking period + ppl = %lu (limit = %u)\n", blank, limits[i]);
> +	if (blank <= limits[i])
> +		return -EINVAL;

The comment and code here are totally out of sync. IIRC the hblank
length check came directly from the TRM. I have no idea if it's correct
for more recent OMAPs, or if it was just copy pasted from the
old TRM when the TRM got adjusted for more recent chips. That is why I
stuck it into a separate function in harmattan.

-- 
Ville Syrjälä
syrjala@sci.fi
http://www.sci.fi/~syrjala/

  reply	other threads:[~2012-03-15 23:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-15 11:49 [PATCH 2/2] OMAPDSS: DISPC: Handle synclost errors in OMAP3 Chandrabhanu Mahapatra
2012-03-15 23:04 ` Ville Syrjälä [this message]
2012-03-16 10:23   ` Tomi Valkeinen
2012-03-16 14:27     ` Mahapatra, Chandrabhanu
2012-03-16 14:18   ` Mahapatra, Chandrabhanu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120315230446.GO17132@sci.fi \
    --to=syrjala@sci.fi \
    --cc=cmahapatra@ti.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=tomi.valkeinen@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).