Skip to contentSkip to conversation

drivers: Add OSD uclass

PATCH New Mario Six 2 participants 7 messages Sep 27, 2018 Framebuffer layer

lore
Share & tools
lore

Mario Six

author
#0 lore raw

PATCH v4 1/6 drivers: Add OSD uclass

Some devices offer a text-based OSD (on-screen display) that can be programmatically controlled (i.e. text displayed on).

Add a uclass to support such devices.

---

v3 -> v4:
None

v2 -> v3:
None

v1 -> v2:
* Use singular case for UCLASS_VIDEO_OSD description
* Expanded description of video_osd_set_mem with example
* Replaced all left-over mentions of pixels with text
* Renamed x and y parameters to col and row
* Expaneded description of color parameter
* Added general description of the OSD uclass
* Expanded description of video_osd_info

---
 drivers/video/Kconfig            |   8 ++
 drivers/video/Makefile           |   1 +
 drivers/video/video_osd-uclass.c |  45 +++++++++
 include/dm/uclass-id.h           |   1 +
 include/video_osd.h              | 192 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 247 insertions(+)
 create mode 100644 drivers/video/video_osd-uclass.c
 create mode 100644 include/video_osd.h
drivers/video/Kconfig +8 -0
index ed0b21f2a72..4e627a315b9 100644
@@ -683,4 +683,12 @@ config VIDEO_DT_SIMPLEFB
 	  The video output is initialized by U-Boot, and kept by the
 	  kernel.
 
+config OSD
+	bool "Enable OSD support"
+	depends on DM
+	default n
+	help
+	   This supports drivers that provide a OSD (on-screen display), which
+	   is a (usually text-oriented) graphics buffer to show information on
+	   a display.
 endmenu
drivers/video/Makefile +1 -0
index 0f41a23193a..9cec564373e 100644
@@ -31,6 +31,7 @@ obj-$(CONFIG_FSL_DIU_FB) += fsl_diu_fb.o videomodes.o
 obj-$(CONFIG_LD9040) += ld9040.o
 obj-$(CONFIG_LG4573) += lg4573.o
 obj-$(CONFIG_LOGICORE_DP_TX) += logicore_dp_tx.o
+obj-$(CONFIG_OSD) += video_osd-uclass.o
 obj-$(CONFIG_PXA_LCD) += pxa_lcd.o
 obj-$(CONFIG_S6E8AX0) += s6e8ax0.o
 obj-$(CONFIG_SCF0403_LCD) += scf0403_lcd.o
drivers/video/video_osd-uclass.c new file +45 -0

45 lines not on this page · raw message

