diff mbox series

[3/4] EFI: console: max rows and cols user limit

Message ID 20210804102217.2419510-4-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
Setup the max rows and columns limit for the EFI console output.

Signed-off-by: Artem Lapkin <art@khadas.com>
---
 lib/efi_loader/Kconfig       | 12 ++++++++++++
 lib/efi_loader/efi_console.c |  5 +++++
 2 files changed, 17 insertions(+)

Comments

Heinrich Schuchardt Aug. 5, 2021, 11:59 a.m. UTC | #1
On 8/4/21 12:22 PM, Artem Lapkin wrote:
> Setup the max rows and columns limit for the EFI console output.

Why should a user set this up?

The size of serial console depends on the remote computers console
windows size.

The size of a video console depends on the attached monitor.

So we have to detect the size dynamically. Hardcoding it does not make
any sense.

Best regards

Heinrich

>
> Signed-off-by: Artem Lapkin <art@khadas.com>
> ---
>   lib/efi_loader/Kconfig       | 12 ++++++++++++
>   lib/efi_loader/efi_console.c |  5 +++++
>   2 files changed, 17 insertions(+)
>
> diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> index dacc3b5881..7d00d6cde5 100644
> --- a/lib/efi_loader/Kconfig
> +++ b/lib/efi_loader/Kconfig
> @@ -381,4 +381,16 @@ config EFI_ESRT
>   	help
>   	  Enabling this option creates the ESRT UEFI system table.
>
> +config EFI_CONSOLE_MAX_ROWS
> +	int "setup console max rows"
> +	default 0
> +	help
> +	  Set console max rows limit or set to zero to disable limit.
> +
> +config EFI_CONSOLE_MAX_COLS
> +	int "setup console max cols"
> +	default 0
> +	help
> +	  Set console max rows limit or set to zero to disable limit.
> +
>   endif
> diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
> index 847069212e..b5d79d788f 100644
> --- a/lib/efi_loader/efi_console.c
> +++ b/lib/efi_loader/efi_console.c
> @@ -351,6 +351,11 @@ static void query_console_size(void)
>   	} else if (query_console_serial(&rows, &cols))
>   		return;
>
> +	if (CONFIG_EFI_CONSOLE_MAX_ROWS > 0)
> +		rows = min(rows, CONFIG_EFI_CONSOLE_MAX_ROWS);
> +	if (CONFIG_EFI_CONSOLE_MAX_COLS > 0)
> +		cols = min(cols, CONFIG_EFI_CONSOLE_MAX_COLS);
> +
>   	/* Test if we can have Mode 1 */
>   	if (cols >= 80 && rows >= 50) {
>   		efi_cout_modes[1].present = 1;
>
Art Nikpal Aug. 6, 2021, 7:58 a.m. UTC | #2
> Why should a user set this up?

only if user need it! by default is 0 no limit

EFI console not usable for some cases: big screen sizes + mux with
serial console

for example

EFI console - fullscreen (1080P) vidconsole - SLUGGISH FRAMERATES AND NOT USABLE

CONFIG_CONSOLE_MUX=y
CONFIG_CONSOLE_NORMAL=y
CONFIG_EFI_CONSOLE_MAX_ROWS=0
CONFIG_EFI_CONSOLE_MAX_COLS=0

https://dl.khadas.com/test/uboot_efi_examples/media/07-EFI_console_example_normal_vidconsole_and_serial_multiplex_adaptation_utf_safe_SLOW_NOT_USABLE.mp4

EFI console - vidconsole with row and column limits - USABLE FRAMERATES

CONFIG_CONSOLE_MUX=y
CONFIG_CONSOLE_NORMAL=y
CONFIG_EFI_CONSOLE_MAX_ROWS=90
CONFIG_EFI_CONSOLE_MAX_COLS=25

https://dl.khadas.com/test/uboot_efi_examples/media/06-EFI_console_example_normal_vidconsole_and_serial_multiplex_adaptation_utf_safe_and_max_cols_90_limit_USABLE.mp4

Please check more information and examples about this

+ https://dl.khadas.com/test/uboot_efi_examples/#readme


On Thu, Aug 5, 2021 at 7:59 PM Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> On 8/4/21 12:22 PM, Artem Lapkin wrote:
> > Setup the max rows and columns limit for the EFI console output.
>
> Why should a user set this up?
>
> The size of serial console depends on the remote computers console
> windows size.
>
> The size of a video console depends on the attached monitor.
>
> So we have to detect the size dynamically. Hardcoding it does not make
> any sense.
>
> Best regards
>
> Heinrich
>
> >
> > Signed-off-by: Artem Lapkin <art@khadas.com>
> > ---
> >   lib/efi_loader/Kconfig       | 12 ++++++++++++
> >   lib/efi_loader/efi_console.c |  5 +++++
> >   2 files changed, 17 insertions(+)
> >
> > diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> > index dacc3b5881..7d00d6cde5 100644
> > --- a/lib/efi_loader/Kconfig
> > +++ b/lib/efi_loader/Kconfig
> > @@ -381,4 +381,16 @@ config EFI_ESRT
> >       help
> >         Enabling this option creates the ESRT UEFI system table.
> >
> > +config EFI_CONSOLE_MAX_ROWS
> > +     int "setup console max rows"
> > +     default 0
> > +     help
> > +       Set console max rows limit or set to zero to disable limit.
> > +
> > +config EFI_CONSOLE_MAX_COLS
> > +     int "setup console max cols"
> > +     default 0
> > +     help
> > +       Set console max rows limit or set to zero to disable limit.
> > +
> >   endif
> > diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
> > index 847069212e..b5d79d788f 100644
> > --- a/lib/efi_loader/efi_console.c
> > +++ b/lib/efi_loader/efi_console.c
> > @@ -351,6 +351,11 @@ static void query_console_size(void)
> >       } else if (query_console_serial(&rows, &cols))
> >               return;
> >
> > +     if (CONFIG_EFI_CONSOLE_MAX_ROWS > 0)
> > +             rows = min(rows, CONFIG_EFI_CONSOLE_MAX_ROWS);
> > +     if (CONFIG_EFI_CONSOLE_MAX_COLS > 0)
> > +             cols = min(cols, CONFIG_EFI_CONSOLE_MAX_COLS);
> > +
> >       /* Test if we can have Mode 1 */
> >       if (cols >= 80 && rows >= 50) {
> >               efi_cout_modes[1].present = 1;
> >
>
Heinrich Schuchardt Aug. 7, 2021, 6:57 a.m. UTC | #3
On 8/6/21 9:58 AM, Art Nikpal wrote:
>> Why should a user set this up?
>
> only if user need it! by default is 0 no limit
>
> EFI console not usable for some cases: big screen sizes + mux with
> serial console
>
> for example
>
> EFI console - fullscreen (1080P) vidconsole - SLUGGISH FRAMERATES AND NOT USABLE
>
> CONFIG_CONSOLE_MUX=y
> CONFIG_CONSOLE_NORMAL=y
> CONFIG_EFI_CONSOLE_MAX_ROWS=0
> CONFIG_EFI_CONSOLE_MAX_COLS=0
>
> https://dl.khadas.com/test/uboot_efi_examples/media/07-EFI_console_example_normal_vidconsole_and_serial_multiplex_adaptation_utf_safe_SLOW_NOT_USABLE.mp4
>
> EFI console - vidconsole with row and column limits - USABLE FRAMERATES
>
> CONFIG_CONSOLE_MUX=y
> CONFIG_CONSOLE_NORMAL=y
> CONFIG_EFI_CONSOLE_MAX_ROWS=90
> CONFIG_EFI_CONSOLE_MAX_COLS=25
>
> https://dl.khadas.com/test/uboot_efi_examples/media/06-EFI_console_example_normal_vidconsole_and_serial_multiplex_adaptation_utf_safe_and_max_cols_90_limit_USABLE.mp4
>
> Please check more information and examples about this
>
> + https://dl.khadas.com/test/uboot_efi_examples/#readme
>
>
> On Thu, Aug 5, 2021 at 7:59 PM Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>>
>> On 8/4/21 12:22 PM, Artem Lapkin wrote:
>>> Setup the max rows and columns limit for the EFI console output.
>>
>> Why should a user set this up?
>>
>> The size of serial console depends on the remote computers console
>> windows size.
>>
>> The size of a video console depends on the attached monitor.
>>
>> So we have to detect the size dynamically. Hardcoding it does not make
>> any sense.
>>
>> Best regards
>>
>> Heinrich
>>
>>>
>>> Signed-off-by: Artem Lapkin <art@khadas.com>
>>> ---
>>>    lib/efi_loader/Kconfig       | 12 ++++++++++++
>>>    lib/efi_loader/efi_console.c |  5 +++++
>>>    2 files changed, 17 insertions(+)
>>>
>>> diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
>>> index dacc3b5881..7d00d6cde5 100644
>>> --- a/lib/efi_loader/Kconfig
>>> +++ b/lib/efi_loader/Kconfig
>>> @@ -381,4 +381,16 @@ config EFI_ESRT
>>>        help
>>>          Enabling this option creates the ESRT UEFI system table.
>>>
>>> +config EFI_CONSOLE_MAX_ROWS
>>> +     int "setup console max rows"

This allows negative values.

Add an allowable range, e.g:

	range 0 65535

>>> +     default 0
>>> +     help
>>> +       Set console max rows limit or set to zero to disable limit.
>>> +
>>> +config EFI_CONSOLE_MAX_COLS
>>> +     int "setup console max cols"

	range 0 65535

>>> +     default 0
>>> +     help
>>> +       Set console max rows limit or set to zero to disable limit.
>>> +
>>>    endif
>>> diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
>>> index 847069212e..b5d79d788f 100644
>>> --- a/lib/efi_loader/efi_console.c
>>> +++ b/lib/efi_loader/efi_console.c
>>> @@ -351,6 +351,11 @@ static void query_console_size(void)
>>>        } else if (query_console_serial(&rows, &cols))
>>>                return;
>>>
>>> +     if (CONFIG_EFI_CONSOLE_MAX_ROWS > 0)
>>> +             rows = min(rows, CONFIG_EFI_CONSOLE_MAX_ROWS);
>>> +     if (CONFIG_EFI_CONSOLE_MAX_COLS > 0)
>>> +             cols = min(cols, CONFIG_EFI_CONSOLE_MAX_COLS);
>>> +

We should not neither call query_vidconsole() nor query_console_serial()
if both CONFIG_EFI_CONSOLE_MAX_ROWS and CONFIG_EFI_CONSOLE_MAX_COLS are set.

The UEFI specification requires that a device providing the
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL must at least support a mode with size
80x25. But some LCD screens are smaller. So if
CONFIG_EFI_CONSOLE_MAX_ROWS or CONFIG_EFI_CONSOLE_MAX_COLS doesn't fit
into 80x25, we should use CONFIG_EFI_CONSOLE_MAX_ROWS and
CONFIG_EFI_CONSOLE_MAX_COLS for mode 0.

Best regards

Heinrich

>>>        /* Test if we can have Mode 1 */
>>>        if (cols >= 80 && rows >= 50) {
>>>                efi_cout_modes[1].present = 1;
>>>
>>
diff mbox series

Patch

diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index dacc3b5881..7d00d6cde5 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -381,4 +381,16 @@  config EFI_ESRT
 	help
 	  Enabling this option creates the ESRT UEFI system table.
 
+config EFI_CONSOLE_MAX_ROWS
+	int "setup console max rows"
+	default 0
+	help
+	  Set console max rows limit or set to zero to disable limit.
+
+config EFI_CONSOLE_MAX_COLS
+	int "setup console max cols"
+	default 0
+	help
+	  Set console max rows limit or set to zero to disable limit.
+
 endif
diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index 847069212e..b5d79d788f 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -351,6 +351,11 @@  static void query_console_size(void)
 	} else if (query_console_serial(&rows, &cols))
 		return;
 
+	if (CONFIG_EFI_CONSOLE_MAX_ROWS > 0)
+		rows = min(rows, CONFIG_EFI_CONSOLE_MAX_ROWS);
+	if (CONFIG_EFI_CONSOLE_MAX_COLS > 0)
+		cols = min(cols, CONFIG_EFI_CONSOLE_MAX_COLS);
+
 	/* Test if we can have Mode 1 */
 	if (cols >= 80 && rows >= 50) {
 		efi_cout_modes[1].present = 1;