public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/3] sunxi: display: Add overscan correction
@ 2015-08-05 15:17 Hans de Goede
  2015-08-05 15:17 ` [U-Boot] [PATCH 1/3] cfbconsole: Remove width argument from the logo functions Hans de Goede
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Hans de Goede @ 2015-08-05 15:17 UTC (permalink / raw)
  To: u-boot

Hi Anatolij, Ian,

This series sits on top of the composite video out series Ian has just
reviewed.

The first 2 patches are preparation patches adding support for stride !=
width to the cfbconsole code. Anatolij, can you either merge these 2
through your tree, or give us your ack for merging these through the
sunxi tree ?

Thanks & Regards,

Hans

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

* [U-Boot] [PATCH 1/3] cfbconsole: Remove width argument from the logo functions
  2015-08-05 15:17 [U-Boot] [PATCH 0/3] sunxi: display: Add overscan correction Hans de Goede
@ 2015-08-05 15:17 ` Hans de Goede
  2015-08-12 21:57   ` Anatolij Gustschin
  2015-08-05 15:17 ` [U-Boot] [PATCH 2/3] cfbconsole: Add support for stride != width Hans de Goede
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Hans de Goede @ 2015-08-05 15:17 UTC (permalink / raw)
  To: u-boot

The passed in width is always VIDEO_COLS. This is a preparation patch
for adding stride != width support to the cfbconsole code.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/video/cfb_console.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
index 7f2ddc1..d122ef7 100644
--- a/drivers/video/cfb_console.c
+++ b/drivers/video/cfb_console.c
@@ -1826,20 +1826,16 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
 static int video_logo_xpos;
 static int video_logo_ypos;
 
-static void plot_logo_or_black(void *screen, int width, int x, int y,	\
-			int black);
+static void plot_logo_or_black(void *screen, int x, int y, int black);
 
