Multiplexed adaptation of the query_console_size() function;
automatically determine the minimal console area that will fit all
outputs properly.

Signed-off-by: Artem Lapkin <[email protected]>
---
 lib/efi_loader/efi_console.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index 3b012e1a66..ef5cf21bf7 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -340,14 +340,18 @@ static int __maybe_unused query_vidconsole(int *rows, int 
*cols)
 static void query_console_size(void)
 {
        int rows = 25, cols = 80;
-       int ret = -ENODEV;
 
-       if (IS_ENABLED(CONFIG_DM_VIDEO))
-               ret = query_vidconsole(&rows, &cols);
-       if (ret)
-               ret = query_console_serial(&rows, &cols);
-       if (ret)
+       if (IS_ENABLED(CONFIG_DM_VIDEO) &&
+           !query_vidconsole(&rows, &cols)) {
+               int rows_serial, cols_serial;
+
+               if (!query_console_serial(&rows_serial, &cols_serial)) {
+                       rows = min(rows, rows_serial);
+                       cols = min(cols, cols_serial);
+               }
+       } else if (query_console_serial(&rows, &cols)) {
                return;
+       }
 
        /* Test if we can have Mode 1 */
        if (cols >= 80 && rows >= 50) {
-- 
2.25.1

Reply via email to