From: Petr Hodina <[email protected]>

The download progress indicator wraps to a new line every 74 dots.
On boards with a video console the row is usually a different width,
so query the active video console's column count and use that instead,
falling back to the old default when no video console is probed.

Signed-off-by: Petr Hodina <[email protected]>
---
Found while testing fastboot flashing on a device using the on-screen
video console. The fixed 74-column dot-wrap assumed a serial terminal
and looked broken on the panel's actual row width.
---
 drivers/fastboot/fb_command.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c
index 18d86988f4c..e6a5f9b840c 100644
--- a/drivers/fastboot/fb_command.c
+++ b/drivers/fastboot/fb_command.c
@@ -5,6 +5,7 @@
 
 #include <command.h>
 #include <console.h>
+#include <dm.h>
 #include <env.h>
 #include <fastboot.h>
 #include <fastboot-internal.h>
@@ -14,9 +15,12 @@
 #include <fb_spi_flash.h>
 #include <part.h>
 #include <stdlib.h>
+#include <video_console.h>
 #include <vsprintf.h>
 #include <linux/printk.h>
 
+#define FASTBOOT_DOT_LINE_WIDTH_DEFAULT        74
+
 /**
  * image_size - final fastboot image size
  */
@@ -266,6 +270,26 @@ u32 fastboot_data_remaining(void)
        return fastboot_bytes_expected - fastboot_bytes_received;
 }
 
+/**
+ * fastboot_dot_line_width() - number of dot columns to print per line
+ *
+ * Return: number of dot columns per line
+ */
+static int fastboot_dot_line_width(void)
+{
+       struct udevice *dev;
+       struct vidconsole_priv *priv;
+
+       if (IS_ENABLED(CONFIG_VIDEO) &&
+           !uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) {
+               priv = dev_get_uclass_priv(dev);
+               if (priv->cols > 0)
+                       return priv->cols;
+       }
+
+       return FASTBOOT_DOT_LINE_WIDTH_DEFAULT;
+}
+
 /**
  * fastboot_data_download() - Copy image data to fastboot_buf_addr.
  *
@@ -304,7 +328,7 @@ void fastboot_data_download(const void *fastboot_data,
 
        if (pre_dot_num != now_dot_num) {
                putc('.');
-               if (!(now_dot_num % 74))
+               if (!(now_dot_num % fastboot_dot_line_width()))
                        putc('\n');
        }
        *response = '\0';

---
base-commit: ece349ade2973e220f524ce59e59711cc919263f
change-id: 20261002-b4-fastboot-dot-width-f56e91316650

Best regards,
--  
Petr Hodina <[email protected]>


Reply via email to