-static void logo_plot(void *screen, int width, int x, int y)
+static void logo_plot(void *screen, int x, int y)
 {
-	plot_logo_or_black(screen, width, x, y, 0);
+	plot_logo_or_black(screen, x, y, 0);
 }
 
 static void logo_black(void)
 {
-	plot_logo_or_black(video_fb_address, \
-			VIDEO_COLS, \
-			video_logo_xpos, \
-			video_logo_ypos, \
+	plot_logo_or_black(video_fb_address, video_logo_xpos, video_logo_ypos,
 			1);
 }
 
@@ -1858,11 +1854,11 @@ U_BOOT_CMD(
 	   " "
 	   );
 
-static void plot_logo_or_black(void *screen, int width, int x, int y, int black)
+static void plot_logo_or_black(void *screen, int x, int y, int black)
 {
 
 	int xcount, i;
-	int skip = (width - VIDEO_LOGO_WIDTH) * VIDEO_PIXEL_SIZE;
+	int skip = (VIDEO_COLS - VIDEO_LOGO_WIDTH) * VIDEO_PIXEL_SIZE;
 	int ycount = video_logo_height;
 	unsigned char r, g, b, *logo_red, *logo_blue, *logo_green;
 	unsigned char *source;
@@ -1880,7 +1876,7 @@ static void plot_logo_or_black(void *screen, int width, int x, int y, int black)
 		y = max(0, (int)(VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT + y + 1));
 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
 
-	dest = (unsigned char *)screen + (y * width  + x) * VIDEO_PIXEL_SIZE;
+	dest = (unsigned char *)screen + (y * VIDEO_COLS  + x) * VIDEO_PIXEL_SIZE;
 
 #ifdef CONFIG_VIDEO_BMP_LOGO
 	source = bmp_logo_bitmap;
@@ -2009,8 +2005,7 @@ static void *video_logo(void)
 	}
 #endif /* CONFIG_SPLASH_SCREEN */
 
-	logo_plot(video_fb_address, VIDEO_COLS,
-		  video_logo_xpos, video_logo_ypos);
+	logo_plot(video_fb_address, video_logo_xpos, video_logo_ypos);
 
 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
 	/*
-- 
2.4.3

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

* [U-Boot] [PATCH 2/3] cfbconsole: Add support for stride != width
  2015-08-05 15:17 [U-Boot] [PATCH 0/3] sunxi: display: Add overscan correction Hans de Goede
  2015-08-05 15:17 ` [U-Boot] [PATCH 1/3] cfbconsole: Remove width argument from the logo functions Hans de Goede
@ 2015-08-05 15:17 ` Hans de Goede
  2015-08-12 22:01   ` Anatolij Gustschin
  2015-08-05 15:17 ` [U-Boot] [PATCH 3/3] sunxi: display: Add overscan correction Hans de Goede
  2015-08-12 22:15 ` [U-Boot] [PATCH 0/3] " Anatolij Gustschin
  3 siblings, 1 reply; 12+ messages in thread
From: Hans de Goede @ 2015-08-05 15:17 UTC (permalink / raw)
  To: u-boot

cfbconsole currently assumes that the width and stride of the framebuffer
are the same, in most places where stride matters it uses a VIDEO_LINE_LEN
helper macro.

This commit changes the few places not using VIDEO_LINE_LEN to also use
VIDEO_LINE_LEN, and protects the default VIDEO_LINE_LEN with a #ifndef
guard, allowing the boards config.h to override and, and thus support
cases where stride != width.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/video/cfb_console.c | 72 +++++++++++++++++++++++----------------------
 1 file changed, 37 insertions(+), 35 deletions(-)

diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
index d122ef7..30e0317 100644
--- a/drivers/video/cfb_console.c
+++ b/drivers/video/cfb_console.c
@@ -283,9 +283,10 @@ void console_cursor(int state);
 
 #define VIDEO_COLS		VIDEO_VISIBLE_COLS
 #define VIDEO_ROWS		VIDEO_VISIBLE_ROWS
-#define VIDEO_SIZE		(VIDEO_ROWS*VIDEO_COLS*VIDEO_PIXEL_SIZE)
-#define VIDEO_PIX_BLOCKS	(VIDEO_SIZE >> 2)
-#define VIDEO_LINE_LEN		(VIDEO_COLS*VIDEO_PIXEL_SIZE)
+#ifndef VIDEO_LINE_LEN
+#define VIDEO_LINE_LEN		(VIDEO_COLS * VIDEO_PIXEL_SIZE)
+#endif
+#define VIDEO_SIZE		(VIDEO_ROWS * VIDEO_LINE_LEN)
 #define VIDEO_BURST_LEN		(VIDEO_COLS/8)
 
 #ifdef	CONFIG_VIDEO_LOGO
@@ -1306,7 +1307,7 @@ static int display_rle8_bitmap(struct bmp_image *img, int xoff, int yoff,
 	struct palette p[256];
 	struct bmp_color_table_entry cte;
 	int green_shift, red_off;
-	int limit = VIDEO_COLS * VIDEO_ROWS;
+	int limit = (VIDEO_LINE_LEN / VIDEO_PIXEL_SIZE) * VIDEO_ROWS;
 	int pixels = 0;
 
 	x = 0;
@@ -1314,7 +1315,8 @@ static int display_rle8_bitmap(struct bmp_image *img, int xoff, int yoff,
 	ncolors = __le32_to_cpu(img->header.colors_used);
 	bpp = VIDEO_PIXEL_SIZE;
 	fbp = (unsigned char *) ((unsigned int) video_fb_address +
-				 (((y + yoff) * VIDEO_COLS) + xoff) * bpp);
+				 (y + yoff) * VIDEO_LINE_LEN +
+				 xoff * bpp);
 
 	bm = (uchar *) img + __le32_to_cpu(img->header.data_offset);
 
@@ -1368,8 +1370,8 @@ static int display_rle8_bitmap(struct bmp_image *img, int xoff, int yoff,
 				y--;
 				fbp = (unsigned char *)
 					((unsigned int) video_fb_address +
-					 (((y + yoff) * VIDEO_COLS) +
-					  xoff) * bpp);
+					 (y + yoff) * VIDEO_LINE_LEN +
+					 xoff * bpp);
 				continue;
 			case 1:
 				/* end of bitmap data marker */
@@ -1381,8 +1383,8 @@ static int display_rle8_bitmap(struct bmp_image *img, int xoff, int yoff,
 				y -= bm[3];
 				fbp = (unsigned char *)
 					((unsigned int) video_fb_address +
-					 (((y + yoff) * VIDEO_COLS) +
-					  x + xoff) * bpp);
+					 (y + yoff) * VIDEO_LINE_LEN +
+					 xoff * bpp);
 				bm += 4;
 				break;
 			default:
@@ -1561,7 +1563,7 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
 
 	bmap = (uchar *) bmp + le32_to_cpu(bmp->header.data_offset);
 	fb = (uchar *) (video_fb_address +
-			((y + height - 1) * VIDEO_COLS * VIDEO_PIXEL_SIZE) +
+			((y + height - 1) * VIDEO_LINE_LEN) +
 			x * VIDEO_PIXEL_SIZE);
 
 #ifdef CONFIG_VIDEO_BMP_RLE8
@@ -1597,7 +1599,7 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
 							   cte.blue);
 				}
 				bmap += padded_line;
