[U-Boot,v3,20/21] efi_loader: Correctly figure out size for vidconsole

Message ID 20170913220546.19560-21-robdclark@gmail.com
State Accepted
Delegated to: Alexander Graf
Headers show
Series
  • efi_loader: enough UEFI for standard distro boot
Related show

Commit Message

Rob Clark Sept. 13, 2017, 10:05 p.m.
If stdout is vidconsole, we cannot rely on ANSI escape sequences to
query the size, as vidconsole cannot reply on stdin.  Instead special-
case this if stdout is vidconsole.

Signed-off-by: Rob Clark <robdclark@gmail.com>
---
 lib/efi_loader/efi_console.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

Comments

Alexander Graf Sept. 21, 2017, 7:04 a.m. | #1
> If stdout is vidconsole, we cannot rely on ANSI escape sequences to
> query the size, as vidconsole cannot reply on stdin.  Instead special-
> case this if stdout is vidconsole.
> 
> Signed-off-by: Rob Clark <robdclark@gmail.com>

Thanks, applied to efi-next

Alex

Patch

diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index e8c02870eb..9048a8d32c 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -8,7 +8,10 @@ 
 
 #include <common.h>
 #include <charset.h>
+#include <dm/device.h>
 #include <efi_loader.h>
+#include <stdio_dev.h>
+#include <video_console.h>
 
 static bool console_size_queried;
 
@@ -222,12 +225,23 @@  static efi_status_t EFIAPI efi_cout_query_mode(
 	EFI_ENTRY("%p, %ld, %p, %p", this, mode_number, columns, rows);
 
 	if (!console_size_queried) {
+		const char *stdout_name = env_get("stdout");
 		int rows, cols;
 
 		console_size_queried = true;
 
-		if (query_console_serial(&rows, &cols))
+		if (stdout_name && !strcmp(stdout_name, "vidconsole") &&
+		    IS_ENABLED(CONFIG_DM_VIDEO)) {
+			struct stdio_dev *stdout_dev =
+				stdio_get_by_name("vidconsole");
+			struct udevice *dev = stdout_dev->priv;
+			struct vidconsole_priv *priv =
+				dev_get_uclass_priv(dev);
+			rows = priv->rows;
+			cols = priv->cols;
+		} else if (query_console_serial(&rows, &cols)) {
 			goto out;
+		}
 
 		/* Test if we can have Mode 1 */
 		if (cols >= 80 && rows >= 50) {