diff mbox series

fastboot: scale download progress dots to video console width

Message ID 20261002-b4-fastboot-dot-width-v1-1-93bb3cb13179@protonmail.com
State Accepted
Delegated to: Mattijs Korpershoek
Headers show
Series fastboot: scale download progress dots to video console width | expand

Commit Message

Petr Hodina via B4 Relay Oct. 2, 2026, 8:52 p.m. UTC
From: Petr Hodina <petr.hodina@protonmail.com>

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 <petr.hodina@protonmail.com>
---
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(-)


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

Best regards,
--  
Petr Hodina <petr.hodina@protonmail.com>

Comments

Mattijs Korpershoek Oct. 13, 2026, 1:09 p.m. UTC | #1
Hi Petr,

Thank you for the patch.

On Fri, Oct 02, 2026 at 22:52, Petr Hodina via B4 Relay <devnull+petr.hodina.protonmail.com@kernel.org> wrote:

> From: Petr Hodina <petr.hodina@protonmail.com>
>
> 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 <petr.hodina@protonmail.com>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
Mattijs Korpershoek Oct. 13, 2026, 3:06 p.m. UTC | #2
Hi,

On Fri, 02 Oct 2026 22:52:57 +0200, Petr Hodina wrote:
> 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.
> 
> 

Thanks, Applied to https://git.u-boot-project.org/u-boot/custodians/u-boot-dfu (u-boot-dfu)

[1/1] fastboot: scale download progress dots to video console width
      https://git.u-boot-project.org/u-boot/custodians/u-boot-dfu/-/commit/21604de81a0ca9f8427214384ef0575e9ce1a6ec

--
Mattijs
diff mbox series

Patch

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';