-				fb -= (VIDEO_VISIBLE_COLS + width) *
+				fb -= VIDEO_LINE_LEN + width *
 					VIDEO_PIXEL_SIZE;
 			}
 			break;
@@ -1628,8 +1630,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
 					*fb++ = *bmap++;
 				}
 				bmap += padded_line;
-				fb -= (VIDEO_VISIBLE_COLS + width) *
-							VIDEO_PIXEL_SIZE;
+				fb -= VIDEO_LINE_LEN + width *
+					VIDEO_PIXEL_SIZE;
 			}
 			break;
 		case GDF__8BIT_332RGB:
@@ -1642,8 +1644,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
 							 cte.blue);
 				}
 				bmap += padded_line;
-				fb -= (VIDEO_VISIBLE_COLS + width) *
-							VIDEO_PIXEL_SIZE;
+				fb -= VIDEO_LINE_LEN + width *
+					VIDEO_PIXEL_SIZE;
 			}
 			break;
 		case GDF_15BIT_555RGB:
@@ -1666,8 +1668,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
 #endif
 				}
 				bmap += padded_line;
-				fb -= (VIDEO_VISIBLE_COLS + width) *
-							VIDEO_PIXEL_SIZE;
+				fb -= VIDEO_LINE_LEN + width *
+					VIDEO_PIXEL_SIZE;
 			}
 			break;
 		case GDF_16BIT_565RGB:
@@ -1680,8 +1682,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
 							  cte.blue);
 				}
 				bmap += padded_line;
-				fb -= (VIDEO_VISIBLE_COLS + width) *
-							VIDEO_PIXEL_SIZE;
+				fb -= VIDEO_LINE_LEN + width *
+					VIDEO_PIXEL_SIZE;
 			}
 			break;
 		case GDF_32BIT_X888RGB:
@@ -1694,8 +1696,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
 							   cte.blue);
 				}
 				bmap += padded_line;
-				fb -= (VIDEO_VISIBLE_COLS + width) *
-							VIDEO_PIXEL_SIZE;
+				fb -= VIDEO_LINE_LEN + width *
+					VIDEO_PIXEL_SIZE;
 			}
 			break;
 		case GDF_24BIT_888RGB:
@@ -1708,8 +1710,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
 							  cte.blue);
 				}
 				bmap += padded_line;
-				fb -= (VIDEO_VISIBLE_COLS + width) *
-							VIDEO_PIXEL_SIZE;
+				fb -= VIDEO_LINE_LEN + width *
+					VIDEO_PIXEL_SIZE;
 			}
 			break;
 		}
@@ -1728,8 +1730,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
 					bmap += 3;
 				}
 				bmap += padded_line;
-				fb -= (VIDEO_VISIBLE_COLS + width) *
-							VIDEO_PIXEL_SIZE;
+				fb -= VIDEO_LINE_LEN + width *
+					VIDEO_PIXEL_SIZE;
 			}
 			break;
 		case GDF_15BIT_555RGB:
@@ -1751,8 +1753,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
 					bmap += 3;
 				}
 				bmap += padded_line;
-				fb -= (VIDEO_VISIBLE_COLS + width) *
-							VIDEO_PIXEL_SIZE;
+				fb -= VIDEO_LINE_LEN + width *
+					VIDEO_PIXEL_SIZE;
 			}
 			break;
 		case GDF_16BIT_565RGB:
@@ -1765,8 +1767,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
 					bmap += 3;
 				}
 				bmap += padded_line;
-				fb -= (VIDEO_VISIBLE_COLS + width) *
-							VIDEO_PIXEL_SIZE;
+				fb -= VIDEO_LINE_LEN + width *
+					VIDEO_PIXEL_SIZE;
 			}
 			break;
 		case GDF_32BIT_X888RGB:
@@ -1779,8 +1781,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
 					bmap += 3;
 				}
 				bmap += padded_line;
-				fb -= (VIDEO_VISIBLE_COLS + width) *
-							VIDEO_PIXEL_SIZE;
+				fb -= VIDEO_LINE_LEN + width *
+					VIDEO_PIXEL_SIZE;
 			}
 			break;
 		case GDF_24BIT_888RGB:
@@ -1793,8 +1795,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
 					bmap += 3;
 				}
 				bmap += padded_line;
-				fb -= (VIDEO_VISIBLE_COLS + width) *
-							VIDEO_PIXEL_SIZE;
+				fb -= VIDEO_LINE_LEN + width *
+					VIDEO_PIXEL_SIZE;
 			}
 			break;
 		default:
@@ -1858,7 +1860,7 @@ static void plot_logo_or_black(void *screen, int x, int y, int black)
 {
 
 	int xcount, i;
-	int skip = (VIDEO_COLS - VIDEO_LOGO_WIDTH) * VIDEO_PIXEL_SIZE;
+	int skip = VIDEO_LINE_LEN - VIDEO_LOGO_WIDTH * VIDEO_PIXEL_SIZE;
 	int ycount = video_logo_height;
 	unsigned char r, g, b, *logo_red, *logo_blue, *logo_green;
 	unsigned char *source;
@@ -1876,7 +1878,7 @@ static void plot_logo_or_black(void *screen, int x, int y, int black)
 		y = max(0, (int)(VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT + y + 1));
 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
 
-	dest = (unsigned char *)screen + (y * VIDEO_COLS  + x) * VIDEO_PIXEL_SIZE;
+	dest = (unsigned char *)screen + y * VIDEO_LINE_LEN + x * VIDEO_PIXEL_SIZE;
 
 #ifdef CONFIG_VIDEO_BMP_LOGO
 	source = bmp_logo_bitmap;
-- 
2.4.3

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

* [U-Boot] [PATCH 3/3] sunxi: display: Add overscan correction
  2015-08-05 15:17 [U-Boot] [PATCH 0/3] sunxi: display: Add overscan correction Hans de Goede
  2015-08-05 15:17 ` [U-Boot] [PATCH 1/3] cfbconsole: Remove width argument from the logo functions Hans de Goede
  2015-08-05 15:17 ` [U-Boot] [PATCH 2/3] cfbconsole: Add support for stride != width Hans de Goede
@ 2015-08-05 15:17 ` Hans de Goede
  2015-08-12 10:45   ` Ian Campbell
  2015-08-12 22:11   ` Anatolij Gustschin
  2015-08-12 22:15 ` [U-Boot] [PATCH 0/3] " Anatolij Gustschin
  3 siblings, 2 replies; 12+ messages in thread
From: Hans de Goede @ 2015-08-05 15:17 UTC (permalink / raw)
  To: u-boot

Add support for making the visual area of the framebuffer smaller and
drawing a black border around it. This is intended for use with
overscanning monitors (esp. with composite video out), to avoid part
of the picture being invisible.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 doc/README.video               |  5 +++++
 drivers/video/sunxi_display.c  | 48 +++++++++++++++++++++++++++++++++---------
 include/configs/sunxi-common.h |  1 +
 3 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/doc/README.video b/doc/README.video
index 4f7a4b5..62ac17b 100644
--- a/doc/README.video
+++ b/doc/README.video
@@ -68,6 +68,11 @@ The sunxi u-boot driver supports the following video-mode options:
     overrides the xres, yres and refresh from the video-mode env. variable.
  Defaults to edid=1.
 
+- overscan_x/overscan_y=<int> - Set x/y overscan value
+ This configures a black border on the left and right resp. top and bottom
+ to deal with overscanning displays. Defaults to overscan_x=32 and
+ overscan_y=20 for composite monitors, 0 for other monitors.
+
 For example to always use the hdmi connector, even if no cable is inserted,
 using edid info when available and otherwise initalizing it at 1024x768 at 60Hz,
 use: "setenv video-mode sunxi:1024x768-24 at 60,monitor=dvi,hpd=0,edid=1".
diff --git a/drivers/video/sunxi_display.c b/drivers/video/sunxi_display.c
index 1868185..1449e0d 100644
--- a/drivers/video/sunxi_display.c
+++ b/drivers/video/sunxi_display.c
@@ -19,6 +19,7 @@
 #include <fdtdec.h>
 #include <fdt_support.h>
 #include <i2c.h>
+#include <malloc.h>
 #include <video_fb.h>
 #include "videomodes.h"
 #include "hitachi_tx18d42vm_lcd.h"
@@ -51,6 +52,7 @@ struct sunxi_display {
 	GraphicDevice graphic_device;
 	enum sunxi_monitor monitor;
 	unsigned int depth;
+	unsigned int fb_addr;
 	unsigned int fb_size;
 } sunxi_display;
 
@@ -1297,9 +1299,10 @@ void *video_hw_init(void)
 #ifdef CONFIG_VIDEO_HDMI
 	int ret, hpd, hpd_delay, edid;
 #endif
+	int i, overscan_offset, overscan_x, overscan_y;
+	unsigned int fb_dma_addr;
 	char mon[16];
 	char *lcd_mode = CONFIG_VIDEO_LCD_MODE;
-	int i;
 
 	memset(&sunxi_display, 0, sizeof(struct sunxi_display));
 
@@ -1310,6 +1313,8 @@ void *video_hw_init(void)
 	hpd_delay = video_get_option_int(options, "hpd_delay", 500);
 	edid = video_get_option_int(options, "edid", 1);
 #endif
+	overscan_x = video_get_option_int(options, "overscan_x", -1);
+	overscan_y = video_get_option_int(options, "overscan_y", -1);
 	sunxi_display.monitor = sunxi_get_default_mon(true);
 	video_get_option_string(options, "monitor", mon, sizeof(mon),
 				sunxi_get_mon_desc(sunxi_display.monitor));
@@ -1386,8 +1391,20 @@ void *video_hw_init(void)
 		break;
 	}
 