include/dm/uclass-id.h +1 -0
index 7027ea076db..15abdce5e52 100644
@@ -92,6 +92,7 @@ enum uclass_id {
 	UCLASS_VIDEO,		/* Video or LCD device */
 	UCLASS_VIDEO_BRIDGE,	/* Video bridge, e.g. DisplayPort to LVDS */
 	UCLASS_VIDEO_CONSOLE,	/* Text console driver for video device */
+	UCLASS_VIDEO_OSD,	/* On-screen display */
 	UCLASS_WDT,		/* Watchdot Timer driver */
 
 	UCLASS_COUNT,
include/video_osd.h new file +192 -0

192 lines not on this page · raw message

--
2.11.0

author
#1 lore raw

PATCH v4 2/6 video_osd: Add ihs_video_out driver

Add a driver for IHS OSDs on IHS FPGAs.

---

v3 -> v4:
None

v2 -> v3:
* Replace dev_read_prop with dev_read_string
* Fixed binding file
* Improved error handling and reporting
* Use static const variables instead of #defines
* Use named constant for some magic values
* Improved documentation

v1 -> v2:
* Renamed x and y parameters to col and row
* Removed duplicate IHS_VIDEO_OUT definition
* Switched error return code of ihs_video_out_set_mem to E2BIG
* Dropped blank lines between dev_read_u32_default calls
* Documented members of ihs_video_out_priv
* Turned printfs into debugs
* Don't display OSD until something has been written to it
* Made the code a bit more readable
* Added binding file
* Expanded documentation and help
* Switched to display_enable
* Switched to regmap usage (instead of fpgamap uclass)
* Renamed 'dp_tx' property to 'video_tx'

---
 .../video/osd/gdsys,ihs_video_out.txt              |  23 ++
 drivers/video/Kconfig                              |   9 +
 drivers/video/Makefile                             |   1 +
 drivers/video/ihs_video_out.c                      | 341 +++++++++++++++++++++
 4 files changed, 374 insertions(+)
 create mode 100644 doc/device-tree-bindings/video/osd/gdsys,ihs_video_out.txt
 create mode 100644 drivers/video/ihs_video_out.c
doc/device-tree-bindings/video/osd/gdsys,ihs_video_out.txt new file +23 -0
new file mode 100644
index 00000000000..d7aacc827ed
@@ -0,0 +1,23 @@
+* Guntermann & Drunck Integrated Hardware Systems OSD
+
+Required properties:
+- compatible: "gdsys,ihs_video_out"
+- reg: A combination of three register spaces:
+       - Register base for the video registers
+       - Register base for the OSD registers
+       - Address of the OSD video memory
+- mode: The initial resolution and frequency: "1024_768_60", "720_400_70", or
+        "640_480_70"
+- clk_gen: phandle to the pixel clock generator
+- dp_tx: phandle to the display associated with the OSD
+
+Example:
+
+fpga0_video0 {
+	compatible = "gdsys,ihs_video_out";
+	reg = <0x100 0x40
+	       0x180 0x20
+	       0x1000 0x1000>;
+	dp_tx = <&fpga0_dp_video0>;
+	clk_gen = <&fpga0_video0_clkgen>;
+};
drivers/video/Kconfig +9 -0
index 4e627a315b9..1e2cbe7afcf 100644
@@ -691,4 +691,13 @@ config OSD
 	   This supports drivers that provide a OSD (on-screen display), which
 	   is a (usually text-oriented) graphics buffer to show information on
 	   a display.
+
+config IHS_VIDEO_OUT
+	bool "Enable IHS video out driver"
+	depends on OSD
+	help
+	  Enable support for the gdsys Integrated Hardware Systems (IHS) video
+	  out On-screen Display (OSD) used on gdsys FPGAs to control dynamic
+	  textual overlays of the display outputs.
+
 endmenu
drivers/video/Makefile +1 -0
index 9cec564373e..290747ba94f 100644
@@ -28,6 +28,7 @@ obj-$(CONFIG_ATMEL_LCD) += atmel_lcdfb.o
 obj-$(CONFIG_CFB_CONSOLE) += cfb_console.o
 obj-$(CONFIG_FORMIKE) += formike.o
 obj-$(CONFIG_FSL_DIU_FB) += fsl_diu_fb.o videomodes.o
+obj-$(CONFIG_IHS_VIDEO_OUT) += ihs_video_out.o
 obj-$(CONFIG_LD9040) += ld9040.o
 obj-$(CONFIG_LG4573) += lg4573.o
 obj-$(CONFIG_LOGICORE_DP_TX) += logicore_dp_tx.o
drivers/video/ihs_video_out.c new file +341 -0

341 lines not on this page · raw message

--
2.11.0

author
#2 lore raw

PATCH v4 3/6 video_osd: Add osd sandbox driver and tests

In reply to Mario Six

Add sandbox driver and tests for the new OSD uclass.

---

v3 -> v4:
None

v2 -> v3:
* Fixed style violations
* Removed sandbox_osd_get_mem from the uclass and moved it into the driver

v1 -> v2:
New in v2

---
 arch/sandbox/dts/test.dts          |   5 +
 arch/sandbox/include/asm/test.h    |   8 ++
 configs/sandbox64_defconfig        |   3 +
 configs/sandbox_defconfig          |   3 +
 configs/sandbox_flattree_defconfig |   3 +
 configs/sandbox_noblk_defconfig    |   3 +
 configs/sandbox_spl_defconfig      |   3 +
 drivers/video/Kconfig              |   6 ++
 drivers/video/Makefile             |   1 +
 drivers/video/sandbox_osd.c        | 161 ++++++++++++++++++++++++++++
 drivers/video/sandbox_osd.h        |  13 +++
 test/dm/Makefile                   |   1 +
 test/dm/osd.c                      | 210 +++++++++++++++++++++++++++++++++++++
 13 files changed, 420 insertions(+)
 create mode 100644 drivers/video/sandbox_osd.c
 create mode 100644 drivers/video/sandbox_osd.h
 create mode 100644 test/dm/osd.c
arch/sandbox/dts/test.dts +5 -0
index b8524e3b7d6..cfa47bcd0de 100644
@@ -37,6 +37,7 @@
 		usb1 = &usb_1;
 		usb2 = &usb_2;
 		axi0 = &axi;
+		osd0 = "/osd";
 	};
 
 	a-test {
@@ -642,6 +643,10 @@
 			};
 		};
 	};
+
+	osd {
+		compatible = "sandbox,sandbox_osd";
+	};
 };
 
 #include "sandbox_pmic.dtsi"
arch/sandbox/include/asm/test.h +8 -0
index c8ae52b248d..89f3d90c734 100644
@@ -90,4 +90,12 @@ long sandbox_i2c_rtc_get_set_base_time(struct udevice *dev, long base_time);
 
 int sandbox_usb_keyb_add_string(struct udevice *dev, const char *str);
 
+/**
+ * sandbox_osd_get_mem() - get the internal memory of a sandbox OSD
+ *
+ * @dev:	OSD device for which to access the internal memory for
+ * @buf:	pointer to buffer to receive the OSD memory data
+ * @buflen:	length of buffer in bytes
+ */
+int sandbox_osd_get_mem(struct udevice *dev, u8 *buf, size_t buflen);
 #endif
configs/sandbox64_defconfig +3 -0
index 27797c6990b..fb511d411a4 100644
@@ -39,6 +39,7 @@ CONFIG_CMD_GPT=y
 CONFIG_CMD_GPT_RENAME=y
 CONFIG_CMD_IDE=y
 CONFIG_CMD_I2C=y
+CONFIG_CMD_OSD=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_READ=y
 CONFIG_CMD_REMOTEPROC=y
@@ -186,6 +187,8 @@ CONFIG_CONSOLE_ROTATION=y
 CONFIG_CONSOLE_TRUETYPE=y
 CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
 CONFIG_VIDEO_SANDBOX_SDL=y
+CONFIG_OSD=y
+CONFIG_SANDBOX_OSD=y
 CONFIG_WDT=y
 CONFIG_WDT_SANDBOX=y
 CONFIG_FS_CBFS=y
configs/sandbox_defconfig +3 -0
index ca121182d65..62d3e20ddd0 100644
@@ -40,6 +40,7 @@ CONFIG_CMD_GPT=y
 CONFIG_CMD_GPT_RENAME=y
 CONFIG_CMD_IDE=y
 CONFIG_CMD_I2C=y
+CONFIG_CMD_OSD=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_READ=y
 CONFIG_CMD_REMOTEPROC=y
@@ -191,6 +192,8 @@ CONFIG_CONSOLE_ROTATION=y
 CONFIG_CONSOLE_TRUETYPE=y
 CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
 CONFIG_VIDEO_SANDBOX_SDL=y
+CONFIG_OSD=y
+CONFIG_SANDBOX_OSD=y
 CONFIG_WDT=y
 CONFIG_WDT_SANDBOX=y
 CONFIG_FS_CBFS=y
configs/sandbox_flattree_defconfig +3 -0
index 618d6462a8c..3dcfdcc5391 100644
@@ -31,6 +31,7 @@ CONFIG_CMD_DEMO=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
+CONFIG_CMD_OSD=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_SF=y
@@ -167,6 +168,8 @@ CONFIG_CONSOLE_ROTATION=y
 CONFIG_CONSOLE_TRUETYPE=y
 CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
 CONFIG_VIDEO_SANDBOX_SDL=y
+CONFIG_OSD=y
+CONFIG_SANDBOX_OSD=y
 CONFIG_CMD_DHRYSTONE=y
 CONFIG_TPM=y
 CONFIG_LZ4=y
configs/sandbox_noblk_defconfig +3 -0
index a7691daa008..34c46142298 100644
@@ -35,6 +35,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_IDE=y
 CONFIG_CMD_I2C=y
+CONFIG_CMD_OSD=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_SF=y
@@ -166,6 +167,8 @@ CONFIG_CONSOLE_ROTATION=y
 CONFIG_CONSOLE_TRUETYPE=y
 CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
 CONFIG_VIDEO_SANDBOX_SDL=y
+CONFIG_OSD=y
+CONFIG_SANDBOX_OSD=y
 CONFIG_FS_CBFS=y
 CONFIG_FS_CRAMFS=y
 CONFIG_CMD_DHRYSTONE=y
configs/sandbox_spl_defconfig +3 -0
index dad5e1ce770..746f59fae85 100644
@@ -43,6 +43,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_IDE=y
 CONFIG_CMD_I2C=y
