Re: [U-Boot] [PATCH v2 05/14] dm: video: Add a driver for a rotated text console

2016-01-21 Thread Simon Glass
On 18 January 2016 at 19:52, Simon Glass  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 
> Acked-by: Anatolij Gustschin 
> ---
>
> 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
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 05/14] dm: video: Add a driver for a rotated text console

2016-01-18 Thread Simon Glass
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 
Acked-by: Anatolij Gustschin 
---

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 000..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 
+#include 
+#include 
+#include 
+#include /* 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