diff mbox series

[4/4] EFI: console: improve vidconsole unicode output

Message ID 20210804102217.2419510-5-art@khadas.com
State Changes Requested, archived
Delegated to: Heinrich Schuchardt
Headers show
Series EFI: console: improves | expand

Commit Message

Art Nikpal Aug. 4, 2021, 10:22 a.m. UTC
If EFI_CONSOLE_UTF_SAFE is enabled and vidconsole is active, unicode
characters will be replaced with "." for all console outputs.

Vidconsole does not support unicode output, and your console will suffer
display issues if EFI_CONSOLE_UTF_SAFE is disabled.

Signed-off-by: Artem Lapkin <art@khadas.com>
---
 lib/efi_loader/Kconfig       | 9 +++++++++
 lib/efi_loader/efi_console.c | 6 +++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

Comments

Heinrich Schuchardt Aug. 5, 2021, 12:01 p.m. UTC | #1
On 8/4/21 12:22 PM, Artem Lapkin wrote:
> If EFI_CONSOLE_UTF_SAFE is enabled and vidconsole is active, unicode
> characters will be replaced with "." for all console outputs.

The TrueType console is meant to support Unicode including the special
characters used by GRUB like left and right triangle.

So this patch is based on a wrong assumption.

Best regards

Heinrich

