[U-Boot] [PATCH] tegra20: display: Add support for flipped panels

Alban Bedel alban.bedel at avionic-design.de
Thu Oct 2 17:15:49 CEST 2014


Add support for two new panel properties, flip-vertical and
flip-horizontal. If set the display controller will be setup to
correctly flip the image.

Change-Id: I324b5d2b0b7ebbde7e08e5f32509cf101c057c84
Signed-off-by: Alban Bedel <alban.bedel at avionic-design.de>
---
 arch/arm/cpu/armv7/tegra20/display.c        | 20 ++++++++++++++++++--
 arch/arm/include/asm/arch-tegra20/display.h |  4 ++++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/arch/arm/cpu/armv7/tegra20/display.c b/arch/arm/cpu/armv7/tegra20/display.c
index fd77f3f..b332dd4 100644
--- a/arch/arm/cpu/armv7/tegra20/display.c
+++ b/arch/arm/cpu/armv7/tegra20/display.c
@@ -20,6 +20,7 @@ static void update_window(struct dc_ctlr *dc, struct disp_ctl_win *win)
 {
 	unsigned h_dda, v_dda;
 	unsigned long val;
+	unsigned x, y;
 
 	val = readl(&dc->cmd.disp_win_header);
 	val |= WINDOW_A_SELECT;
@@ -58,11 +59,22 @@ static void update_window(struct dc_ctlr *dc, struct disp_ctl_win *win)
 	val = WIN_ENABLE;
 	if (win->bpp < 24)
 		val |= COLOR_EXPAND;
+	if (win->flip_h)
+		val |= H_DIRECTION;
+	if (win->flip_v)
+		val |= V_DIRECTION;
 	writel(val, &dc->win.win_opt);
 
+	x = win->x;
+	if (win->flip_h)
+		x += (win->w - 1) * (win->bpp / 8);
+	y = win->y;
+	if (win->flip_v)
+		y += win->h - 1;
+
 	writel((unsigned long)win->phys_addr, &dc->winbuf.start_addr);
-	writel(win->x, &dc->winbuf.addr_h_offset);
-	writel(win->y, &dc->winbuf.addr_v_offset);
+	writel(x, &dc->winbuf.addr_h_offset);
+	writel(y, &dc->winbuf.addr_v_offset);
 
 	writel(0xff00, &dc->win.blend_nokey);
 	writel(0xff00, &dc->win.blend_1win);
@@ -204,6 +216,8 @@ int setup_window(struct disp_ctl_win *win, struct fdt_disp_config *config)
 	win->out_y = 0;
 	win->out_w = config->width;
 	win->out_h = config->height;
+	win->flip_h = config->flip_h;
+	win->flip_v = config->flip_v;
 	win->phys_addr = config->frame_buffer;
 	win->stride = config->width * (1 << config->log2_bpp) / 8;
 	debug("%s: depth = %d\n", __func__, config->log2_bpp);
@@ -258,6 +272,8 @@ static int tegra_decode_panel(const void *blob, int node,
 
 	config->width = fdtdec_get_int(blob, node, "xres", -1);
 	config->height = fdtdec_get_int(blob, node, "yres", -1);
+	config->flip_h = fdtdec_get_bool(blob, node, "flip-horizontal");
+	config->flip_v = fdtdec_get_bool(blob, node, "flip-vertical");
 	config->pixel_clock = fdtdec_get_int(blob, node, "clock", 0);
 	if (!config->pixel_clock || config->width == -1 ||
 			config->height == -1) {
diff --git a/arch/arm/include/asm/arch-tegra20/display.h b/arch/arm/include/asm/arch-tegra20/display.h
index a04c84e..05c7bd5 100644
--- a/arch/arm/include/asm/arch-tegra20/display.h
+++ b/arch/arm/include/asm/arch-tegra20/display.h
@@ -25,6 +25,8 @@ struct disp_ctl_win {
 	unsigned	out_y;		/* Top edge of output window (row) */
 	unsigned	out_w;		/* Width of output window in pixels */
 	unsigned	out_h;		/* Height of output window in pixels */
+	unsigned	flip_h;		/* Horizontally flip the image */
+	unsigned	flip_v;		/* Vertically flip the image */
 };
 
 #define FDT_LCD_TIMINGS	4
@@ -53,6 +55,8 @@ struct fdt_disp_config {
 	int width;			/* width in pixels */
 	int height;			/* height in pixels */
 	int bpp;			/* number of bits per pixel */
+	unsigned flip_h;		/* Horizontally flip the image */
+	unsigned flip_v;		/* Vertically flip the image */
 
 	/*
 	 * log2 of number of bpp, in general, unless it bpp is 24 in which
-- 
2.1.1



More information about the U-Boot mailing list