+	/* Yes these defaults are quite high, overscan on composite sucks... */
+	if (overscan_x == -1)
+		overscan_x = sunxi_is_composite() ? 32 : 0;
+	if (overscan_y == -1)
+		overscan_y = sunxi_is_composite() ? 20 : 0;
+
 	sunxi_display.fb_size =
 		(mode->xres * mode->yres * 4 + 0xfff) & ~0xfff;
+	overscan_offset = (overscan_y * mode->xres + overscan_x) * 4;
+	/* We want to keep the fb_base for simplefb page aligned, where as
+	 * the sunxi dma engines will happily accept an unaligned address. */
+	if (overscan_offset)
+		sunxi_display.fb_size += 0x1000;
+
 	if (sunxi_display.fb_size > CONFIG_SUNXI_MAX_FB_SIZE) {
 		printf("Error need %dkB for fb, but only %dkB is reserved\n",
 		       sunxi_display.fb_size >> 10,
@@ -1395,25 +1412,37 @@ void *video_hw_init(void)
 		return NULL;
 	}
 
-	printf("Setting up a %dx%d%s %s console\n", mode->xres, mode->yres,
+	printf("Setting up a %dx%d%s %s console (overscan %dx%d)\n",
+	       mode->xres, mode->yres,
 	       (mode->vmode == FB_VMODE_INTERLACED) ? "i" : "",
-	       sunxi_get_mon_desc(sunxi_display.monitor));
+	       sunxi_get_mon_desc(sunxi_display.monitor),
+	       overscan_x, overscan_y);
 
 	gd->fb_base = gd->bd->bi_dram[0].start +
 		      gd->bd->bi_dram[0].size - sunxi_display.fb_size;
 	sunxi_engines_init();
-	sunxi_mode_set(mode, gd->fb_base - CONFIG_SYS_SDRAM_BASE);
+
+	fb_dma_addr = gd->fb_base - CONFIG_SYS_SDRAM_BASE;
+	sunxi_display.fb_addr = gd->fb_base;
+	if (overscan_offset) {
+		fb_dma_addr += 0x1000 - (overscan_offset & 0xfff);
+		sunxi_display.fb_addr += (overscan_offset + 0xfff) & ~0xfff;
+		memset((void *)gd->fb_base, 0, sunxi_display.fb_size);
+		flush_cache(gd->fb_base, sunxi_display.fb_size);
+	}
+	sunxi_mode_set(mode, fb_dma_addr);
 
 	/*
 	 * These are the only members of this structure that are used. All the
 	 * others are driver specific. There is nothing to decribe pitch or
 	 * stride, but we are lucky with our hw.
 	 */
-	graphic_device->frameAdrs = gd->fb_base;
+	graphic_device->frameAdrs = sunxi_display.fb_addr;
 	graphic_device->gdfIndex = GDF_32BIT_X888RGB;
 	graphic_device->gdfBytesPP = 4;
-	graphic_device->winSizeX = mode->xres;
-	graphic_device->winSizeY = mode->yres;
+	graphic_device->winSizeX = mode->xres - 2 * overscan_x;
+	graphic_device->winSizeY = mode->yres - 2 * overscan_y;
+	graphic_device->plnSizeX = mode->xres * graphic_device->gdfBytesPP;
 
 	return graphic_device;
 }
@@ -1490,10 +1519,9 @@ int sunxi_simplefb_setup(void *blob)
 		return ret;
 	}
 
