[PATCH 2/4] video: ipuv3: Adjust videomode to IPU limitations
Sascha Hauer
s.hauer at pengutronix.de
Fri Aug 7 06:40:07 PDT 2015
The IPU needs an upper margin >= 2. Make this sure. This is based
on Linux commit:
commit 6541d71082fdb91f862c92920c6530e4e0548d6f
Author: Jiada Wang <jiada_wang at 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 at 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
More information about the barebox
mailing list