diff mbox series

[2/4] EFI: console: query_console_size: multiplex adaptation

Message ID 20210804102217.2419510-3-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
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 <art@khadas.com>
---
 lib/efi_loader/efi_console.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
diff mbox series

Patch

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) {