-	ret = fdt_setup_simplefb_node(blob, offset, gd->fb_base,
+	ret = fdt_setup_simplefb_node(blob, offset, sunxi_display.fb_addr,
 			graphic_device->winSizeX, graphic_device->winSizeY,
-			graphic_device->winSizeX * graphic_device->gdfBytesPP,
-			"x8r8g8b8");
+			graphic_device->plnSizeX, "x8r8g8b8");
 	if (ret)
 		eprintf("Cannot setup simplefb: Error setting properties\n");
 
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index a2cbcf5..83b6556 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -302,6 +302,7 @@ extern int soft_i2c_gpio_scl;
 #define CONFIG_VIDEO_LOGO
 #define CONFIG_VIDEO_STD_TIMINGS
 #define CONFIG_I2C_EDID
+#define VIDEO_LINE_LEN (pGD->plnSizeX)
 
 /* allow both serial and cfb console. */
 #define CONFIG_CONSOLE_MUX
-- 
2.4.3

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

* [U-Boot] [PATCH 3/3] sunxi: display: Add overscan correction
  2015-08-05 15:17 ` [U-Boot] [PATCH 3/3] sunxi: display: Add overscan correction Hans de Goede
@ 2015-08-12 10:45   ` Ian Campbell
  2015-08-12 12:44     ` Hans de Goede
  2015-08-12 16:42     ` Hans de Goede
  2015-08-12 22:11   ` Anatolij Gustschin
  1 sibling, 2 replies; 12+ messages in thread
From: Ian Campbell @ 2015-08-12 10:45 UTC (permalink / raw)
  To: u-boot

On Wed, 2015-08-05 at 17:17 +0200, Hans de Goede wrote:
>  > 	> sunxi_display.fb_size =
>  > 	> 	> (mode->xres * mode->yres * 4 + 0xfff) & ~0xfff;
> +> 	> overscan_offset = (overscan_y * mode->xres + overscan_x) * 4;
> +> 	> /* We want to keep the fb_base for simplefb page aligned, where as
> +> 	>  * the sunxi dma engines will happily accept an unaligned address. */
> +> 	> if (overscan_offset)
> +> 	> 	> sunxi_display.fb_size += 0x1000;

Why plus 4K regardless of the magnitude of overscan_offset? What if it was
0x1004?

Also, what's the link between fb_base's alignment and fb_size which is
implied by the comment?

>  > 	> gd->fb_base = gd->bd->bi_dram[0].start +
>  > 	> 	>       gd->bd->bi_dram[0].size - sunxi_display.fb_size;
>  > 	> sunxi_engines_init();
> -> 	> sunxi_mode_set(mode, gd->fb_base - CONFIG_SYS_SDRAM_BASE);
> +
> +> 	> fb_dma_addr = gd->fb_base - CONFIG_SYS_SDRAM_BASE;
> +> 	> sunxi_display.fb_addr = gd->fb_base;
> +> 	> if (overscan_offset) {
> +> 	> 	> fb_dma_addr += 0x1000 - (overscan_offset & 0xfff);
> +> 	> 	> sunxi_display.fb_addr += (overscan_offset + 0xfff) & ~0xfff;
> +> 	> 	> memset((void *)gd->fb_base, 0, sunxi_display.fb_size);
> +> 	> 	> flush_cache(gd->fb_base, sunxi_display.fb_size);
> +> 	> }

Hrm, I think this starts to answer, but I'm still not sure I follow, sorry.

> +	sunxi_mode_set(mode, fb_dma_addr);
>  
>  	/*
>  > 	>  * These are the only members of this structure that are used. All the
>  > 	>  * others are driver specific. There is nothing to decribe pitch or


Pre-existing typo "describe".

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

* [U-Boot] [PATCH 3/3] sunxi: display: Add overscan correction
  2015-08-12 10:45   ` Ian Campbell
