Patchwork [U-Boot,10/11] powerpc/ppc4xx: Consider gdsys FPGA OSD size

login
register
mail settings
Submitter Dirk Eibach
Date April 22, 2013, 11:16 a.m.
Message ID <1366629372-32022-11-git-send-email-eibach@gdsys.de>
Download mbox | patch
Permalink /patch/238460/
State Superseded
Delegated to: Stefan Roese
Headers show

Comments

Dirk Eibach - April 22, 2013, 11:16 a.m.
OSD size was constant 32x16 characters.
Now the size is set as announced by the FPGA.

Signed-off-by: Dirk Eibach <eibach@gdsys.de>
---
 board/gdsys/common/osd.c |   35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)

Patch

diff --git a/board/gdsys/common/osd.c b/board/gdsys/common/osd.c
index 81c8136..d557a2e 100644
--- a/board/gdsys/common/osd.c
+++ b/board/gdsys/common/osd.c
@@ -22,6 +22,7 @@ 
  */
 
 #include <common.h>
+#include <malloc.h>
 #include "bb_i2c.h"
 #include <asm/io.h>
 
@@ -42,10 +43,6 @@ 
 
 #define PIXCLK_640_480_60 25180000
 
-#define BASE_WIDTH 32
-#define BASE_HEIGHT 16
-#define BUFSIZE (BASE_WIDTH * BASE_HEIGHT)
-
 enum {
 	CH7301_CM = 0x1c,		/* Clock Mode Register */
 	CH7301_IC = 0x1d,		/* Input Clock Register */
@@ -67,6 +64,11 @@  enum {
 	CH7301_DSP = 0x56,		/* DVI Sync polarity Register */
 };
 
+unsigned int base_width;
+unsigned int base_height;
+size_t bufsize;
+u16 *buf;
+
 unsigned int max_osd_screen = CONFIG_SYS_OSD_SCREENS - 1;
 
 #if defined(CONFIG_SYS_ICS8N3QV01) || defined(CONFIG_SYS_SIL1178)
@@ -264,7 +266,7 @@  static int osd_write_videomem(unsigned screen, unsigned offset,
 	unsigned int k;
 
 	for (k = 0; k < charcount; ++k) {
-		if (offset + k >= BUFSIZE)
+		if (offset + k >= bufsize)
 			return -1;
 		fpga_set_reg(screen, REG(videomem) + sizeof(u16) * (offset + k),
 			     data[k]);
@@ -284,7 +286,6 @@  static int osd_print(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		unsigned len;
 		u8 color;
 		unsigned int k;
-		u16 buf[BUFSIZE];
 		char *text;
 		int res;
 
@@ -298,12 +299,12 @@  static int osd_print(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		color = simple_strtoul(argv[3], NULL, 16);
 		text = argv[4];
 		charcount = strlen(text);
-		len = (charcount > BUFSIZE) ? BUFSIZE : charcount;
+		len = (charcount > bufsize) ? bufsize : charcount;
 
 		for (k = 0; k < len; ++k)
 			buf[k] = (text[k] << 8) | color;
 
-		res = osd_write_videomem(screen, y * BASE_WIDTH + x, buf, len);
+		res = osd_write_videomem(screen, y * base_width + x, buf, len);
 		if (res < 0)
 			return res;
 	}
@@ -315,15 +316,17 @@  int osd_probe(unsigned screen)
 {
 	u16 version = fpga_get_reg(screen, REG(osd.version));
 	u16 features = fpga_get_reg(screen, REG(osd.features));
-	unsigned width;
-	unsigned height;
 	u8 value;
 
-	width = ((features & 0x3f00) >> 8) + 1;
-	height = (features & 0x001f) + 1;
+	base_width = ((features & 0x3f00) >> 8) + 1;
+	base_height = (features & 0x001f) + 1;
+	bufsize = base_width * base_height;
+	buf = malloc(sizeof(u16) * bufsize);
+	if (!buf)
+		return -1;
 
 	printf("OSD%d:  Digital-OSD version %01d.%02d, %d" "x%d characters\n",
-		screen, version/100, version%100, width, height);
+		screen, version/100, version%100, base_width, base_height);
 
 #ifdef CONFIG_SYS_CH7301
 	value = bb_i2c_reg_read(screen, CH7301_I2C_ADDR, CH7301_DID);
@@ -386,7 +389,7 @@  int osd_write(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		unsigned x;
 		unsigned y;
 		unsigned k;
-		u16 buffer[BASE_WIDTH];
+		u16 buffer[base_width];
 		char *rp;
 		u16 *wp = buffer;
 		unsigned count = (argc > 4) ?
@@ -411,13 +414,13 @@  int osd_write(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 			rp += 4;
 			wp++;
-			if (wp - buffer > BASE_WIDTH)
+			if (wp - buffer > base_width)
 				break;
 		}
 
 		for (k = 0; k < count; ++k) {
 			unsigned offset =
-				y * BASE_WIDTH + x + k * (wp - buffer);
+				y * base_width + x + k * (wp - buffer);
 			osd_write_videomem(screen, offset, buffer,
 				wp - buffer);
 		}