mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/4] video: ipuv3: Adjust videomode to IPU limitations
Date: Fri,  7 Aug 2015 15:40:07 +0200	[thread overview]
Message-ID: <1438954809-5962-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1438954809-5962-1-git-send-email-s.hauer@pengutronix.de>

The IPU needs an upper margin >= 2. Make this sure. This is based
on Linux commit:

commit 6541d71082fdb91f862c92920c6530e4e0548d6f
Author: Jiada Wang <jiada_wang@mentor.com>
Date:   Thu Dec 18 18:00:20 2014 -0800

    gpu: ipu-di: Add ipu_di_adjust_videomode()

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/video/imx-ipu-v3/ipufb.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/video/imx-ipu-v3/ipufb.c b/drivers/video/imx-ipu-v3/ipufb.c
index e804c31..ebfcfcc 100644
--- a/drivers/video/imx-ipu-v3/ipufb.c
+++ b/drivers/video/imx-ipu-v3/ipufb.c
@@ -75,6 +75,31 @@ static inline u_int chan_to_field(u_int chan, struct fb_bitfield *bf)
 	return chan << bf->offset;
 }
 
+static int ipu_crtc_adjust_videomode(struct ipufb_info *fbi, struct fb_videomode *mode)
+{
+	u32 diff;
+
+	if (mode->lower_margin >= 2)
+		return 0;
+
+	diff = 2 - mode->lower_margin;
+
+	if (mode->upper_margin >= diff) {
+		mode->upper_margin -= diff;
+	} else if (mode->vsync_len > diff) {
+		mode->vsync_len = mode->vsync_len - diff;
+	} else {
+		dev_warn(fbi->dev, "failed to adjust videomode\n");
+		return -EINVAL;
+	}
+
+	mode->lower_margin = 2;
+
+	dev_warn(fbi->dev, "videomode adapted for IPU restrictions\n");
+
+	return 0;
+}
+
 int ipu_crtc_mode_set(struct ipufb_info *fbi,
 			       struct fb_videomode *mode,
 			       int x, int y)
@@ -109,6 +134,11 @@ int ipu_crtc_mode_set(struct ipufb_info *fbi,
 
 	sig_cfg.v_start_width = mode->upper_margin;
 	sig_cfg.v_sync_width = mode->vsync_len;
+
+	ret = ipu_crtc_adjust_videomode(fbi, mode);
+	if (ret)
+		return ret;
+
 	sig_cfg.v_end_width = mode->lower_margin;
 	sig_cfg.pixelclock = PICOS2KHZ(mode->pixclock) * 1000UL;
 	sig_cfg.clkflags = di_mode.di_clkflags;
-- 
2.4.6


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2015-08-07 13:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-07 13:40 video: update imx-ipu-v3 and hdmi support Sascha Hauer
2015-08-07 13:40 ` [PATCH 1/4] video: imx-hdmi: sync with kernel Sascha Hauer
2015-08-07 13:40 ` Sascha Hauer [this message]
2015-08-07 13:40 ` [PATCH 3/4] ARM: implement dma_alloc_writecombine Sascha Hauer
2015-08-07 13:40 ` [PATCH 4/4] video: imx-ipu-v3: Use writecombine memory for fb Sascha Hauer

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=1438954809-5962-3-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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