@ 2015-08-12 12:44     ` Hans de Goede
  2015-08-12 16:18       ` Ian Campbell
  2015-08-12 16:42     ` Hans de Goede
  1 sibling, 1 reply; 12+ messages in thread
From: Hans de Goede @ 2015-08-12 12:44 UTC (permalink / raw)
  To: u-boot

Hi,

On 12-08-15 12:45, Ian Campbell wrote:
> On Wed, 2015-08-05 at 17:17 +0200, Hans de Goede wrote:
>>   > 	> sunxi_display.fb_size =
>>   > 	> 	> (mode->xres * mode->yres * 4 + 0xfff) & ~0xfff;
>> +> 	> overscan_offset = (overscan_y * mode->xres + overscan_x) * 4;
>> +> 	> /* We want to keep the fb_base for simplefb page aligned, where as
>> +> 	>  * the sunxi dma engines will happily accept an unaligned address. */
>> +> 	> if (overscan_offset)
>> +> 	> 	> sunxi_display.fb_size += 0x1000;
>
> Why plus 4K regardless of the magnitude of overscan_offset? What if it was
> 0x1004?

If overscan offset is 0x1004 then we make the simplefb start point to
fb_base + 0x2000:

sunxi_display.fb_addr = gd->fb_base
sunxi_display.fb_addr += (overscan_offset + 0xfff) & ~0xfff

And make the dma engine start at fb_base + 0xffc:

fb_dma_addr = gd->fb_base
fb_dma_addr += 0x1000 - (overscan_offset & 0xfff)

Notice how we make the dma_engine start at less then 0x1000 offset of
fb_base, so making fb_size 0x1000 larger is enough.

Basically to page-align the start of the simplefb / sunxi_display.fb_addr
we only need a single page, the rest we can get by offsetting
sunxi_display.fb_addr from fb_base by a multiple of the page size.

> Also, what's the link between fb_base's alignment and fb_size which is
> implied by the comment?

To align we need a page extra size as the dma-engine may start at
an offset of up-to a page-size from gd->fb_base and the dma-engine
will dma a full framebuffer size, including the black borders.

>
>>   > 	> gd->fb_base = gd->bd->bi_dram[0].start +
>>   > 	> 	>       gd->bd->bi_dram[0].size - sunxi_display.fb_size;
>>   > 	> sunxi_engines_init();
>> -> 	> sunxi_mode_set(mode, gd->fb_base - CONFIG_SYS_SDRAM_BASE);
>> +
>> +> 	> fb_dma_addr = gd->fb_base - CONFIG_SYS_SDRAM_BASE;
>> +> 	> sunxi_display.fb_addr = gd->fb_base;
>> +> 	> if (overscan_offset) {
>> +> 	> 	> fb_dma_addr += 0x1000 - (overscan_offset & 0xfff);
>> +> 	> 	> sunxi_display.fb_addr += (overscan_offset + 0xfff) & ~0xfff;
>> +> 	> 	> memset((void *)gd->fb_base, 0, sunxi_display.fb_size);
>> +> 	> 	> flush_cache(gd->fb_base, sunxi_display.fb_size);
>> +> 	> }
>
> Hrm, I think this starts to answer, but I'm still not sure I follow, sorry.

Correct this is the answer, sorry for the tricky maths, this is the best
solution without wasting a ton of memory with large overscans.

I hope the above explanation helps, if not keep asking.

>> +	sunxi_mode_set(mode, fb_dma_addr);
>>
>>   	/*
>>   > 	>  * These are the only members of this structure that are used. All the
>>   > 	>  * others are driver specific. There is nothing to decribe pitch or
>
>
> Pre-existing typo "describe".

Will fix,

Regards,

Hans

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

* [U-Boot] [PATCH 3/3] sunxi: display: Add overscan correction
  2015-08-12 12:44     ` Hans de Goede
@ 2015-08-12 16:18       ` Ian Campbell
  0 siblings, 0 replies; 12+ messages in thread
From: Ian Campbell @ 2015-08-12 16:18 UTC (permalink / raw)
  To: u-boot

On Wed, 2015-08-12 at 14:44 +0200, Hans de Goede wrote:
> 
[...big snip...]

> I hope the above explanation helps, if not keep asking.

It very much did, thanks.

Acked-by: Ian Campbell <ijc@hellion.org.uk>

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

* [U-Boot] [PATCH 3/3] sunxi: display: Add overscan correction
  2015-08-12 10:45   ` Ian Campbell
  2015-08-12 12:44     ` Hans de Goede
@ 2015-08-12 16:42     ` Hans de Goede
  1 sibling, 0 replies; 12+ messages in thread
From: Hans de Goede @ 2015-08-12 16:42 UTC (permalink / raw)
  To: u-boot

Hi,

On 08/12/2015 12:45 PM, Ian Campbell wrote:

<snip>

