All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support
@ 2016-01-19  2:52 Simon Glass
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 01/14] dm: video: Add a video uclass Simon Glass
                   ` (14 more replies)
  0 siblings, 15 replies; 32+ messages in thread
From: Simon Glass @ 2016-01-19  2:52 UTC (permalink / raw)
  To: u-boot

This series starts the process of converting LCD and video devices over to
use driver model. Both now use a very similar API thanks to earlier work by
Nikita Kiryanov. With the driver-model conversion these will end up unified
in a single uclass.

Unfortunately there are different features supported by each. This
implementation provides for a common set of features which should serve
most purposes. The intent is to support:

- bitmap devices with 8, 16 and 32 bits per pixel
- text console wih white on black or vice versa
- rotated text console
- bitmap display (BMP format)

More can be added as additional boards are ported over to use driver model
for video.

The name 'video' is chosen for the uclass since it is more generic than LCD.
Another option would be 'display' but that would introduce a third concept
to U-Boot which seems like the wrong approach.

The existing LCD and video init functions are not needed now, so this uclass
does not implement them. This includes lcd_ctrl_init(), lcd_enable() and
video_init().

Tests are provided to check that console text and bitmap output is correct.
These should be able to be extended as more features are added.

Future work will convert a few boards over to use driver model for video.
Likely targets are x86, exynos, tegra. Also, Rockchip LCD support will be
added using driver model (patches will likely be sent some time in January).

Changes in v2:
- Fix Ebabling typo in comment
- Remove duplicated @fb_size line in common
- Fix comment for video_get_ysize()
- Fix reference to \n which should be \b
- Fix 'withthe' typo in comment
- Fix 'resolutino' typo in comment

Simon Glass (14):
  dm: video: Add a video uclass
  dm: lcd: Avoid using the lcd.h header file with driver model
  dm: video: Add a uclass for the text console
  dm: video: Add a 'normal' text console driver
  dm: video: Add a driver for a rotated text console
  common: Move LCD and video memory reservation together
  dm: common: Add memory reservation for the video uclass
  dm: video: Implement the bmp command for driver model
  dm: stdio: video: Plumb the video uclass into stdio
  sandbox: Move CONFIG_VIDEO_SANDBOX_SDL to Kconfig
  dm: video: sandbox: Convert sandbox to use driver model for video
  dm: video: test: Add tests for the video uclass
  dm: video: test: Add tests for rotated consoles
  dm: video: test: Test that bitmap display works correctly

 arch/sandbox/dts/sandbox.dts      |   1 +
 arch/sandbox/dts/test.dts         |   7 +
 board/sandbox/sandbox.c           |  17 --
 common/Makefile                   |   2 +
 common/board_f.c                  |  71 ++++---
 common/cmd_bmp.c                  |  22 +-
 common/lcd.c                      |  11 -
 common/stdio.c                    |  19 +-
 configs/sandbox_defconfig         |   5 +-
 drivers/serial/sandbox.c          |   5 +-
 drivers/video/Kconfig             |  62 ++++++
 drivers/video/Makefile            |   3 +
 drivers/video/console_normal.c    | 141 ++++++++++++
 drivers/video/console_rotate.c    | 436 ++++++++++++++++++++++++++++++++++++++
 drivers/video/sandbox_sdl.c       |  90 ++++----
 drivers/video/vidconsole-uclass.c | 239 +++++++++++++++++++++
 drivers/video/video-uclass.c      | 249 ++++++++++++++++++++++
 drivers/video/video_bmp.c         | 353 ++++++++++++++++++++++++++++++
 include/asm-generic/global_data.h |   4 +
 include/configs/sandbox.h         |  13 +-
 include/dm/test.h                 |   8 +
 include/dm/uclass-id.h            |   2 +
 include/fdtdec.h                  |   1 -
 include/lcd.h                     |  12 +-
 include/video.h                   | 168 ++++++++++++++-
 include/video_console.h           | 136 ++++++++++++
 lib/fdtdec.c                      |   1 -
 test/dm/Makefile                  |   1 +
 test/dm/video.c                   | 271 +++++++++++++++++++++++
 tools/logos/denx-comp.bmp         | Bin 0 -> 4148 bytes
 30 files changed, 2221 insertions(+), 129 deletions(-)
 create mode 100644 drivers/video/console_normal.c
 create mode 100644 drivers/video/console_rotate.c
 create mode 100644 drivers/video/vidconsole-uclass.c
 create mode 100644 drivers/video/video-uclass.c
 create mode 100644 drivers/video/video_bmp.c
 create mode 100644 include/video_console.h
 create mode 100644 test/dm/video.c
 create mode 100644 tools/logos/denx-comp.bmp

-- 
2.6.0.rc2.230.g3dd15c0

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 01/14] dm: video: Add a video uclass
  2016-01-19  2:52 [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support Simon Glass
@ 2016-01-19  2:52 ` Simon Glass
  2016-01-21 15:18   ` Simon Glass
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 02/14] dm: lcd: Avoid using the lcd.h header file with driver model Simon Glass
                   ` (13 subsequent siblings)
  14 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2016-01-19  2:52 UTC (permalink / raw)
  To: u-boot

U-Boot has separate code for LCDs and 'video' devices. Both now use a
very similar API thanks to earlier work by Nikita Kiryanov. With the driver-
model conversion we should unify these into a single uclass.

Unfortunately there are different features supported by each. This
implementation provides for a common set of features which should serve
most purposes. The intent is to support:

- bitmap devices with 8, 16 and 32 bits per pixel
- text console wih white on black or vice versa
- rotated text console
- bitmap display (BMP format)

More can be added as additional boards are ported over to use driver model
for video.

The name 'video' is chosen for the uclass since it is more generic than LCD.
Another option would be 'display' but that would introduce a third concept
to U-Boot which seems like the wrong approach.

The existing LCD and video init functions are not needed now, so this uclass
makes no attempt to implement them.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2:
- Fix Ebabling typo in comment
- Remove duplicated @fb_size line in common
- Fix comment for video_get_ysize()

 drivers/video/Kconfig        |  40 ++++++++
 drivers/video/Makefile       |   1 +
 drivers/video/video-uclass.c | 228 +++++++++++++++++++++++++++++++++++++++++++
 include/dm/uclass-id.h       |   1 +
 include/video.h              | 168 +++++++++++++++++++++++++++++--
 5 files changed, 432 insertions(+), 6 deletions(-)
 create mode 100644 drivers/video/video-uclass.c

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index caf1efc..946d958 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -4,6 +4,46 @@
 
 menu "Graphics support"
 
+config DM_VIDEO
+	bool "Enable driver model support for LCD/video"
+	depends on DM
+	help
+	  This enables driver model for LCD and video devices. These support
+	  a bitmap display of various sizes and depths which can be drawn on
+	  to display a command-line console or splash screen. Enabling this
+	  option compiles in the video uclass and routes all LCD/video access
+	  through this.
+
+config VIDEO_BPP8
+	bool "Support 8-bit-per-pixel displays"
+	depends on DM_VIDEO
+	default y if DM_VIDEO
+	help
+	  Support drawing text and bitmaps onto a 8-bit-per-pixel display.
+	  Enabling this will include code to support this display. Without
+	  this option, such displays will not be supported and console output
+	  will be empty.
+
+config VIDEO_BPP16
+	bool "Support 16-bit-per-pixel displays"
+	depends on DM_VIDEO
+	default y if DM_VIDEO
+	help
+	  Support drawing text and bitmaps onto a 16-bit-per-pixel display.
+	  Enabling this will include code to support this display. Without
+	  this option, such displays will not be supported and console output
+	  will be empty.
+
+config VIDEO_BPP32
+	bool "Support 32-bit-per-pixel displays"
+	depends on DM_VIDEO
+	default y if DM_VIDEO
+	help
+	  Support drawing text and bitmaps onto a 32-bit-per-pixel display.
+	  Enabling this will include code to support this display. Without
+	  this option, such displays will not be supported and console output
+	  will be empty.
+
 config VIDEO_VESA
 	bool "Enable VESA video driver support"
 	default n
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index e85fd8a..7192013 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -7,6 +7,7 @@
 
 ifdef CONFIG_DM
 obj-$(CONFIG_DISPLAY_PORT) += dp-uclass.o
+obj-$(CONFIG_DM_VIDEO) += video-uclass.o
 endif
 
 obj-$(CONFIG_ATI_RADEON_FB) += ati_radeon_fb.o videomodes.o
diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
new file mode 100644
index 0000000..1615889
--- /dev/null
+++ b/drivers/video/video-uclass.c
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 2015 Google, Inc
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <mapmem.h>
+#include <stdio_dev.h>
+#include <video.h>
+#include <video_console.h>
+#include <dm/lists.h>
+#include <dm/device-internal.h>
+#include <dm/uclass-internal.h>
+#ifdef CONFIG_SANDBOX
+#include <asm/sdl.h>
+#endif
+
+/*
+ * Theory of operation:
+ *
+ * Before relocation each device is bound. The driver for each device must
+ * set the @align and @size values in struct video_uc_platdata. This
+ * information represents the requires size and alignment of the frame buffer
+ * for the device. The values can be an over-estimate but cannot be too
+ * small. The actual values will be suppled (in the same manner) by the bind()
+ * method after relocation.
+ *
+ * This information is then picked up by video_reserve() which works out how
+ * much memory is needed for all devices. This is allocated between
+ * gd->video_bottom and gd->video_top.
+ *
+ * After relocation the same process occurs. The driver supplies the same
+ * @size and @align information and this time video_post_bind() checks that
+ * the drivers does not overflow the allocated memory.
+ *
+ * The frame buffer address is actually set (to plat->base) in
+ * video_post_probe(). This function also clears the frame buffer and
+ * allocates a suitable text console device. This can then be used to write
+ * text to the video device.
+ */
+DECLARE_GLOBAL_DATA_PTR;
+
+static ulong alloc_fb(struct udevice *dev, ulong *addrp)
+{
+	struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
+	ulong base, align, size;
+
+	align = plat->align ? plat->align : 1 << 20;
+	base = *addrp - plat->size;
+	base &= ~(align - 1);
+	plat->base = base;
+	size = *addrp - base;
+	*addrp = base;
+
+	return size;
+}
+
+int video_reserve(ulong *addrp)
+{
+	struct udevice *dev;
+	ulong size;
+
+	gd->video_top = *addrp;
+	for (uclass_find_first_device(UCLASS_VIDEO, &dev);
+	     dev;
+	     uclass_find_next_device(&dev)) {
+		size = alloc_fb(dev, addrp);
+		debug("%s: Reserving %lx bytes at %lx for video device '%s'\n",
+		      __func__, size, *addrp, dev->name);
+	}
+	gd->video_bottom = *addrp;
+	debug("Video frame buffers from %lx to %lx\n", gd->video_bottom,
+	      gd->video_top);
+
+	return 0;
+}
+
+static int video_clear(struct udevice *dev)
+{
+	struct video_priv *priv = dev_get_uclass_priv(dev);
+
+	if (priv->bpix == VIDEO_BPP32) {
+		u32 *ppix = priv->fb;
+		u32 *end = priv->fb + priv->fb_size;
+
+		while (ppix < end)
+			*ppix++ = priv->colour_bg;
+	} else {
+		memset(priv->fb, priv->colour_bg, priv->fb_size);
+	}
+
+	return 0;
+}
+
+/* Flush video activity to the caches */
+void video_sync(struct udevice *vid)
+{
+	/*
+	 * flush_dcache_range() is declared in common.h but it seems that some
+	 * architectures do not actually implement it. Is there a way to find
+	 * out whether it exists? For now, ARM is safe.
+	 */
+#if defined(CONFIG_ARM) && !defined(CONFIG_SYS_DCACHE_OFF)
+	struct video_priv *priv = dev_get_uclass_priv(vid);
+
+	if (priv->flush_dcache) {
+		flush_dcache_range((ulong)priv->fb,
+				   (ulong)priv->fb + priv->fb_size);
+	}
+#elif defined(CONFIG_VIDEO_SANDBOX_SDL)
+	struct video_priv *priv = dev_get_uclass_priv(vid);
+	static ulong last_sync;
+
+	if (get_timer(last_sync) > 10) {
+		sandbox_sdl_sync(priv->fb);
+		last_sync = get_timer(0);
+	}
+#endif
+}
+
+void video_sync_all(void)
+{
+	struct udevice *dev;
+
+	for (uclass_find_first_device(UCLASS_VIDEO, &dev);
+	     dev;
+	     uclass_find_next_device(&dev)) {
+		if (device_active(dev))
+			video_sync(dev);
+	}
+}
+
+int video_get_xsize(struct udevice *dev)
+{
+	struct video_priv *priv = dev_get_uclass_priv(dev);
+
+	return priv->xsize;
+}
+
+int video_get_ysize(struct udevice *dev)
+{
+	struct video_priv *priv = dev_get_uclass_priv(dev);
+
+	return priv->ysize;
+}
+
+/* Set up the colour map */
+static int video_pre_probe(struct udevice *dev)
+{
+	struct video_priv *priv = dev_get_uclass_priv(dev);
+
+	priv->cmap = calloc(256, sizeof(ushort));
+	if (!priv->cmap)
+		return -ENOMEM;
+
+	return 0;
+}
+
+static int video_pre_remove(struct udevice *dev)
+{
+	struct video_priv *priv = dev_get_uclass_priv(dev);
+
+	free(priv->cmap);
+
+	return 0;
+}
+
+/* Set up the display ready for use */
+static int video_post_probe(struct udevice *dev)
+{
+	struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
+	struct video_priv *priv = dev_get_uclass_priv(dev);
+	char name[30], drv[15], *str;
+	struct udevice *cons;
+	int ret;
+
+	/* Set up the line and display size */
+	priv->fb = map_sysmem(plat->base, plat->size);
+	priv->line_length = priv->xsize * VNBYTES(priv->bpix);
+	priv->fb_size = priv->line_length * priv->ysize;
+
+	/* Set up colours - we could in future support other colours */
+#ifdef CONFIG_SYS_WHITE_ON_BLACK
+	priv->colour_fg = 0xffffff;
+#else
+	priv->colour_bg = 0xffffff;
+#endif
+	video_clear(dev);
+
+	return 0;
+};
+
+/* Post-relocation, allocate memory for the frame buffer */
+static int video_post_bind(struct udevice *dev)
+{
+	ulong addr = gd->video_top;
+	ulong size;
+
+	/* Before relocation there is nothing to do here */
+	if ((!gd->flags & GD_FLG_RELOC))
+		return 0;
+	size = alloc_fb(dev, &addr);
+	if (addr < gd->video_bottom) {
+		/* Device tree node may need the 'u-boot,dm-pre-reloc' tag */
+		printf("Video device '%s' cannot allocate frame buffer memory -ensure the device is set up before relocation\n",
+		       dev->name);
+		return -ENOSPC;
+	}
+	debug("%s: Claiming %lx bytes at %lx for video device '%s'\n",
+	      __func__, size, addr, dev->name);
+	gd->video_bottom = addr;
+
+	return 0;
+}
+
+UCLASS_DRIVER(video) = {
+	.id		= UCLASS_VIDEO,
+	.name		= "video",
+	.flags		= DM_UC_FLAG_SEQ_ALIAS,
+	.post_bind	= video_post_bind,
+	.pre_probe	= video_pre_probe,
+	.post_probe	= video_post_probe,
+	.pre_remove	= video_pre_remove,
+	.per_device_auto_alloc_size	= sizeof(struct video_priv),
+	.per_device_platdata_auto_alloc_size = sizeof(struct video_uc_platdata),
+};
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index 27fa0b6..3934375 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -66,6 +66,7 @@ enum uclass_id {
 	UCLASS_USB,		/* USB bus */
 	UCLASS_USB_DEV_GENERIC,	/* USB generic device */
 	UCLASS_USB_HUB,		/* USB hub */
+	UCLASS_VIDEO,		/* Video or LCD device */
 	UCLASS_VIDEO_BRIDGE,	/* Video bridge, e.g. DisplayPort to LVDS */
 
 	UCLASS_COUNT,
diff --git a/include/video.h b/include/video.h
index 65e4ec1..b20f06f 100644
--- a/include/video.h
+++ b/include/video.h
@@ -1,14 +1,167 @@
 /*
-** MPC823 Video Controller
-** =======================
-** (C) 2000 by Paolo Scaffardi (arsenio at tin.it)
-** AIRVENT SAM s.p.a - RIMINI(ITALY)
-**
-*/
+ * Video uclass and legacy implementation
+ *
+ * Copyright (c) 2015 Google, Inc
+ *
+ * MPC823 Video Controller
+ * =======================
+ * (C) 2000 by Paolo Scaffardi (arsenio at tin.it)
+ * AIRVENT SAM s.p.a - RIMINI(ITALY)
+ *
+ */
 
 #ifndef _VIDEO_H_
 #define _VIDEO_H_
 
+#ifdef CONFIG_DM_VIDEO
+
+#include <stdio_dev.h>
+
+struct video_uc_platdata {
+	uint align;
+	uint size;
+	ulong base;
+};
+
+/*
+ * Bits per pixel selector. Each value n is such that the bits-per-pixel is
+ * 2 ^ n
+ */
+enum video_log2_bpp {
+	VIDEO_BPP1	= 0,
+	VIDEO_BPP2,
+	VIDEO_BPP4,
+	VIDEO_BPP8,
+	VIDEO_BPP16,
+	VIDEO_BPP32,
+};
+
+/*
+ * Convert enum video_log2_bpp to bytes and bits. Note we omit the outer
+ * brackets to allow multiplication by fractional pixels.
+ */
+#define VNBYTES(bpix)	(1 << (bpix)) / 8
+
+#define VNBITS(bpix)	(1 << (bpix))
+
+/**
+ * struct video_priv - Device information used by the video uclass
+ *
+ * @xsize:	Number of pixel columns (e.g. 1366)
+ * @ysize:	Number of pixels rows (e.g.. 768)
+ * @tor:	Display rotation (0=none, 1=90 degrees clockwise, etc.)
+ * @bpix:	Encoded bits per pixel
+ * @fb:		Frame buffer
+ * @fb_size:	Frame buffer size
+ * @line_length:	Length of each frame buffer line, in bytes
+ * @colour_fg:	Foreground colour (pixel value)
+ * @colour_bg:	Background colour (pixel value)
+ * @flush_dcache:	true to enable flushing of the data cache after
+ *		the LCD is updated
+ * @cmap:	Colour map for 8-bit-per-pixel displays
+ */
+struct video_priv {
+	/* Things set up by the driver: */
+	ushort xsize;
+	ushort ysize;
+	ushort rot;
+	enum video_log2_bpp bpix;
+
+	/*
+	 * Things that are private to the uclass: don't use these in the
+	 * driver
+	 */
+	void *fb;
+	int fb_size;
+	int line_length;
+	int colour_fg;
+	int colour_bg;
+	bool flush_dcache;
+	ushort *cmap;
+};
+
+/* Placeholder - there are no video operations@present */
+struct video_ops {
+};
+
+#define video_get_ops(dev)        ((struct video_ops *)(dev)->driver->ops)
+
+/**
+ * video_reserve() - Reserve frame-buffer memory for video devices
+ *
+ * Note: This function is for internal use.
+ *
+ * This uses the uclass platdata's @size and @align members to figure out
+ * a size and position for each frame buffer as part of the pre-relocation
+ * process of determining the post-relocation memory layout.
+ *
+ * gd->video_top is set to the initial value of *@addrp and gd->video_bottom
+ * is set to the final value.
+ *
+ * @addrp:	On entry, the top of available memory. On exit, the new top,
+ *		after allocating the required memory.
+ * @return 0
+ */
+int video_reserve(ulong *addrp);
+
+/**
+ * video_sync() - Sync a device's frame buffer with its hardware
+ *
+ * Some frame buffers are cached or have a secondary frame buffer. This
+ * function syncs these up so that the current contents of the U-Boot frame
+ * buffer are displayed to the user.
+ *
+ * @dev:	Device to sync
+ */
+void video_sync(struct udevice *vid);
+
+/**
+ * video_sync_all() - Sync all devices' frame buffers with there hardware
+ *
+ * This calls video_sync() on all active video devices.
+ */
+void video_sync_all(void);
+
+/**
+ * video_bmp_display() - Display a BMP file
+ *
+ * @dev:	Device to display the bitmap on
+ * @bmp_image:	Address of bitmap image to display
+ * @x:		X position in pixels from the left
+ * @y:		Y position in pixels from the top
+ * @align:	true to adjust the coordinates to centre the image. If false
+ *		the coordinates are used as is. If true:
+ *
+ *		- if a coordinate is 0x7fff then the image will be centred in
+ *		  that direction
+ *		- if a coordinate is -ve then it will be offset to the
+ *		  left/top of the centre by that many pixels
+ *		- if a coordinate is positive it will be used unchnaged.
+ * @return 0 if OK, -ve on error
+ */
+int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
+		      bool align);
+
+/**
+ * video_get_xsize() - Get the width of the display in pixels
+ *
+ * @dev:	Device to check
+ * @return device frame buffer width in pixels
+ */
+int video_get_xsize(struct udevice *dev);
+
+/**
+ * video_get_ysize() - Get the height of the display in pixels
+ *
+ * @dev:	Device to check
+ * @return device frame buffer height in pixels
+ */
+int video_get_ysize(struct udevice *dev);
+
+#endif /* CONFIG_DM_VIDEO */
+
+#ifndef CONFIG_DM_VIDEO
+
 /* Video functions */
 
 struct stdio_dev;