+CONFIG_CMD_OSD=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_SF=y
@@ -185,6 +186,8 @@ CONFIG_CONSOLE_ROTATION=y
 CONFIG_CONSOLE_TRUETYPE=y
 CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
 CONFIG_VIDEO_SANDBOX_SDL=y
+CONFIG_OSD=y
+CONFIG_SANDBOX_OSD=y
 CONFIG_FS_CBFS=y
 CONFIG_FS_CRAMFS=y
 CONFIG_CMD_DHRYSTONE=y
drivers/video/Kconfig +6 -0
index 1e2cbe7afcf..c68066692d7 100644
@@ -692,6 +692,12 @@ config OSD
 	   is a (usually text-oriented) graphics buffer to show information on
 	   a display.
 
+config SANDBOX_OSD
+	bool "Enable sandbox OSD"
+	depends on OSD
+	help
+	  Enable support for sandbox OSD device used for testing purposes.
+
 config IHS_VIDEO_OUT
 	bool "Enable IHS video out driver"
 	depends on OSD
drivers/video/Makefile +1 -0
index 290747ba94f..b31017e436d 100644
@@ -34,6 +34,7 @@ obj-$(CONFIG_LG4573) += lg4573.o
 obj-$(CONFIG_LOGICORE_DP_TX) += logicore_dp_tx.o
 obj-$(CONFIG_OSD) += video_osd-uclass.o
 obj-$(CONFIG_PXA_LCD) += pxa_lcd.o
+obj-$(CONFIG_SANDBOX_OSD) += sandbox_osd.o
 obj-$(CONFIG_S6E8AX0) += s6e8ax0.o
 obj-$(CONFIG_SCF0403_LCD) += scf0403_lcd.o
 obj-$(CONFIG_VIDEO_BCM2835) += bcm2835.o
drivers/video/sandbox_osd.c new file +161 -0

161 lines not on this page · raw message

drivers/video/sandbox_osd.h new file +13 -0
new file mode 100644
index 00000000000..15a2c91c52d
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2018
+ * Mario Six, Guntermann & Drunck GmbH, mario.six at gdsys.cc
+ */
+
+enum {
+	COLOR_BLACK,
+	COLOR_WHITE,
+	COLOR_RED,
+	COLOR_GREEN,
+	COLOR_BLUE,
+};
test/dm/Makefile +1 -0
index 8b1ba915d01..16033271f8d 100644
@@ -22,6 +22,7 @@ obj-$(CONFIG_LED) += led.o
 obj-$(CONFIG_DM_MAILBOX) += mailbox.o
 obj-$(CONFIG_DM_MMC) += mmc.o
 obj-y += ofnode.o
+obj-$(CONFIG_OSD) += osd.o
 obj-$(CONFIG_DM_PCI) += pci.o
 obj-$(CONFIG_PHY) += phy.o
 obj-$(CONFIG_POWER_DOMAIN) += power-domain.o
test/dm/osd.c new file +210 -0

210 lines not on this page · raw message

--
2.11.0

author
#3 lore raw

PATCH v4 4/6 test: Add ut_asserteq_mem

In reply to Mario Six

Add a unit test assert-method, which compares two given memory areas for byte-wise equality.

---

v3 -> v4:
None

v2 -> v3:
New in v3

---
 include/test/ut.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
include/test/ut.h +18 -0
index fce75fd12a0..19bcb8c3748 100644
@@ -78,6 +78,24 @@ void ut_failf(struct unit_test_state *uts, const char *fname, int line,
 	}								\
 }
 
+/* Assert that two memory areas are equal */
+#define ut_asserteq_mem(expr1, expr2, len) {				\
+	const u8 *val1 = (u8 *)(expr1), *val2 = (u8 *)(expr2);		\
+	const uint __len = len;						\
+									\
+	if (memcmp(val1, val2, __len)) {				\
+		char __buf1[64 + 1] = "\0";				\
+		char __buf2[64 + 1] = "\0";				\
+		bin2hex(__buf1, val1, min(__len, (uint)32));		\
+		bin2hex(__buf2, val2, min(__len, (uint)32));		\
+		ut_failf(uts, __FILE__, __LINE__, __func__,		\
+			 #expr1 " = " #expr2,				\
+			 "Expected \"%s\", got \"%s\"",			\
+			 __buf1, __buf2);				\
+		return CMD_RET_FAILURE;					\
+	}								\
+}
+
 /* Assert that two pointers are equal */
 #define ut_asserteq_ptr(expr1, expr2) {					\
 	const void *val1 = (expr1), *val2 = (expr2);			\