>> +	sunxi_mode_set(mode, fb_dma_addr);
>>
>>   	/*
>>   > 	>  * These are the only members of this structure that are used. All the
>>   > 	>  * others are driver specific. There is nothing to decribe pitch or
>
>
> Pre-existing typo "describe".

Actually part of the overscan patch series is adding support for pitch != width
to the cfbconsole code, so that comment is no longer accurate, I've squashed a fix
for the comment into the patch adding overscan support to drivers/video/sunxi_display.c

Regards,

Hans

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

* [U-Boot] [PATCH 1/3] cfbconsole: Remove width argument from the logo functions
  2015-08-05 15:17 ` [U-Boot] [PATCH 1/3] cfbconsole: Remove width argument from the logo functions Hans de Goede
@ 2015-08-12 21:57   ` Anatolij Gustschin
  0 siblings, 0 replies; 12+ messages in thread
From: Anatolij Gustschin @ 2015-08-12 21:57 UTC (permalink / raw)
  To: u-boot

On Wed,  5 Aug 2015 17:17:29 +0200
Hans de Goede <hdegoede@redhat.com> wrote:

> The passed in width is always VIDEO_COLS. This is a preparation patch
> for adding stride != width support to the cfbconsole code.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Acked-by: Anatolij Gustschin <agust@denx.de>

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

* [U-Boot] [PATCH 2/3] cfbconsole: Add support for stride != width
  2015-08-05 15:17 ` [U-Boot] [PATCH 2/3] cfbconsole: Add support for stride != width Hans de Goede
@ 2015-08-12 22:01   ` Anatolij Gustschin
  0 siblings, 0 replies; 12+ messages in thread
From: Anatolij Gustschin @ 2015-08-12 22:01 UTC (permalink / raw)
  To: u-boot

On Wed,  5 Aug 2015 17:17:30 +0200
Hans de Goede <hdegoede@redhat.com> wrote:

> cfbconsole currently assumes that the width and stride of the framebuffer
> are the same, in most places where stride matters it uses a VIDEO_LINE_LEN
> helper macro.
> 
> This commit changes the few places not using VIDEO_LINE_LEN to also use
> VIDEO_LINE_LEN, and protects the default VIDEO_LINE_LEN with a #ifndef
> guard, allowing the boards config.h to override and, and thus support
> cases where stride != width.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Acked-by: Anatolij Gustschin <agust@denx.de>

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

* [U-Boot] [PATCH 3/3] sunxi: display: Add overscan correction
  2015-08-05 15:17 ` [U-Boot] [PATCH 3/3] sunxi: display: Add overscan correction Hans de Goede
  2015-08-12 10:45   ` Ian Campbell
@ 2015-08-12 22:11   ` Anatolij Gustschin
  1 sibling, 0 replies; 12+ messages in thread
From: Anatolij Gustschin @ 2015-08-12 22:11 UTC (permalink / raw)
  To: u-boot

On Wed,  5 Aug 2015 17:17:31 +0200
Hans de Goede <hdegoede@redhat.com> wrote:

> Add support for making the visual area of the framebuffer smaller and
> drawing a black border around it. This is intended for use with
> overscanning monitors (esp. with composite video out), to avoid part
> of the picture being invisible.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Acked-by: Anatolij Gustschin <agust@denx.de>

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

* [U-Boot] [PATCH 0/3] sunxi: display: Add overscan correction
  2015-08-05 15:17 [U-Boot] [PATCH 0/3] sunxi: display: Add overscan correction Hans de Goede
                   ` (2 preceding siblings ...)
  2015-08-05 15:17 ` [U-Boot] [PATCH 3/3] sunxi: display: Add overscan correction Hans de Goede
@ 2015-08-12 22:15 ` Anatolij Gustschin
  3 siblings, 0 replies; 12+ messages in thread
From: Anatolij Gustschin @ 2015-08-12 22:15 UTC (permalink / raw)
  To: u-boot

Hi Hans,

On Wed,  5 Aug 2015 17:17:28 +0200
Hans de Goede <hdegoede@redhat.com> wrote:
... 
> The first 2 patches are preparation patches adding support for stride !=
> width to the cfbconsole code. Anatolij, can you either merge these 2
> through your tree, or give us your ack for merging these through the
> sunxi tree ?

I've replied with acks, please merge through the sunxi tree.

Thanks,

Anatolij

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

end of thread, other threads:[~2015-08-12 22:15 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-05 15:17 [U-Boot] [PATCH 0/3] sunxi: display: Add overscan correction Hans de Goede
2015-08-05 15:17 ` [U-Boot] [PATCH 1/3] cfbconsole: Remove width argument from the logo functions Hans de Goede
2015-08-12 21:57   ` Anatolij Gustschin
2015-08-05 15:17 ` [U-Boot] [PATCH 2/3] cfbconsole: Add support for stride != width Hans de Goede
2015-08-12 22:01   ` Anatolij Gustschin
2015-08-05 15:17 ` [U-Boot] [PATCH 3/3] sunxi: display: Add overscan correction Hans de Goede
2015-08-12 10:45   ` Ian Campbell
2015-08-12 12:44     ` Hans de Goede
2015-08-12 16:18       ` Ian Campbell
2015-08-12 16:42     ` Hans de Goede
2015-08-12 22:11   ` Anatolij Gustschin
2015-08-12 22:15 ` [U-Boot] [PATCH 0/3] " Anatolij Gustschin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox