Add command to query information from and write text to on-screen
display (OSD) devices.
Signed-off-by: Mario Six
---
v1 -> v2:
* Added explanation for what a OSD is
* Added explanation of the color parameter
* Moved GDSYS_LEGACY_OSD_CMDS to gdsys Kconfig
---
board/gdsys/mpc8308/Kconfig | 11 ++
cmd/Kconfig | 8 +
cmd/Makefile| 1 +
cmd/osd.c | 378
4 files changed, 398 insertions(+)
create mode 100644 cmd/osd.c
diff --git a/board/gdsys/mpc8308/Kconfig b/board/gdsys/mpc8308/Kconfig
index cb29c25c650..9d99f686923 100644
--- a/board/gdsys/mpc8308/Kconfig
+++ b/board/gdsys/mpc8308/Kconfig
@@ -1,3 +1,9 @@
+config GDSYS_LEGACY_OSD_CMDS
+ bool
+ help
+ Use the 'osdw', 'osdp', and 'osdsize' legacy commands required by
+ gdsys devices.
+
if TARGET_HRCON
config SYS_BOARD
@@ -9,6 +15,9 @@ config SYS_VENDOR
config SYS_CONFIG_NAME
default "hrcon"
+config GDSYS_LEGACY_OSD_CMDS
+ default y
+
endif
if TARGET_STRIDER
@@ -22,6 +31,8 @@ config SYS_VENDOR
config SYS_CONFIG_NAME
default "strider"
+config GDSYS_LEGACY_OSD_CMDS
+ default y
endif
config CMD_IOLOOP
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 38406fcfdac..898839c8d75 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -865,6 +865,14 @@ config CMD_ONENAND
and erasing blocks. It allso provides a way to show and change
bad blocks, and test the device.
+config CMD_OSD
+ bool "osd"
+ help
+ Enable the 'osd' command which allows to query information from and
+ write text data to a on-screen display (OSD) device; a virtual device
+ associated with a display capable of displaying a text overlay on the
+ display it's associated with..
+
config CMD_PART
bool "part"
select PARTITION_UUIDS
diff --git a/cmd/Makefile b/cmd/Makefile
index 0d7322ee0a4..4aeab8e5c77 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -62,6 +62,7 @@ obj-$(CONFIG_CMD_FUSE) += fuse.o
obj-$(CONFIG_CMD_GETTIME) += gettime.o
obj-$(CONFIG_CMD_GPIO) += gpio.o
obj-$(CONFIG_CMD_HVC) += smccc.o
+obj-$(CONFIG_CMD_OSD) += osd.o
obj-$(CONFIG_CMD_I2C) += i2c.o
obj-$(CONFIG_CMD_IOTRACE) += iotrace.o
obj-$(CONFIG_CMD_HASH) += hash.o
diff --git a/cmd/osd.c b/cmd/osd.c
new file mode 100644
index 000..8afbe85475b
--- /dev/null
+++ b/cmd/osd.c
@@ -0,0 +1,378 @@
+/*
+ * (C) Copyright 2017
+ * Mario Six, Guntermann & Drunck GmbH, mario@gdsys.cc
+ *
+ * based on the gdsys osd driver, which is
+ *
+ * (C) Copyright 2010
+ * Dirk Eibach, Guntermann & Drunck GmbH, eib...@gdsys.de
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include
+#include
+#include
+#include
+
+#ifndef CONFIG_GDSYS_LEGACY_OSD_CMDS
+static struct udevice *osd_cur;
+#endif
+
+#ifdef CONFIG_GDSYS_LEGACY_OSD_CMDS
+int do_osd_write(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ struct udevice *dev;
+ uint x, y;
+ uint count;
+ char *hexstr;
+ u8 *buffer;
+ size_t buflen;
+
+ if (argc < 4 || (strlen(argv[3])) % 2) {
+ cmd_usage(cmdtp);
+ return CMD_RET_FAILURE;
+ }
+
+ x = simple_strtoul(argv[1], NULL, 16);
+ y = simple_strtoul(argv[2], NULL, 16);
+ hexstr = argv[3];
+ count = (argc > 4) ? simple_strtoul(argv[4], NULL, 16) : 1;
+
+ buflen = strlen(hexstr) / 2;
+ buffer = malloc(buflen);
+ hex2bin(buffer, hexstr, buflen);
+
+ for (uclass_first_device(UCLASS_VIDEO_OSD, &dev);
+dev;
+uclass_next_device(&dev)) {
+ int res;
+
+ res = video_osd_set_mem(dev, x, y, buffer, buflen, count);
+
+ if (res) {
+ printf("Could not write to video mem on osd %s\n",
+ dev->name);
+ return CMD_RET_FAILURE;
+ }
+ }
+
+ free(buffer);
+
+ return CMD_RET_SUCCESS;
+}
+
+static int do_osd_print(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+ struct udevice *dev;
+ uint x, y;
+ u8 color;
+ char *text;
+
+ if (argc < 5) {
+ cmd_usage(cmdtp);
+ return CMD_RET_FAILURE;
+ }
+
+ x = simple_strtoul(argv[1], NULL, 16);
+ y = simple_strtoul(argv[2], NULL, 16);
+ color = simple_strtoul(argv[3], NULL, 16);
+ text = argv[4];
+
+ for (uclass_first_device(UCLASS_VIDEO_OSD, &dev);
+dev;
+uclass_next_device(&dev)) {
+ int res;
+
+ res = video_osd_print(dev, x, y, color, text);
+ if (res) {
+ printf("Could not print string to osd %s\n", dev->name);
+ return CMD_RET_FAILURE;
+ }
+ }
+
+ return CMD_RET_SUCCESS;
+}
+
+int do_osd_size(cmd_tbl_t *cmdtp, int fl