--
2.11.0

author
#4 lore raw

PATCH v4 5/6 test: list: Add tests for hexdump.c

In reply to Mario Six

Add tests for the hex2bin, bin2hex, and hex_to_bin functions, which were recently added to U-Boot.

---

v3 -> v4:
None

v2 -> v3:
New in v3

---
 test/Makefile      |  1 +
 test/lib/Makefile  |  5 +++
 test/lib/hexdump.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 101 insertions(+)
 create mode 100644 test/lib/Makefile
 create mode 100644 test/lib/hexdump.c
test/Makefile +1 -0
index 1092011fdb0..1468ca1baa9 100644
@@ -9,3 +9,4 @@ obj-$(CONFIG_SANDBOX) += compression.o
 obj-$(CONFIG_SANDBOX) += print_ut.o
 obj-$(CONFIG_UT_TIME) += time_ut.o
 obj-$(CONFIG_$(SPL_)LOG) += log/
+obj-$(CONFIG_UNIT_TEST) += lib/
test/lib/Makefile new file +5 -0
new file mode 100644
index 00000000000..ea68fae566f
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2018
+# Mario Six, Guntermann & Drunck GmbH, mario.six at gdsys.cc
+obj-y += hexdump.o
test/lib/hexdump.c new file +95 -0

95 lines not on this page · raw message

--
2.11.0

author
#5 lore raw

PATCH v4 6/6 cmd: Add osd commands

In reply to Mario Six

Add command to query information from and write text to on-screen display (OSD) devices.

---

v3 -> v4:
* Fixed compilation issue in legacy commands

v2 -> v3:
* Fixed style violations
* Moved gdsys legacy OSD cmds to their own file
* Made sure allocated buffer is always freed
* Improved error handling
* Improved documentation

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/common/Makefile  |   4 +
 board/gdsys/common/osd_cmd.c | 146 ++++++++++++++++++++++
 board/gdsys/mpc8308/Kconfig  |  11 ++
 cmd/Kconfig                  |   8 ++
 cmd/Makefile                 |   1 +
 cmd/osd.c                    | 291 +++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 461 insertions(+)
 create mode 100644 board/gdsys/common/osd_cmd.c
 create mode 100644 cmd/osd.c
board/gdsys/common/Makefile +4 -0
index 698ea3b02bc..af9058a5d77 100644
@@ -15,3 +15,7 @@ obj-$(CONFIG_STRIDER) += mclink.o dp501.o phy.o ioep-fpga.o adv7611.o ch7301.o
 obj-$(CONFIG_STRIDER) += fanctrl.o
 obj-$(CONFIG_STRIDER_CON) += osd.o
 obj-$(CONFIG_STRIDER_CON_DP) += osd.o
+
+ifdef CONFIG_OSD
+obj-$(CONFIG_GDSYS_LEGACY_OSD_CMDS) += osd_cmd.o
+endif
board/gdsys/common/osd_cmd.c new file +146 -0

146 lines not on this page · raw message

board/gdsys/mpc8308/Kconfig +11 -0
index cb29c25c650..9d99f686923 100644
@@ -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
cmd/Kconfig +8 -0
index cf97a0f2be3..442b90a9d3f 100644
@@ -913,6 +913,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 HAVE_BLOCK_DEVICE
cmd/Makefile +1 -0
index d3815abf267..8f91570306d 100644
@@ -97,6 +97,7 @@ obj-$(CONFIG_CMD_MTDPARTS) += mtdparts.o
 obj-$(CONFIG_CMD_NAND) += nand.o
 obj-$(CONFIG_CMD_NET) += net.o
 obj-$(CONFIG_CMD_ONENAND) += onenand.o
+obj-$(CONFIG_CMD_OSD) += osd.o
 obj-$(CONFIG_CMD_PART) += part.o
 ifdef CONFIG_PCI
 obj-$(CONFIG_CMD_PCI) += pci.o
cmd/osd.c new file +291 -0

291 lines not on this page · raw message

--
2.11.0

#6 lore raw

PATCH v4 1/6 drivers: Add OSD uclass

In reply to Mario Six

Hi Mario,

Quoted 4 lines · On Thu, 27 Sep 2018 09:19:29 +0200 Mario Six mario.six at gdsys.cc wrote:

Some devices offer a text-based OSD (on-screen display) that can be programmatically controlled (i.e. text displayed on).

Add a uclass to support such devices.

Applied whole series to u-boot-video/master, thanks!

--
Anatolij