@@ -73,4 +226,7 @@ int kwh043st20_f01_spi_startup(unsigned int bus, unsigned int cs,
 int lg4573_spi_startup(unsigned int bus, unsigned int cs,
 	unsigned int max_hz, unsigned int spi_mode);
 #endif
+
+#endif /* CONFIG_DM_VIDEO */
+
 #endif
-- 
2.6.0.rc2.230.g3dd15c0

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 02/14] dm: lcd: Avoid using the lcd.h header file with driver model
  2016-01-19  2:52 [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support Simon Glass
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 01/14] dm: video: Add a video uclass Simon Glass
@ 2016-01-19  2:52 ` Simon Glass
  2016-01-21 15:18   ` Simon Glass
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 03/14] dm: video: Add a uclass for the text console Simon Glass
                   ` (12 subsequent siblings)
  14 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2016-01-19  2:52 UTC (permalink / raw)
  To: u-boot

The LCD functions and definitions are not used with the driver model video
uclass. When all boards are converted over we can remove the file. For now,
use #ifdef to omit the contents.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2: None

 common/Makefile |  2 ++
 include/lcd.h   | 12 ++++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/common/Makefile b/common/Makefile
index 2a1d9f8..2492275 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -205,7 +205,9 @@ obj-$(CONFIG_I2C_EDID) += edid.o
 obj-$(CONFIG_KALLSYMS) += kallsyms.o
 obj-y += splash.o
 obj-$(CONFIG_SPLASH_SOURCE) += splash_source.o
+ifndef CONFIG_DM_VIDEO
 obj-$(CONFIG_LCD) += lcd.o lcd_console.o
+endif
 obj-$(CONFIG_LCD_ROTATION) += lcd_console_rotation.o
 obj-$(CONFIG_LCD_DT_SIMPLEFB) += lcd_simplefb.o
 obj-$(CONFIG_LYNXKDI) += lynxkdi.o
diff --git a/include/lcd.h b/include/lcd.h
index 59202b7..d7651a8 100644
--- a/include/lcd.h
+++ b/include/lcd.h
@@ -18,6 +18,12 @@
 #include <asm/byteorder.h>
 #endif
 
+int bmp_display(ulong addr, int x, int y);
+struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
+			     void **alloc_addr);
+
+#ifndef CONFIG_DM_VIDEO
+
 extern char lcd_is_enabled;
 extern int lcd_line_length;
 extern struct vidinfo panel_info;
@@ -26,10 +32,6 @@ void lcd_ctrl_init(void *lcdbase);
 void lcd_enable(void);
 void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue);
 
-struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
-			     void **alloc_addr);
-int bmp_display(ulong addr, int x, int y);
-
 /**
  * Set whether we need to flush the dcache when changing the LCD image. This
  * defaults to off.
@@ -209,4 +211,6 @@ void lcd_sync(void);
 #define PAGE_SIZE	4096
 #endif
 
+#endif /* !CONFIG_DM_VIDEO */
+
 #endif	/* _LCD_H_ */
-- 
2.6.0.rc2.230.g3dd15c0

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 03/14] dm: video: Add a uclass for the text console
  2016-01-19  2:52 [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support Simon Glass
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 01/14] dm: video: Add a video uclass Simon Glass
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 02/14] dm: lcd: Avoid using the lcd.h header file with driver model Simon Glass
@ 2016-01-19  2:52 ` Simon Glass
  2016-01-21 15:18   ` Simon Glass
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 04/14] dm: video: Add a 'normal' text console driver Simon Glass
                   ` (11 subsequent siblings)
  14 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2016-01-19  2:52 UTC (permalink / raw)
  To: u-boot

The existing LCD/video interface suffers from conflating the bitmap display
with text output on that display. As a result the implementation is more
complex than it needs to me.

We can support multiple text console drivers. Create a separate uclass to
support this, with its own API.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2:
- Fix reference to \n which should be \b
- Fix 'withthe' typo in comment

 drivers/video/Makefile            |   2 +-
 drivers/video/vidconsole-uclass.c | 239 ++++++++++++++++++++++++++++++++++++++
 drivers/video/video-uclass.c      |  21 ++++
 include/dm/uclass-id.h            |   1 +
 include/video_console.h           | 136 ++++++++++++++++++++++
 5 files changed, 398 insertions(+), 1 deletion(-)
 create mode 100644 drivers/video/vidconsole-uclass.c
 create mode 100644 include/video_console.h

diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 7192013..e82f1ae 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -7,7 +7,7 @@
 
 ifdef CONFIG_DM
 obj-$(CONFIG_DISPLAY_PORT) += dp-uclass.o
-obj-$(CONFIG_DM_VIDEO) += video-uclass.o
+obj-$(CONFIG_DM_VIDEO) += video-uclass.o vidconsole-uclass.o
 endif
 
 obj-$(CONFIG_ATI_RADEON_FB) += ati_radeon_fb.o videomodes.o
diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
new file mode 100644
index 0000000..ea10189
--- /dev/null
+++ b/drivers/video/vidconsole-uclass.c
@@ -0,0 +1,239 @@
+/*
+ * Copyright (c) 2015 Google, Inc
+ * (C) Copyright 2001-2015
+ * DENX Software Engineering -- wd at denx.de
+ * Compulab Ltd - http://compulab.co.il/
+ * Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <video.h>
+#include <video_console.h>
+#include <video_font.h>		/* Get font data, width and height */
+
+/* By default we scroll by a single line */
+#ifndef CONFIG_CONSOLE_SCROLL_LINES
+#define CONFIG_CONSOLE_SCROLL_LINES 1
+#endif
+
+int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, char ch)
+{
+	struct vidconsole_ops *ops = vidconsole_get_ops(dev);
+
+	if (!ops->putc_xy)
+		return -ENOSYS;
+	return ops->putc_xy(dev, x, y, ch);
+}
+
+int vidconsole_move_rows(struct udevice *dev, uint rowdst, uint rowsrc,
+			 uint count)
+{
+	struct vidconsole_ops *ops = vidconsole_get_ops(dev);
+
+	if (!ops->move_rows)
+		return -ENOSYS;
+	return ops->move_rows(dev, rowdst, rowsrc, count);
+}
+
+int vidconsole_set_row(struct udevice *dev, uint row, int clr)
+{
+	struct vidconsole_ops *ops = vidconsole_get_ops(dev);
+
+	if (!ops->set_row)
+		return -ENOSYS;
+	return ops->set_row(dev, row, clr);
+}
+
+/* Move backwards one space */
+static void vidconsole_back(struct udevice *dev)
+{
+	struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
+
+	if (--priv->curr_col < 0) {
+		priv->curr_col = priv->cols - 1;
+		if (--priv->curr_row < 0)
+			priv->curr_row = 0;
+	}
+
+	vidconsole_putc_xy(dev, priv->curr_col * VIDEO_FONT_WIDTH,
+			   priv->curr_row * VIDEO_FONT_HEIGHT, ' ');
+}
+
+/* Move to a newline, scrolling the display if necessary */
+static void vidconsole_newline(struct udevice *dev)
+{
+	struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
+	struct udevice *vid_dev = dev->parent;
+	struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev);
+	const int rows = CONFIG_CONSOLE_SCROLL_LINES;
+	int i;
+
+	priv->curr_col = 0;
+
+	/* Check if we need to scroll the terminal */
+	if (++priv->curr_row >= priv->rows) {
+		vidconsole_move_rows(dev, 0, rows, priv->rows - rows);
+		for (i = 0; i < rows; i++)
+			vidconsole_set_row(dev, priv->rows - i - 1,
+					   vid_priv->colour_bg);
+		priv->curr_row -= rows;
+	}
+	video_sync(dev->parent);
+}
+
+int vidconsole_put_char(struct udevice *dev, char ch)
+{
+	struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
+	int ret;
+
+	switch (ch) {
+	case '\r':
+		priv->curr_col = 0;
+		break;
+	case '\n':
+		vidconsole_newline(dev);
+		break;
+	case '\t':	/* Tab (8 chars alignment) */
+		priv->curr_col +=  8;
+		priv->curr_col &= ~7;
+
+		if (priv->curr_col >= priv->cols)
+			vidconsole_newline(dev);
+		break;
+	case '\b':
+		vidconsole_back(dev);
+		break;
+	default:
+		/*
+		 * Failure of this function normally indicates an unsupported
+		 * colour depth. Check this and return an error to help with
+		 * diagnosis.
+		 */
+		ret = vidconsole_putc_xy(dev,
+					 priv->curr_col * VIDEO_FONT_WIDTH,
+					 priv->curr_row * VIDEO_FONT_HEIGHT,
+					 ch);
+		if (ret)
+			return ret;
+		if (++priv->curr_col >= priv->cols)
+			vidconsole_newline(dev);
+		break;
+	}
+
+	return 0;
+}
+
+static void vidconsole_putc(struct stdio_dev *sdev, const char ch)
+{
+	struct udevice *dev = sdev->priv;
+
+	vidconsole_put_char(dev, ch);
+}
+
+static void vidconsole_puts(struct stdio_dev *sdev, const char *s)
+{
+	struct udevice *dev = sdev->priv;
+
+	while (*s)
+		vidconsole_put_char(dev, *s++);
+}
+
+/* Set up the number of rows and colours (rotated drivers override this) */
+static int vidconsole_pre_probe(struct udevice *dev)
+{
+	struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
+	struct udevice *vid = dev->parent;
+	struct video_priv *vid_priv = dev_get_uclass_priv(vid);
+
+	priv->rows = vid_priv->ysize / VIDEO_FONT_HEIGHT;
+	priv->cols = vid_priv->xsize / VIDEO_FONT_WIDTH;
+
+	return 0;
+}
+
+/* Register the device with stdio */
+static int vidconsole_post_probe(struct udevice *dev)
+{
+	struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
+	struct stdio_dev *sdev = &priv->sdev;
+	int ret;
+
+	strlcpy(sdev->name, dev->name, sizeof(sdev->name));
+	sdev->flags = DEV_FLAGS_OUTPUT;
+	sdev->putc = vidconsole_putc;
+	sdev->puts = vidconsole_puts;
+	sdev->priv = dev;
+	ret = stdio_register(sdev);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+UCLASS_DRIVER(vidconsole) = {
+	.id		= UCLASS_VIDEO_CONSOLE,
+	.name		= "vidconsole0",
+	.pre_probe	= vidconsole_pre_probe,
+	.post_probe	= vidconsole_post_probe,
+	.per_device_auto_alloc_size	= sizeof(struct vidconsole_priv),
+};
+
+void vidconsole_position_cursor(struct udevice *dev, unsigned col, unsigned row)
+{
+	struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
+
+	priv->curr_col = min_t(short, col, priv->cols - 1);
+	priv->curr_row = min_t(short, row, priv->rows - 1);
+}
+
+static int do_video_setcursor(cmd_tbl_t *cmdtp, int flag, int argc,
+			      char *const argv[])
+{
+	unsigned int col, row;
+	struct udevice *dev;
+
+	if (argc != 3)
+		return CMD_RET_USAGE;
+
+	uclass_first_device(UCLASS_VIDEO_CONSOLE, &dev);
+	if (!dev)
+		return CMD_RET_FAILURE;
+	col = simple_strtoul(argv[1], NULL, 10);
+	row = simple_strtoul(argv[2], NULL, 10);
+	vidconsole_position_cursor(dev, col, row);
+
+	return 0;
+}
+
+static int do_video_puts(cmd_tbl_t *cmdtp, int flag, int argc,
+			 char *const argv[])
+{
+	struct udevice *dev;
+	const char *s;
+
+	if (argc != 2)
+		return CMD_RET_USAGE;
+
+	uclass_first_device(UCLASS_VIDEO_CONSOLE, &dev);
+	if (!dev)
+		return CMD_RET_FAILURE;
+	for (s = argv[1]; *s; s++)
+		vidconsole_put_char(dev, *s);
+
+	return 0;
+}
+
+U_BOOT_CMD(
+	setcurs, 3,	1,	do_video_setcursor,
+	"set cursor position within screen",
+	"    <col> <row> in character"
+);
+
+U_BOOT_CMD(
+	lcdputs, 2,	1,	do_video_puts,
+	"print string on video framebuffer",
+	"    <string>"
+);
diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index 1615889..63d0d9d 100644
--- a/drivers/video/video-uclass.c
+++ b/drivers/video/video-uclass.c
@@ -189,6 +189,27 @@ static int video_post_probe(struct udevice *dev)
 #endif
 	video_clear(dev);
 
+	/*
+	 * Create a text console devices. For now we always do this, although
+	 * it might be useful to support only bitmap drawing on the device
+	 * for boards that don't need to display text.
+	 */
+	snprintf(name, sizeof(name), "%s.vidconsole", dev->name);
+	str = strdup(name);
+	if (!str)
+		return -ENOMEM;
+	snprintf(drv, sizeof(drv), "vidconsole%d", priv->rot);
+	ret = device_bind_driver(dev, drv, str, &cons);
+	if (ret) {
+		debug("%s: Cannot bind console driver\n", __func__);
+		return ret;
+	}
+	ret = device_probe(cons);
+	if (ret) {
+		debug("%s: Cannot probe console driver\n", __func__);
+		return ret;
+	}
+
 	return 0;
 };
 
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index 3934375..a0a3a79 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -68,6 +68,7 @@ enum uclass_id {
 	UCLASS_USB_HUB,		/* USB hub */
 	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_COUNT,
 	UCLASS_INVALID = -1,
diff --git a/include/video_console.h b/include/video_console.h
new file mode 100644
index 0000000..c0fc792
--- /dev/null
+++ b/include/video_console.h
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2015 Google, Inc
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __video_console_h
+#define __video_console_h
+
+/**
+ * struct vidconsole_priv - uclass-private data about a console device
+ *
+ * @sdev:	stdio device, acting as an output sink
+ * @curr_col:	Current text column (0=left)
+ * @curr_row:	Current row (0=top)
+ * @rows:	Number of text rows
+ * @cols:	Number of text columns
+ */
+struct vidconsole_priv {
+	struct stdio_dev sdev;
+	int curr_col;
+	int curr_row;
+	int rows;
+	int cols;
+};
+
+/**
+ * struct vidconsole_ops - Video console operations
+ *
+ * These operations work on either an absolute console position (measured
+ * in pixels) or a text row number (measured in rows, where each row consists
+ * of an entire line of text - typically 16 pixels).
+ */
+struct vidconsole_ops {
+	/**
+	 * putc_xy() - write a single character to a position
+	 *
+	 * @dev:	Device to write to
+	 * @x:		Pixel X position (0=left-most pixel)
+	 * @y:		Pixel Y position (0=top-most pixel)
+	 * @ch:		Character to write
+	 * @return 0 if OK, -ve on error
+	 */
+	int (*putc_xy)(struct udevice *dev, uint x, uint y, char ch);
+
+	/**
+	 * move_rows() - Move text rows from one place to another
+	 *
+	 * @dev:	Device to adjust
+	 * @rowdst:	Destination text row (0=top)
+	 * @rowsrc:	Source start text row
+	 * @count:	Number of text rows to move
+	 * @return 0 if OK, -ve on error
+	 */
+	int (*move_rows)(struct udevice *dev, uint rowdst, uint rowsrc,
+			  uint count);
+
+	/**
+	 * set_row() - Set the colour of a text row
+	 *
+	 * Every pixel contained within the text row is adjusted
+	 *
+	 * @dev:	Device to adjust
+	 * @row:	Text row to adjust (0=top)
+	 * @clr:	Raw colour (pixel value) to write to each pixel
+	 * @return 0 if OK, -ve on error
+	 */
+	int (*set_row)(struct udevice *dev, uint row, int clr);
+};
+
+/* Get a pointer to the driver operations for a video console device */
+#define vidconsole_get_ops(dev)  ((struct vidconsole_ops *)(dev)->driver->ops)
+
+/**
+ * vidconsole_putc_xy() - write a single character to a position
+ *
+ * @dev:	Device to write to
+ * @x:		Pixel X position (0=left-most pixel)
+ * @y:		Pixel Y position (0=top-most pixel)
+ * @ch:		Character to write
+ * @return 0 if OK, -ve on error
+ */
+int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, char ch);
+
+/**
+ * vidconsole_move_rows() - Move text rows from one place to another
+ *
+ * @dev:	Device to adjust
+ * @rowdst:	Destination text row (0=top)
+ * @rowsrc:	Source start text row
+ * @count:	Number of text rows to move
+ * @return 0 if OK, -ve on error
+ */
+int vidconsole_move_rows(struct udevice *dev, uint rowdst, uint rowsrc,
+			 uint count);
+
+/**
+ * vidconsole_set_row() - Set the colour of a text row
+ *
+ * Every pixel contained within the text row is adjusted
+ *
+ * @dev:	Device to adjust
+ * @row:	Text row to adjust (0=top)
+ * @clr:	Raw colour (pixel value) to write to each pixel
+ * @return 0 if OK, -ve on error
+ */
+int vidconsole_set_row(struct udevice *dev, uint row, int clr);
+
+/**
+ * vidconsole_put_char() - Output a character to the current console position
+ *
+ * Outputs a character to the console and advances the cursor. This function
+ * handles wrapping to new lines and scrolling the console. Special
+ * characters are handled also: \n, \r, \b and \t.
+ *
+ * The device always starts with the cursor at position 0,0 (top left). It
+ * can be adjusted manually using vidconsole_position_cursor().
+ *
+ * @dev:	Device to adjust
+ * @ch:		Character to write
+ * @return 0 if OK, -ve on error
+ */
+int vidconsole_put_char(struct udevice *dev, char ch);
+
+/**
+ * vidconsole_position_cursor() - Move the text cursor
+ *
+ * @dev:	Device to adjust
+ * @col:	New cursor text column
+ * @row:	New cursor text row
+ * @return 0 if OK, -ve on error
+ */
+void vidconsole_position_cursor(struct udevice *dev, unsigned col,
+				unsigned row);
+
+#endif
-- 
2.6.0.rc2.230.g3dd15c0

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 04/14] dm: video: Add a 'normal' text console driver
  2016-01-19  2:52 [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support Simon Glass
                   ` (2 preceding siblings ...)
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 03/14] dm: video: Add a uclass for the text console Simon Glass
@ 2016-01-19  2:52 ` Simon Glass
  2016-01-21 15:18   ` Simon Glass
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 05/14] dm: video: Add a driver for a rotated text console Simon Glass
                   ` (10 subsequent siblings)
  14 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2016-01-19  2:52 UTC (permalink / raw)
  To: u-boot

Most of the time we don't need to rotate the display so a simple font
blitting feature is enough for our purposes. Add a simple driver which
supports this function. It provides text output on the console using
the standard 8x16-pixel font.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2: None

 drivers/video/Makefile         |   2 +-
 drivers/video/console_normal.c | 141 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 142 insertions(+), 1 deletion(-)
 create mode 100644 drivers/video/console_normal.c

diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index e82f1ae..b4eba8e 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -7,7 +7,7 @@
 
 ifdef CONFIG_DM
 obj-$(CONFIG_DISPLAY_PORT) += dp-uclass.o
-obj-$(CONFIG_DM_VIDEO) += video-uclass.o vidconsole-uclass.o
+obj-$(CONFIG_DM_VIDEO) += video-uclass.o vidconsole-uclass.o console_normal.o
 endif
 
 obj-$(CONFIG_ATI_RADEON_FB) += ati_radeon_fb.o videomodes.o
diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c
new file mode 100644
index 0000000..d1031c8
--- /dev/null
+++ b/drivers/video/console_normal.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2015 Google, Inc
+ * (C) Copyright 2001-2015
+ * DENX Software Engineering -- wd at denx.de
+ * Compulab Ltd - http://compulab.co.il/
+ * Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <video.h>
+#include <video_console.h>
+#include <video_font.h>		/* Get font data, width and height */
+
+static int console_normal_set_row(struct udevice *dev, uint row, int clr)
+{
+	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
+	void *line;
+	int pixels = VIDEO_FONT_HEIGHT * vid_priv->line_length;
+	int i;
+
+	line = vid_priv->fb + row * VIDEO_FONT_HEIGHT * vid_priv->line_length;
+	switch (vid_priv->bpix) {
+#ifdef CONFIG_VIDEO_BPP8
+	case VIDEO_BPP8: {
+		uint8_t *dst = line;
+
+		for (i = 0; i < pixels; i++)
+			*dst++ = clr;
+		break;
+	}
+#endif
+#ifdef CONFIG_VIDEO_BPP16
+	case VIDEO_BPP16: {
+		uint16_t *dst = line;
+
+		for (i = 0; i < pixels; i++)
+			*dst++ = clr;
+		break;
+	}
+#endif
+#ifdef CONFIG_VIDEO_BPP32
+	case VIDEO_BPP32: {
+		uint32_t *dst = line;
+
+		for (i = 0; i < pixels; i++)
+			*dst++ = clr;
+		break;
+	}
+#endif
+	default:
+		return -ENOSYS;
+	}
+
+	return 0;
+}
+
+static int console_normal_move_rows(struct udevice *dev, uint rowdst,
+				     uint rowsrc, uint count)
+{
+	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
+	void *dst;
+	void *src;
+
+	dst = vid_priv->fb + rowdst * VIDEO_FONT_HEIGHT * vid_priv->line_length;
+	src = vid_priv->fb + rowsrc * VIDEO_FONT_HEIGHT * vid_priv->line_length;
+	memmove(dst, src, VIDEO_FONT_HEIGHT * vid_priv->line_length * count);
+
+	return 0;
+}
+
+static int console_normal_putc_xy(struct udevice *dev, uint x, uint y, char ch)
+{
+	struct udevice *vid = dev->parent;
+	struct video_priv *vid_priv = dev_get_uclass_priv(vid);
+	int i, row;
+	void *line = vid_priv->fb + y * vid_priv->line_length +
+		x * VNBYTES(vid_priv->bpix);
+
+	for (row = 0; row < VIDEO_FONT_HEIGHT; row++) {
+		uchar bits = video_fontdata[ch * VIDEO_FONT_HEIGHT + row];
+
+		switch (vid_priv->bpix) {
+#ifdef CONFIG_VIDEO_BPP8
+		case VIDEO_BPP8: {
+			uint8_t *dst = line;
+
+			for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
+				*dst++ = (bits & 0x80) ? vid_priv->colour_fg
+					: vid_priv->colour_bg;
+				bits <<= 1;
+			}
+			break;
+		}
+#endif
+#ifdef CONFIG_VIDEO_BPP16
+		case VIDEO_BPP16: {
+			uint16_t *dst = line;
+
+			for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
+				*dst++ = (bits & 0x80) ? vid_priv->colour_fg
+					: vid_priv->colour_bg;
+				bits <<= 1;
+			}
+			break;
+		}
+#endif
+#ifdef CONFIG_VIDEO_BPP32
+		case VIDEO_BPP32: {
+			uint32_t *dst = line;
+
+			for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
+				*dst++ = (bits & 0x80) ? vid_priv->colour_fg
+					: vid_priv->colour_bg;
+				bits <<= 1;
+			}
+			break;
+		}
+#endif
+		default:
+			return -ENOSYS;
+		}
+		line += vid_priv->line_length;
+	}
+
+	return 0;
+}
+
+struct vidconsole_ops console_normal_ops = {
+	.putc_xy	= console_normal_putc_xy,
+	.move_rows	= console_normal_move_rows,
+	.set_row	= console_normal_set_row,
+};
+
+U_BOOT_DRIVER(vidconsole_normal) = {
+	.name	= "vidconsole0",
+	.id	= UCLASS_VIDEO_CONSOLE,
+	.ops	= &console_normal_ops,
+};
-- 
2.6.0.rc2.230.g3dd15c0

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 05/14] dm: video: Add a driver for a rotated text console
  2016-01-19  2:52 [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support Simon Glass
                   ` (3 preceding siblings ...)
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 04/14] dm: video: Add a 'normal' text console driver Simon Glass
@ 2016-01-19  2:52 ` Simon Glass
  2016-01-21 15:19   ` Simon Glass
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 06/14] common: Move LCD and video memory reservation together Simon Glass
                   ` (9 subsequent siblings)
  14 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2016-01-19  2:52 UTC (permalink / raw)
  To: u-boot

Sometimes the console must be rotated. Add a driver which supports rotating
the text clockwise to 90, 180 and 270 degrees. This can support devices
where the display is rotated for mechanical reasons.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2: None

 drivers/video/Kconfig          |  13 ++
 drivers/video/Makefile         |   1 +
 drivers/video/console_rotate.c | 436 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 450 insertions(+)
 create mode 100644 drivers/video/console_rotate.c

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 946d958..499d00d 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -44,6 +44,19 @@ config VIDEO_BPP32
 	  this option, such displays will not be supported and console output
 	  will be empty.
 
+config VIDEO_ROTATION
+	bool "Support rotated displays"
+	depends on DM_VIDEO
+	help
+	  Sometimes, for example if the display is mounted in portrait
+	  mode or even if it's mounted landscape but rotated by 180degree,
+	  we need to rotate our content of the display relative to the
+	  framebuffer, so that user can read the messages which are
+	  printed out. Enable this option to include a text driver which can
+	  support this. The rotation is set by the 'rot' parameter in
+	  struct video_priv: 0=unrotated, 1=90 degrees clockwise, 2=180
+	  degrees, 3=270 degrees.
+
 config VIDEO_VESA
 	bool "Enable VESA video driver support"
 	default n
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index b4eba8e..8f26d1d 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -8,6 +8,7 @@
 ifdef CONFIG_DM
 obj-$(CONFIG_DISPLAY_PORT) += dp-uclass.o
 obj-$(CONFIG_DM_VIDEO) += video-uclass.o vidconsole-uclass.o console_normal.o
+obj-$(CONFIG_VIDEO_ROTATION) += console_rotate.o
 endif
 
 obj-$(CONFIG_ATI_RADEON_FB) += ati_radeon_fb.o videomodes.o
diff --git a/drivers/video/console_rotate.c b/drivers/video/console_rotate.c
new file mode 100644
index 0000000..ebb31d8
--- /dev/null
+++ b/drivers/video/console_rotate.c
@@ -0,0 +1,436 @@
+/*
+ * Copyright (c) 2015 Google, Inc
+ * (C) Copyright 2015
+ * Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <video.h>
+#include <video_console.h>
+#include <video_font.h>		/* Get font data, width and height */
+
+static int console_set_row_1(struct udevice *dev, uint row, int clr)
+{
+	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
+	int pbytes = VNBYTES(vid_priv->bpix);
+	void *line;
+	int i, j;
+
+	line = vid_priv->fb + vid_priv->line_length -
+		(row + 1) * VIDEO_FONT_HEIGHT * pbytes;
+	for (j = 0; j < vid_priv->ysize; j++) {
+		switch (vid_priv->bpix) {
+#ifdef CONFIG_VIDEO_BPP8
+		case VIDEO_BPP8: {
+			uint8_t *dst = line;
+
+			for (i = 0; i < VIDEO_FONT_HEIGHT; i++)
+				*dst++ = clr;
+			break;
+		}
+#endif
+#ifdef CONFIG_VIDEO_BPP16
+		case VIDEO_BPP16: {
+			uint16_t *dst = line;
+
+			for (i = 0; i < VIDEO_FONT_HEIGHT; i++)
+				*dst++ = clr;
+			break;
+		}
+#endif
+#ifdef CONFIG_VIDEO_BPP32
+		case VIDEO_BPP32: {
+			uint32_t *dst = line;
+
+			for (i = 0; i < VIDEO_FONT_HEIGHT; i++)
+				*dst++ = clr;
+			break;
+		}
+#endif
+		default:
+			return -ENOSYS;
+		}
+		line += vid_priv->line_length;
+	}
+
+	return 0;
+}
+
+static int console_move_rows_1(struct udevice *dev, uint rowdst, uint rowsrc,
+			       uint count)
+{
+	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
+	void *dst;
+	void *src;
+	int pbytes = VNBYTES(vid_priv->bpix);
+	int j;
+
+	dst = vid_priv->fb + vid_priv->line_length -
+		(rowdst + count) * VIDEO_FONT_HEIGHT * pbytes;
+	src = vid_priv->fb + vid_priv->line_length -
+		(rowsrc + count) * VIDEO_FONT_HEIGHT * pbytes;
+
+	for (j = 0; j < vid_priv->ysize; j++) {
+		memmove(dst, src, VIDEO_FONT_HEIGHT * pbytes * count);
+		src += vid_priv->line_length;
+		dst += vid_priv->line_length;
+	}
+
+	return 0;
+}
+
+static int console_putc_xy_1(struct udevice *dev, uint x, uint y, char ch)
+{
+	struct udevice *vid = dev->parent;
+	struct video_priv *vid_priv = dev_get_uclass_priv(vid);
+	int pbytes = VNBYTES(vid_priv->bpix);
+	int i, col;
+	int mask = 0x80;
+	void *line = vid_priv->fb + (x + 1) * vid_priv->line_length -
+		(y + 1) * pbytes;
+	uchar *pfont = video_fontdata + ch * VIDEO_FONT_HEIGHT;
+
+	for (col = 0; col < VIDEO_FONT_HEIGHT; col++) {
+		switch (vid_priv->bpix) {
+#ifdef CONFIG_VIDEO_BPP8
+		case VIDEO_BPP8: {
+			uint8_t *dst = line;
+
+			for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
+				*dst-- = (pfont[i] & mask) ? vid_priv->colour_fg
+					: vid_priv->colour_bg;
+			}
+			break;
+		}
+#endif
+#ifdef CONFIG_VIDEO_BPP16
+		case VIDEO_BPP16: {
+			uint16_t *dst = line;
+
+			for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
+				*dst-- = (pfont[i] & mask) ? vid_priv->colour_fg
+					: vid_priv->colour_bg;
+			}
+			break;
+		}
+#endif
+#ifdef CONFIG_VIDEO_BPP32
+		case VIDEO_BPP32: {
+			uint32_t *dst = line;
+
+			for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
+				*dst-- = (pfont[i] & mask) ? vid_priv->colour_fg
+					: vid_priv->colour_bg;
+			}
+			break;
+		}
+#endif
+		default:
+			return -ENOSYS;
+		}
+		line += vid_priv->line_length;
+		mask >>= 1;
+	}
+
+	return 0;
+}
+
+
+static int console_set_row_2(struct udevice *dev, uint row, int clr)
+{
+	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
+	void *line;
+	int pixels = VIDEO_FONT_HEIGHT * vid_priv->xsize;
+	int i;
+
+	line = vid_priv->fb + vid_priv->ysize * vid_priv->line_length -
+		(row + 1) * VIDEO_FONT_HEIGHT * vid_priv->line_length;
+	switch (vid_priv->bpix) {
+#ifdef CONFIG_VIDEO_BPP8
+	case VIDEO_BPP8: {
+		uint8_t *dst = line;
+
+		for (i = 0; i < pixels; i++)
+			*dst++ = clr;
+		break;
+	}
+#endif
+#ifdef CONFIG_VIDEO_BPP16
+	case VIDEO_BPP16: {
+		uint16_t *dst = line;
+
+		for (i = 0; i < pixels; i++)
+			*dst++ = clr;
+		break;
+	}
+#endif
+#ifdef CONFIG_VIDEO_BPP32
+	case VIDEO_BPP32: {
+		uint32_t *dst = line;
+
+		for (i = 0; i < pixels; i++)
+			*dst++ = clr;
+		break;
+	}
+#endif
+	default:
+		return -ENOSYS;
+	}
+
+	return 0;
+}
+
+static int console_move_rows_2(struct udevice *dev, uint rowdst, uint rowsrc,
+			       uint count)
+{
+	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
+	void *dst;
+	void *src;
+	void *end;
+
+	end = vid_priv->fb + vid_priv->ysize * vid_priv->line_length;
+	dst = end - (rowdst + count) * VIDEO_FONT_HEIGHT *
+		vid_priv->line_length;
+	src = end - (rowsrc + count) * VIDEO_FONT_HEIGHT *
+		vid_priv->line_length;
+	memmove(dst, src, VIDEO_FONT_HEIGHT * vid_priv->line_length * count);
+
+	return 0;
+}
+
+static int console_putc_xy_2(struct udevice *dev, uint x, uint y, char ch)
+{
+	struct udevice *vid = dev->parent;
+	struct video_priv *vid_priv = dev_get_uclass_priv(vid);
+	int i, row;
+	void *line;
+
+	line = vid_priv->fb + (vid_priv->ysize - y - 1) *
+		vid_priv->line_length +
+		(vid_priv->xsize - x - VIDEO_FONT_WIDTH - 1) *
+		VNBYTES(vid_priv->bpix);
+
+	for (row = 0; row < VIDEO_FONT_HEIGHT; row++) {
+		uchar bits = video_fontdata[ch * VIDEO_FONT_HEIGHT + row];
+
+		switch (vid_priv->bpix) {
+#ifdef CONFIG_VIDEO_BPP8
+		case VIDEO_BPP8: {
+			uint8_t *dst = line;
+
+			for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
+				*dst-- = (bits & 0x80) ? vid_priv->colour_fg
+					: vid_priv->colour_bg;
+				bits <<= 1;
+			}
+			break;
+		}
+#endif
+#ifdef CONFIG_VIDEO_BPP16
+		case VIDEO_BPP16: {
+			uint16_t *dst = line;
+
+			for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
+				*dst-- = (bits & 0x80) ? vid_priv->colour_fg
+					: vid_priv->colour_bg;
+				bits <<= 1;
+			}
+			break;
+		}
+#endif
+#ifdef CONFIG_VIDEO_BPP32
+		case VIDEO_BPP32: {
+			uint32_t *dst = line;
+
+			for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
+				*dst-- = (bits & 0x80) ? vid_priv->colour_fg
+					: vid_priv->colour_bg;
+				bits <<= 1;
+			}
+			break;
+		}
+#endif
+		default:
+			return -ENOSYS;
+		}
+		line -= vid_priv->line_length;
+	}
+
+	return 0;
+}
+
+static int console_set_row_3(struct udevice *dev, uint row, int clr)
+{
+	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
+	int pbytes = VNBYTES(vid_priv->bpix);
+	void *line;
+	int i, j;
+
+	line = vid_priv->fb + row * VIDEO_FONT_HEIGHT * pbytes;
+	for (j = 0; j < vid_priv->ysize; j++) {
+		switch (vid_priv->bpix) {
+#ifdef CONFIG_VIDEO_BPP8
+		case VIDEO_BPP8: {
+			uint8_t *dst = line;
+
+			for (i = 0; i < VIDEO_FONT_HEIGHT; i++)
+				*dst++ = clr;
+			break;
+		}
+#endif
+#ifdef CONFIG_VIDEO_BPP16
+		case VIDEO_BPP16: {
+			uint16_t *dst = line;
+
+			for (i = 0; i < VIDEO_FONT_HEIGHT; i++)
+				*dst++ = clr;
+			break;
+		}
+#endif
+#ifdef CONFIG_VIDEO_BPP32
+		case VIDEO_BPP32: {
+			uint32_t *dst = line;
+
+			for (i = 0; i < VIDEO_FONT_HEIGHT; i++)
+				*dst++ = clr;
+			break;
+		}
+#endif
+		default:
+			return -ENOSYS;
+		}
+		line += vid_priv->line_length;
+	}
+
+	return 0;
+}
+
+static int console_move_rows_3(struct udevice *dev, uint rowdst, uint rowsrc,
+			       uint count)
+{
+	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
+	void *dst;
+	void *src;
+	int pbytes = VNBYTES(vid_priv->bpix);
+	int j;
+
+	dst = vid_priv->fb + rowdst * VIDEO_FONT_HEIGHT * pbytes;
+	src = vid_priv->fb + rowsrc * VIDEO_FONT_HEIGHT * pbytes;
+
+	for (j = 0; j < vid_priv->ysize; j++) {
+		memmove(dst, src, VIDEO_FONT_HEIGHT * pbytes * count);
+		src += vid_priv->line_length;
+		dst += vid_priv->line_length;
+	}
+
+	return 0;
+}
+
+static int console_putc_xy_3(struct udevice *dev, uint x, uint y, char ch)
+{
+	struct udevice *vid = dev->parent;
+	struct video_priv *vid_priv = dev_get_uclass_priv(vid);
+	int pbytes = VNBYTES(vid_priv->bpix);
+	int i, col;
+	int mask = 0x80;
+	void *line = vid_priv->fb + (vid_priv->ysize - x - 1) *
+		vid_priv->line_length + y * pbytes;
+	uchar *pfont = video_fontdata + ch * VIDEO_FONT_HEIGHT;
+
+	for (col = 0; col < VIDEO_FONT_HEIGHT; col++) {
+		switch (vid_priv->bpix) {
+#ifdef CONFIG_VIDEO_BPP8
+		case VIDEO_BPP8: {
+			uint8_t *dst = line;
+
+			for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
+				*dst++ = (pfont[i] & mask) ? vid_priv->colour_fg
+					: vid_priv->colour_bg;
+			}
+			break;
+		}
+#endif
+#ifdef CONFIG_VIDEO_BPP16
+		case VIDEO_BPP16: {
+			uint16_t *dst = line;
+
+			for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
+				*dst++ = (pfont[i] & mask) ? vid_priv->colour_fg
+					: vid_priv->colour_bg;
+			}
+			break;
+		}
+#endif
+#ifdef CONFIG_VIDEO_BPP32
+		case VIDEO_BPP32: {
+			uint32_t *dst = line;
+
+			for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
+				*dst++ = (pfont[i] & mask) ? vid_priv->colour_fg
+					: vid_priv->colour_bg;
+			}
+			break;
+		}
+#endif
+		default:
+			return -ENOSYS;
+		}
+		line -= vid_priv->line_length;
+		mask >>= 1;
+	}
+
+	return 0;
+}
+
+
+static int console_probe_1_3(struct udevice *dev)
+{
+	struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
+	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
+
+	priv->cols = vid_priv->ysize / VIDEO_FONT_WIDTH;
+	priv->rows = vid_priv->xsize / VIDEO_FONT_HEIGHT;
+
+	return 0;
+}
+
+struct vidconsole_ops console_ops_1 = {
+	.putc_xy	= console_putc_xy_1,
+	.move_rows	= console_move_rows_1,
+	.set_row	= console_set_row_1,
+};
+
+struct vidconsole_ops console_ops_2 = {
+	.putc_xy	= console_putc_xy_2,
+	.move_rows	= console_move_rows_2,
+	.set_row	= console_set_row_2,
+};
+
+struct vidconsole_ops console_ops_3 = {
+	.putc_xy	= console_putc_xy_3,
+	.move_rows	= console_move_rows_3,
+	.set_row	= console_set_row_3,
+};
+
+U_BOOT_DRIVER(vidconsole_1) = {
+	.name	= "vidconsole1",
+	.id	= UCLASS_VIDEO_CONSOLE,
+	.ops	= &console_ops_1,
+	.probe	= console_probe_1_3,
+};
+
+U_BOOT_DRIVER(vidconsole_2) = {
+	.name	= "vidconsole2",
+	.id	= UCLASS_VIDEO_CONSOLE,
+	.ops	= &console_ops_2,
+};
+
+U_BOOT_DRIVER(vidconsole_3) = {
+	.name	= "vidconsole3",
+	.id	= UCLASS_VIDEO_CONSOLE,
+	.ops	= &console_ops_3,
+	.probe	= console_probe_1_3,
+};
-- 
2.6.0.rc2.230.g3dd15c0

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 06/14] common: Move LCD and video memory reservation together
  2016-01-19  2:52 [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support Simon Glass
                   ` (4 preceding siblings ...)
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 05/14] dm: video: Add a driver for a rotated text console Simon Glass
@ 2016-01-19  2:52 ` Simon Glass
  2016-01-21 15:18   ` Simon Glass
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 07/14] dm: common: Add memory reservation for the video uclass Simon Glass
                   ` (8 subsequent siblings)
  14 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2016-01-19  2:52 UTC (permalink / raw)
  To: u-boot

These two functions are conceptually the same. Move them together in the
pre-relocation init.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2: None

 common/board_f.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/common/board_f.c b/common/board_f.c
index 8094ac4..068db0d 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -451,22 +451,10 @@ static int reserve_lcd(void)
 }
 #endif /* CONFIG_LCD */
 
