Re: [PATCH 1/5] video console: unite normal and rotated files

2023-01-11 Thread Dzmitry Sankouski
I'll reword the commit description. Files contain similar logic, and
common code may be extracted after putting it together.

пт, 30 дек. 2022 г. в 01:41, Simon Glass :
>
> Hi Dzmitry,
>
> On Mon, 26 Dec 2022 at 13:49, Dzmitry Sankouski  wrote:
> >
> > Put video console driver code in one file.
>
> This isn't quite true as we still have TrueType.
>
> Also, what combine them?
>
> >
> > Signed-off-by: Dzmitry Sankouski 
> > ---
> >  drivers/video/Kconfig |   8 +-
> >  drivers/video/Makefile|   3 +-
> >  drivers/video/console_normal.c| 178 --
> >  .../{console_rotate.c => console_simple.c}| 166 
> >  4 files changed, 171 insertions(+), 184 deletions(-)
> >  delete mode 100644 drivers/video/console_normal.c
> >  rename drivers/video/{console_rotate.c => console_simple.c} (75%)
>
> Regards,
> Simon


Re: [PATCH 1/5] video console: unite normal and rotated files

2022-12-29 Thread Simon Glass
Hi Dzmitry,

On Mon, 26 Dec 2022 at 13:49, Dzmitry Sankouski  wrote:
>
> Put video console driver code in one file.

This isn't quite true as we still have TrueType.

Also, what combine them?

>
> Signed-off-by: Dzmitry Sankouski 
> ---
>  drivers/video/Kconfig |   8 +-
>  drivers/video/Makefile|   3 +-
>  drivers/video/console_normal.c| 178 --
>  .../{console_rotate.c => console_simple.c}| 166 
>  4 files changed, 171 insertions(+), 184 deletions(-)
>  delete mode 100644 drivers/video/console_normal.c
>  rename drivers/video/{console_rotate.c => console_simple.c} (75%)

Regards,
Simon


[PATCH 1/5] video console: unite normal and rotated files

2022-12-26 Thread Dzmitry Sankouski
Put video console driver code in one file.

Signed-off-by: Dzmitry Sankouski 
---
 drivers/video/Kconfig |   8 +-
 drivers/video/Makefile|   3 +-
 drivers/video/console_normal.c| 178 --
 .../{console_rotate.c => console_simple.c}| 166 
 4 files changed, 171 insertions(+), 184 deletions(-)
 delete mode 100644 drivers/video/console_normal.c
 rename drivers/video/{console_rotate.c => console_simple.c} (75%)

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index c841b99bb3..bc7f20cf64 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -124,17 +124,17 @@ config VIDEO_MIPI_DSI
  The MIPI Display Serial Interface (MIPI DSI) defines a high-speed
  serial interface between a host processor and a display module.
 
-config CONSOLE_NORMAL
+config VIDEO_CONSOLE
bool "Support a simple text console"
default y
help
  Support drawing text on the frame buffer console so that it can be
- used as a console. Rotation is not supported by this driver (see
- CONFIG_CONSOLE_ROTATION for that). A built-in 8x16 font is used
- for the display.
+ used as a console. See CONFIG_CONSOLE_ROTATION for rotation support.
+ A built-in 8x16 font is used for the display.
 
 config CONSOLE_ROTATION
bool "Support rotated displays"
+   depends on VIDEO_CONSOLE
help
  Sometimes, for example if the display is mounted in portrait
  mode or even if it's mounted landscape but rotated by 180degree,
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 40a871d638..75decf707d 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -7,8 +7,7 @@ ifdef CONFIG_DM
 obj-$(CONFIG_BACKLIGHT) += backlight-uclass.o
 obj-$(CONFIG_BACKLIGHT_GPIO) += backlight_gpio.o
 obj-$(CONFIG_BACKLIGHT_PWM) += pwm_backlight.o
-obj-$(CONFIG_CONSOLE_NORMAL) += console_normal.o
-obj-$(CONFIG_CONSOLE_ROTATION) += console_rotate.o
+obj-$(CONFIG_VIDEO_CONSOLE) += console_simple.o
 obj-$(CONFIG_CONSOLE_TRUETYPE) += console_truetype.o fonts/
 obj-$(CONFIG_DISPLAY) += display-uclass.o
 obj-$(CONFIG_VIDEO_MIPI_DSI) += dsi-host-uclass.o
diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c
deleted file mode 100644
index 04f022491e..00
--- a/drivers/video/console_normal.c
+++ /dev/null
@@ -1,178 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (c) 2015 Google, Inc
- * (C) Copyright 2001-2015
- * DENX Software Engineering -- w...@denx.de
- * Compulab Ltd - http://compulab.co.il/
- * Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com
- */
-
-#include 
-#include 
-#include 
-#include 
-#include /* 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, *end;
-   int pixels = VIDEO_FONT_HEIGHT * vid_priv->xsize;
-   int ret;
-   int i;
-
-   line = vid_priv->fb + row * VIDEO_FONT_HEIGHT * vid_priv->line_length;
-   switch (vid_priv->bpix) {
-   case VIDEO_BPP8:
-   if (IS_ENABLED(CONFIG_VIDEO_BPP8)) {
-   uint8_t *dst = line;
-
-   for (i = 0; i < pixels; i++)
-   *dst++ = clr;
-   end = dst;
-   break;
-   }
-   case VIDEO_BPP16:
-   if (IS_ENABLED(CONFIG_VIDEO_BPP16)) {
-   uint16_t *dst = line;
-
-   for (i = 0; i < pixels; i++)
-   *dst++ = clr;
-   end = dst;
-   break;
-   }
-   case VIDEO_BPP32:
-   if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
-   uint32_t *dst = line;
-
-   for (i = 0; i < pixels; i++)
-   *dst++ = clr;
-   end = dst;
-   break;
-   }
-   default:
-   return -ENOSYS;
-   }
-   ret = vidconsole_sync_copy(dev, line, end);
-   if (ret)
-   return ret;
-
-   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;
-   int size;
-   int ret;
-
-   dst = vid_priv->fb + rowdst * VIDEO_FONT_HEIGHT * vid_priv->line_length;
-   src = vid_priv->fb + rowsrc * VIDEO_FONT_HEIGHT * vid_priv->line_length;
-   size = VIDEO_FONT_HEIGHT * vid_priv->line_length * count;
-   ret = vidconsole_memmove(dev, dst, src, size);
-   if (ret)
-   return ret;
-
-   return 0;
-}
-
-static int