diff mbox series

[U-Boot,v3,1/6] drivers: Add OSD uclass

Message ID 20180626112854.13285-1-mario.six@gdsys.cc
State Superseded
Delegated to: Anatolij Gustschin
Headers show
Series [U-Boot,v3,1/6] drivers: Add OSD uclass | expand

Commit Message

Mario Six June 26, 2018, 11:28 a.m. UTC
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.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Mario Six <mario.six@gdsys.cc>

---

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           |   2 +-
 drivers/video/video_osd-uclass.c |  45 +++++++++
 include/dm/uclass-id.h           |   1 +
 include/video_osd.h              | 192 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 247 insertions(+), 1 deletion(-)
 create mode 100644 drivers/video/video_osd-uclass.c
 create mode 100644 include/video_osd.h

--
2.11.0

Comments

Anatolij Gustschin Aug. 1, 2018, 4:55 p.m. UTC | #1
Hi Mario,

On Tue, 26 Jun 2018 13:28:49 +0200
Mario Six mario.six@gdsys.cc wrote:
...
> ---
>  drivers/video/Kconfig            |   8 ++
>  drivers/video/Makefile           |   2 +-
>  drivers/video/video_osd-uclass.c |  45 +++++++++
>  include/dm/uclass-id.h           |   1 +
>  include/video_osd.h              | 192 +++++++++++++++++++++++++++++++++++++++
>  5 files changed, 247 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/video/video_osd-uclass.c
>  create mode 100644 include/video_osd.h

Applied to u-boot-video/master after fixing Makefile changes.

...
> -obj-$(CONFIG_VIDEO_FSL_DCU_FB) += fsl_dcu_fb.o videomodes.o

This line shouldn't be removed. Fixed when applying.

--
Anatolij
Mario Six Sept. 26, 2018, 1:45 p.m. UTC | #2
Hi Anatolij,
On Wed, Aug 1, 2018 at 6:56 PM Anatolij Gustschin <agust@denx.de> wrote:
>
> Hi Mario,
>
> On Tue, 26 Jun 2018 13:28:49 +0200
> Mario Six mario.six@gdsys.cc wrote:
> ...
> > ---
> >  drivers/video/Kconfig            |   8 ++
> >  drivers/video/Makefile           |   2 +-
> >  drivers/video/video_osd-uclass.c |  45 +++++++++
> >  include/dm/uclass-id.h           |   1 +
> >  include/video_osd.h              | 192 +++++++++++++++++++++++++++++++++++++++
> >  5 files changed, 247 insertions(+), 1 deletion(-)
> >  create mode 100644 drivers/video/video_osd-uclass.c
> >  create mode 100644 include/video_osd.h
>
> Applied to u-boot-video/master after fixing Makefile changes.
>
> ...
> > -obj-$(CONFIG_VIDEO_FSL_DCU_FB) += fsl_dcu_fb.o videomodes.o
>
> This line shouldn't be removed. Fixed when applying.
>
> --
> Anatolij
>
Was there another issue with the series that I missed? It looks like it wasn't
applied to u-boot-video/master.

Best regards,
Mario
Anatolij Gustschin Sept. 27, 2018, 6:40 a.m. UTC | #3
Hi Mario,

On Wed, 26 Sep 2018 15:45:57 +0200
Mario Six mario.six@gdsys.cc wrote:
... 
> Was there another issue with the series that I missed? It looks like it wasn't
> applied to u-boot-video/master.

After applying, build-testing didn't work due to some Travis-CI issues,
so I stopped the tests and never got to it since then, sorry.

I've applied the rebased series again and fixed osd0 alias, but
there are some other build issues [1] (it seems the patch 6/6 is not
needed?). Could you please check? Thanks!

[1] https://travis-ci.org/vdsao/u-boot-video/jobs/433775307

--
Anatolij
Anatolij Gustschin Sept. 27, 2018, 6:49 a.m. UTC | #4
On Thu, 27 Sep 2018 08:40:58 +0200
Anatolij Gustschin agust@denx.de wrote:
...
> I've applied the rebased series again and fixed osd0 alias, but
> there are some other build issues [1] (it seems the patch 6/6 is not
> needed?). Could you please check? Thanks!

The rebased series is here:

 http://git.denx.de/?p=u-boot/u-boot-video.git;a=shortlog;h=refs/heads/osd-new

--
Anatolij
Mario Six Sept. 27, 2018, 7:09 a.m. UTC | #5
Hi Anatolij,

On Thu, Sep 27, 2018 at 8:50 AM Anatolij Gustschin <agust@denx.de> wrote:
>
> On Thu, 27 Sep 2018 08:40:58 +0200
> Anatolij Gustschin agust@denx.de wrote:
> ...
> > I've applied the rebased series again and fixed osd0 alias, but
> > there are some other build issues [1] (it seems the patch 6/6 is not
> > needed?). Could you please check? Thanks!
>
> The rebased series is here:
>
>  http://git.denx.de/?p=u-boot/u-boot-video.git;a=shortlog;h=refs/heads/osd-new
>
Thanks, and I found the issue (I had the legacy commands Kconfig setting logic
wrong).