-static int reserve_trace(void)
-{
-#ifdef CONFIG_TRACE
-	gd->relocaddr -= CONFIG_TRACE_BUFFER_SIZE;
-	gd->trace_buff = map_sysmem(gd->relocaddr, CONFIG_TRACE_BUFFER_SIZE);
-	debug("Reserving %dk for trace data at: %08lx\n",
-	      CONFIG_TRACE_BUFFER_SIZE >> 10, gd->relocaddr);
-#endif
-
-	return 0;
-}
-
 #if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \
 		!defined(CONFIG_ARM) && !defined(CONFIG_X86) && \
 		!defined(CONFIG_BLACKFIN) && !defined(CONFIG_M68K)
-static int reserve_video(void)
+static int reserve_legacy_video(void)
 {
 	/* reserve memory for video display (always full pages) */
 	gd->relocaddr = video_setmem(gd->relocaddr);
@@ -476,6 +464,18 @@ static int reserve_video(void)
 }
 #endif
 
+static int reserve_trace(void)
+{
+#ifdef CONFIG_TRACE
+	gd->relocaddr -= CONFIG_TRACE_BUFFER_SIZE;
+	gd->trace_buff = map_sysmem(gd->relocaddr, CONFIG_TRACE_BUFFER_SIZE);
+	debug("Reserving %dk for trace data at: %08lx\n",
+	      CONFIG_TRACE_BUFFER_SIZE >> 10, gd->relocaddr);
+#endif
+
+	return 0;
+}
+
 static int reserve_uboot(void)
 {
 	/*
@@ -960,13 +960,13 @@ static init_fnc_t init_sequence_f[] = {
 #ifdef CONFIG_LCD
 	reserve_lcd,
 #endif
-	reserve_trace,
 	/* TODO: Why the dependency on CONFIG_8xx? */
 #if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \
 		!defined(CONFIG_ARM) && !defined(CONFIG_X86) && \
 		!defined(CONFIG_BLACKFIN) && !defined(CONFIG_M68K)
 	reserve_video,
 #endif
+	reserve_trace,
 #if !defined(CONFIG_BLACKFIN)
 	reserve_uboot,
 #endif
-- 
2.6.0.rc2.230.g3dd15c0

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 07/14] dm: common: Add memory reservation for the video uclass
  2016-01-19  2:52 [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support Simon Glass
                   ` (5 preceding siblings ...)
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 06/14] common: Move LCD and video memory reservation together Simon Glass
@ 2016-01-19  2:52 ` Simon Glass
  2016-01-21 15:19   ` Simon Glass
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 08/14] dm: video: Implement the bmp command for driver model Simon Glass
                   ` (7 subsequent siblings)
  14 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2016-01-19  2:52 UTC (permalink / raw)
  To: u-boot

Before relocation we need to reserve memory for the video driver frame
buffers so that they can use this memory when they start up (after
relocation). Add a call to the uclass to permit this.

The current top and bottom of the region is stored in global_data so that
it can be checked post-relocation to ensure enough memory is available. No
video device should be probed before relocation.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2: None

 common/board_f.c                  | 47 +++++++++++++++++++++++++++++----------
 include/asm-generic/global_data.h |  4 ++++
 2 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/common/board_f.c b/common/board_f.c
index 068db0d..c470b59 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -46,6 +46,7 @@
 #include <spi.h>
 #include <status_led.h>
 #include <trace.h>
+#include <video.h>
 #include <watchdog.h>
 #include <asm/errno.h>
 #include <asm/io.h>
@@ -437,21 +438,38 @@ static int reserve_mmu(void)
 }
 #endif
 
-#ifdef CONFIG_LCD
+#ifdef CONFIG_DM_VIDEO
+static int reserve_video(void)
+{
+	ulong addr;
+	int ret;
+
+	addr = gd->relocaddr;
+	ret = video_reserve(&addr);
+	if (ret)
+		return ret;
+	gd->relocaddr = addr;
+
+	return 0;
+}
+#else
+
+# ifdef CONFIG_LCD
 static int reserve_lcd(void)
 {
-#ifdef CONFIG_FB_ADDR
+#  ifdef CONFIG_FB_ADDR
 	gd->fb_base = CONFIG_FB_ADDR;
-#else
+#  else
 	/* reserve memory for LCD display (always full pages) */
 	gd->relocaddr = lcd_setmem(gd->relocaddr);
 	gd->fb_base = gd->relocaddr;
-#endif /* CONFIG_FB_ADDR */
+#  endif /* CONFIG_FB_ADDR */
+
 	return 0;
 }
-#endif /* CONFIG_LCD */
+# endif /* CONFIG_LCD */
 
-#if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \
+# if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \
 		!defined(CONFIG_ARM) && !defined(CONFIG_X86) && \
 		!defined(CONFIG_BLACKFIN) && !defined(CONFIG_M68K)
 static int reserve_legacy_video(void)
@@ -462,7 +480,8 @@ static int reserve_legacy_video(void)
 
 	return 0;
 }
-#endif
+# endif
+#endif /* !CONFIG_DM_VIDEO */
 
 static int reserve_trace(void)
 {
@@ -957,15 +976,19 @@ static init_fnc_t init_sequence_f[] = {
 		defined(CONFIG_ARM)
 	reserve_mmu,
 #endif
-#ifdef CONFIG_LCD
+#ifdef CONFIG_DM_VIDEO
+	reserve_video,
+#else
+# ifdef CONFIG_LCD
 	reserve_lcd,
-#endif
+# endif
 	/* TODO: Why the dependency on CONFIG_8xx? */
-#if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \
+# if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \
 		!defined(CONFIG_ARM) && !defined(CONFIG_X86) && \
 		!defined(CONFIG_BLACKFIN) && !defined(CONFIG_M68K)
-	reserve_video,
-#endif
+	reserve_legacy_video,
+# endif
+#endif /* CONFIG_DM_VIDEO */
 	reserve_trace,
 #if !defined(CONFIG_BLACKFIN)
 	reserve_uboot,
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index 5d8b043..a587d3c 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -122,6 +122,10 @@ typedef struct global_data {
 	struct membuff console_out;	/* console output */
 	struct membuff console_in;	/* console input */
 #endif
+#ifdef CONFIG_DM_VIDEO
+	ulong video_top;		/* Top of video frame buffer area */
+	ulong video_bottom;		/* Bottom of video frame buffer area */
+#endif
 } gd_t;
 #endif
 
-- 
2.6.0.rc2.230.g3dd15c0

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 08/14] dm: video: Implement the bmp command for driver model
  2016-01-19  2:52 [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support Simon Glass
                   ` (6 preceding siblings ...)
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 07/14] dm: common: Add memory reservation for the video uclass Simon Glass
@ 2016-01-19  2:52 ` Simon Glass
  2016-01-21 15:19   ` Simon Glass
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 09/14] dm: stdio: video: Plumb the video uclass into stdio Simon Glass
                   ` (6 subsequent siblings)
  14 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2016-01-19  2:52 UTC (permalink / raw)
  To: u-boot

This command can use the bitmap display code in the uclass. This is similar
to the code in lcd.c and cfb_console.c. These other copies will go away when
all boards are converted to use driver model for video.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2: None

 common/cmd_bmp.c          |  22 ++-
 drivers/video/Makefile    |   1 +
 drivers/video/video_bmp.c | 353 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 375 insertions(+), 1 deletion(-)
 create mode 100644 drivers/video/video_bmp.c

diff --git a/common/cmd_bmp.c b/common/cmd_bmp.c
index f04b7d4..fd5b7db 100644
--- a/common/cmd_bmp.c
+++ b/common/cmd_bmp.c
@@ -10,7 +10,9 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <lcd.h>
+#include <mapmem.h>
 #include <bmp_layout.h>
 #include <command.h>
 #include <asm/byteorder.h>
@@ -225,6 +227,9 @@ static int bmp_info(ulong addr)
  */
 int bmp_display(ulong addr, int x, int y)
 {
+#ifdef CONFIG_DM_VIDEO
+	struct udevice *dev;
+#endif
 	int ret;
 	struct bmp_image *bmp = map_sysmem(addr, 0);
 	void *bmp_alloc_addr = NULL;
@@ -240,7 +245,22 @@ int bmp_display(ulong addr, int x, int y)
 	}
 	addr = map_to_sysmem(bmp);
 
-#if defined(CONFIG_LCD)
+#ifdef CONFIG_DM_VIDEO
+	ret = uclass_first_device(UCLASS_VIDEO, &dev);
+	if (!ret) {
+		if (!dev)
+			ret = -ENODEV;
+		if (!ret) {
+			bool align = false;
+
+# ifdef CONFIG_SPLASH_SCREEN_ALIGN
+			align = true;
+# endif /* CONFIG_SPLASH_SCREEN_ALIGN */
+			ret = video_bmp_display(dev, addr, x, y, align);
+		}
+	}
+	return ret ? CMD_RET_FAILURE : 0;
+#elif defined(CONFIG_LCD)
 	ret = lcd_display_bitmap(addr, x, y);
 #elif defined(CONFIG_VIDEO)
 	ret = video_display_bitmap(addr, x, y);
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 8f26d1d..ee04629 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -8,6 +8,7 @@
 ifdef CONFIG_DM
 obj-$(CONFIG_DISPLAY_PORT) += dp-uclass.o
 obj-$(CONFIG_DM_VIDEO) += video-uclass.o vidconsole-uclass.o console_normal.o
+obj-$(CONFIG_DM_VIDEO) += video_bmp.o
 obj-$(CONFIG_VIDEO_ROTATION) += console_rotate.o
 endif
 
diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c
new file mode 100644
index 0000000..c9075d6
--- /dev/null
+++ b/drivers/video/video_bmp.c
@@ -0,0 +1,353 @@
+/*
+ * Copyright (c) 2015 Google, Inc
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <bmp_layout.h>
+#include <dm.h>
+#include <mapmem.h>
+#include <video.h>
+#include <watchdog.h>
+#include <asm/unaligned.h>
+
+#ifdef CONFIG_VIDEO_BMP_RLE8
+#define BMP_RLE8_ESCAPE		0
+#define BMP_RLE8_EOL		0
+#define BMP_RLE8_EOBMP		1
+#define BMP_RLE8_DELTA		2
+
+static void draw_unencoded_bitmap(ushort **fbp, uchar *bmap, ushort *cmap,
+				  int cnt)
+{
+	while (cnt > 0) {
+		*(*fbp)++ = cmap[*bmap++];
+		cnt--;
+	}
+}
+
+static void draw_encoded_bitmap(ushort **fbp, ushort col, int cnt)
+{
+	ushort *fb = *fbp;
+
+	while (cnt > 0) {
+		*fb++ = col;
+		cnt--;
+	}
+	*fbp = fb;
+}
+
+static void video_display_rle8_bitmap(struct udevice *dev,
+				      struct bmp_image *bmp, ushort *cmap,
+				      uchar *fb, int x_off, int y_off)
+{
+	struct video_priv *priv = dev_get_uclass_priv(dev);
+	uchar *bmap;
+	ulong width, height;
+	ulong cnt, runlen;
+	int x, y;
+	int decode = 1;
+
+	debug("%s\n", __func__);
+	width = get_unaligned_le32(&bmp->header.width);
+	height = get_unaligned_le32(&bmp->header.height);
+	bmap = (uchar *)bmp + get_unaligned_le32(&bmp->header.data_offset);
+
+	x = 0;
+	y = height - 1;
+
+	while (decode) {
+		if (bmap[0] == BMP_RLE8_ESCAPE) {
+			switch (bmap[1]) {
+			case BMP_RLE8_EOL:
+				/* end of line */
+				bmap += 2;
+				x = 0;
+				y--;
+				/* 16bpix, 2-byte per pixel, width should *2 */
+				fb -= (width * 2 + priv->line_length);
+				break;
+			case BMP_RLE8_EOBMP:
+				/* end of bitmap */
+				decode = 0;
+				break;
+			case BMP_RLE8_DELTA:
+				/* delta run */
+				x += bmap[2];
+				y -= bmap[3];
+				/* 16bpix, 2-byte per pixel, x should *2 */
+				fb = (uchar *)(priv->fb + (y + y_off - 1)
+					* priv->line_length + (x + x_off) * 2);
+				bmap += 4;
+				break;
+			default:
+				/* unencoded run */
+				runlen = bmap[1];
+				bmap += 2;
+				if (y < height) {
+					if (x < width) {
+						if (x + runlen > width)
+							cnt = width - x;
+						else
+							cnt = runlen;
+						draw_unencoded_bitmap(
+							(ushort **)&fb,
+							bmap, cmap, cnt);
+					}
+					x += runlen;
+				}
+				bmap += runlen;
+				if (runlen & 1)
+					bmap++;
+			}
+		} else {
+			/* encoded run */
+			if (y < height) {
+				runlen = bmap[0];
+				if (x < width) {
+					/* aggregate the same code */
+					while (bmap[0] == 0xff &&
+					       bmap[2] != BMP_RLE8_ESCAPE &&
+					       bmap[1] == bmap[3]) {
+						runlen += bmap[2];
+						bmap += 2;
+					}
+					if (x + runlen > width)
+						cnt = width - x;
+					else
+						cnt = runlen;
+					draw_encoded_bitmap((ushort **)&fb,
+						cmap[bmap[1]], cnt);
+				}
+				x += runlen;
+			}
+			bmap += 2;
+		}
+	}
+}
+#endif
+
+__weak void fb_put_byte(uchar **fb, uchar **from)
+{
+	*(*fb)++ = *(*from)++;
+}
+
+#if defined(CONFIG_BMP_16BPP)
+__weak void fb_put_word(uchar **fb, uchar **from)
+{
+	*(*fb)++ = *(*from)++;
+	*(*fb)++ = *(*from)++;
+}
+#endif /* CONFIG_BMP_16BPP */
+
+#define BMP_ALIGN_CENTER	0x7fff
+
+/**
+ * video_splash_align_axis() - Align a single coordinate
+ *
+ *- if a coordinate is 0x7fff then the image will be centred in
+ *  that direction
+ *- if a coordinate is -ve then it will be offset to the
+ *  left/top of the centre by that many pixels
+ *- if a coordinate is positive it will be used unchnaged.
+ *
+ * @axis:	Input and output coordinate
+ * @panel_size:	Size of panel in pixels for that axis
+ * @picture_size:	Size of bitmap in pixels for that axis
+ */
+static void video_splash_align_axis(int *axis, unsigned long panel_size,
+				    unsigned long picture_size)
+{
+	unsigned long panel_picture_delta = panel_size - picture_size;
+	unsigned long axis_alignment;
+
+	if (*axis == BMP_ALIGN_CENTER)
+		axis_alignment = panel_picture_delta / 2;
+	else if (*axis < 0)
+		axis_alignment = panel_picture_delta + *axis + 1;
+	else
+		return;
+
+	*axis = max(0, (int)axis_alignment);
+}
+
+static void video_set_cmap(struct udevice *dev,
+			   struct bmp_color_table_entry *cte, unsigned colours)
+{
+	struct video_priv *priv = dev_get_uclass_priv(dev);
+	int i;
+	ushort *cmap = priv->cmap;
+
+	debug("%s: colours=%d\n", __func__, colours);
+	for (i = 0; i < colours; ++i) {
+		*cmap = ((cte->red   << 8) & 0xf800) |
+			((cte->green << 3) & 0x07e0) |
+			((cte->blue  >> 3) & 0x001f);
+		cmap++;
+		cte++;
+	}
+}
+
+int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
+		      bool align)
+{
+	struct video_priv *priv = dev_get_uclass_priv(dev);
+	ushort *cmap_base = NULL;
+	ushort i, j;
+	uchar *fb;
+	struct bmp_image *bmp = map_sysmem(bmp_image, 0);
+	uchar *bmap;
+	ushort padded_width;
+	unsigned long width, height, byte_width;
+	unsigned long pwidth = priv->xsize;
+	unsigned colours, bpix, bmp_bpix;
+	struct bmp_color_table_entry *palette;
+	int hdr_size;
+
+	if (!bmp || !(bmp->header.signature[0] == 'B' &&
+	    bmp->header.signature[1] == 'M')) {
+		printf("Error: no valid bmp image at %lx\n", bmp_image);
+
+		return -EINVAL;
+	}
+
+	width = get_unaligned_le32(&bmp->header.width);
+	height = get_unaligned_le32(&bmp->header.height);
+	bmp_bpix = get_unaligned_le16(&bmp->header.bit_count);
+	hdr_size = get_unaligned_le16(&bmp->header.size);
+	debug("hdr_size=%d, bmp_bpix=%d\n", hdr_size, bmp_bpix);
+	palette = (void *)bmp + 14 + hdr_size;
+
+	colours = 1 << bmp_bpix;
+
+	bpix = VNBITS(priv->bpix);
+
+	if (bpix != 1 && bpix != 8 && bpix != 16 && bpix != 32) {
+		printf("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
+		       bpix, bmp_bpix);
+
+		return -EINVAL;
+	}
+
+	/*
+	 * We support displaying 8bpp BMPs on 16bpp LCDs
+	 * and displaying 24bpp BMPs on 32bpp LCDs
+	 * */
+	if (bpix != bmp_bpix &&
+	    !(bmp_bpix == 8 && bpix == 16) &&
+	    !(bmp_bpix == 24 && bpix == 32)) {
+		printf("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
+		       bpix, get_unaligned_le16(&bmp->header.bit_count));
+		return -EPERM;
+	}
+
+	debug("Display-bmp: %d x %d  with %d colours, display %d\n",
+	      (int)width, (int)height, (int)colours, 1 << bpix);
+
+	if (bmp_bpix == 8)
+		video_set_cmap(dev, palette, colours);
+
+	padded_width = (width & 0x3 ? (width & ~0x3) + 4 : width);
+
+	if (align) {
+		video_splash_align_axis(&x, priv->xsize, width);
+		video_splash_align_axis(&y, priv->ysize, height);
+	}
+
+	if ((x + width) > pwidth)
+		width = pwidth - x;
+	if ((y + height) > priv->ysize)
+		height = priv->ysize - y;
+
+	bmap = (uchar *)bmp + get_unaligned_le32(&bmp->header.data_offset);
+	fb = (uchar *)(priv->fb +
+		(y + height - 1) * priv->line_length + x * bpix / 8);
+
+	switch (bmp_bpix) {
+	case 1:
+	case 8: {
+		cmap_base = priv->cmap;
+#ifdef CONFIG_VIDEO_BMP_RLE8
+		u32 compression = get_unaligned_le32(&bmp->header.compression);
+		debug("compressed %d %d\n", compression, BMP_BI_RLE8);
+		if (compression == BMP_BI_RLE8) {
+			if (bpix != 16) {
+				/* TODO implement render code for bpix != 16 */
+				printf("Error: only support 16 bpix");
+				return -EPROTONOSUPPORT;
+			}
+			video_display_rle8_bitmap(dev, bmp, cmap_base, fb, x,
+						  y);
+			break;
+		}
+#endif
+
+		if (bpix != 16)
+			byte_width = width;
+		else
+			byte_width = width * 2;
+
+		for (i = 0; i < height; ++i) {
+			WATCHDOG_RESET();
+			for (j = 0; j < width; j++) {
+				if (bpix != 16) {
+					fb_put_byte(&fb, &bmap);
+				} else {
+					*(uint16_t *)fb = cmap_base[*bmap];
+					bmap++;
+					fb += sizeof(uint16_t) / sizeof(*fb);
+				}
+			}
+			bmap += (padded_width - width);
+			fb -= byte_width + priv->line_length;
+		}
+		break;
+	}
+#if defined(CONFIG_BMP_16BPP)
+	case 16:
+		for (i = 0; i < height; ++i) {
+			WATCHDOG_RESET();
+			for (j = 0; j < width; j++)
+				fb_put_word(&fb, &bmap);
+
+			bmap += (padded_width - width) * 2;
+			fb -= width * 2 + lcd_line_length;
+		}
+		break;
+#endif /* CONFIG_BMP_16BPP */
+#if defined(CONFIG_BMP_24BMP)
+	case 24:
+		for (i = 0; i < height; ++i) {
+			for (j = 0; j < width; j++) {
+				*(fb++) = *(bmap++);
+				*(fb++) = *(bmap++);
+				*(fb++) = *(bmap++);
+				*(fb++) = 0;
+			}
+			fb -= lcd_line_length + width * (bpix / 8);
+		}
+		break;
+#endif /* CONFIG_BMP_24BMP */
+#if defined(CONFIG_BMP_32BPP)
+	case 32:
+		for (i = 0; i < height; ++i) {
+			for (j = 0; j < width; j++) {
+				*(fb++) = *(bmap++);
+				*(fb++) = *(bmap++);
+				*(fb++) = *(bmap++);
+				*(fb++) = *(bmap++);
+			}
+			fb -= lcd_line_length + width * (bpix / 8);
+		}
+		break;
+#endif /* CONFIG_BMP_32BPP */
+	default:
+		break;
+	};
+
+	video_sync(dev);
+
+	return 0;
+}
+
-- 
2.6.0.rc2.230.g3dd15c0

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 09/14] dm: stdio: video: Plumb the video uclass into stdio
  2016-01-19  2:52 [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support Simon Glass
                   ` (7 preceding siblings ...)
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 08/14] dm: video: Implement the bmp command for driver model Simon Glass
@ 2016-01-19  2:52 ` Simon Glass
  2016-01-21 15:19   ` Simon Glass
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 10/14] sandbox: Move CONFIG_VIDEO_SANDBOX_SDL to Kconfig Simon Glass
                   ` (5 subsequent siblings)
  14 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2016-01-19  2:52 UTC (permalink / raw)
  To: u-boot

Register video drivers with stdio so that they can be used for text output.
This needs to be done explicitly for now. At some point we should be able to
convert stdio itself to driver model and avoid this step.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2: None

 common/stdio.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/common/stdio.c b/common/stdio.c
index 8311ac7..7252bab 100644
--- a/common/stdio.c
+++ b/common/stdio.c
@@ -281,12 +281,23 @@ int stdio_add_devices(void)
 	i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
 #endif
 #endif
-#ifdef CONFIG_LCD
+#ifdef CONFIG_DM_VIDEO
+	struct udevice *vdev;
+
+	for (ret = uclass_first_device(UCLASS_VIDEO, &vdev);
+	     vdev;
+	     ret = uclass_next_device(&vdev))
+		;
+	if (ret)
+		printf("%s: Video device failed (ret=%d)\n", __func__, ret);
+#else
+# if defined(CONFIG_LCD)
 	drv_lcd_init ();
-#endif
-#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
+# endif
+# if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
 	drv_video_init ();
-#endif
+# endif
+#endif /* CONFIG_DM_VIDEO */
 #if defined(CONFIG_KEYBOARD) && !defined(CONFIG_DM_KEYBOARD)
 	drv_keyboard_init ();
 #endif
-- 
2.6.0.rc2.230.g3dd15c0

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 10/14] sandbox: Move CONFIG_VIDEO_SANDBOX_SDL to Kconfig
  2016-01-19  2:52 [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support Simon Glass
                   ` (8 preceding siblings ...)
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 09/14] dm: stdio: video: Plumb the video uclass into stdio Simon Glass
@ 2016-01-19  2:52 ` Simon Glass
  2016-01-21 15:19   ` Simon Glass
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 11/14] dm: video: sandbox: Convert sandbox to use driver model for video Simon Glass
                   ` (4 subsequent siblings)
  14 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2016-01-19  2:52 UTC (permalink / raw)
  To: u-boot

Move this option to Kconfig. This is quite simple as only sandbox uses the
driver.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2: None

 configs/sandbox_defconfig | 3 ++-
 drivers/video/Kconfig     | 9 +++++++++
 include/configs/sandbox.h | 1 -
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 731fc25..e4b8412 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -1,6 +1,7 @@
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_PCI=y
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
+CONFIG_DM_PCI_COMPAT=y
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_FIT_SIGNATURE=y
@@ -51,7 +52,6 @@ CONFIG_SPI_FLASH_SST=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_DM_ETH=y
 CONFIG_DM_PCI=y
-CONFIG_DM_PCI_COMPAT=y
 CONFIG_PCI_SANDBOX=y
 CONFIG_PINCTRL=y
 CONFIG_PINCONF=y
@@ -76,6 +76,7 @@ CONFIG_USB_EMUL=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_SYS_USB_EVENT_POLL=y
+CONFIG_VIDEO_SANDBOX_SDL=y
 CONFIG_SYS_VSNPRINTF=y
 CONFIG_CMD_DHRYSTONE=y
 CONFIG_TPM=y
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 499d00d..ae122da 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -300,6 +300,15 @@ config DISPLAY_PORT
 	   to drive LCD panels. This framework provides support for enabling
 	   these displays where supported by the video hardware.
 
+config VIDEO_SANDBOX_SDL
+	bool "Enable sandbox video console using SDL"
+	depends on SANDBOX
+	help
+	  When using sandbox you can enable an emulated LCD display which
+	  appears as an SDL (Simple DirectMedia Layer) window. This is a
+	  console device and can display stdout output. Within U-Boot is is
+	  a normal bitmap display and can display images as well as text.
+
 config VIDEO_TEGRA124
 	bool "Enable video support on Tegra124"
 	help
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index d3112e1..e1be603 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -159,7 +159,6 @@
 /* LCD and keyboard require SDL support */
 #ifdef CONFIG_SANDBOX_SDL
 #define CONFIG_LCD
-#define CONFIG_VIDEO_SANDBOX_SDL
 #define CONFIG_CMD_BMP
 #define CONFIG_BOARD_EARLY_INIT_F
 #define CONFIG_CONSOLE_MUX
-- 
2.6.0.rc2.230.g3dd15c0

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 11/14] dm: video: sandbox: Convert sandbox to use driver model for video
  2016-01-19  2:52 [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support Simon Glass
                   ` (9 preceding siblings ...)
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 10/14] sandbox: Move CONFIG_VIDEO_SANDBOX_SDL to Kconfig Simon Glass
@ 2016-01-19  2:52 ` Simon Glass
  2016-01-21 15:19   ` Simon Glass
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 12/14] dm: video: test: Add tests for the video uclass Simon Glass
                   ` (3 subsequent siblings)
  14 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2016-01-19  2:52 UTC (permalink / raw)
  To: u-boot

Now that driver model support is available, convert sandbox over to use it.
We can remove a few of the special hooks that sandbox currently has.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2: None

 arch/sandbox/dts/sandbox.dts |  1 +
 board/sandbox/sandbox.c      | 17 --------
 common/lcd.c                 | 11 -----
 configs/sandbox_defconfig    |  1 +
 drivers/serial/sandbox.c     |  5 +--
 drivers/video/sandbox_sdl.c  | 95 ++++++++++++++++++++++----------------------
 include/configs/sandbox.h    | 10 ++---
 include/fdtdec.h             |  1 -
 lib/fdtdec.c                 |  1 -
 9 files changed, 56 insertions(+), 86 deletions(-)

diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index d2addb4..e3f02bf 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -117,6 +117,7 @@
 	};
 
 	lcd {
+		u-boot,dm-pre-reloc;
 		compatible = "sandbox,lcd-sdl";
 		xres = <1366>;
 		yres = <768>;
diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
index 592f772..b41e9de 100644
--- a/board/sandbox/sandbox.c
+++ b/board/sandbox/sandbox.c
@@ -47,23 +47,6 @@ int dram_init(void)
 	return 0;
 }
 
-#ifdef CONFIG_BOARD_EARLY_INIT_F
-int board_early_init_f(void)
-{
-#ifdef CONFIG_VIDEO_SANDBOX_SDL
-	int ret;
-
-	ret = sandbox_lcd_sdl_early_init();
-	if (ret) {
-		puts("Could not init sandbox LCD emulation\n");
-		return ret;
-	}
-#endif
-
-	return 0;
-}
-#endif
-
 #ifdef CONFIG_BOARD_LATE_INIT
 int board_late_init(void)
 {
diff --git a/common/lcd.c b/common/lcd.c
index d29308a..2f3594a 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -31,10 +31,6 @@
 #endif
 #endif
 
-#ifdef CONFIG_SANDBOX
-#include <asm/sdl.h>
-#endif
-
 #ifndef CONFIG_LCD_ALIGNMENT
 #define CONFIG_LCD_ALIGNMENT PAGE_SIZE
 #endif
@@ -72,13 +68,6 @@ void lcd_sync(void)
 	if (lcd_flush_dcache)
 		flush_dcache_range((u32)lcd_base,
 			(u32)(lcd_base + lcd_get_size(&line_length)));
-#elif defined(CONFIG_SANDBOX) && defined(CONFIG_VIDEO_SANDBOX_SDL)
-	static ulong last_sync;
-
-	if (get_timer(last_sync) > 10) {
-		sandbox_sdl_sync(lcd_base);
-		last_sync = get_timer(0);
-	}
 #endif
 }
 
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index e4b8412..3b6017f 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -76,6 +76,7 @@ CONFIG_USB_EMUL=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_SYS_USB_EVENT_POLL=y
+CONFIG_DM_VIDEO=y
 CONFIG_VIDEO_SANDBOX_SDL=y
 CONFIG_SYS_VSNPRINTF=y
 CONFIG_CMD_DHRYSTONE=y
diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c
index cd2f91e..45dff98 100644
--- a/drivers/serial/sandbox.c
+++ b/drivers/serial/sandbox.c
@@ -16,6 +16,7 @@
 #include <lcd.h>
 #include <os.h>
 #include <serial.h>
+#include <video.h>
 #include <linux/compiler.h>
 #include <asm/state.h>
 
@@ -114,9 +115,7 @@ static int sandbox_serial_pending(struct udevice *dev, bool input)
 		return 0;
 
 	os_usleep(100);
-#ifdef CONFIG_LCD
-	lcd_sync();
-#endif
+	video_sync_all();
 	if (next_index == serial_buf_read)
 		return 1;	/* buffer full */
 
diff --git a/drivers/video/sandbox_sdl.c b/drivers/video/sandbox_sdl.c
index ba4578e..450628e 100644
--- a/drivers/video/sandbox_sdl.c
+++ b/drivers/video/sandbox_sdl.c
@@ -5,75 +5,76 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <fdtdec.h>
-#include <lcd.h>
-#include <malloc.h>
+#include <video.h>
 #include <asm/sdl.h>
 #include <asm/u-boot-sandbox.h>
+#include <dm/test.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
 enum {
-	/* Maximum LCD size we support */
+	/* Default LCD size we support */
 	LCD_MAX_WIDTH		= 1366,
 	LCD_MAX_HEIGHT		= 768,
-	LCD_MAX_LOG2_BPP	= 4,		/* 2^4 = 16 bpp */
 };
 
-vidinfo_t panel_info;
 
-void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
-{
-}
+/* This platform data is needed in tests, so declare it here */
+struct sandbox_sdl_plat {
+	int xres;
+	int yres;
+	int bpix;
+	int rot;
+};
 
-void lcd_ctrl_init(void *lcdbase)
+static int sandbox_sdl_probe(struct udevice *dev)
 {
-	/*
-	 * Allocate memory to keep BMP color conversion map. This is required
-	 * for 8 bit BMPs only (hence 256 colors). If malloc fails - keep
-	 * going, it is not even clear if displyaing the bitmap will be
-	 * required on the way up.
-	 */
-	panel_info.cmap = malloc(256 * NBITS(panel_info.vl_bpix) / 8);
-}
+	struct sandbox_sdl_plat *plat = dev_get_platdata(dev);
+	struct video_priv *uc_priv = dev_get_uclass_priv(dev);
+	int ret;
 
-void lcd_enable(void)
-{
-	if (sandbox_sdl_init_display(panel_info.vl_col, panel_info.vl_row,
-				     panel_info.vl_bpix))
+	ret = sandbox_sdl_init_display(plat->xres, plat->yres, plat->bpix);
+	if (ret) {
 		puts("LCD init failed\n");
+		return ret;
+	}
+	uc_priv->xsize = plat->xres;
+	uc_priv->ysize = plat->yres;
+	uc_priv->bpix = plat->bpix;
+	uc_priv->rot = plat->rot;
+
+	return 0;
 }
 
-int sandbox_lcd_sdl_early_init(void)
+static int sandbox_sdl_bind(struct udevice *dev)
 {
+	struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev);
+	struct sandbox_sdl_plat *plat = dev_get_platdata(dev);
 	const void *blob = gd->fdt_blob;
-	int xres = LCD_MAX_WIDTH, yres = LCD_MAX_HEIGHT;
-	int node;
+	int node = dev->of_offset;
 	int ret = 0;
 
-	/*
-	 * The code in common/lcd.c does not cope with not being able to
-	 * set up a frame buffer. It will just happily keep writing to
-	 * invalid memory. So here we make sure that at least some buffer
-	 * is available even if it actually won't be displayed.
-	 */
-	node = fdtdec_next_compatible(blob, 0, COMPAT_SANDBOX_LCD_SDL);
-	if (node >= 0) {
-		xres = fdtdec_get_int(blob, node, "xres", LCD_MAX_WIDTH);
-		yres = fdtdec_get_int(blob, node, "yres", LCD_MAX_HEIGHT);
-		if (xres < 0 || xres > LCD_MAX_WIDTH) {
-			xres = LCD_MAX_WIDTH;
-			ret = -EINVAL;
-		}
-		if (yres < 0 || yres > LCD_MAX_HEIGHT) {
-			yres = LCD_MAX_HEIGHT;
-			ret = -EINVAL;
-		}
-	}
-
-	panel_info.vl_col = xres;
-	panel_info.vl_row = yres;
-	panel_info.vl_bpix = LCD_COLOR16;
+	plat->xres = fdtdec_get_int(blob, node, "xres", LCD_MAX_WIDTH);
+	plat->yres = fdtdec_get_int(blob, node, "yres", LCD_MAX_HEIGHT);
+	plat->bpix = VIDEO_BPP16;
+	uc_plat->size = plat->xres * plat->yres * (1 << plat->bpix) / 8;
+	debug("%s: Frame buffer size %x\n", __func__, uc_plat->size);
 
 	return ret;
 }
+
+static const struct udevice_id sandbox_sdl_ids[] = {
+	{ .compatible = "sandbox,lcd-sdl" },
+	{ }
+};
+
+U_BOOT_DRIVER(sdl_sandbox) = {
+	.name	= "sdl_sandbox",
+	.id	= UCLASS_VIDEO,
+	.of_match = sandbox_sdl_ids,
+	.bind	= sandbox_sdl_bind,
+	.probe	= sandbox_sdl_probe,
+	.platdata_auto_alloc_size	= sizeof(struct sandbox_sdl_plat),
+};
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index e1be603..23ae44c 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -158,9 +158,7 @@
 
 /* LCD and keyboard require SDL support */
 #ifdef CONFIG_SANDBOX_SDL
-#define CONFIG_LCD
 #define CONFIG_CMD_BMP
-#define CONFIG_BOARD_EARLY_INIT_F
 #define CONFIG_CONSOLE_MUX
 #define CONFIG_SYS_CONSOLE_IS_IN_ENV
 #define LCD_BPP			LCD_COLOR16
@@ -169,12 +167,12 @@
 #define CONFIG_KEYBOARD
 
 #define SANDBOX_SERIAL_SETTINGS		"stdin=serial,cros-ec-keyb,usbkbd\0" \
-					"stdout=serial,lcd\0" \
-					"stderr=serial,lcd\0"
+					"stdout=serial,lcd.vidconsole\0" \
+					"stderr=serial,lcd.vidconsole\0"
 #else
 #define SANDBOX_SERIAL_SETTINGS		"stdin=serial\0" \
-					"stdout=serial,lcd\0" \
-					"stderr=serial,lcd\0"
+					"stdout=serial,lcd.vidconsole\0" \
+					"stderr=serial,lcd.vidconsole\0"
 #endif
 
 #define SANDBOX_ETH_SETTINGS		"ethaddr=00:00:11:22:33:44\0" \
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 27b350e..25e98c9 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -151,7 +151,6 @@ enum fdt_compat_id {
 	COMPAT_GENERIC_SPI_FLASH,	/* Generic SPI Flash chip */
 	COMPAT_MAXIM_98095_CODEC,	/* MAX98095 Codec */
 	COMPAT_SAMSUNG_EXYNOS5_I2C,	/* Exynos5 High Speed I2C Controller */
-	COMPAT_SANDBOX_LCD_SDL,		/* Sandbox LCD emulation with SDL */
 	COMPAT_SAMSUNG_EXYNOS_SYSMMU,	/* Exynos sysmmu */
 	COMPAT_INTEL_MICROCODE,		/* Intel microcode update */
 	COMPAT_MEMORY_SPD,		/* Memory SPD information */
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index b50d105..d56e1b1 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -56,7 +56,6 @@ static const char * const compat_names[COMPAT_COUNT] = {
 	COMPAT(GENERIC_SPI_FLASH, "spi-flash"),
 	COMPAT(MAXIM_98095_CODEC, "maxim,max98095-codec"),
 	COMPAT(SAMSUNG_EXYNOS5_I2C, "samsung,exynos5-hsi2c"),
-	COMPAT(SANDBOX_LCD_SDL, "sandbox,lcd-sdl"),
 	COMPAT(SAMSUNG_EXYNOS_SYSMMU, "samsung,sysmmu-v3.3"),
 	COMPAT(INTEL_MICROCODE, "intel,microcode"),
 	COMPAT(MEMORY_SPD, "memory-spd"),
-- 
2.6.0.rc2.230.g3dd15c0

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 12/14] dm: video: test: Add tests for the video uclass
  2016-01-19  2:52 [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support Simon Glass
                   ` (10 preceding siblings ...)
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 11/14] dm: video: sandbox: Convert sandbox to use driver model for video Simon Glass
@ 2016-01-19  2:52 ` Simon Glass
  2016-01-21 15:19   ` Simon Glass
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 13/14] dm: video: test: Add tests for rotated consoles Simon Glass
                   ` (2 subsequent siblings)
  14 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2016-01-19  2:52 UTC (permalink / raw)
  To: u-boot

Add tests that check that the video console is working correcty. Also check
that text output produces the expected result. Test coverage includes
character output, wrapping and scrolling.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2:
- Fix 'resolutino' typo in comment

 arch/sandbox/dts/test.dts   |   7 ++
 drivers/video/sandbox_sdl.c |   9 ---
 include/dm/test.h           |   8 ++
 test/dm/Makefile            |   1 +
 test/dm/video.c             | 190 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 206 insertions(+), 9 deletions(-)
 create mode 100644 test/dm/video.c

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 2e0d320..9b8d658 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -195,6 +195,13 @@
 		vss-microvolts = <0>;
 	};
 
+	lcd {
+		u-boot,dm-pre-reloc;
+		compatible = "sandbox,lcd-sdl";
+		xres = <1366>;
+		yres = <768>;
+	};
+
 	leds {
 		compatible = "gpio-leds";
 
diff --git a/drivers/video/sandbox_sdl.c b/drivers/video/sandbox_sdl.c
index 450628e..21448a1 100644
--- a/drivers/video/sandbox_sdl.c
+++ b/drivers/video/sandbox_sdl.c
@@ -20,15 +20,6 @@ enum {
 	LCD_MAX_HEIGHT		= 768,
 };
 
-
-/* This platform data is needed in tests, so declare it here */
-struct sandbox_sdl_plat {
-	int xres;
-	int yres;
-	int bpix;
-	int rot;
-};
-
 static int sandbox_sdl_probe(struct udevice *dev)
 {
 	struct sandbox_sdl_plat *plat = dev_get_platdata(dev);
diff --git a/include/dm/test.h b/include/dm/test.h
index a4bc5c8..ca924d9 100644
--- a/include/dm/test.h
+++ b/include/dm/test.h
@@ -155,6 +155,14 @@ enum {
 /* Declare a new driver model test */
 #define DM_TEST(_name, _flags)	UNIT_TEST(_name, _flags, dm_test)
 
+/* This platform data is needed in tests, so declare it here */
+struct sandbox_sdl_plat {
+	int xres;
+	int yres;
+	int bpix;
+	int rot;
+};
+
 /* Declare ping methods for the drivers */
 int test_ping(struct udevice *dev, int pingval, int *pingret);
 int testfdt_ping(struct udevice *dev, int pingval, int *pingret);
diff --git a/test/dm/Makefile b/test/dm/Makefile
index 3ff1b75..d4f3f22 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -34,5 +34,6 @@ obj-$(CONFIG_DM_USB) += usb.o
 obj-$(CONFIG_DM_PMIC) += pmic.o
 obj-$(CONFIG_DM_REGULATOR) += regulator.o
 obj-$(CONFIG_TIMER) += timer.o
+obj-$(CONFIG_DM_VIDEO) += video.o
 obj-$(CONFIG_ADC) += adc.o
 endif
diff --git a/test/dm/video.c b/test/dm/video.c
new file mode 100644
index 0000000..b197b01
--- /dev/null
+++ b/test/dm/video.c
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2014 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <bzlib.h>
+#include <dm.h>
+#include <mapmem.h>
+#include <os.h>
+#include <video.h>
+#include <video_console.h>
+#include <dm/test.h>
+#include <dm/uclass-internal.h>
+#include <test/ut.h>
+
+/*
+ * These tests use the standard sandbox frame buffer, the resolution of which
+ * is defined in the device tree. This only supports 16bpp so the tests only
+ * test that code path. It would be possible to adjust this fairly easily,
+ * by adjusting the bpix value in struct sandbox_sdl_plat. However the code
+ * in sandbox_sdl_sync() would also need to change to handle the different
+ * surface depth.
+ */
+DECLARE_GLOBAL_DATA_PTR;
+
+/* Basic test of the video uclass */
+static int dm_test_video_base(struct unit_test_state *uts)
+{
+	struct video_priv *priv;
+	struct udevice *dev;
+
+	ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
+	ut_asserteq(1366, video_get_xsize(dev));
+	ut_asserteq(768, video_get_ysize(dev));
+	priv = dev_get_uclass_priv(dev);
+	ut_asserteq(priv->fb_size, 1366 * 768 * 2);
+
+	return 0;
+}
+DM_TEST(dm_test_video_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/**
+ * compress_frame_buffer() - Compress the frame buffer and return its size
+ *
+ * We want to write tests which perform operations on the video console and
+ * check that the frame buffer ends up with the correct contents. But it is
+ * painful to store 'known good' images for comparison with the frame
+ * buffer. As an alternative, we can compress the frame buffer and check the
+ * size of the compressed data. This provides a pretty good level of
+ * certainty and the resulting tests need only check a single value.
+ *
+ * @dev:	Video device
+ * @return compressed size of the frame buffer, or -ve on error
+ */
+static int compress_frame_buffer(struct udevice *dev)
+{
+	struct video_priv *priv = dev_get_uclass_priv(dev);
+	uint destlen;
+	void *dest;
+	int ret;
+
+	destlen = priv->fb_size;
+	dest = malloc(priv->fb_size);
+	if (!dest)
+		return -ENOMEM;
+	ret = BZ2_bzBuffToBuffCompress(dest, &destlen,
+				       priv->fb, priv->fb_size,
+				       3, 0, 0);
+	free(dest);
+	if (ret)
+		return ret;
+
+	return destlen;
+}
+
+/*
+ * Call this function at any point to halt and show the current display. Be
+ * sure to run the test with the -l flag.
+ */
+static void __maybe_unused see_output(void)
+{
+	video_sync_all();
+	while (1);
+}
+
+/* Test text output works on the video console */
+static int dm_test_video_text(struct unit_test_state *uts)
+{
+	struct udevice *dev, *con;
+	int i;
+
+#define WHITE		0xffff
+#define SCROLL_LINES	100
+
+	ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
+	ut_asserteq(46, compress_frame_buffer(dev));
+
+	ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
+	vidconsole_putc_xy(con, 0, 0, 'a');
+	ut_asserteq(79, compress_frame_buffer(dev));
+
+	vidconsole_putc_xy(con, 0, 0, ' ');
+	ut_asserteq(46, compress_frame_buffer(dev));
+
+	for (i = 0; i < 20; i++)
+		vidconsole_putc_xy(con, i * 8, 0, ' ' + i);
+	ut_asserteq(273, compress_frame_buffer(dev));
+
+	vidconsole_set_row(con, 0, WHITE);
+	ut_asserteq(46, compress_frame_buffer(dev));
+
+	for (i = 0; i < 20; i++)
+		vidconsole_putc_xy(con, i * 8, 0, ' ' + i);
+	ut_asserteq(273, compress_frame_buffer(dev));
+
+	return 0;
+}
+DM_TEST(dm_test_video_text, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test handling of special characters in the console */
+static int dm_test_video_chars(struct unit_test_state *uts)
+{
+	struct udevice *dev, *con;
+	const char *test_string = "Well\b\b\b\bxhe is\r \n\ta very modest  \bman\n\t\tand Has much to\b\bto be modest about.";
+	const char *s;
+
+	ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
+	ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
+	for (s = test_string; *s; s++)
+		vidconsole_put_char(con, *s);
+	ut_asserteq(466, compress_frame_buffer(dev));
+
+	return 0;
+}
+DM_TEST(dm_test_video_chars, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/**
+ * check_vidconsole_output() - Run a text console test
+ *
+ * @uts:	Test state
+ * @rot:	Console rotation (0, 90, 180, 270)
+ * @wrap_size:	Expected size of compressed frame buffer for the wrap test
+ * @scroll_size: Same for the scroll test
+ * @return 0 on success
+ */
+static int check_vidconsole_output(struct unit_test_state *uts, int rot,
+				   int wrap_size, int scroll_size)
+{
+	struct udevice *dev, *con;
+	struct sandbox_sdl_plat *plat;
+	int i;
+
+	ut_assertok(uclass_find_device(UCLASS_VIDEO, 0, &dev));
+	ut_assert(!device_active(dev));
+	plat = dev_get_platdata(dev);
+	plat->rot = rot;
+
+	ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
+	ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
+	ut_asserteq(46, compress_frame_buffer(dev));
+
+	/* Check display wrap */
+	for (i = 0; i < 120; i++)
+		vidconsole_put_char(con, 'A' + i % 50);
+	ut_asserteq(wrap_size, compress_frame_buffer(dev));
+
+	/* Check display scrolling */
+	for (i = 0; i < SCROLL_LINES; i++) {
+		vidconsole_put_char(con, 'A' + i % 50);
+		vidconsole_put_char(con, '\n');
+	}
+	ut_asserteq(scroll_size, compress_frame_buffer(dev));
+
+	/* If we scroll enough, the screen becomes blank again */
+	for (i = 0; i < SCROLL_LINES; i++)
+		vidconsole_put_char(con, '\n');
+	ut_asserteq(46, compress_frame_buffer(dev));
+
+	return 0;
+}
+
+/* Test text output through the console uclass */
+static int dm_test_video_context(struct unit_test_state *uts)
+{
+	return check_vidconsole_output(uts, 0, 788, 453);
+}
+DM_TEST(dm_test_video_context, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
-- 
2.6.0.rc2.230.g3dd15c0

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 13/14] dm: video: test: Add tests for rotated consoles
  2016-01-19  2:52 [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support Simon Glass
                   ` (11 preceding siblings ...)
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 12/14] dm: video: test: Add tests for the video uclass Simon Glass
@ 2016-01-19  2:52 ` Simon Glass
  2016-01-21 15:26   ` Simon Glass
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 14/14] dm: video: test: Test that bitmap display works correctly Simon Glass
  2016-01-19  2:56 ` [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support Simon Glass
  14 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2016-01-19  2:52 UTC (permalink / raw)
  To: u-boot

Test that text is displayed correctly when the console is rotated.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2: None

 configs/sandbox_defconfig |  1 +
 test/dm/video.c           | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 3b6017f..b55d5e5 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -77,6 +77,7 @@ CONFIG_USB_STORAGE=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_SYS_USB_EVENT_POLL=y
 CONFIG_DM_VIDEO=y
+CONFIG_VIDEO_ROTATION=y
 CONFIG_VIDEO_SANDBOX_SDL=y
 CONFIG_SYS_VSNPRINTF=y
 CONFIG_CMD_DHRYSTONE=y
diff --git a/test/dm/video.c b/test/dm/video.c
index b197b01..65db216 100644
--- a/test/dm/video.c
+++ b/test/dm/video.c
@@ -188,3 +188,30 @@ static int dm_test_video_context(struct unit_test_state *uts)
 	return check_vidconsole_output(uts, 0, 788, 453);
 }
 DM_TEST(dm_test_video_context, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test rotated text output through the console uclass */
+static int dm_test_video_rotation1(struct unit_test_state *uts)
+{
+	ut_assertok(check_vidconsole_output(uts, 1, 1112, 680));
+
+	return 0;
+}
+DM_TEST(dm_test_video_rotation1, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test rotated text output through the console uclass */
+static int dm_test_video_rotation2(struct unit_test_state *uts)
+{
+	ut_assertok(check_vidconsole_output(uts, 2, 785, 446));
+
+	return 0;
+}
+DM_TEST(dm_test_video_rotation2, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test rotated text output through the console uclass */
+static int dm_test_video_rotation3(struct unit_test_state *uts)
+{
+	ut_assertok(check_vidconsole_output(uts, 3, 1134, 681));
+
+	return 0;
+}
+DM_TEST(dm_test_video_rotation3, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
-- 
2.6.0.rc2.230.g3dd15c0

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 14/14] dm: video: test: Test that bitmap display works correctly
  2016-01-19  2:52 [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support Simon Glass
                   ` (12 preceding siblings ...)
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 13/14] dm: video: test: Add tests for rotated consoles Simon Glass
@ 2016-01-19  2:52 ` Simon Glass
  2016-01-21 15:26   ` Simon Glass
  2016-01-19  2:56 ` [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support Simon Glass
  14 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2016-01-19  2:52 UTC (permalink / raw)
  To: u-boot

Add a test for the 'bmp' command. Test both the uncompressed and compressed
versions of the file, since they use different code paths.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2: None

 include/configs/sandbox.h |   2 ++
 test/dm/video.c           |  54 ++++++++++++++++++++++++++++++++++++++++++++++
 tools/logos/denx-comp.bmp | Bin 0 -> 4148 bytes
 3 files changed, 56 insertions(+)
 create mode 100644 tools/logos/denx-comp.bmp

diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index 23ae44c..6498981 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -163,6 +163,8 @@
 #define CONFIG_SYS_CONSOLE_IS_IN_ENV
 #define LCD_BPP			LCD_COLOR16
 #define CONFIG_LCD_BMP_RLE8
+#define CONFIG_VIDEO_BMP_RLE8
+#define CONFIG_SPLASH_SCREEN_ALIGN
 
 #define CONFIG_KEYBOARD
 
diff --git a/test/dm/video.c b/test/dm/video.c
index 65db216..9f5e7fc 100644
--- a/test/dm/video.c
+++ b/test/dm/video.c
@@ -215,3 +215,57 @@ static int dm_test_video_rotation3(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_video_rotation3, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Read a file into memory and return a pointer to it */
+static int read_file(struct unit_test_state *uts, const char *fname,
+		     ulong *addrp)
+{
+	int buf_size = 100000;
+	ulong addr = 0;
+	int size, fd;
+	char *buf;
+
+	buf = map_sysmem(addr, 0);
+	ut_assert(buf != NULL);
+	fd = os_open(fname, OS_O_RDONLY);
+	ut_assert(fd >= 0);
+	size = os_read(fd, buf, buf_size);
+	ut_assert(size >= 0);
+	ut_assert(size < buf_size);
+	os_close(fd);
+	*addrp = addr;
+
+	return 0;
+}
+
+/* Test drawing a bitmap file */
+static int dm_test_video_bmp(struct unit_test_state *uts)
+{
+	struct udevice *dev;
+	ulong addr;
+
+	ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
+	ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr));
+
+	ut_assertok(video_bmp_display(dev, addr, 0, 0, false));
+	ut_asserteq(1368, compress_frame_buffer(dev));
+
+	return 0;
+}
+DM_TEST(dm_test_video_bmp, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test drawing a compressed bitmap file */
+static int dm_test_video_bmp_comp(struct unit_test_state *uts)
+{
+	struct udevice *dev;
+	ulong addr;
+
+	ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
+	ut_assertok(read_file(uts, "tools/logos/denx-comp.bmp", &addr));
+
+	ut_assertok(video_bmp_display(dev, addr, 0, 0, false));
+	ut_asserteq(1368, compress_frame_buffer(dev));
+
+	return 0;
+}
+DM_TEST(dm_test_video_bmp_comp, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
diff --git a/tools/logos/denx-comp.bmp b/tools/logos/denx-comp.bmp
new file mode 100644
index 0000000000000000000000000000000000000000..89d0f471c85cf734b5f0e2bb2508d39f5b9e72b8
GIT binary patch
literal 4148
zcmeH}JBVCW7{|ZwzF%|i?CfTD_HOoU9!9h=1``B36Gbe<AYvs!EaD?*V<8b+Q&?(h
zNm>O{DjKjbg$6`yOp(GSK^vPDZ4|D*@7%dFJBwIaNQOOg&pqGkfBxTN_VhC+$KpTl
zM<VaCyTW>jrIN8kJ}yPxm at R)`htdsy{^j&j&%I?E`#k at -`>WrHoIihlzQ6JN0~jqn
zgj at QYdis={dEtzlefg}Md-I%Jc;|v#ymV16eQ-%Ge{@-{esWc=eRfT*e|=qUet%PL
z-M%Gvf4(cbzwOE+Uv%>LSDie2qmviE>E!kAI(hqtPTu>mlMioqa^<H^KE2b)m%nuK
z?XR8O+U?}dAD!&}*-6(e!CJy}@8uo?_ZawZ7&z)eQPqg=^fjjm&q%{i0w;3B1(LE}
zaayQoo;Wl`y+mtvNrLoMmObq}a*1eVHnGEx<c?`p*n8&B0#3AwMMIt;&%|Vf)0DaA
zzs(c7Ff~+o40zXk<gLx4`Dwh4#pwNxdVG;-?e~>BEe!{g)#(V#agEl14zzi`$D5%s
zxvl-43?GQ2u=fRGtroue`*EhW8*bbC<23pwk6<$|S%ii0Z3uJEc#jXcv7GY;|I2=J
zI80oxtto8I8H88-S>z!r#$nX^3R3cI at dkvwSE2+I!R#E}O7UP(dtagDZ5DxiRH0|p
zvZsmZ_<IzVFC;ZA<>psiY%J!PM>Cvgg|EaU=*9hM2-d+rSlF99rv<Ly^CZ5WpeB$M
zNBj5mNp$XGZ}PxJ@V>%HBrE8$qk<dWdk)6zsOwCT)jjgkv<;_tY*bKe9QCy|<~f0<
z*m@(i%)yBD#oQX-k*}h9u<s+8u36(9UdUdc#z at xR$=lm`WswFXR?R85AVy5Q5m-b^
z`0()te^w!!=ax&qE3vQXQ|`FmQ{OXSfM2VD0Tn#Z3n3@Qggw{1R7<<Jv2B)<9(w{F
z!>SAG84r2S)au+;M<C#)Rx9R112BRfmJ-{AGII2DTJT+YO)c>ba<j0mCAUl+tE|~w
zU>+VaPEupqD(fNijN5a5?<=l0?(F@z`ACBj?_jnQtBYZ+63f`MIj6;gun?rwc6r?C
zmac1i%xSCZVmuZjv<{Jpk?eTP;B1pdx3`>bCXE>Wa6*1sdX;BzaITd#I^J+OI;A^+
zmnk>pS+{eIqR|#CTLn7wfKIvZ8ojnDn{%D2S#cHe%pJ5$gj+J5%SMeJgq7_P^3*xl
zAU-}e<{C8-N~hx*jl}K1D|brJ$roN4ZbS6#2A$Z|)Cd)tYhX9$b~Ps at IV?3{#^iHk
z+b}h$o7 at p&q8nDP71c_AM<uM3SeMq(S%2SxTcoU*JVdTQ3i7)2Q?-C;Dm~fqxJy@p
zh#9g1KWhp4q3Ks+`>u1ot($tDN3OtQ(PU_Wk!h*b1dWV!+<U8$Vh>K!$mIab=2R{Z
z&*a=5jl3!58s>+7%lNGt^;%T!Bty$`YI;nhI+G3f&d|)|g!eVZi?T|uk&`Kt;-wzs
zx`GGuvc1qbMx`F{_A4e~Ro*_M3iip`y)x$AvgPWMH2YWSlC6$Ya=2t2ne}0^PM<Ox
z!L`S`j;0<N@@OvKgH3}$o>8-V at 5Ha6+z%rsSY&a=hTS*tJRO5e`h+?=;2B=o!>DD?
z<QvqAWsz#%!uOP15L-8g{AocCA+=n`Of=J6WSC5of1Bnu$=EAhRj1%&&-_?a3tbR!
z7LDzH7@H(@VKECIxyqSli`w%Q&3_W)I<?xj`RBj$!sZqou4^%MJ)7%vh(>e-eNtHm
zlnpbYM03$2v1{xXCe?V%IX#%tf%Xd=F+=)&sS!O|@|(M at o4Pvd#Z_&s*AHX$7=55E
z{XL<-C)VGoJ7n0BM{VA;bnbMR4jI#dD$h?Do|eh7HB1&Xvu(1)bV@*wPQj|}FqaIy
zO{R4^9mbM%n}}`Mta4jF9jlfcFd1`j1`~_k=1o5ri5D?5GRyrsQP>Aq=iDlT>0!=J
xZO)RVl5uUE)G_*-_8u``QZKPxq!rV&4Qw8@)aGW0-441JsjvUhv$Xq&{tYdt;;8 at t

literal 0
HcmV?d00001

-- 
2.6.0.rc2.230.g3dd15c0

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support
  2016-01-19  2:52 [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support Simon Glass
                   ` (13 preceding siblings ...)
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 14/14] dm: video: test: Test that bitmap display works correctly Simon Glass
@ 2016-01-19  2:56 ` Simon Glass
  2016-01-19  2:57   ` Simon Glass
  14 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2016-01-19  2:56 UTC (permalink / raw)
  To: u-boot

Hi,

On 18 January 2016 at 19:52, Simon Glass <sjg@chromium.org> wrote:
> This series starts the process of converting LCD and video devices over to
> use driver model. Both now use a very similar API thanks to earlier work by
> Nikita Kiryanov. With the driver-model conversion these will end up unified
> in a single uclass.
>
> Unfortunately there are different features supported by each. This
> implementation provides for a common set of features which should serve
> most purposes. The intent is to support:
>
> - bitmap devices with 8, 16 and 32 bits per pixel
> - text console wih white on black or vice versa
> - rotated text console
> - bitmap display (BMP format)
>
> More can be added as additional boards are ported over to use driver model
> for video.
>
> The name 'video' is chosen for the uclass since it is more generic than LCD.
> Another option would be 'display' but that would introduce a third concept
> to U-Boot which seems like the wrong approach.
>
> The existing LCD and video init functions are not needed now, so this uclass
> does not implement them. This includes lcd_ctrl_init(), lcd_enable() and
> video_init().
>
> Tests are provided to check that console text and bitmap output is correct.
> These should be able to be extended as more features are added.
>
> Future work will convert a few boards over to use driver model for video.
> Likely targets are x86, exynos, tegra. Also, Rockchip LCD support will be
> added using driver model (patches will likely be sent some time in January).
>
> Changes in v2:
> - Fix Ebabling typo in comment
> - Remove duplicated @fb_size line in common
> - Fix comment for video_get_ysize()
> - Fix reference to \n which should be \b
> - Fix 'withthe' typo in comment
> - Fix 'resolutino' typo in comment
>
> Simon Glass (14):
>   dm: video: Add a video uclass
>   dm: lcd: Avoid using the lcd.h header file with driver model
>   dm: video: Add a uclass for the text console
>   dm: video: Add a 'normal' text console driver
>   dm: video: Add a driver for a rotated text console
>   common: Move LCD and video memory reservation together
>   dm: common: Add memory reservation for the video uclass
>   dm: video: Implement the bmp command for driver model
>   dm: stdio: video: Plumb the video uclass into stdio
>   sandbox: Move CONFIG_VIDEO_SANDBOX_SDL to Kconfig
>   dm: video: sandbox: Convert sandbox to use driver model for video
>   dm: video: test: Add tests for the video uclass
>   dm: video: test: Add tests for rotated consoles
>   dm: video: test: Test that bitmap display works correctly
>
>  arch/sandbox/dts/sandbox.dts      |   1 +
>  arch/sandbox/dts/test.dts         |   7 +
>  board/sandbox/sandbox.c           |  17 --
>  common/Makefile                   |   2 +
>  common/board_f.c                  |  71 ++++---
>  common/cmd_bmp.c                  |  22 +-
>  common/lcd.c                      |  11 -
>  common/stdio.c                    |  19 +-
>  configs/sandbox_defconfig         |   5 +-
>  drivers/serial/sandbox.c          |   5 +-
>  drivers/video/Kconfig             |  62 ++++++
>  drivers/video/Makefile            |   3 +
>  drivers/video/console_normal.c    | 141 ++++++++++++
>  drivers/video/console_rotate.c    | 436 ++++++++++++++++++++++++++++++++++++++
>  drivers/video/sandbox_sdl.c       |  90 ++++----
>  drivers/video/vidconsole-uclass.c | 239 +++++++++++++++++++++
>  drivers/video/video-uclass.c      | 249 ++++++++++++++++++++++
>  drivers/video/video_bmp.c         | 353 ++++++++++++++++++++++++++++++
>  include/asm-generic/global_data.h |   4 +
>  include/configs/sandbox.h         |  13 +-
>  include/dm/test.h                 |   8 +
>  include/dm/uclass-id.h            |   2 +
>  include/fdtdec.h                  |   1 -
>  include/lcd.h                     |  12 +-
>  include/video.h                   | 168 ++++++++++++++-
>  include/video_console.h           | 136 ++++++++++++
>  lib/fdtdec.c                      |   1 -
>  test/dm/Makefile                  |   1 +
>  test/dm/video.c                   | 271 +++++++++++++++++++++++
>  tools/logos/denx-comp.bmp         | Bin 0 -> 4148 bytes
>  30 files changed, 2221 insertions(+), 129 deletions(-)
>  create mode 100644 drivers/video/console_normal.c
>  create mode 100644 drivers/video/console_rotate.c
>  create mode 100644 drivers/video/vidconsole-uclass.c
>  create mode 100644 drivers/video/video-uclass.c
>  create mode 100644 drivers/video/video_bmp.c
>  create mode 100644 include/video_console.h
>  create mode 100644 test/dm/video.c
>  create mode 100644 tools/logos/denx-comp.bmp
>
> --
> 2.6.0.rc2.230.g3dd15c0
>

This is available at u-boot-dm branch rbk-working if you are
interested in trying it out. But it only works for sandbox.

make O=sandbox sandbox_defconfig all
./sandbox/u-boot -Dl

Regards,
Simon

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support
  2016-01-19  2:56 ` [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support Simon Glass
@ 2016-01-19  2:57   ` Simon Glass
  2016-01-20  7:28     ` Anatolij Gustschin
  0 siblings, 1 reply; 32+ messages in thread
From: Simon Glass @ 2016-01-19  2:57 UTC (permalink / raw)
  To: u-boot

Hi Anatolij,

On 18 January 2016 at 19:56, Simon Glass <sjg@chromium.org> wrote:
> Hi,
>
> On 18 January 2016 at 19:52, Simon Glass <sjg@chromium.org> wrote:
>> This series starts the process of converting LCD and video devices over to
>> use driver model. Both now use a very similar API thanks to earlier work by
>> Nikita Kiryanov. With the driver-model conversion these will end up unified
>> in a single uclass.
>>
>> Unfortunately there are different features supported by each. This
>> implementation provides for a common set of features which should serve
>> most purposes. The intent is to support:
>>
>> - bitmap devices with 8, 16 and 32 bits per pixel
>> - text console wih white on black or vice versa
>> - rotated text console
>> - bitmap display (BMP format)
>>
>> More can be added as additional boards are ported over to use driver model
>> for video.
>>
>> The name 'video' is chosen for the uclass since it is more generic than LCD.
>> Another option would be 'display' but that would introduce a third concept
>> to U-Boot which seems like the wrong approach.
>>
>> The existing LCD and video init functions are not needed now, so this uclass
>> does not implement them. This includes lcd_ctrl_init(), lcd_enable() and
>> video_init().
>>
>> Tests are provided to check that console text and bitmap output is correct.
>> These should be able to be extended as more features are added.
>>
>> Future work will convert a few boards over to use driver model for video.
>> Likely targets are x86, exynos, tegra. Also, Rockchip LCD support will be
>> added using driver model (patches will likely be sent some time in January).
>>
>> Changes in v2:
>> - Fix Ebabling typo in comment
>> - Remove duplicated @fb_size line in common
>> - Fix comment for video_get_ysize()
>> - Fix reference to \n which should be \b
>> - Fix 'withthe' typo in comment
>> - Fix 'resolutino' typo in comment

If this looks OK, please let me know if you plan to pick this up,
otherwise I'll bring it via DM. There are some dependent patches in
dm/master, but I can send a pull request for those.

Regards,
Simon

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support
  2016-01-19  2:57   ` Simon Glass
@ 2016-01-20  7:28     ` Anatolij Gustschin
  0 siblings, 0 replies; 32+ messages in thread
From: Anatolij Gustschin @ 2016-01-20  7:28 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Mon, 18 Jan 2016 19:57:53 -0700
Simon Glass <sjg@chromium.org> wrote:
...
> >> Changes in v2:
> >> - Fix Ebabling typo in comment
> >> - Remove duplicated @fb_size line in common
> >> - Fix comment for video_get_ysize()
> >> - Fix reference to \n which should be \b
> >> - Fix 'withthe' typo in comment
> >> - Fix 'resolutino' typo in comment
> 
> If this looks OK, please let me know if you plan to pick this up,
> otherwise I'll bring it via DM. There are some dependent patches in
> dm/master, but I can send a pull request for those.

I can apply this series when the dependent patches in dm/master are
merged to u-boot/master. You can merge this series via DM if you like,
no objection from my side.

Thanks,
Anatolij

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 01/14] dm: video: Add a video uclass
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 01/14] dm: video: Add a video uclass Simon Glass
@ 2016-01-21 15:18   ` Simon Glass
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Glass @ 2016-01-21 15:18 UTC (permalink / raw)
  To: u-boot

On 18 January 2016 at 19:52, Simon Glass <sjg@chromium.org> wrote:
> U-Boot has separate code for LCDs and 'video' devices. Both now use a
> very similar API thanks to earlier work by Nikita Kiryanov. With the driver-
> model conversion we should unify these into a single uclass.
>
> Unfortunately there are different features supported by each. This
> implementation provides for a common set of features which should serve
> most purposes. The intent is to support:
>
> - bitmap devices with 8, 16 and 32 bits per pixel
> - text console wih white on black or vice versa
> - rotated text console
> - bitmap display (BMP format)
>
> More can be added as additional boards are ported over to use driver model
> for video.
>
> The name 'video' is chosen for the uclass since it is more generic than LCD.
> Another option would be 'display' but that would introduce a third concept
> to U-Boot which seems like the wrong approach.
>
> The existing LCD and video init functions are not needed now, so this uclass
> makes no attempt to implement them.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Acked-by: Anatolij Gustschin <agust@denx.de>
> ---
>
> Changes in v2:
> - Fix Ebabling typo in comment
> - Remove duplicated @fb_size line in common
> - Fix comment for video_get_ysize()
>
>  drivers/video/Kconfig        |  40 ++++++++
>  drivers/video/Makefile       |   1 +
>  drivers/video/video-uclass.c | 228 +++++++++++++++++++++++++++++++++++++++++++
>  include/dm/uclass-id.h       |   1 +
>  include/video.h              | 168 +++++++++++++++++++++++++++++--
>  5 files changed, 432 insertions(+), 6 deletions(-)
>  create mode 100644 drivers/video/video-uclass.c

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 02/14] dm: lcd: Avoid using the lcd.h header file with driver model
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 02/14] dm: lcd: Avoid using the lcd.h header file with driver model Simon Glass
@ 2016-01-21 15:18   ` Simon Glass
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Glass @ 2016-01-21 15:18 UTC (permalink / raw)
  To: u-boot

On 18 January 2016 at 19:52, Simon Glass <sjg@chromium.org> wrote:
> The LCD functions and definitions are not used with the driver model video
> uclass. When all boards are converted over we can remove the file. For now,
> use #ifdef to omit the contents.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Acked-by: Anatolij Gustschin <agust@denx.de>
> ---
>
> Changes in v2: None
>
>  common/Makefile |  2 ++
>  include/lcd.h   | 12 ++++++++----
>  2 files changed, 10 insertions(+), 4 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 03/14] dm: video: Add a uclass for the text console
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 03/14] dm: video: Add a uclass for the text console Simon Glass
@ 2016-01-21 15:18   ` Simon Glass
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Glass @ 2016-01-21 15:18 UTC (permalink / raw)
  To: u-boot

On 18 January 2016 at 19:52, Simon Glass <sjg@chromium.org> wrote:
> The existing LCD/video interface suffers from conflating the bitmap display
> with text output on that display. As a result the implementation is more
> complex than it needs to me.
>
> We can support multiple text console drivers. Create a separate uclass to
> support this, with its own API.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Acked-by: Anatolij Gustschin <agust@denx.de>
> ---
>
> Changes in v2:
> - Fix reference to \n which should be \b
> - Fix 'withthe' typo in comment
>
>  drivers/video/Makefile            |   2 +-
>  drivers/video/vidconsole-uclass.c | 239 ++++++++++++++++++++++++++++++++++++++
>  drivers/video/video-uclass.c      |  21 ++++
>  include/dm/uclass-id.h            |   1 +
>  include/video_console.h           | 136 ++++++++++++++++++++++
>  5 files changed, 398 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/video/vidconsole-uclass.c
>  create mode 100644 include/video_console.h

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 04/14] dm: video: Add a 'normal' text console driver
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 04/14] dm: video: Add a 'normal' text console driver Simon Glass
@ 2016-01-21 15:18   ` Simon Glass
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Glass @ 2016-01-21 15:18 UTC (permalink / raw)
  To: u-boot

On 18 January 2016 at 19:52, Simon Glass <sjg@chromium.org> wrote:
> Most of the time we don't need to rotate the display so a simple font
> blitting feature is enough for our purposes. Add a simple driver which
> supports this function. It provides text output on the console using
> the standard 8x16-pixel font.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Acked-by: Anatolij Gustschin <agust@denx.de>
> ---
>
> Changes in v2: None
>
>  drivers/video/Makefile         |   2 +-
>  drivers/video/console_normal.c | 141 +++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 142 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/video/console_normal.c

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 06/14] common: Move LCD and video memory reservation together
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 06/14] common: Move LCD and video memory reservation together Simon Glass
@ 2016-01-21 15:18   ` Simon Glass
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Glass @ 2016-01-21 15:18 UTC (permalink / raw)
  To: u-boot

On 18 January 2016 at 19:52, Simon Glass <sjg@chromium.org> wrote:
> These two functions are conceptually the same. Move them together in the
> pre-relocation init.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Acked-by: Anatolij Gustschin <agust@denx.de>
> ---
>
> Changes in v2: None
>
>  common/board_f.c | 28 ++++++++++++++--------------
>  1 file changed, 14 insertions(+), 14 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 05/14] dm: video: Add a driver for a rotated text console
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 05/14] dm: video: Add a driver for a rotated text console Simon Glass
@ 2016-01-21 15:19   ` Simon Glass
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Glass @ 2016-01-21 15:19 UTC (permalink / raw)
  To: u-boot

On 18 January 2016 at 19:52, Simon Glass <sjg@chromium.org> wrote:
> Sometimes the console must be rotated. Add a driver which supports rotating
> the text clockwise to 90, 180 and 270 degrees. This can support devices
> where the display is rotated for mechanical reasons.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Acked-by: Anatolij Gustschin <agust@denx.de>
> ---
>
> Changes in v2: None
>
>  drivers/video/Kconfig          |  13 ++
>  drivers/video/Makefile         |   1 +
>  drivers/video/console_rotate.c | 436 +++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 450 insertions(+)
>  create mode 100644 drivers/video/console_rotate.c

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 08/14] dm: video: Implement the bmp command for driver model
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 08/14] dm: video: Implement the bmp command for driver model Simon Glass
@ 2016-01-21 15:19   ` Simon Glass
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Glass @ 2016-01-21 15:19 UTC (permalink / raw)
  To: u-boot

On 18 January 2016 at 19:52, Simon Glass <sjg@chromium.org> wrote:
> This command can use the bitmap display code in the uclass. This is similar
> to the code in lcd.c and cfb_console.c. These other copies will go away when
> all boards are converted to use driver model for video.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Acked-by: Anatolij Gustschin <agust@denx.de>
> ---
>
> Changes in v2: None
>
>  common/cmd_bmp.c          |  22 ++-
>  drivers/video/Makefile    |   1 +
>  drivers/video/video_bmp.c | 353 ++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 375 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/video/video_bmp.c

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 07/14] dm: common: Add memory reservation for the video uclass
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 07/14] dm: common: Add memory reservation for the video uclass Simon Glass
@ 2016-01-21 15:19   ` Simon Glass
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Glass @ 2016-01-21 15:19 UTC (permalink / raw)
  To: u-boot

On 18 January 2016 at 19:52, Simon Glass <sjg@chromium.org> wrote:
> Before relocation we need to reserve memory for the video driver frame
> buffers so that they can use this memory when they start up (after
> relocation). Add a call to the uclass to permit this.
>
> The current top and bottom of the region is stored in global_data so that
> it can be checked post-relocation to ensure enough memory is available. No
> video device should be probed before relocation.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Acked-by: Anatolij Gustschin <agust@denx.de>
> ---
>
> Changes in v2: None
>
>  common/board_f.c                  | 47 +++++++++++++++++++++++++++++----------
>  include/asm-generic/global_data.h |  4 ++++
>  2 files changed, 39 insertions(+), 12 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 09/14] dm: stdio: video: Plumb the video uclass into stdio
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 09/14] dm: stdio: video: Plumb the video uclass into stdio Simon Glass
@ 2016-01-21 15:19   ` Simon Glass
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Glass @ 2016-01-21 15:19 UTC (permalink / raw)
  To: u-boot

On 18 January 2016 at 19:52, Simon Glass <sjg@chromium.org> wrote:
> Register video drivers with stdio so that they can be used for text output.
> This needs to be done explicitly for now. At some point we should be able to
> convert stdio itself to driver model and avoid this step.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Acked-by: Anatolij Gustschin <agust@denx.de>
> ---
>
> Changes in v2: None
>
>  common/stdio.c | 19 +++++++++++++++----
>  1 file changed, 15 insertions(+), 4 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 10/14] sandbox: Move CONFIG_VIDEO_SANDBOX_SDL to Kconfig
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 10/14] sandbox: Move CONFIG_VIDEO_SANDBOX_SDL to Kconfig Simon Glass
@ 2016-01-21 15:19   ` Simon Glass
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Glass @ 2016-01-21 15:19 UTC (permalink / raw)
  To: u-boot

On 18 January 2016 at 19:52, Simon Glass <sjg@chromium.org> wrote:
> Move this option to Kconfig. This is quite simple as only sandbox uses the
> driver.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Acked-by: Anatolij Gustschin <agust@denx.de>
> ---
>
> Changes in v2: None
>
>  configs/sandbox_defconfig | 3 ++-
>  drivers/video/Kconfig     | 9 +++++++++
>  include/configs/sandbox.h | 1 -
>  3 files changed, 11 insertions(+), 2 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 11/14] dm: video: sandbox: Convert sandbox to use driver model for video
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 11/14] dm: video: sandbox: Convert sandbox to use driver model for video Simon Glass
@ 2016-01-21 15:19   ` Simon Glass
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Glass @ 2016-01-21 15:19 UTC (permalink / raw)
  To: u-boot

On 18 January 2016 at 19:52, Simon Glass <sjg@chromium.org> wrote:
> Now that driver model support is available, convert sandbox over to use it.
> We can remove a few of the special hooks that sandbox currently has.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Acked-by: Anatolij Gustschin <agust@denx.de>
> ---
>
> Changes in v2: None
>
>  arch/sandbox/dts/sandbox.dts |  1 +
>  board/sandbox/sandbox.c      | 17 --------
>  common/lcd.c                 | 11 -----
>  configs/sandbox_defconfig    |  1 +
>  drivers/serial/sandbox.c     |  5 +--
>  drivers/video/sandbox_sdl.c  | 95 ++++++++++++++++++++++----------------------
>  include/configs/sandbox.h    | 10 ++---
>  include/fdtdec.h             |  1 -
>  lib/fdtdec.c                 |  1 -
>  9 files changed, 56 insertions(+), 86 deletions(-)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 12/14] dm: video: test: Add tests for the video uclass
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 12/14] dm: video: test: Add tests for the video uclass Simon Glass
@ 2016-01-21 15:19   ` Simon Glass
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Glass @ 2016-01-21 15:19 UTC (permalink / raw)
  To: u-boot

On 18 January 2016 at 19:52, Simon Glass <sjg@chromium.org> wrote:
> Add tests that check that the video console is working correcty. Also check
> that text output produces the expected result. Test coverage includes
> character output, wrapping and scrolling.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Acked-by: Anatolij Gustschin <agust@denx.de>
> ---
>
> Changes in v2:
> - Fix 'resolutino' typo in comment
>
>  arch/sandbox/dts/test.dts   |   7 ++
>  drivers/video/sandbox_sdl.c |   9 ---
>  include/dm/test.h           |   8 ++
>  test/dm/Makefile            |   1 +
>  test/dm/video.c             | 190 ++++++++++++++++++++++++++++++++++++++++++++
>  5 files changed, 206 insertions(+), 9 deletions(-)
>  create mode 100644 test/dm/video.c

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 13/14] dm: video: test: Add tests for rotated consoles
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 13/14] dm: video: test: Add tests for rotated consoles Simon Glass
@ 2016-01-21 15:26   ` Simon Glass
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Glass @ 2016-01-21 15:26 UTC (permalink / raw)
  To: u-boot

On 18 January 2016 at 19:52, Simon Glass <sjg@chromium.org> wrote:
> Test that text is displayed correctly when the console is rotated.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Acked-by: Anatolij Gustschin <agust@denx.de>
> ---
>
> Changes in v2: None
>
>  configs/sandbox_defconfig |  1 +
>  test/dm/video.c           | 27 +++++++++++++++++++++++++++
>  2 files changed, 28 insertions(+)

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [U-Boot] [PATCH v2 14/14] dm: video: test: Test that bitmap display works correctly
  2016-01-19  2:52 ` [U-Boot] [PATCH v2 14/14] dm: video: test: Test that bitmap display works correctly Simon Glass
@ 2016-01-21 15:26   ` Simon Glass
  0 siblings, 0 replies; 32+ messages in thread
From: Simon Glass @ 2016-01-21 15:26 UTC (permalink / raw)
  To: u-boot

On 18 January 2016 at 19:52, Simon Glass <sjg@chromium.org> wrote:
> Add a test for the 'bmp' command. Test both the uncompressed and compressed
> versions of the file, since they use different code paths.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Acked-by: Anatolij Gustschin <agust@denx.de>
> ---
>
> Changes in v2: None
>
>  include/configs/sandbox.h |   2 ++
>  test/dm/video.c           |  54 ++++++++++++++++++++++++++++++++++++++++++++++
>  tools/logos/denx-comp.bmp | Bin 0 -> 4148 bytes
>  3 files changed, 56 insertions(+)
>  create mode 100644 tools/logos/denx-comp.bmp

Applied to u-boot-dm

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2016-01-21 15:26 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-19  2:52 [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support Simon Glass
2016-01-19  2:52 ` [U-Boot] [PATCH v2 01/14] dm: video: Add a video uclass Simon Glass
2016-01-21 15:18   ` Simon Glass
2016-01-19  2:52 ` [U-Boot] [PATCH v2 02/14] dm: lcd: Avoid using the lcd.h header file with driver model Simon Glass
2016-01-21 15:18   ` Simon Glass
2016-01-19  2:52 ` [U-Boot] [PATCH v2 03/14] dm: video: Add a uclass for the text console Simon Glass
2016-01-21 15:18   ` Simon Glass
2016-01-19  2:52 ` [U-Boot] [PATCH v2 04/14] dm: video: Add a 'normal' text console driver Simon Glass
2016-01-21 15:18   ` Simon Glass
2016-01-19  2:52 ` [U-Boot] [PATCH v2 05/14] dm: video: Add a driver for a rotated text console Simon Glass
2016-01-21 15:19   ` Simon Glass
2016-01-19  2:52 ` [U-Boot] [PATCH v2 06/14] common: Move LCD and video memory reservation together Simon Glass
2016-01-21 15:18   ` Simon Glass
2016-01-19  2:52 ` [U-Boot] [PATCH v2 07/14] dm: common: Add memory reservation for the video uclass Simon Glass
2016-01-21 15:19   ` Simon Glass
2016-01-19  2:52 ` [U-Boot] [PATCH v2 08/14] dm: video: Implement the bmp command for driver model Simon Glass
2016-01-21 15:19   ` Simon Glass
2016-01-19  2:52 ` [U-Boot] [PATCH v2 09/14] dm: stdio: video: Plumb the video uclass into stdio Simon Glass
2016-01-21 15:19   ` Simon Glass
2016-01-19  2:52 ` [U-Boot] [PATCH v2 10/14] sandbox: Move CONFIG_VIDEO_SANDBOX_SDL to Kconfig Simon Glass
2016-01-21 15:19   ` Simon Glass
2016-01-19  2:52 ` [U-Boot] [PATCH v2 11/14] dm: video: sandbox: Convert sandbox to use driver model for video Simon Glass
2016-01-21 15:19   ` Simon Glass
2016-01-19  2:52 ` [U-Boot] [PATCH v2 12/14] dm: video: test: Add tests for the video uclass Simon Glass
2016-01-21 15:19   ` Simon Glass
2016-01-19  2:52 ` [U-Boot] [PATCH v2 13/14] dm: video: test: Add tests for rotated consoles Simon Glass
2016-01-21 15:26   ` Simon Glass
2016-01-19  2:52 ` [U-Boot] [PATCH v2 14/14] dm: video: test: Test that bitmap display works correctly Simon Glass
2016-01-21 15:26   ` Simon Glass
2016-01-19  2:56 ` [U-Boot] [PATCH v2 00/14] dm: video: Introduce initial driver-model video support Simon Glass
2016-01-19  2:57   ` Simon Glass
2016-01-20  7:28     ` Anatolij Gustschin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.