diff mbox

[U-Boot,v1,16/18] board: gdsys: Add osdsize command

Message ID 1446029199-11704-17-git-send-email-dirk.eibach@gdsys.cc
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Dirk Eibach Oct. 28, 2015, 10:46 a.m. UTC
From: Dirk Eibach <dirk.eibach@gdsys.cc>

osdsize adjusts the gdsys IHS osd dimensions in characters.

Signed-off-by: Dirk Eibach <dirk.eibach@gdsys.cc>
---

 board/gdsys/common/osd.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

Comments

Tom Rini Nov. 13, 2015, 1:30 a.m. UTC | #1
On Wed, Oct 28, 2015 at 11:46:37AM +0100, Dirk Eibach wrote:

> From: Dirk Eibach <dirk.eibach@gdsys.cc>
> 
> osdsize adjusts the gdsys IHS osd dimensions in characters.
> 
> Signed-off-by: Dirk Eibach <dirk.eibach@gdsys.cc>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/board/gdsys/common/osd.c b/board/gdsys/common/osd.c
index b288df8..a774bec 100644
--- a/board/gdsys/common/osd.c
+++ b/board/gdsys/common/osd.c
@@ -27,6 +27,8 @@ 
 #define DP501_I2C_ADDR 0x08
 
 #define PIXCLK_640_480_60 25180000
+#define MAX_X_CHARS 53
+#define MAX_Y_CHARS 26
 
 #ifdef CONFIG_SYS_OSD_DH
 #define MAX_OSD_SCREEN 8
@@ -464,6 +466,35 @@  int osd_write(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return 0;
 }
 
+int osd_size(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	unsigned screen;
+	unsigned x;
+	unsigned y;
+
+	if (argc < 3) {
+		cmd_usage(cmdtp);
+		return 1;
+	}
+
+	x = simple_strtoul(argv[1], NULL, 16);
+	y = simple_strtoul(argv[2], NULL, 16);
+
+	if (!x || (x > 64) || (x > MAX_X_CHARS) ||
+	    !y || (y > 32) || (y > MAX_Y_CHARS)) {
+		cmd_usage(cmdtp);
+		return 1;
+	}
+
+	for (screen = 0; screen < MAX_OSD_SCREEN; ++screen) {
+		OSD_SET_REG(screen, xy_size, ((x - 1) << 8) | (y - 1));
+		OSD_SET_REG(screen, x_pos, 32767 * (640 - 12 * x) / 65535);
+		OSD_SET_REG(screen, y_pos, 32767 * (480 - 18 * y) / 65535);
+	}
+
+	return 0;
+}
+
 U_BOOT_CMD(
 	osdw, 5, 0, osd_write,
 	"write 16-bit hex encoded buffer to osd memory",
@@ -475,3 +506,10 @@  U_BOOT_CMD(
 	"write ASCII buffer to osd memory",
 	"pos_x pos_y color text\n"
 );
+
+U_BOOT_CMD(
+	osdsize, 3, 0, osd_size,
+	"set OSD XY size in characters",
+	"size_x(max. " __stringify(MAX_X_CHARS)
+	") size_y(max. " __stringify(MAX_Y_CHARS) ")\n"
+);