Expect a v4 soon.

> --
> Anatolij
>
Best regards,
Mario
diff mbox series

Patch

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 5ee9032dc9..dfd7b87add 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -667,4 +667,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
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 7c89c67dce..f1523fda7b 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -24,7 +24,7 @@  obj-$(CONFIG_ATMEL_HLCD) += atmel_hlcdfb.o
 obj-$(CONFIG_ATMEL_LCD) += atmel_lcdfb.o
 obj-$(CONFIG_CFB_CONSOLE) += cfb_console.o
 obj-$(CONFIG_FSL_DIU_FB) += fsl_diu_fb.o videomodes.o
-obj-$(CONFIG_VIDEO_FSL_DCU_FB) += fsl_dcu_fb.o videomodes.o
+obj-$(CONFIG_OSD) += video_osd-uclass.o
 obj-$(CONFIG_PXA_LCD) += pxa_lcd.o
 obj-$(CONFIG_SCF0403_LCD) += scf0403_lcd.o
 obj-$(CONFIG_S6E8AX0) += s6e8ax0.o
diff --git a/drivers/video/video_osd-uclass.c b/drivers/video/video_osd-uclass.c
new file mode 100644
index 0000000000..82136a292b
--- /dev/null
+++ b/drivers/video/video_osd-uclass.c
@@ -0,0 +1,45 @@ 
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2017
+ * Mario Six,  Guntermann & Drunck GmbH, mario.six@gdsys.cc
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <video_osd.h>
+
+int video_osd_get_info(struct udevice *dev, struct video_osd_info *info)
+{
+	struct video_osd_ops *ops = video_osd_get_ops(dev);
+
+	return ops->get_info(dev, info);
+}
+
+int video_osd_set_mem(struct udevice *dev, uint col, uint row, u8 *buf,
+		      size_t buflen, uint count)
+{
+	struct video_osd_ops *ops = video_osd_get_ops(dev);
+
+	return ops->set_mem(dev, col, row, buf, buflen, count);
+}
+
+int video_osd_set_size(struct udevice *dev, uint col, uint row)
+{
+	struct video_osd_ops *ops = video_osd_get_ops(dev);
+
+	return ops->set_size(dev, col, row);
+}
+
+int video_osd_print(struct udevice *dev, uint col, uint row, ulong color,
+		    char *text)
+{
+	struct video_osd_ops *ops = video_osd_get_ops(dev);
+
+	return ops->print(dev, col, row, color, text);
+}
+
+UCLASS_DRIVER(video_osd) = {
+	.id		= UCLASS_VIDEO_OSD,
+	.name		= "video_osd",
+	.flags		= DM_UC_FLAG_SEQ_ALIAS,
+};
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index d7f9df3583..e42f8481bf 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -89,6 +89,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,
diff --git a/include/video_osd.h b/include/video_osd.h
new file mode 100644
index 0000000000..01ac94b425
--- /dev/null
+++ b/include/video_osd.h
@@ -0,0 +1,192 @@ 
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2017
+ * Mario Six,  Guntermann & Drunck GmbH, mario.six@gdsys.cc
+ */
+
+#ifndef _VIDEO_OSD_H_
+#define _VIDEO_OSD_H_
+
+struct video_osd_info {
+	/* The width of the OSD display in columns */
+	uint width;
+	/* The height of the OSD display in rows */
+	uint height;
+	/* The major version of the OSD device */
+	uint major_version;
+	/* The minor version of the OSD device */
+	uint minor_version;
+};
+
+/**
+ * struct video_osd_ops - driver operations for OSD uclass
+ *
+ * The OSD uclass implements support for text-oriented on-screen displays,
+ * which are taken to be devices that independently display a graphical
+ * text-based overlay over the video output of an associated display.
+ *
+ * The functions defined by the uclass support writing text to the display in
+ * either a generic form (by specifying a string, a driver-specific color value
+ * for the text, and screen coordinates in rows and columns) or a
+ * driver-specific form (by specifying "raw" driver-specific data to display at
+ * a given coordinate).
+ *
+ * Functions to read device information and set the size of the virtual OSD
+ * screen (in rows and columns) are also supported.
+ *
+ * Drivers should support these operations unless otherwise noted. These
+ * operations are intended to be used by uclass code, not directly from
+ * other code.
+ */
+struct video_osd_ops {
+	/**
+	 * get_info() - Get information about a OSD instance
+	 *
+	 * A OSD instance may keep some internal data about itself. This
+	 * function can be used to access this data.
+	 *
+	 * @dev:	OSD instance to query.
+	 * @info:	Pointer to a structure that takes the information read
+	 *		from the OSD instance.
+	 * @return 0 if OK, -ve on error.
+	 */
+	int (*get_info)(struct udevice *dev, struct video_osd_info *info);
+
+	/**
+	 * set_mem() - Write driver-specific text data to OSD screen
+	 *
+	 * The passed data are device-specific, and it's up to the driver how
+	 * to interpret them. How the count parameter is interpreted is also
+	 * driver-specific; most likely the given data will be written to the
+	 * OSD count times back-to-back, which is e.g. convenient for filling
+	 * areas of the OSD with a single character.
+	 *
+	 * For example a invocation of
+	 *
+	 * video_osd_set_mem(dev, 0, 0, "A", 1, 10);
+	 *
+	 * will write the device-specific text data "A" to the positions (0, 0)
+	 * to (9, 0) on the OSD.
+	 *
+	 * Device-specific text data may, e.g. be a special encoding of glyphs
+	 * to display and color values in binary format.
+	 *
+	 * @dev:	OSD instance to write to.
+	 * @col:	Horizontal character coordinate to write to.
+	 * @row		Vertical character coordinate to write to.
+	 * @buf:	Array containing device-specific data to write to the
+	 *		specified coordinate on the OSD screen.
+	 * @buflen:	Length of the data in the passed buffer (in byte).
+	 * @count:	Write count many repetitions of the given text data
+	 * @return 0 if OK, -ve on error.
+	 */
+	int (*set_mem)(struct udevice *dev, uint col, uint row, u8 *buf,
+		       size_t buflen, uint count);
+
+	/**
+	 * set_size() - Set the position and dimension of the OSD's
+	 *              writeable window
+	 *
+	 * @dev:	OSD instance to write to.
+	 * @col		The number of characters in the window's columns
+	 * @row		The number of characters in the window's rows
+	 * @return 0 if OK, -ve on error.
+	 */
+	int (*set_size)(struct udevice *dev, uint col, uint row);
+
+	/**
+	 * print() - Print a string in a given color to specified coordinates
+	 *	     on the OSD
+	 *
+	 * @dev:	OSD instance to write to.
+	 * @col		The x-coordinate of the position the string should be
+	 *		written to
+	 * @row		The y-coordinate of the position the string should be
+	 *		written to
+	 * @color:	The color in which the specified string should be
+	 *		printed; the interpretation of the value is
+	 *		driver-specific, and possible values should be defined
+	 *		e.g. in a driver include file.
+	 * @text:	The string data that should be printed on the OSD
+	 * @return 0 if OK, -ve on error.
+	 */
+	int (*print)(struct udevice *dev, uint col, uint row, ulong color,
+		     char *text);
+};
+
+#define video_osd_get_ops(dev)	((struct video_osd_ops *)(dev)->driver->ops)
+
+/**
+ * video_osd_get_info() - Get information about a OSD instance
+ *
+ * A OSD instance may keep some internal data about itself. This function can
+ * be used to access this data.
+ *
+ * @dev:	OSD instance to query.
+ * @info:	Pointer to a structure that takes the information read from the
+ *		OSD instance.
+ * @return 0 if OK, -ve on error.
+ */
+int video_osd_get_info(struct udevice *dev, struct video_osd_info *info);
+
+/**
+ * video_osd_set_mem() - Write text data to OSD memory
+ *
+ * The passed data are device-specific, and it's up to the driver how to
+ * interpret them. How the count parameter is interpreted is also
+ * driver-specific; most likely the given data will be written to the OSD count
+ * times back-to-back, which is e.g. convenient for filling areas of the OSD
+ * with a single character.
+ *
+ * For example a invocation of
+ *
+ * video_osd_set_mem(dev, 0, 0, "A", 1, 10);
+ *
+ * will write the device-specific text data "A" to the positions (0, 0) to (9,
+ * 0) on the OSD.
+ *
+ * Device-specific text data may, e.g. be a special encoding of glyphs to
+ * display and color values in binary format.
+ *
+ * @dev:	OSD instance to write to.
+ * @col:	Horizontal character coordinate to write to.
+ * @row		Vertical character coordinate to write to.
+ * @buf:	Array containing device-specific data to write to the specified
+ *		coordinate on the OSD screen.
+ * @buflen:	Length of the data in the passed buffer (in byte).
+ * @count:	Write count many repetitions of the given text data
+ * @return 0 if OK, -ve on error.
+ */
+int video_osd_set_mem(struct udevice *dev, uint col, uint row, u8 *buf,
+		      size_t buflen, uint count);
+
+/**
+ * video_osd_set_size() - Set the position and dimension of the OSD's
+ *              writeable window
+ *
+ * @dev:	OSD instance to write to.
+ * @col		The number of characters in the window's columns
+ * @row		The number of characters in the window's rows
+ * @return 0 if OK, -ve on error.
+ */
+int video_osd_set_size(struct udevice *dev, uint col, uint row);
+
+/**
+ * video_osd_print() - Print a string in a given color to specified coordinates
+ *		       on the OSD
+ *
+ * @dev:	OSD instance to write to.
+ * @col		The x-coordinate of the position the string should be written
+ *		to
+ * @row		The y-coordinate of the position the string should be written
+ *		to
+ * @color:	The color in which the specified string should be printed; the
+ *		interpretation of the value is driver-specific, and possible
+ *		values should be defined e.g. in a driver include file.
+ * @text:	The string data that should be printed on the OSD
+ * @return 0 if OK, -ve on error.
+ */
+int video_osd_print(struct udevice *dev, uint col, uint row, ulong color,
+		    char *text);
+
+#endif /* !_VIDEO_OSD_H_ */