>
> Vidconsole does not support unicode output, and your console will suffer
> display issues if EFI_CONSOLE_UTF_SAFE is disabled.
>
> Signed-off-by: Artem Lapkin <art@khadas.com>
> ---
>   lib/efi_loader/Kconfig       | 9 +++++++++
>   lib/efi_loader/efi_console.c | 6 +++++-
>   2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> index 7d00d6cde5..886e0ce111 100644
> --- a/lib/efi_loader/Kconfig
> +++ b/lib/efi_loader/Kconfig
> @@ -393,4 +393,13 @@ config EFI_CONSOLE_MAX_COLS
>   	help
>   	  Set console max rows limit or set to zero to disable limit.
>
> +config EFI_CONSOLE_UTF_SAFE
> +	bool "If vidconsole is active, unicode characters will be replaced with '.'"
> +	default n
> +	help
> +	  If EFI_CONSOLE_UTF_SAFE is enabled and vidconsole is active, unicode
> +	  characters will be replaced with "." for all console outputs.
> +	  Vidconsole does not support unicode output, and your console will
> +	  suffer display issues if EFI_CONSOLE_UTF_SAFE is disabled.
> +
>   endif
> diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
> index b5d79d788f..bd1c14995d 100644
> --- a/lib/efi_loader/efi_console.c
> +++ b/lib/efi_loader/efi_console.c
> @@ -19,6 +19,8 @@
>   #define EFI_COUT_MODE_2 2
>   #define EFI_MAX_COUT_MODE 3
>
> +static int vidconsole_active;
> +
>   struct cout_mode {
>   	unsigned long columns;
>   	unsigned long rows;
> @@ -163,7 +165,8 @@ static efi_status_t EFIAPI efi_cout_output_string(
>   	}
>   	pos = buf;
>   	utf16_utf8_strcpy(&pos, string);
> -	fputs(stdout, buf);
> +	fputs(stdout, IS_ENABLED(CONFIG_EFI_CONSOLE_UTF_SAFE) &&
> +	      strlen(buf) > 1 && vidconsole_active ? "." : buf);
>   	free(buf);
>
>   	/*
> @@ -327,6 +330,7 @@ static int __maybe_unused query_vidconsole(int *rows, int *cols)
>   		return -ENODEV;
>   	*rows = priv->rows;
>   	*cols = priv->cols;
> +	vidconsole_active = 1;
>   	return 0;
>   }
>
>
Art Nikpal Aug. 6, 2021, 7:47 a.m. UTC | #2
> The TrueType console is meant to support Unicode including the special
characters used by GRUB like left and right triangle.

Yes is meant but not works (on my side) ...

uboot TrueType vidconsole does not work properly as a unicode console
in my case and have other problems

CONFIG_CONSOLE_MUX=y
CONFIG_CONSOLE_NORMAL=y
CONFIG_CONSOLE_TRUETYPE=y
CONFIG_CONSOLE_TRUETYPE_SIZE=18
CONFIG_CONSOLE_TRUETYPE_NIMBUS=y

please check more information and examples about this

+ https://dl.khadas.com/test/uboot_efi_examples/#readme
+ https://dl.khadas.com/test/uboot_efi_examples/media/02-EFI_console_example_true_type_vidconsole_and_serial_as_is_NOT_USABLE.mp4
+ https://dl.khadas.com/test/uboot_efi_examples/media/02-EFI_console_example_true_type_vidconsole_and_serial_as_is_NOT_USABLE.png
+ https://dl.khadas.com/test/uboot_efi_examples/media/02-EFI_console_example_true_type_vidconsole_and_serial_as_is_NOT_USABLE_2.png

On Thu, Aug 5, 2021 at 8:01 PM Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> On 8/4/21 12:22 PM, Artem Lapkin wrote:
> > If EFI_CONSOLE_UTF_SAFE is enabled and vidconsole is active, unicode
> > characters will be replaced with "." for all console outputs.
>
> The TrueType console is meant to support Unicode including the special
> characters used by GRUB like left and right triangle.
>
> So this patch is based on a wrong assumption.
>
> Best regards
>
> Heinrich
>
> >
> > Vidconsole does not support unicode output, and your console will suffer
> > display issues if EFI_CONSOLE_UTF_SAFE is disabled.
> >
> > Signed-off-by: Artem Lapkin <art@khadas.com>
> > ---
> >   lib/efi_loader/Kconfig       | 9 +++++++++
> >   lib/efi_loader/efi_console.c | 6 +++++-
> >   2 files changed, 14 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> > index 7d00d6cde5..886e0ce111 100644
> > --- a/lib/efi_loader/Kconfig
> > +++ b/lib/efi_loader/Kconfig
> > @@ -393,4 +393,13 @@ config EFI_CONSOLE_MAX_COLS
> >       help
> >         Set console max rows limit or set to zero to disable limit.
> >
> > +config EFI_CONSOLE_UTF_SAFE
> > +     bool "If vidconsole is active, unicode characters will be replaced with '.'"
> > +     default n
> > +     help
> > +       If EFI_CONSOLE_UTF_SAFE is enabled and vidconsole is active, unicode
> > +       characters will be replaced with "." for all console outputs.
> > +       Vidconsole does not support unicode output, and your console will
> > +       suffer display issues if EFI_CONSOLE_UTF_SAFE is disabled.
> > +
> >   endif
> > diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
> > index b5d79d788f..bd1c14995d 100644
> > --- a/lib/efi_loader/efi_console.c
> > +++ b/lib/efi_loader/efi_console.c
> > @@ -19,6 +19,8 @@
> >   #define EFI_COUT_MODE_2 2
> >   #define EFI_MAX_COUT_MODE 3
> >
> > +static int vidconsole_active;
> > +
> >   struct cout_mode {
> >       unsigned long columns;
> >       unsigned long rows;
> > @@ -163,7 +165,8 @@ static efi_status_t EFIAPI efi_cout_output_string(
> >       }
> >       pos = buf;
> >       utf16_utf8_strcpy(&pos, string);
> > -     fputs(stdout, buf);
> > +     fputs(stdout, IS_ENABLED(CONFIG_EFI_CONSOLE_UTF_SAFE) &&
> > +           strlen(buf) > 1 && vidconsole_active ? "." : buf);
> >       free(buf);
> >
> >       /*
> > @@ -327,6 +330,7 @@ static int __maybe_unused query_vidconsole(int *rows, int *cols)
> >               return -ENODEV;
> >       *rows = priv->rows;
> >       *cols = priv->cols;
> > +     vidconsole_active = 1;
> >       return 0;
> >   }
> >
> >
>
diff mbox series

Patch

diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 7d00d6cde5..886e0ce111 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -393,4 +393,13 @@  config EFI_CONSOLE_MAX_COLS
 	help
 	  Set console max rows limit or set to zero to disable limit.
 
+config EFI_CONSOLE_UTF_SAFE
+	bool "If vidconsole is active, unicode characters will be replaced with '.'"
+	default n
+	help
+	  If EFI_CONSOLE_UTF_SAFE is enabled and vidconsole is active, unicode
+	  characters will be replaced with "." for all console outputs.
+	  Vidconsole does not support unicode output, and your console will
+	  suffer display issues if EFI_CONSOLE_UTF_SAFE is disabled.
+
 endif
diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index b5d79d788f..bd1c14995d 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -19,6 +19,8 @@ 
 #define EFI_COUT_MODE_2 2
 #define EFI_MAX_COUT_MODE 3
 
+static int vidconsole_active;
+
 struct cout_mode {
 	unsigned long columns;
 	unsigned long rows;
@@ -163,7 +165,8 @@  static efi_status_t EFIAPI efi_cout_output_string(
 	}
 	pos = buf;
 	utf16_utf8_strcpy(&pos, string);
-	fputs(stdout, buf);
+	fputs(stdout, IS_ENABLED(CONFIG_EFI_CONSOLE_UTF_SAFE) &&
+	      strlen(buf) > 1 && vidconsole_active ? "." : buf);
 	free(buf);
 
 	/*
@@ -327,6 +330,7 @@  static int __maybe_unused query_vidconsole(int *rows, int *cols)
 		return -ENODEV;
 	*rows = priv->rows;
 	*cols = priv->cols;
+	vidconsole_active = 1;
 	return 0;
 }