diff options
Diffstat (limited to 'config/module/u-boot/default')
10 files changed, 3389 insertions, 0 deletions
diff --git a/config/module/u-boot/default/nuke.list b/config/module/u-boot/default/nuke.list new file mode 100644 index 00000000..f3a3fcc3 --- /dev/null +++ b/config/module/u-boot/default/nuke.list @@ -0,0 +1 @@ +test/lib/strlcat.c diff --git a/config/module/u-boot/default/patches/0001-clk-rockchip-rk3399-Set-hardcoded-clock-rates-same-a.patch b/config/module/u-boot/default/patches/0001-clk-rockchip-rk3399-Set-hardcoded-clock-rates-same-a.patch new file mode 100644 index 00000000..8227b076 --- /dev/null +++ b/config/module/u-boot/default/patches/0001-clk-rockchip-rk3399-Set-hardcoded-clock-rates-same-a.patch @@ -0,0 +1,100 @@ +From ee94f55d37fc8c133faa5055184f75f99830cfdc Mon Sep 17 00:00:00 2001 +From: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Date: Fri, 8 Oct 2021 17:33:22 +0300 +Subject: [PATCH] clk: rockchip: rk3399: Set hardcoded clock rates same as + devicetree + +Update hardcoded RK3399 clock rate definitions to match those in its +devicetree (rk3399.dtsi), based on clock-controller assigned-clocks. +Add and initialize NPLL since it's on that list, though nothing seems to +use it in the driver so far. + +Also update VOP ACLK to 400MHz as it divides from CPLL (now 800MHz). +All this stops the displayed vendor bitmap from getting disfigured +when chainloading U-Boot from coreboot+depthcharge (as RW_LEGACY). + +Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Link: https://github.com/alpernebbi/u-boot/commit/7e73b7a7550cfdd22a1413c263026e41e56e7617 +--- + .../include/asm/arch-rockchip/cru_rk3399.h | 19 ++++++++++--------- + drivers/clk/rockchip/clk_rk3399.c | 10 ++++++---- + 2 files changed, 16 insertions(+), 13 deletions(-) + +diff --git a/arch/arm/include/asm/arch-rockchip/cru_rk3399.h b/arch/arm/include/asm/arch-rockchip/cru_rk3399.h +index d941a129f3e5..54035c0df1f3 100644 +--- a/arch/arm/include/asm/arch-rockchip/cru_rk3399.h ++++ b/arch/arm/include/asm/arch-rockchip/cru_rk3399.h +@@ -69,7 +69,8 @@ check_member(rockchip_cru, sdio1_con[1], 0x594); + #define LPLL_HZ (600*MHz) + #define BPLL_HZ (600*MHz) + #define GPLL_HZ (594*MHz) +-#define CPLL_HZ (384*MHz) ++#define CPLL_HZ (800*MHz) ++#define NPLL_HZ (1000*MHz) + #define PPLL_HZ (676*MHz) + + #define PMU_PCLK_HZ (48*MHz) +@@ -82,16 +83,16 @@ check_member(rockchip_cru, sdio1_con[1], 0x594); + #define ATCLK_CORE_B_HZ (300*MHz) + #define PCLK_DBG_B_HZ (100*MHz) + +-#define PERIHP_ACLK_HZ (148500*KHz) +-#define PERIHP_HCLK_HZ (148500*KHz) +-#define PERIHP_PCLK_HZ (37125*KHz) ++#define PERIHP_ACLK_HZ (150*MHz) ++#define PERIHP_HCLK_HZ (75*MHz) ++#define PERIHP_PCLK_HZ (37500*KHz) + +-#define PERILP0_ACLK_HZ (99000*KHz) +-#define PERILP0_HCLK_HZ (99000*KHz) +-#define PERILP0_PCLK_HZ (49500*KHz) ++#define PERILP0_ACLK_HZ (100*MHz) ++#define PERILP0_HCLK_HZ (100*MHz) ++#define PERILP0_PCLK_HZ (50*MHz) + +-#define PERILP1_HCLK_HZ (99000*KHz) +-#define PERILP1_PCLK_HZ (49500*KHz) ++#define PERILP1_HCLK_HZ (100*MHz) ++#define PERILP1_PCLK_HZ (50*MHz) + + #define PWM_CLOCK_HZ PMU_PCLK_HZ + +diff --git a/drivers/clk/rockchip/clk_rk3399.c b/drivers/clk/rockchip/clk_rk3399.c +index 6e87db18be07..1b8ffe9e794e 100644 +--- a/drivers/clk/rockchip/clk_rk3399.c ++++ b/drivers/clk/rockchip/clk_rk3399.c +@@ -53,10 +53,11 @@ struct pll_div { + .fbdiv = (u32)((u64)hz * _refdiv * _postdiv1 * _postdiv2 / OSC_HZ),\ + .postdiv1 = _postdiv1, .postdiv2 = _postdiv2}; + +-static const struct pll_div gpll_init_cfg = PLL_DIVISORS(GPLL_HZ, 2, 2, 1); +-static const struct pll_div cpll_init_cfg = PLL_DIVISORS(CPLL_HZ, 1, 2, 2); ++static const struct pll_div gpll_init_cfg = PLL_DIVISORS(GPLL_HZ, 1, 4, 1); ++static const struct pll_div cpll_init_cfg = PLL_DIVISORS(CPLL_HZ, 1, 3, 1); ++static const struct pll_div npll_init_cfg = PLL_DIVISORS(NPLL_HZ, 1, 3, 1); + #if !defined(CONFIG_XPL_BUILD) +-static const struct pll_div ppll_init_cfg = PLL_DIVISORS(PPLL_HZ, 2, 2, 1); ++static const struct pll_div ppll_init_cfg = PLL_DIVISORS(PPLL_HZ, 3, 2, 1); + #endif + + static const struct pll_div apll_l_1600_cfg = PLL_DIVISORS(1600 * MHz, 3, 1, 1); +@@ -681,7 +682,7 @@ static ulong rk3399_spi_set_clk(struct rockchip_cru *cru, ulong clk_id, uint hz) + static ulong rk3399_vop_set_clk(struct rockchip_cru *cru, ulong clk_id, u32 hz) + { + struct pll_div vpll_config = {0}; +- int aclk_vop = 198 * MHz; ++ int aclk_vop = 400 * MHz; + void *aclkreg_addr, *dclkreg_addr; + u32 div; + +@@ -1394,6 +1395,7 @@ static void rkclk_init(struct rockchip_cru *cru) + /* configure gpll cpll */ + rkclk_set_pll(&cru->gpll_con[0], &gpll_init_cfg); + rkclk_set_pll(&cru->cpll_con[0], &cpll_init_cfg); ++ rkclk_set_pll(&cru->npll_con[0], &npll_init_cfg); + + /* configure perihp aclk, hclk, pclk */ + aclk_div = GPLL_HZ / PERIHP_ACLK_HZ - 1; +-- +2.49.0 + diff --git a/config/module/u-boot/default/patches/0002-video-improve-UEFI-experience-on-DM_VIDEO.patch b/config/module/u-boot/default/patches/0002-video-improve-UEFI-experience-on-DM_VIDEO.patch new file mode 100644 index 00000000..e2de311c --- /dev/null +++ b/config/module/u-boot/default/patches/0002-video-improve-UEFI-experience-on-DM_VIDEO.patch @@ -0,0 +1,246 @@ +From 780d8ffe985441824a242e5b853721dfe14435dd Mon Sep 17 00:00:00 2001 +From: Andre Przywara <andre.przywara@arm.com> +Date: Mon, 10 Jan 2022 00:56:31 +0000 +Subject: [PATCH 1/3] video: Add cursor support for video consoles + +So far the video console is completely lacking any cursor, which makes +typing and correcting quite irritating. + +Add a simple cursor display by writing a SPACE glyph in the background +colour to the next character position on the screen. Any typed character +will naturally overwrite it, so we need to only explicitly clear it if +the next character will appear somewhere else (newline, backspace). + +Signed-off-by: Andre Przywara <andre.przywara@arm.com> +Reviewed-by: Simon Glass <sjg@chromium.org> +Tested-by: Simon Glass <sjg@chromium.org> +Link: https://lore.kernel.org/r/20220110005638.21599-2-andre.przywara@arm.com +[Alper: Rebase for console_set_font(), reword for CONFIG_VIDEO] +Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> +--- + drivers/video/console_core.c | 1 + + drivers/video/vidconsole-uclass.c | 42 +++++++++++++++++++++++++++++++ + include/video_console.h | 1 + + 3 files changed, 44 insertions(+) + +diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c +index 939363653f6c..6b531718276f 100644 +--- a/drivers/video/console_core.c ++++ b/drivers/video/console_core.c +@@ -30,6 +30,7 @@ static int console_set_font(struct udevice *dev, struct video_fontdata *fontdata + debug("height: %d\n", fontdata->height); + + priv->fontdata = fontdata; ++ vc_priv->cursor_visible = true; + vc_priv->x_charsize = fontdata->width; + vc_priv->y_charsize = fontdata->height; + if (vid_priv->rot % 2) { +diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c +index ebe96bf0c2f3..8613c464040f 100644 +--- a/drivers/video/vidconsole-uclass.c ++++ b/drivers/video/vidconsole-uclass.c +@@ -57,6 +57,26 @@ int vidconsole_entry_start(struct udevice *dev) + return ops->entry_start(dev); + } + ++static void draw_cursor(struct udevice *dev, bool state) ++{ ++ struct vidconsole_priv *priv = dev_get_uclass_priv(dev); ++ struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); ++ u32 tmp; ++ ++ if (!priv->cursor_visible) ++ return; ++ ++ if (state) { ++ tmp = vid_priv->colour_bg; ++ vid_priv->colour_bg = vid_priv->colour_fg; ++ } ++ ++ vidconsole_putc_xy(dev, priv->xcur_frac, priv->ycur, ' '); ++ ++ if (state) ++ vid_priv->colour_bg = tmp; ++} ++ + /* Move backwards one space */ + static int vidconsole_back(struct udevice *dev) + { +@@ -64,6 +84,8 @@ static int vidconsole_back(struct udevice *dev) + struct vidconsole_ops *ops = vidconsole_get_ops(dev); + int ret; + ++ draw_cursor(dev, false); ++ + if (ops->backspace) { + ret = ops->backspace(dev); + if (ret != -ENOSYS) +@@ -90,6 +112,8 @@ static void vidconsole_newline(struct udevice *dev) + const int rows = CONFIG_VAL(CONSOLE_SCROLL_LINES); + int i, ret; + ++ draw_cursor(dev, false); ++ + priv->xcur_frac = priv->xstart_frac; + priv->ycur += priv->y_charsize; + +@@ -286,6 +310,14 @@ static void vidconsole_escape_char(struct udevice *dev, char ch) + + break; + } ++ case 'l': ++ draw_cursor(dev, false); ++ priv->cursor_visible = 0; ++ break; ++ case 'h': ++ priv->cursor_visible = 1; ++ draw_cursor(dev, true); ++ break; + case 'J': { + int mode; + +@@ -460,6 +492,11 @@ int vidconsole_put_char(struct udevice *dev, char ch) + struct vidconsole_priv *priv = dev_get_uclass_priv(dev); + int cp, ret; + ++ /* ++ * We don't need to clear the cursor since we are going to overwrite ++ * that character anyway. ++ */ ++ + if (priv->escape) { + vidconsole_escape_char(dev, ch); + return 0; +@@ -474,6 +511,7 @@ int vidconsole_put_char(struct udevice *dev, char ch) + /* beep */ + break; + case '\r': ++ draw_cursor(dev, false); + priv->xcur_frac = priv->xstart_frac; + break; + case '\n': +@@ -481,6 +519,7 @@ int vidconsole_put_char(struct udevice *dev, char ch) + vidconsole_entry_start(dev); + break; + case '\t': /* Tab (8 chars alignment) */ ++ draw_cursor(dev, false); + priv->xcur_frac = ((priv->xcur_frac / priv->tab_width_frac) + + 1) * priv->tab_width_frac; + +@@ -505,6 +544,8 @@ int vidconsole_put_char(struct udevice *dev, char ch) + break; + } + ++ draw_cursor(dev, true); ++ + return 0; + } + +@@ -725,6 +766,7 @@ static int vidconsole_pre_probe(struct udevice *dev) + struct video_priv *vid_priv = dev_get_uclass_priv(vid); + + priv->xsize_frac = VID_TO_POS(vid_priv->xsize); ++ priv->cursor_visible = false; + + return 0; + } +diff --git a/include/video_console.h b/include/video_console.h +index 723d2315606d..17a9aa3f9295 100644 +--- a/include/video_console.h ++++ b/include/video_console.h +@@ -74,6 +74,7 @@ struct vidconsole_priv { + int escape_len; + int row_saved; + int col_saved; ++ bool cursor_visible; + char escape_buf[32]; + char utf8_buf[5]; + }; +-- +2.49.0 + + +From b2b921d7bc69b505562cf02d1b4c6f6d4325c7d5 Mon Sep 17 00:00:00 2001 +From: Andre Przywara <andre.przywara@arm.com> +Date: Mon, 10 Jan 2022 00:56:36 +0000 +Subject: [PATCH 2/3] efi-selftest: Add international characters test + +UEFI relies entirely on unicode output, which actual fonts displayed on +the screen might not be ready for. + +Add a test displaying some international characters, to reveal missing +glyphs, especially in our builtin fonts. +This would be needed to be manually checked on the screen for +correctness. + +Signed-off-by: Andre Przywara <andre.przywara@arm.com> +Link: https://lore.kernel.org/r/20220110005638.21599-7-andre.przywara@arm.com +--- + lib/efi_selftest/efi_selftest_textoutput.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/lib/efi_selftest/efi_selftest_textoutput.c b/lib/efi_selftest/efi_selftest_textoutput.c +index a3023c82567c..2f8d8d323c2b 100644 +--- a/lib/efi_selftest/efi_selftest_textoutput.c ++++ b/lib/efi_selftest/efi_selftest_textoutput.c +@@ -154,6 +154,11 @@ static int execute(void) + efi_st_printf("Unicode not handled properly\n"); + return EFI_ST_FAILURE; + } ++ ret = con_out->output_string(con_out, L"Österreich Edelweiß Smørrebrød Smörgås Niño René >Ἑλλάς<\n"); ++ if (ret != EFI_ST_SUCCESS) { ++ efi_st_error("OutputString failed for international chars\n"); ++ return EFI_ST_FAILURE; ++ } + efi_st_printf("\n"); + ret = con_out->output_string(con_out, text); + if (ret != EFI_ST_SUCCESS) { +-- +2.49.0 + + +From 082422499a5f2689e715df68bfd025a5cc15cc64 Mon Sep 17 00:00:00 2001 +From: Andre Przywara <andre.przywara@arm.com> +Date: Mon, 10 Jan 2022 00:56:37 +0000 +Subject: [PATCH 3/3] efi_selftest: Add box drawing character selftest + +UEFI applications rely on Unicode output capability, and might use that +for drawing pseudo-graphical interfaces using Unicode defined box +drawing characters. + +Add a simple test to display the most basic box characters, which would +need to be checked manually on the screen for correctness. +To facilitate this, add a three second delay after the output at this +point. + +Signed-off-by: Andre Przywara <andre.przywara@arm.com> +Link: https://lore.kernel.org/r/20220110005638.21599-8-andre.przywara@arm.com +--- + lib/efi_selftest/efi_selftest_textoutput.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/lib/efi_selftest/efi_selftest_textoutput.c b/lib/efi_selftest/efi_selftest_textoutput.c +index 2f8d8d323c2b..02209a5bf224 100644 +--- a/lib/efi_selftest/efi_selftest_textoutput.c ++++ b/lib/efi_selftest/efi_selftest_textoutput.c +@@ -159,6 +159,17 @@ static int execute(void) + efi_st_error("OutputString failed for international chars\n"); + return EFI_ST_FAILURE; + } ++ ret = con_out->output_string(con_out, L"┌─┬─┐\n"); ++ ret |= con_out->output_string(con_out, L"│ │ │\n"); ++ ret |= con_out->output_string(con_out, L"├─┼─┤\n"); ++ ret |= con_out->output_string(con_out, L"│ │ │\n"); ++ ret |= con_out->output_string(con_out, L"└─┴─┘\n"); ++ if (ret != EFI_ST_SUCCESS) { ++ efi_st_error("OutputString failed for box drawing chars\n"); ++ return EFI_ST_FAILURE; ++ } ++ con_out->output_string(con_out, L"waiting for admiration...\n"); ++ EFI_CALL(systab.boottime->stall(3000000)); + efi_st_printf("\n"); + ret = con_out->output_string(con_out, text); + if (ret != EFI_ST_SUCCESS) { +-- +2.49.0 + diff --git a/config/module/u-boot/default/patches/0003-Add-video-damage-tracking.patch b/config/module/u-boot/default/patches/0003-Add-video-damage-tracking.patch new file mode 100644 index 00000000..18c93ab8 --- /dev/null +++ b/config/module/u-boot/default/patches/0003-Add-video-damage-tracking.patch @@ -0,0 +1,2399 @@ +From dae1f9cafd3d2061336f5d230ebc1f236423fa0e Mon Sep 17 00:00:00 2001 +From: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Date: Fri, 18 Aug 2023 13:31:36 +0300 +Subject: [PATCH 01/13] video: test: Split copy frame buffer check into a + function + +While checking frame buffer contents, the video tests also check if the +copy frame buffer contents match the main frame buffer. To test if only +the modified regions are updated after a sync, we will need to create +situations where the two are mismatched. Split this check into another +function that we can skip calling, since we won't want it to error on +those mismatched cases. + +Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Reviewed-by: Simon Glass <sjg@chromium.org> +Link: https://lore.kernel.org/u-boot/20230821135111.3558478-2-alpernebiyasak@gmail.com/ +--- + test/dm/video.c | 69 +++++++++++++++++++++++++++++++++++++++++-------- + 1 file changed, 58 insertions(+), 11 deletions(-) + +diff --git a/test/dm/video.c b/test/dm/video.c +index e347c1403fda..01fa9e1b2415 100644 +--- a/test/dm/video.c ++++ b/test/dm/video.c +@@ -54,9 +54,6 @@ DM_TEST(dm_test_video_base, UTF_SCAN_PDATA | UTF_SCAN_FDT); + * size of the compressed data. This provides a pretty good level of + * certainty and the resulting tests need only check a single value. + * +- * If the copy framebuffer is enabled, this compares it to the main framebuffer +- * too. +- * + * @uts: Test state + * @dev: Video device + * Return: compressed size of the frame buffer, or -ve on error +@@ -65,7 +62,6 @@ static int compress_frame_buffer(struct unit_test_state *uts, + struct udevice *dev) + { + struct video_priv *priv = dev_get_uclass_priv(dev); +- struct video_priv *uc_priv = dev_get_uclass_priv(dev); + uint destlen; + void *dest; + int ret; +@@ -81,16 +77,34 @@ static int compress_frame_buffer(struct unit_test_state *uts, + if (ret) + return ret; + +- /* Check here that the copy frame buffer is working correctly */ +- if (IS_ENABLED(CONFIG_VIDEO_COPY)) { +- ut_assertf(!memcmp(uc_priv->fb, uc_priv->copy_fb, +- uc_priv->fb_size), +- "Copy framebuffer does not match fb"); +- } +- + return destlen; + } + ++/** ++ * check_copy_frame_buffer() - Compare main frame buffer to copy ++ * ++ * If the copy frame buffer is enabled, this compares it to the main ++ * frame buffer. Normally they should have the same contents after a ++ * sync. ++ * ++ * @uts: Test state ++ * @dev: Video device ++ * Return: 0, or -ve on error ++ */ ++static int check_copy_frame_buffer(struct unit_test_state *uts, ++ struct udevice *dev) ++{ ++ struct video_priv *priv = dev_get_uclass_priv(dev); ++ ++ if (!IS_ENABLED(CONFIG_VIDEO_COPY)) ++ return 0; ++ ++ ut_assertf(!memcmp(priv->fb, priv->copy_fb, priv->fb_size), ++ "Copy framebuffer does not match fb"); ++ ++ return 0; ++} ++ + /* + * Call this function at any point to halt and show the current display. Be + * sure to run the test with the -l flag. +@@ -154,24 +168,30 @@ static int dm_test_video_text(struct unit_test_state *uts) + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + ut_assertok(vidconsole_select_font(con, "8x16", 0)); + ut_asserteq(46, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + vidconsole_putc_xy(con, 0, 0, 'a'); + ut_asserteq(79, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + vidconsole_putc_xy(con, 0, 0, ' '); + ut_asserteq(46, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + for (i = 0; i < 20; i++) + vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i); + ut_asserteq(273, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + vidconsole_set_row(con, 0, WHITE); + ut_asserteq(46, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + for (i = 0; i < 20; i++) + vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i); + ut_asserteq(273, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; + } +@@ -190,24 +210,30 @@ static int dm_test_video_text_12x22(struct unit_test_state *uts) + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + ut_assertok(vidconsole_select_font(con, "12x22", 0)); + ut_asserteq(46, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + vidconsole_putc_xy(con, 0, 0, 'a'); + ut_asserteq(89, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + vidconsole_putc_xy(con, 0, 0, ' '); + ut_asserteq(46, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + for (i = 0; i < 20; i++) + vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i); + ut_asserteq(363, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + vidconsole_set_row(con, 0, WHITE); + ut_asserteq(46, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + for (i = 0; i < 20; i++) + vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i); + ut_asserteq(363, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; + } +@@ -225,6 +251,7 @@ static int dm_test_video_chars(struct unit_test_state *uts) + ut_assertok(vidconsole_select_font(con, "8x16", 0)); + vidconsole_put_string(con, test_string); + ut_asserteq(466, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; + } +@@ -246,19 +273,23 @@ static int dm_test_video_ansi(struct unit_test_state *uts) + video_clear(con->parent); + video_sync(con->parent, false); + ut_asserteq(46, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + /* test clear escape sequence: [2J */ + vidconsole_put_string(con, "A\tB\tC"ANSI_ESC"[2J"); + ut_asserteq(46, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + /* test set-cursor: [%d;%df */ + vidconsole_put_string(con, "abc"ANSI_ESC"[2;2fab"ANSI_ESC"[4;4fcd"); + ut_asserteq(143, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + /* test colors (30-37 fg color, 40-47 bg color) */ + vidconsole_put_string(con, ANSI_ESC"[30;41mfoo"); /* black on red */ + vidconsole_put_string(con, ANSI_ESC"[33;44mbar"); /* yellow on blue */ + ut_asserteq(272, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; + } +@@ -291,11 +322,13 @@ static int check_vidconsole_output(struct unit_test_state *uts, int rot, + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + ut_assertok(vidconsole_select_font(con, "8x16", 0)); + ut_asserteq(46, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + /* Check display wrap */ + for (i = 0; i < 120; i++) + vidconsole_put_char(con, 'A' + i % 50); + ut_asserteq(wrap_size, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + /* Check display scrolling */ + for (i = 0; i < SCROLL_LINES; i++) { +@@ -303,11 +336,13 @@ static int check_vidconsole_output(struct unit_test_state *uts, int rot, + vidconsole_put_char(con, '\n'); + } + ut_asserteq(scroll_size, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + /* If we scroll enough, the screen becomes blank again */ + for (i = 0; i < SCROLL_LINES; i++) + vidconsole_put_char(con, '\n'); + ut_asserteq(46, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; + } +@@ -382,6 +417,7 @@ static int dm_test_video_bmp(struct unit_test_state *uts) + + ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); + ut_asserteq(1368, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; + } +@@ -401,6 +437,7 @@ static int dm_test_video_bmp8(struct unit_test_state *uts) + + ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); + ut_asserteq(1247, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; + } +@@ -424,6 +461,7 @@ static int dm_test_video_bmp16(struct unit_test_state *uts) + + ut_assertok(video_bmp_display(dev, dst, 0, 0, false)); + ut_asserteq(3700, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; + } +@@ -447,6 +485,7 @@ static int dm_test_video_bmp24(struct unit_test_state *uts) + + ut_assertok(video_bmp_display(dev, dst, 0, 0, false)); + ut_asserteq(3656, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; + } +@@ -470,6 +509,7 @@ static int dm_test_video_bmp24_32(struct unit_test_state *uts) + + ut_assertok(video_bmp_display(dev, dst, 0, 0, false)); + ut_asserteq(6827, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; + } +@@ -488,6 +528,7 @@ static int dm_test_video_bmp32(struct unit_test_state *uts) + + ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); + ut_asserteq(2024, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; + } +@@ -504,6 +545,7 @@ static int dm_test_video_bmp_comp(struct unit_test_state *uts) + + ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); + ut_asserteq(1368, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; + } +@@ -523,6 +565,7 @@ static int dm_test_video_comp_bmp32(struct unit_test_state *uts) + + ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); + ut_asserteq(2024, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; + } +@@ -542,6 +585,7 @@ static int dm_test_video_comp_bmp8(struct unit_test_state *uts) + + ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); + ut_asserteq(1247, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; + } +@@ -557,6 +601,7 @@ static int dm_test_video_truetype(struct unit_test_state *uts) + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + vidconsole_put_string(con, test_string); + ut_asserteq(12174, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; + } +@@ -578,6 +623,7 @@ static int dm_test_video_truetype_scroll(struct unit_test_state *uts) + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + vidconsole_put_string(con, test_string); + ut_asserteq(34287, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; + } +@@ -599,6 +645,7 @@ static int dm_test_video_truetype_bs(struct unit_test_state *uts) + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + vidconsole_put_string(con, test_string); + ut_asserteq(29471, compress_frame_buffer(uts, dev)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; + } +-- +2.49.0 + + +From 3c4f71fb10a827db53d6ed637e39afb5cc19a871 Mon Sep 17 00:00:00 2001 +From: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Date: Sun, 20 Aug 2023 17:46:46 +0300 +Subject: [PATCH 02/13] video: test: Support checking copy frame buffer + contents + +The video tests have a helper function to generate a pseudo-digest of +frame buffer contents, but it only does so for the main one. There is +another check that the copy frame buffer is the same as that. But +neither is enough to test if only the modified regions are copied to the +copy frame buffer, since we will want the two to be different in very +specific ways. + +Add a boolean argument to the existing helper function to indicate which +frame buffer we want to inspect, and update the existing callers. + +Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Reviewed-by: Simon Glass <sjg@chromium.org> +Link: https://lore.kernel.org/u-boot/20230821135111.3558478-3-alpernebiyasak@gmail.com/ +--- + test/dm/video.c | 76 ++++++++++++++++++++++++++----------------------- + 1 file changed, 41 insertions(+), 35 deletions(-) + +diff --git a/test/dm/video.c b/test/dm/video.c +index 01fa9e1b2415..edb1b4ede8c9 100644 +--- a/test/dm/video.c ++++ b/test/dm/video.c +@@ -56,22 +56,28 @@ DM_TEST(dm_test_video_base, UTF_SCAN_PDATA | UTF_SCAN_FDT); + * + * @uts: Test state + * @dev: Video device ++ * @use_copy: Use copy frame buffer if available + * Return: compressed size of the frame buffer, or -ve on error + */ + static int compress_frame_buffer(struct unit_test_state *uts, +- struct udevice *dev) ++ struct udevice *dev, ++ bool use_copy) + { + struct video_priv *priv = dev_get_uclass_priv(dev); + uint destlen; + void *dest; + int ret; + ++ if (!IS_ENABLED(CONFIG_VIDEO_COPY)) ++ use_copy = false; ++ + destlen = priv->fb_size; + dest = malloc(priv->fb_size); + if (!dest) + return -ENOMEM; + ret = BZ2_bzBuffToBuffCompress(dest, &destlen, +- priv->fb, priv->fb_size, ++ use_copy ? priv->copy_fb : priv->fb, ++ priv->fb_size, + 3, 0, 0); + free(dest); + if (ret) +@@ -167,30 +173,30 @@ static int dm_test_video_text(struct unit_test_state *uts) + ut_assertok(video_get_nologo(uts, &dev)); + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + ut_assertok(vidconsole_select_font(con, "8x16", 0)); +- ut_asserteq(46, compress_frame_buffer(uts, dev)); ++ ut_asserteq(46, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + vidconsole_putc_xy(con, 0, 0, 'a'); +- ut_asserteq(79, compress_frame_buffer(uts, dev)); ++ ut_asserteq(79, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + vidconsole_putc_xy(con, 0, 0, ' '); +- ut_asserteq(46, compress_frame_buffer(uts, dev)); ++ ut_asserteq(46, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + for (i = 0; i < 20; i++) + vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i); +- ut_asserteq(273, compress_frame_buffer(uts, dev)); ++ ut_asserteq(273, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + vidconsole_set_row(con, 0, WHITE); +- ut_asserteq(46, compress_frame_buffer(uts, dev)); ++ ut_asserteq(46, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + for (i = 0; i < 20; i++) + vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i); +- ut_asserteq(273, compress_frame_buffer(uts, dev)); ++ ut_asserteq(273, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; +@@ -209,30 +215,30 @@ static int dm_test_video_text_12x22(struct unit_test_state *uts) + ut_assertok(video_get_nologo(uts, &dev)); + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + ut_assertok(vidconsole_select_font(con, "12x22", 0)); +- ut_asserteq(46, compress_frame_buffer(uts, dev)); ++ ut_asserteq(46, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + vidconsole_putc_xy(con, 0, 0, 'a'); +- ut_asserteq(89, compress_frame_buffer(uts, dev)); ++ ut_asserteq(89, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + vidconsole_putc_xy(con, 0, 0, ' '); +- ut_asserteq(46, compress_frame_buffer(uts, dev)); ++ ut_asserteq(46, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + for (i = 0; i < 20; i++) + vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i); +- ut_asserteq(363, compress_frame_buffer(uts, dev)); ++ ut_asserteq(363, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + vidconsole_set_row(con, 0, WHITE); +- ut_asserteq(46, compress_frame_buffer(uts, dev)); ++ ut_asserteq(46, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + for (i = 0; i < 20; i++) + vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i); +- ut_asserteq(363, compress_frame_buffer(uts, dev)); ++ ut_asserteq(363, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; +@@ -250,7 +256,7 @@ static int dm_test_video_chars(struct unit_test_state *uts) + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + ut_assertok(vidconsole_select_font(con, "8x16", 0)); + vidconsole_put_string(con, test_string); +- ut_asserteq(466, compress_frame_buffer(uts, dev)); ++ ut_asserteq(466, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; +@@ -272,23 +278,23 @@ static int dm_test_video_ansi(struct unit_test_state *uts) + /* reference clear: */ + video_clear(con->parent); + video_sync(con->parent, false); +- ut_asserteq(46, compress_frame_buffer(uts, dev)); ++ ut_asserteq(46, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + /* test clear escape sequence: [2J */ + vidconsole_put_string(con, "A\tB\tC"ANSI_ESC"[2J"); +- ut_asserteq(46, compress_frame_buffer(uts, dev)); ++ ut_asserteq(46, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + /* test set-cursor: [%d;%df */ + vidconsole_put_string(con, "abc"ANSI_ESC"[2;2fab"ANSI_ESC"[4;4fcd"); +- ut_asserteq(143, compress_frame_buffer(uts, dev)); ++ ut_asserteq(143, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + /* test colors (30-37 fg color, 40-47 bg color) */ + vidconsole_put_string(con, ANSI_ESC"[30;41mfoo"); /* black on red */ + vidconsole_put_string(con, ANSI_ESC"[33;44mbar"); /* yellow on blue */ +- ut_asserteq(272, compress_frame_buffer(uts, dev)); ++ ut_asserteq(272, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; +@@ -321,13 +327,13 @@ static int check_vidconsole_output(struct unit_test_state *uts, int rot, + ut_assertok(video_get_nologo(uts, &dev)); + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + ut_assertok(vidconsole_select_font(con, "8x16", 0)); +- ut_asserteq(46, compress_frame_buffer(uts, dev)); ++ ut_asserteq(46, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + /* Check display wrap */ + for (i = 0; i < 120; i++) + vidconsole_put_char(con, 'A' + i % 50); +- ut_asserteq(wrap_size, compress_frame_buffer(uts, dev)); ++ ut_asserteq(wrap_size, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + /* Check display scrolling */ +@@ -335,13 +341,13 @@ static int check_vidconsole_output(struct unit_test_state *uts, int rot, + vidconsole_put_char(con, 'A' + i % 50); + vidconsole_put_char(con, '\n'); + } +- ut_asserteq(scroll_size, compress_frame_buffer(uts, dev)); ++ ut_asserteq(scroll_size, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + /* If we scroll enough, the screen becomes blank again */ + for (i = 0; i < SCROLL_LINES; i++) + vidconsole_put_char(con, '\n'); +- ut_asserteq(46, compress_frame_buffer(uts, dev)); ++ ut_asserteq(46, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; +@@ -416,7 +422,7 @@ static int dm_test_video_bmp(struct unit_test_state *uts) + ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr)); + + ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); +- ut_asserteq(1368, compress_frame_buffer(uts, dev)); ++ ut_asserteq(1368, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; +@@ -436,7 +442,7 @@ static int dm_test_video_bmp8(struct unit_test_state *uts) + ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr)); + + ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); +- ut_asserteq(1247, compress_frame_buffer(uts, dev)); ++ ut_asserteq(1247, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; +@@ -460,7 +466,7 @@ static int dm_test_video_bmp16(struct unit_test_state *uts) + &src_len)); + + ut_assertok(video_bmp_display(dev, dst, 0, 0, false)); +- ut_asserteq(3700, compress_frame_buffer(uts, dev)); ++ ut_asserteq(3700, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; +@@ -484,7 +490,7 @@ static int dm_test_video_bmp24(struct unit_test_state *uts) + &src_len)); + + ut_assertok(video_bmp_display(dev, dst, 0, 0, false)); +- ut_asserteq(3656, compress_frame_buffer(uts, dev)); ++ ut_asserteq(3656, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; +@@ -508,7 +514,7 @@ static int dm_test_video_bmp24_32(struct unit_test_state *uts) + &src_len)); + + ut_assertok(video_bmp_display(dev, dst, 0, 0, false)); +- ut_asserteq(6827, compress_frame_buffer(uts, dev)); ++ ut_asserteq(6827, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; +@@ -527,7 +533,7 @@ static int dm_test_video_bmp32(struct unit_test_state *uts) + ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr)); + + ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); +- ut_asserteq(2024, compress_frame_buffer(uts, dev)); ++ ut_asserteq(2024, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; +@@ -544,7 +550,7 @@ static int dm_test_video_bmp_comp(struct unit_test_state *uts) + ut_assertok(read_file(uts, "tools/logos/denx-comp.bmp", &addr)); + + ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); +- ut_asserteq(1368, compress_frame_buffer(uts, dev)); ++ ut_asserteq(1368, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; +@@ -564,7 +570,7 @@ static int dm_test_video_comp_bmp32(struct unit_test_state *uts) + ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr)); + + ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); +- ut_asserteq(2024, compress_frame_buffer(uts, dev)); ++ ut_asserteq(2024, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; +@@ -584,7 +590,7 @@ static int dm_test_video_comp_bmp8(struct unit_test_state *uts) + ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr)); + + ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); +- ut_asserteq(1247, compress_frame_buffer(uts, dev)); ++ ut_asserteq(1247, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; +@@ -600,7 +606,7 @@ static int dm_test_video_truetype(struct unit_test_state *uts) + ut_assertok(video_get_nologo(uts, &dev)); + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + vidconsole_put_string(con, test_string); +- ut_asserteq(12174, compress_frame_buffer(uts, dev)); ++ ut_asserteq(12174, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; +@@ -622,7 +628,7 @@ static int dm_test_video_truetype_scroll(struct unit_test_state *uts) + ut_assertok(video_get_nologo(uts, &dev)); + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + vidconsole_put_string(con, test_string); +- ut_asserteq(34287, compress_frame_buffer(uts, dev)); ++ ut_asserteq(34287, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; +@@ -644,7 +650,7 @@ static int dm_test_video_truetype_bs(struct unit_test_state *uts) + ut_assertok(video_get_nologo(uts, &dev)); + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + vidconsole_put_string(con, test_string); +- ut_asserteq(29471, compress_frame_buffer(uts, dev)); ++ ut_asserteq(29471, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + return 0; +-- +2.49.0 + + +From ecd9200f2068ab8bbeda5c7b8ddc4b8d7ca6b038 Mon Sep 17 00:00:00 2001 +From: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Date: Fri, 18 Aug 2023 17:31:27 +0300 +Subject: [PATCH 03/13] video: test: Test partial updates of hardware frame + buffer + +With VIDEO_COPY enabled, only the modified parts of the frame buffer are +intended to be copied to the hardware. Add a test that checks this, by +overwriting contents we prepared without telling the video uclass and +then checking if the overwritten contents have been redrawn on the next +sync. + +Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Reviewed-by: Simon Glass <sjg@chromium.org> +Link: https://lore.kernel.org/u-boot/20230821135111.3558478-4-alpernebiyasak@gmail.com/ +--- + test/dm/video.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 54 insertions(+) + +diff --git a/test/dm/video.c b/test/dm/video.c +index edb1b4ede8c9..80e65d66dbaf 100644 +--- a/test/dm/video.c ++++ b/test/dm/video.c +@@ -656,3 +656,57 @@ static int dm_test_video_truetype_bs(struct unit_test_state *uts) + return 0; + } + DM_TEST(dm_test_video_truetype_bs, UTF_SCAN_PDATA | UTF_SCAN_FDT); ++ ++/* Test partial rendering onto hardware frame buffer */ ++static int dm_test_video_copy(struct unit_test_state *uts) ++{ ++ struct sandbox_sdl_plat *plat; ++ struct video_uc_plat *uc_plat; ++ struct udevice *dev, *con; ++ struct video_priv *priv; ++ const char *test_string = "\n\tCriticism may not be agreeable, but it is necessary.\t"; ++ ulong addr; ++ ++ if (!IS_ENABLED(CONFIG_VIDEO_COPY)) ++ return -EAGAIN; ++ ++ ut_assertok(uclass_find_first_device(UCLASS_VIDEO, &dev)); ++ ut_assertnonnull(dev); ++ uc_plat = dev_get_uclass_plat(dev); ++ uc_plat->hide_logo = true; ++ plat = dev_get_plat(dev); ++ plat->font_size = 32; ++ ut_assert(!device_active(dev)); ++ ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev)); ++ ut_assertnonnull(dev); ++ priv = dev_get_uclass_priv(dev); ++ ++ ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr)); ++ ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); ++ ++ ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); ++ vidconsole_put_string(con, "\n\n\n\n\n"); ++ vidconsole_put_string(con, test_string); ++ vidconsole_put_string(con, test_string); ++ ++ ut_asserteq(6678, compress_frame_buffer(uts, dev, false)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); ++ ++ /* ++ * Secretly clear the hardware frame buffer, but in a different ++ * color (black) to see which parts will be overwritten. ++ */ ++ memset(priv->copy_fb, 0, priv->fb_size); ++ ++ /* ++ * We should have the full content on the main buffer, but only ++ * the new content should have been copied to the copy buffer. ++ */ ++ vidconsole_put_string(con, test_string); ++ vidconsole_put_string(con, test_string); ++ ut_asserteq(7589, compress_frame_buffer(uts, dev, false)); ++ ut_asserteq(5278, compress_frame_buffer(uts, dev, true)); ++ ++ return 0; ++} ++DM_TEST(dm_test_video_copy, UTF_SCAN_PDATA | UTF_SCAN_FDT); +-- +2.49.0 + + +From 6ecfb63749d955fc28e6312583865c902ffb1175 Mon Sep 17 00:00:00 2001 +From: Alexander Graf <agraf@csgraf.de> +Date: Fri, 10 Jun 2022 00:59:15 +0200 +Subject: [PATCH 04/13] dm: video: Add damage tracking API + +We are going to introduce image damage tracking to fasten up screen +refresh on large displays. This patch adds damage tracking for up to +one rectangle of the screen which is typically enough to hold blt or +text print updates. Callers into this API and a reduced dcache flush +code path will follow in later patches. + +Signed-off-by: Alexander Graf <agraf@csgraf.de> +Reported-by: Da Xue <da@libre.computer> +[Alper: Use xstart/yend, document new fields, return void from + video_damage(), declare priv, drop headers, use IS_ENABLED()] +Co-developed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Link: https://lore.kernel.org/u-boot/20230821135111.3558478-5-alpernebiyasak@gmail.com/ +Reviewed-by: Simon Glass <sjg@chromium.org> +--- + drivers/video/Kconfig | 13 ++++++++++++ + drivers/video/video-uclass.c | 35 +++++++++++++++++++++++++++++++ + include/video.h | 40 ++++++++++++++++++++++++++++++++++-- + 3 files changed, 86 insertions(+), 2 deletions(-) + +diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig +index 3c3cebaacd02..5d67067891be 100644 +--- a/drivers/video/Kconfig ++++ b/drivers/video/Kconfig +@@ -98,6 +98,19 @@ config VIDEO_COPY + To use this, your video driver must set @copy_base in + struct video_uc_plat. + ++config VIDEO_DAMAGE ++ bool "Enable damage tracking of frame buffer regions" ++ help ++ On some machines (most ARM), the display frame buffer resides in ++ RAM. To make the display controller pick up screen updates, we ++ have to flush frame buffer contents from CPU caches into RAM which ++ can be a slow operation. ++ ++ This feature adds damage tracking to collect information about regions ++ that received updates. When we want to sync, we then only flush ++ regions of the frame buffer that were modified before, speeding up ++ screen refreshes significantly. ++ + config BACKLIGHT_PWM + bool "Generic PWM based Backlight Driver" + depends on BACKLIGHT && DM_PWM +diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c +index ff4f21995859..da035e5c92b7 100644 +--- a/drivers/video/video-uclass.c ++++ b/drivers/video/video-uclass.c +@@ -367,6 +367,34 @@ void video_set_default_colors(struct udevice *dev, bool invert) + priv->colour_bg = video_index_to_colour(priv, back); + } + ++/* Notify about changes in the frame buffer */ ++#ifdef CONFIG_VIDEO_DAMAGE ++void video_damage(struct udevice *vid, int x, int y, int width, int height) ++{ ++ struct video_priv *priv = dev_get_uclass_priv(vid); ++ int xend = x + width; ++ int yend = y + height; ++ ++ if (x > priv->xsize) ++ return; ++ ++ if (y > priv->ysize) ++ return; ++ ++ if (xend > priv->xsize) ++ xend = priv->xsize; ++ ++ if (yend > priv->ysize) ++ yend = priv->ysize; ++ ++ /* Span a rectangle across all old and new damage */ ++ priv->damage.xstart = min(x, priv->damage.xstart); ++ priv->damage.ystart = min(y, priv->damage.ystart); ++ priv->damage.xend = max(xend, priv->damage.xend); ++ priv->damage.yend = max(yend, priv->damage.yend); ++} ++#endif ++ + /* Flush video activity to the caches */ + int video_sync(struct udevice *vid, bool force) + { +@@ -400,6 +428,13 @@ int video_sync(struct udevice *vid, bool force) + #endif + priv->last_sync = get_timer(0); + ++ if (IS_ENABLED(CONFIG_VIDEO_DAMAGE)) { ++ priv->damage.xstart = priv->xsize; ++ priv->damage.ystart = priv->ysize; ++ priv->damage.xend = 0; ++ priv->damage.yend = 0; ++ } ++ + return 0; + } + +diff --git a/include/video.h b/include/video.h +index a1f7fd7e839c..7eed112e00c4 100644 +--- a/include/video.h ++++ b/include/video.h +@@ -85,6 +85,11 @@ enum video_format { + * @fb_size: Frame buffer size + * @copy_fb: Copy of the frame buffer to keep up to date; see struct + * video_uc_plat ++ * @damage: A bounding box of framebuffer regions updated since last sync ++ * @damage.xstart: X start position in pixels from the left ++ * @damage.ystart: Y start position in pixels from the top ++ * @damage.xend: X end position in pixels from the left ++ * @damage.xend: Y end position in pixels from the top + * @line_length: Length of each frame buffer line, in bytes. This can be + * set by the driver, but if not, the uclass will set it after + * probing +@@ -113,6 +118,12 @@ struct video_priv { + void *fb; + int fb_size; + void *copy_fb; ++ struct { ++ int xstart; ++ int ystart; ++ int xend; ++ int yend; ++ } damage; + int line_length; + u32 colour_fg; + u32 colour_bg; +@@ -259,8 +270,9 @@ int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend, + * @return: 0 on success, error code otherwise + * + * Some frame buffers are cached or have a secondary frame buffer. This +- * function syncs these up so that the current contents of the U-Boot frame +- * buffer are displayed to the user. ++ * function syncs the damaged parts of them up so that the current contents ++ * of the U-Boot frame buffer are displayed to the user. It clears the damage ++ * buffer. + */ + int video_sync(struct udevice *vid, bool force); + +@@ -380,6 +392,30 @@ static inline int video_sync_copy_all(struct udevice *dev) + + #endif + ++#ifdef CONFIG_VIDEO_DAMAGE ++/** ++ * video_damage() - Notify the video subsystem about screen updates. ++ * ++ * @vid: Device to sync ++ * @x: Upper left X coordinate of the damaged rectangle ++ * @y: Upper left Y coordinate of the damaged rectangle ++ * @width: Width of the damaged rectangle ++ * @height: Height of the damaged rectangle ++ * ++ * Some frame buffers are cached or have a secondary frame buffer. This ++ * function notifies the video subsystem about rectangles that were updated ++ * within the frame buffer. They may only get written to the screen on the ++ * next call to video_sync(). ++ */ ++void video_damage(struct udevice *vid, int x, int y, int width, int height); ++#else ++static inline void video_damage(struct udevice *vid, int x, int y, int width, ++ int height) ++{ ++ return; ++} ++#endif /* CONFIG_VIDEO_DAMAGE */ ++ + /** + * video_is_active() - Test if one video device it active + * +-- +2.49.0 + + +From c23d99983901910dadf43f2b4d0b833a0a6d6c92 Mon Sep 17 00:00:00 2001 +From: Alexander Graf <agraf@csgraf.de> +Date: Fri, 10 Jun 2022 00:59:16 +0200 +Subject: [PATCH 05/13] dm: video: Add damage notification on display fills + +Let's report the video damage when we fill parts of the screen. This +way we can later lazily flush only relevant regions to hardware. + +Signed-off-by: Alexander Graf <agraf@csgraf.de> +Reported-by: Da Xue <da@libre.computer> +[Alper: Move from video_clear() to video_fill(), video_fill_part()] +Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Reviewed-by: Simon Glass <sjg@chromium.org> +Link: https://lore.kernel.org/u-boot/20230821135111.3558478-6-alpernebiyasak@gmail.com/ +--- + drivers/video/video-uclass.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c +index da035e5c92b7..1c07613539f2 100644 +--- a/drivers/video/video-uclass.c ++++ b/drivers/video/video-uclass.c +@@ -214,6 +214,8 @@ int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend, + if (ret) + return ret; + ++ video_damage(dev, xstart, ystart, xend - xstart, yend - ystart); ++ + return 0; + } + +@@ -262,6 +264,8 @@ int video_fill(struct udevice *dev, u32 colour) + if (ret) + return ret; + ++ video_damage(dev, 0, 0, priv->xsize, priv->ysize); ++ + return video_sync(dev, false); + } + +-- +2.49.0 + + +From bc55519e74270926ee3680002c58fdeb21cd41ce Mon Sep 17 00:00:00 2001 +From: Alexander Graf <agraf@csgraf.de> +Date: Fri, 10 Jun 2022 00:59:17 +0200 +Subject: [PATCH 06/13] vidconsole: Add damage notifications to all vidconsole + drivers + +Now that we have a damage tracking API, let's populate damage done by +vidconsole drivers. We try to declare as little memory as damaged as +possible. + +Signed-off-by: Alexander Graf <agraf@csgraf.de> +Reported-by: Da Xue <da@libre.computer> +[Alper: Rebase for met->baseline, fontdata->height/width, make rotated + console_putc_xy() damages pass tests, edit patch message] +Co-developed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Link: https://lore.kernel.org/u-boot/20230821135111.3558478-7-alpernebiyasak@gmail.com/ +--- + drivers/video/console_normal.c | 18 +++++++++++ + drivers/video/console_rotate.c | 54 ++++++++++++++++++++++++++++++++ + drivers/video/console_truetype.c | 21 +++++++++++++ + 3 files changed, 93 insertions(+) + +diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c +index 6f4194a18147..51ac8cc78e9d 100644 +--- a/drivers/video/console_normal.c ++++ b/drivers/video/console_normal.c +@@ -39,6 +39,12 @@ static int console_set_row(struct udevice *dev, uint row, int clr) + if (ret) + return ret; + ++ video_damage(dev->parent, ++ 0, ++ fontdata->height * row, ++ vid_priv->xsize, ++ fontdata->height); ++ + return 0; + } + +@@ -60,6 +66,12 @@ static int console_move_rows(struct udevice *dev, uint rowdst, + if (ret) + return ret; + ++ video_damage(dev->parent, ++ 0, ++ fontdata->height * rowdst, ++ vid_priv->xsize, ++ fontdata->height * count); ++ + return 0; + } + +@@ -91,6 +103,12 @@ static int console_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp) + if (ret) + return ret; + ++ video_damage(dev->parent, ++ x, ++ y, ++ fontdata->width, ++ fontdata->height); ++ + ret = vidconsole_sync_copy(dev, start, line); + if (ret) + return ret; +diff --git a/drivers/video/console_rotate.c b/drivers/video/console_rotate.c +index a3f8c6352f83..f11dc3a0b075 100644 +--- a/drivers/video/console_rotate.c ++++ b/drivers/video/console_rotate.c +@@ -36,6 +36,12 @@ static int console_set_row_1(struct udevice *dev, uint row, int clr) + if (ret) + return ret; + ++ video_damage(dev->parent, ++ vid_priv->xsize - ((row + 1) * fontdata->height), ++ 0, ++ fontdata->height, ++ vid_priv->ysize); ++ + return 0; + } + +@@ -64,6 +70,12 @@ static int console_move_rows_1(struct udevice *dev, uint rowdst, uint rowsrc, + dst += vid_priv->line_length; + } + ++ video_damage(dev->parent, ++ vid_priv->xsize - ((rowdst + count) * fontdata->height), ++ 0, ++ count * fontdata->height, ++ vid_priv->ysize); ++ + return 0; + } + +@@ -97,6 +109,12 @@ static int console_putc_xy_1(struct udevice *dev, uint x_frac, uint y, int cp) + if (ret) + return ret; + ++ video_damage(dev->parent, ++ vid_priv->xsize - y - fontdata->height, ++ linenum - 1, ++ fontdata->height, ++ fontdata->width); ++ + return VID_TO_POS(fontdata->width); + } + +@@ -121,6 +139,12 @@ static int console_set_row_2(struct udevice *dev, uint row, int clr) + if (ret) + return ret; + ++ video_damage(dev->parent, ++ 0, ++ vid_priv->ysize - (row + 1) * fontdata->height, ++ vid_priv->xsize, ++ fontdata->height); ++ + return 0; + } + +@@ -142,6 +166,12 @@ static int console_move_rows_2(struct udevice *dev, uint rowdst, uint rowsrc, + vidconsole_memmove(dev, dst, src, + fontdata->height * vid_priv->line_length * count); + ++ video_damage(dev->parent, ++ 0, ++ vid_priv->ysize - (rowdst + count) * fontdata->height, ++ vid_priv->xsize, ++ count * fontdata->height); ++ + return 0; + } + +@@ -175,6 +205,12 @@ static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, int cp) + if (ret) + return ret; + ++ video_damage(dev->parent, ++ x - fontdata->width + 1, ++ linenum - fontdata->height + 1, ++ fontdata->width, ++ fontdata->height); ++ + return VID_TO_POS(fontdata->width); + } + +@@ -199,6 +235,12 @@ static int console_set_row_3(struct udevice *dev, uint row, int clr) + if (ret) + return ret; + ++ video_damage(dev->parent, ++ row * fontdata->height, ++ 0, ++ fontdata->height, ++ vid_priv->ysize); ++ + return 0; + } + +@@ -225,6 +267,12 @@ static int console_move_rows_3(struct udevice *dev, uint rowdst, uint rowsrc, + dst += vid_priv->line_length; + } + ++ video_damage(dev->parent, ++ rowdst * fontdata->height, ++ 0, ++ count * fontdata->height, ++ vid_priv->ysize); ++ + return 0; + } + +@@ -257,6 +305,12 @@ static int console_putc_xy_3(struct udevice *dev, uint x_frac, uint y, int cp) + if (ret) + return ret; + ++ video_damage(dev->parent, ++ y, ++ linenum - fontdata->width + 1, ++ fontdata->height, ++ fontdata->width); ++ + return VID_TO_POS(fontdata->width); + } + +diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c +index 17a29817664f..073ddcfb6950 100644 +--- a/drivers/video/console_truetype.c ++++ b/drivers/video/console_truetype.c +@@ -190,6 +190,7 @@ struct console_tt_store { + static int console_truetype_set_row(struct udevice *dev, uint row, int clr) + { + struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); ++ struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); + struct console_tt_priv *priv = dev_get_priv(dev); + struct console_tt_metrics *met = priv->cur_met; + void *end, *line; +@@ -233,6 +234,12 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr) + if (ret) + return ret; + ++ video_damage(dev->parent, ++ 0, ++ vc_priv->y_charsize * row, ++ vid_priv->xsize, ++ vc_priv->y_charsize); ++ + return 0; + } + +@@ -240,6 +247,7 @@ static int console_truetype_move_rows(struct udevice *dev, uint rowdst, + uint rowsrc, uint count) + { + struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); ++ struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); + struct console_tt_priv *priv = dev_get_priv(dev); + struct console_tt_metrics *met = priv->cur_met; + void *dst; +@@ -258,6 +266,12 @@ static int console_truetype_move_rows(struct udevice *dev, uint rowdst, + for (i = 0; i < priv->pos_ptr; i++) + priv->pos[i].ypos -= diff; + ++ video_damage(dev->parent, ++ 0, ++ vc_priv->y_charsize * rowdst, ++ vid_priv->xsize, ++ vc_priv->y_charsize * count); ++ + return 0; + } + +@@ -418,6 +432,13 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y, + + line += vid_priv->line_length; + } ++ ++ video_damage(dev->parent, ++ VID_TO_PIXEL(x) + xoff, ++ y + met->baseline + yoff, ++ width, ++ height); ++ + ret = vidconsole_sync_copy(dev, start, line); + if (ret) + return ret; +-- +2.49.0 + + +From e759e3ab52f4373d4f2487d857118b3f0b5998b2 Mon Sep 17 00:00:00 2001 +From: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Date: Fri, 18 Aug 2023 17:55:08 +0300 +Subject: [PATCH 07/13] video: test: Test video damage tracking via vidconsole + +With VIDEO_DAMAGE, the video uclass tracks updated regions of the frame +buffer in order to avoid unnecessary work during a video sync. Enable +the config in sandbox and add a test for it, by printing strings at a +few locations and checking the tracked region. + +Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Reviewed-by: Simon Glass <sjg@chromium.org> +Link: https://lore.kernel.org/u-boot/20230821135111.3558478-8-alpernebiyasak@gmail.com/ +--- + configs/sandbox_defconfig | 1 + + test/dm/video.c | 56 +++++++++++++++++++++++++++++++++++++++ + 2 files changed, 57 insertions(+) + +diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig +index 861a1f4cd90e..8bf36ff325d8 100644 +--- a/configs/sandbox_defconfig ++++ b/configs/sandbox_defconfig +@@ -328,6 +328,7 @@ CONFIG_USB_ETH_CDC=y + CONFIG_VIDEO=y + CONFIG_VIDEO_FONT_SUN12X22=y + CONFIG_VIDEO_COPY=y ++CONFIG_VIDEO_DAMAGE=y + CONFIG_CONSOLE_ROTATION=y + CONFIG_CONSOLE_TRUETYPE=y + CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y +diff --git a/test/dm/video.c b/test/dm/video.c +index 80e65d66dbaf..e76fa986d359 100644 +--- a/test/dm/video.c ++++ b/test/dm/video.c +@@ -710,3 +710,59 @@ static int dm_test_video_copy(struct unit_test_state *uts) + return 0; + } + DM_TEST(dm_test_video_copy, UTF_SCAN_PDATA | UTF_SCAN_FDT); ++ ++/* Test video damage tracking */ ++static int dm_test_video_damage(struct unit_test_state *uts) ++{ ++ struct sandbox_sdl_plat *plat; ++ struct udevice *dev, *con; ++ struct video_priv *priv; ++ const char *test_string_1 = "Criticism may not be agreeable, "; ++ const char *test_string_2 = "but it is necessary."; ++ const char *test_string_3 = "It fulfils the same function as pain in the human body."; ++ ++ if (!IS_ENABLED(CONFIG_VIDEO_DAMAGE)) ++ return -EAGAIN; ++ ++ ut_assertok(uclass_find_device(UCLASS_VIDEO, 0, &dev)); ++ ut_assert(!device_active(dev)); ++ plat = dev_get_plat(dev); ++ plat->font_size = 32; ++ ++ ut_assertok(video_get_nologo(uts, &dev)); ++ ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); ++ priv = dev_get_uclass_priv(dev); ++ ++ vidconsole_position_cursor(con, 14, 10); ++ vidconsole_put_string(con, test_string_2); ++ ut_asserteq(449, priv->damage.xstart); ++ ut_asserteq(325, priv->damage.ystart); ++ ut_asserteq(661, priv->damage.xend); ++ ut_asserteq(350, priv->damage.yend); ++ ++ vidconsole_position_cursor(con, 7, 5); ++ vidconsole_put_string(con, test_string_1); ++ ut_asserteq(225, priv->damage.xstart); ++ ut_asserteq(164, priv->damage.ystart); ++ ut_asserteq(661, priv->damage.xend); ++ ut_asserteq(350, priv->damage.yend); ++ ++ vidconsole_position_cursor(con, 21, 15); ++ vidconsole_put_string(con, test_string_3); ++ ut_asserteq(225, priv->damage.xstart); ++ ut_asserteq(164, priv->damage.ystart); ++ ut_asserteq(1280, priv->damage.xend); ++ ut_asserteq(510, priv->damage.yend); ++ ++ video_sync(dev, false); ++ ut_asserteq(priv->xsize, priv->damage.xstart); ++ ut_asserteq(priv->ysize, priv->damage.ystart); ++ ut_asserteq(0, priv->damage.xend); ++ ut_asserteq(0, priv->damage.yend); ++ ++ ut_asserteq(7339, compress_frame_buffer(uts, dev, false)); ++ ut_assertok(check_copy_frame_buffer(uts, dev)); ++ ++ return 0; ++} ++DM_TEST(dm_test_video_damage, UTF_SCAN_PDATA | UTF_SCAN_FDT); +-- +2.49.0 + + +From aa9d791d839b1004809b4a6cba38cd0bfd3dafa9 Mon Sep 17 00:00:00 2001 +From: Alexander Graf <agraf@csgraf.de> +Date: Fri, 10 Jun 2022 00:59:18 +0200 +Subject: [PATCH 08/13] video: Add damage notification on bmp display + +Let's report the video damage when we draw a bitmap on the screen. This +way we can later lazily flush only relevant regions to hardware. + +Signed-off-by: Alexander Graf <agraf@csgraf.de> +Reported-by: Da Xue <da@libre.computer> +Reviewed-by: Simon Glass <sjg@chromium.org> +Link: https://lore.kernel.org/u-boot/20230821135111.3558478-9-alpernebiyasak@gmail.com/ +--- + drivers/video/video_bmp.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c +index ad512d99a1b9..78de95607924 100644 +--- a/drivers/video/video_bmp.c ++++ b/drivers/video/video_bmp.c +@@ -459,6 +459,8 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, + break; + }; + ++ video_damage(dev, x, y, width, height); ++ + /* Find the position of the top left of the image in the framebuffer */ + fb = (uchar *)(priv->fb + y * priv->line_length + x * bpix / 8); + ret = video_sync_copy(dev, start, fb); +-- +2.49.0 + + +From 68262daa712e3202149aa0249bcff233234b6dfa Mon Sep 17 00:00:00 2001 +From: Alexander Graf <agraf@csgraf.de> +Date: Fri, 10 Jun 2022 00:59:19 +0200 +Subject: [PATCH 09/13] efi_loader: GOP: Add damage notification on BLT + +Now that we have a damage tracking API, let's populate damage done by +UEFI payloads when they BLT data onto the screen. + +Signed-off-by: Alexander Graf <agraf@csgraf.de> +Reported-by: Da Xue <da@libre.computer> +Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> +[Alper: Add struct comment for new member] +Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Reviewed-by: Simon Glass <sjg@chromium.org> +Link: https://lore.kernel.org/u-boot/20230821135111.3558478-10-alpernebiyasak@gmail.com/ +--- + lib/efi_loader/efi_gop.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c +index 4593975be5af..3abb47d610e6 100644 +--- a/lib/efi_loader/efi_gop.c ++++ b/lib/efi_loader/efi_gop.c +@@ -26,6 +26,7 @@ static const efi_guid_t efi_gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; + * @ops: graphical output protocol interface + * @info: graphical output mode information + * @mode: graphical output mode ++ * @vdev: backing video device + * @bpix: bits per pixel + * @fb: frame buffer + */ +@@ -34,6 +35,7 @@ struct efi_gop_obj { + struct efi_gop ops; + struct efi_gop_mode_info info; + struct efi_gop_mode mode; ++ struct udevice *vdev; + /* Fields we only have access to during init */ + u32 bpix; + void *fb; +@@ -122,6 +124,7 @@ static __always_inline efi_status_t gop_blt_int(struct efi_gop *this, + u32 *fb32 = gopobj->fb; + u16 *fb16 = gopobj->fb; + struct efi_gop_pixel *buffer = __builtin_assume_aligned(bufferp, 4); ++ bool blt_to_video = (operation != EFI_BLT_VIDEO_TO_BLT_BUFFER); + + if (delta) { + /* Check for 4 byte alignment */ +@@ -245,6 +248,9 @@ static __always_inline efi_status_t gop_blt_int(struct efi_gop *this, + dlineoff += dwidth; + } + ++ if (blt_to_video) ++ video_damage(gopobj->vdev, dx, dy, width, height); ++ + return EFI_SUCCESS; + } + +@@ -551,6 +557,7 @@ efi_status_t efi_gop_register(void) + gopobj->info.pixels_per_scanline = col; + gopobj->bpix = bpix; + gopobj->fb = map_sysmem(fb_base, fb_size); ++ gopobj->vdev = vdev; + + return EFI_SUCCESS; + } +-- +2.49.0 + + +From b9d38bb68233d917a84c589b098699bd9ef08d70 Mon Sep 17 00:00:00 2001 +From: Alexander Graf <agraf@csgraf.de> +Date: Fri, 10 Jun 2022 00:59:20 +0200 +Subject: [PATCH 10/13] video: Only dcache flush damaged lines + +Now that we have a damage area tells us which parts of the frame buffer +actually need updating, let's only dcache flush those on video_sync() +calls. With this optimization in place, frame buffer updates - especially +on large screen such as 4k displays - speed up significantly. + +Signed-off-by: Alexander Graf <agraf@csgraf.de> +Reported-by: Da Xue <da@libre.computer> +[Alper: Use damage.xstart/yend, IS_ENABLED()] +Co-developed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Link: https://lore.kernel.org/u-boot/20230821135111.3558478-11-alpernebiyasak@gmail.com/ +--- + drivers/video/video-uclass.c | 43 +++++++++++++++++++++++++++++++----- + 1 file changed, 38 insertions(+), 5 deletions(-) + +diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c +index 1c07613539f2..2dffcc229f6f 100644 +--- a/drivers/video/video-uclass.c ++++ b/drivers/video/video-uclass.c +@@ -399,6 +399,40 @@ void video_damage(struct udevice *vid, int x, int y, int width, int height) + } + #endif + ++#if defined(CONFIG_ARM) && !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) ++static void video_flush_dcache(struct udevice *vid, bool use_copy) ++{ ++ struct video_priv *priv = dev_get_uclass_priv(vid); ++ ulong fb = use_copy ? (ulong)priv->copy_fb : (ulong)priv->fb; ++ ++ if (!priv->flush_dcache) ++ return; ++ ++ if (!IS_ENABLED(CONFIG_VIDEO_DAMAGE)) { ++ flush_dcache_range(fb, ALIGN(fb + priv->fb_size, ++ CONFIG_SYS_CACHELINE_SIZE)); ++ ++ return; ++ } ++ ++ if (priv->damage.xend && priv->damage.yend) { ++ int lstart = priv->damage.xstart * VNBYTES(priv->bpix); ++ int lend = priv->damage.xend * VNBYTES(priv->bpix); ++ int y; ++ ++ for (y = priv->damage.ystart; y < priv->damage.yend; y++) { ++ ulong start = fb + (y * priv->line_length) + lstart; ++ ulong end = start + lend - lstart; ++ ++ start = ALIGN_DOWN(start, CONFIG_SYS_CACHELINE_SIZE); ++ end = ALIGN(end, CONFIG_SYS_CACHELINE_SIZE); ++ ++ flush_dcache_range(start, end); ++ } ++ } ++} ++#endif ++ + /* Flush video activity to the caches */ + int video_sync(struct udevice *vid, bool force) + { +@@ -422,11 +456,10 @@ int video_sync(struct udevice *vid, bool force) + * out whether it exists? For now, ARM is safe. + */ + #if defined(CONFIG_ARM) && !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) +- if (priv->flush_dcache) { +- flush_dcache_range((ulong)priv->fb, +- ALIGN((ulong)priv->fb + priv->fb_size, +- CONFIG_SYS_CACHELINE_SIZE)); +- } ++ video_flush_dcache(vid, false); ++ ++ if (IS_ENABLED(CONFIG_VIDEO_COPY)) ++ video_flush_dcache(vid, true); + #elif defined(CONFIG_VIDEO_SANDBOX_SDL) + sandbox_sdl_sync(priv->fb); + #endif +-- +2.49.0 + + +From bcb0061c373dca651760928ec6f8e13842b26e55 Mon Sep 17 00:00:00 2001 +From: Alexander Graf <agraf@csgraf.de> +Date: Fri, 10 Jun 2022 00:59:21 +0200 +Subject: [PATCH 11/13] video: Use VIDEO_DAMAGE for VIDEO_COPY + +CONFIG_VIDEO_COPY implemented a range-based copying mechanism: If we +print a single character, it will always copy the full range of bytes +from the top left corner of the character to the lower right onto the +uncached frame buffer. This includes pretty much the full line contents +of the printed character. + +Since we now have proper damage tracking, let's make use of that to reduce +the amount of data we need to copy. With this patch applied, we will only +copy the tiny rectangle surrounding characters when we print them, +speeding up the video console. + +After this, changes to the main frame buffer are not immediately copied +to the copy frame buffer, but postponed until the next video device +sync. So issue an explicit sync before inspecting the copy frame buffer +contents for the video tests. + +Signed-off-by: Alexander Graf <agraf@csgraf.de> +[Alper: Rebase for fontdata->height/w, fill_part(), fix memmove(dev), + drop from defconfig, use damage.xstart/yend, use IS_ENABLED(), + call video_sync() before copy_fb check, update video_copy test] +Co-developed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Link: https://lore.kernel.org/u-boot/20230821135111.3558478-12-alpernebiyasak@gmail.com/ +--- + configs/sandbox_defconfig | 1 - + drivers/video/Kconfig | 5 ++ + drivers/video/console_normal.c | 13 +---- + drivers/video/console_rotate.c | 44 +++----------- + drivers/video/console_truetype.c | 20 +------ + drivers/video/vidconsole-uclass.c | 16 ------ + drivers/video/video-uclass.c | 96 ++++++++----------------------- + drivers/video/video_bmp.c | 7 --- + include/video.h | 37 ------------ + include/video_console.h | 52 ----------------- + test/dm/video.c | 3 +- + 11 files changed, 43 insertions(+), 251 deletions(-) + +diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig +index 8bf36ff325d8..861a1f4cd90e 100644 +--- a/configs/sandbox_defconfig ++++ b/configs/sandbox_defconfig +@@ -328,7 +328,6 @@ CONFIG_USB_ETH_CDC=y + CONFIG_VIDEO=y + CONFIG_VIDEO_FONT_SUN12X22=y + CONFIG_VIDEO_COPY=y +-CONFIG_VIDEO_DAMAGE=y + CONFIG_CONSOLE_ROTATION=y + CONFIG_CONSOLE_TRUETYPE=y + CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y +diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig +index 5d67067891be..964174b01acc 100644 +--- a/drivers/video/Kconfig ++++ b/drivers/video/Kconfig +@@ -89,11 +89,14 @@ config VIDEO_PCI_DEFAULT_FB_SIZE + + config VIDEO_COPY + bool "Enable copying the frame buffer to a hardware copy" ++ select VIDEO_DAMAGE + help + On some machines (e.g. x86), reading from the frame buffer is very + slow because it is uncached. To improve performance, this feature + allows the frame buffer to be kept in cached memory (allocated by + U-Boot) and then copied to the hardware frame-buffer as needed. ++ It uses the VIDEO_DAMAGE feature to keep track of regions to copy ++ and will only copy actually touched regions. + + To use this, your video driver must set @copy_base in + struct video_uc_plat. +@@ -111,6 +114,8 @@ config VIDEO_DAMAGE + regions of the frame buffer that were modified before, speeding up + screen refreshes significantly. + ++ It is also used by VIDEO_COPY to identify which regions changed. ++ + config BACKLIGHT_PWM + bool "Generic PWM based Backlight Driver" + depends on BACKLIGHT && DM_PWM +diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c +index 51ac8cc78e9d..07db613ac53c 100644 +--- a/drivers/video/console_normal.c ++++ b/drivers/video/console_normal.c +@@ -35,10 +35,6 @@ static int console_set_row(struct udevice *dev, uint row, int clr) + fill_pixel_and_goto_next(&dst, clr, pbytes, pbytes); + end = dst; + +- ret = vidconsole_sync_copy(dev, line, end); +- if (ret) +- return ret; +- + video_damage(dev->parent, + 0, + fontdata->height * row, +@@ -57,14 +53,11 @@ static int console_move_rows(struct udevice *dev, uint rowdst, + void *dst; + void *src; + int size; +- int ret; + + dst = vid_priv->fb + rowdst * fontdata->height * vid_priv->line_length; + src = vid_priv->fb + rowsrc * fontdata->height * vid_priv->line_length; + size = fontdata->height * vid_priv->line_length * count; +- ret = vidconsole_memmove(dev, dst, src, size); +- if (ret) +- return ret; ++ memmove(dst, src, size); + + video_damage(dev->parent, + 0, +@@ -109,10 +102,6 @@ static int console_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp) + fontdata->width, + fontdata->height); + +- ret = vidconsole_sync_copy(dev, start, line); +- if (ret) +- return ret; +- + return VID_TO_POS(fontdata->width); + } + +diff --git a/drivers/video/console_rotate.c b/drivers/video/console_rotate.c +index f11dc3a0b075..886b25dcfafc 100644 +--- a/drivers/video/console_rotate.c ++++ b/drivers/video/console_rotate.c +@@ -21,7 +21,6 @@ static int console_set_row_1(struct udevice *dev, uint row, int clr) + int pbytes = VNBYTES(vid_priv->bpix); + void *start, *dst, *line; + int i, j; +- int ret; + + start = vid_priv->fb + vid_priv->line_length - + (row + 1) * fontdata->height * pbytes; +@@ -32,9 +31,6 @@ static int console_set_row_1(struct udevice *dev, uint row, int clr) + fill_pixel_and_goto_next(&dst, clr, pbytes, pbytes); + line += vid_priv->line_length; + } +- ret = vidconsole_sync_copy(dev, start, line); +- if (ret) +- return ret; + + video_damage(dev->parent, + vid_priv->xsize - ((row + 1) * fontdata->height), +@@ -54,7 +50,7 @@ static int console_move_rows_1(struct udevice *dev, uint rowdst, uint rowsrc, + int pbytes = VNBYTES(vid_priv->bpix); + void *dst; + void *src; +- int j, ret; ++ int j; + + dst = vid_priv->fb + vid_priv->line_length - + (rowdst + count) * fontdata->height * pbytes; +@@ -62,10 +58,7 @@ static int console_move_rows_1(struct udevice *dev, uint rowdst, uint rowsrc, + (rowsrc + count) * fontdata->height * pbytes; + + for (j = 0; j < vid_priv->ysize; j++) { +- ret = vidconsole_memmove(dev, dst, src, +- fontdata->height * pbytes * count); +- if (ret) +- return ret; ++ memmove(dst, src, fontdata->height * pbytes * count); + src += vid_priv->line_length; + dst += vid_priv->line_length; + } +@@ -105,10 +98,6 @@ static int console_putc_xy_1(struct udevice *dev, uint x_frac, uint y, int cp) + return ret; + + /* We draw backwards from 'start, so account for the first line */ +- ret = vidconsole_sync_copy(dev, start - vid_priv->line_length, line); +- if (ret) +- return ret; +- + video_damage(dev->parent, + vid_priv->xsize - y - fontdata->height, + linenum - 1, +@@ -125,7 +114,7 @@ static int console_set_row_2(struct udevice *dev, uint row, int clr) + struct video_fontdata *fontdata = priv->fontdata; + void *start, *line, *dst, *end; + int pixels = fontdata->height * vid_priv->xsize; +- int i, ret; ++ int i; + int pbytes = VNBYTES(vid_priv->bpix); + + start = vid_priv->fb + vid_priv->ysize * vid_priv->line_length - +@@ -135,9 +124,6 @@ static int console_set_row_2(struct udevice *dev, uint row, int clr) + for (i = 0; i < pixels; i++) + fill_pixel_and_goto_next(&dst, clr, pbytes, pbytes); + end = dst; +- ret = vidconsole_sync_copy(dev, start, end); +- if (ret) +- return ret; + + video_damage(dev->parent, + 0, +@@ -163,8 +149,7 @@ static int console_move_rows_2(struct udevice *dev, uint rowdst, uint rowsrc, + vid_priv->line_length; + src = end - (rowsrc + count) * fontdata->height * + vid_priv->line_length; +- vidconsole_memmove(dev, dst, src, +- fontdata->height * vid_priv->line_length * count); ++ memmove(dst, src, fontdata->height * vid_priv->line_length * count); + + video_damage(dev->parent, + 0, +@@ -200,11 +185,6 @@ static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, int cp) + if (ret) + return ret; + +- /* Add 4 bytes to allow for the first pixel writen */ +- ret = vidconsole_sync_copy(dev, start + 4, line); +- if (ret) +- return ret; +- + video_damage(dev->parent, + x - fontdata->width + 1, + linenum - fontdata->height + 1, +@@ -221,7 +201,7 @@ static int console_set_row_3(struct udevice *dev, uint row, int clr) + struct video_fontdata *fontdata = priv->fontdata; + int pbytes = VNBYTES(vid_priv->bpix); + void *start, *dst, *line; +- int i, j, ret; ++ int i, j; + + start = vid_priv->fb + row * fontdata->height * pbytes; + line = start; +@@ -231,9 +211,6 @@ static int console_set_row_3(struct udevice *dev, uint row, int clr) + fill_pixel_and_goto_next(&dst, clr, pbytes, pbytes); + line += vid_priv->line_length; + } +- ret = vidconsole_sync_copy(dev, start, line); +- if (ret) +- return ret; + + video_damage(dev->parent, + row * fontdata->height, +@@ -253,16 +230,13 @@ static int console_move_rows_3(struct udevice *dev, uint rowdst, uint rowsrc, + int pbytes = VNBYTES(vid_priv->bpix); + void *dst; + void *src; +- int j, ret; ++ int j; + + dst = vid_priv->fb + rowdst * fontdata->height * pbytes; + src = vid_priv->fb + rowsrc * fontdata->height * pbytes; + + for (j = 0; j < vid_priv->ysize; j++) { +- ret = vidconsole_memmove(dev, dst, src, +- fontdata->height * pbytes * count); +- if (ret) +- return ret; ++ memmove(dst, src, fontdata->height * pbytes * count); + src += vid_priv->line_length; + dst += vid_priv->line_length; + } +@@ -298,10 +272,6 @@ static int console_putc_xy_3(struct udevice *dev, uint x_frac, uint y, int cp) + line = start; + + ret = fill_char_horizontally(pfont, &line, vid_priv, fontdata, NORMAL_DIRECTION); +- if (ret) +- return ret; +- /* Add a line to allow for the first pixels writen */ +- ret = vidconsole_sync_copy(dev, start + vid_priv->line_length, line); + if (ret) + return ret; + +diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c +index 073ddcfb6950..56c3af3d5aad 100644 +--- a/drivers/video/console_truetype.c ++++ b/drivers/video/console_truetype.c +@@ -194,7 +194,6 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr) + struct console_tt_priv *priv = dev_get_priv(dev); + struct console_tt_metrics *met = priv->cur_met; + void *end, *line; +- int ret; + + line = vid_priv->fb + row * met->font_size * vid_priv->line_length; + end = line + met->font_size * vid_priv->line_length; +@@ -230,9 +229,6 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr) + default: + return -ENOSYS; + } +- ret = vidconsole_sync_copy(dev, line, end); +- if (ret) +- return ret; + + video_damage(dev->parent, + 0, +@@ -252,14 +248,11 @@ static int console_truetype_move_rows(struct udevice *dev, uint rowdst, + struct console_tt_metrics *met = priv->cur_met; + void *dst; + void *src; +- int i, diff, ret; ++ int i, diff; + + dst = vid_priv->fb + rowdst * met->font_size * vid_priv->line_length; + src = vid_priv->fb + rowsrc * met->font_size * vid_priv->line_length; +- ret = vidconsole_memmove(dev, dst, src, met->font_size * +- vid_priv->line_length * count); +- if (ret) +- return ret; ++ memmove(dst, src, met->font_size * vid_priv->line_length * count); + + /* Scroll up our position history */ + diff = (rowsrc - rowdst) * met->font_size; +@@ -292,7 +285,7 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y, + u8 *bits, *data; + int advance; + void *start, *end, *line; +- int row, ret; ++ int row; + + /* First get some basic metrics about this character */ + stbtt_GetCodepointHMetrics(font, cp, &advance, &lsb); +@@ -439,9 +432,6 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y, + width, + height); + +- ret = vidconsole_sync_copy(dev, start, line); +- if (ret) +- return ret; + free(data); + + return width_frac; +@@ -872,7 +862,6 @@ static int truetype_set_cursor_visible(struct udevice *dev, bool visible, + uint row, width, height, xoff; + void *start, *line; + uint out, val; +- int ret; + + if (xpl_phase() <= PHASE_SPL) + return -ENOSYS; +@@ -962,9 +951,6 @@ static int truetype_set_cursor_visible(struct udevice *dev, bool visible, + + line += vid_priv->line_length; + } +- ret = vidconsole_sync_copy(dev, start, line); +- if (ret) +- return ret; + + return video_sync(vid, true); + } +diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c +index 8613c464040f..ce6c8bb70cb7 100644 +--- a/drivers/video/vidconsole-uclass.c ++++ b/drivers/video/vidconsole-uclass.c +@@ -803,22 +803,6 @@ UCLASS_DRIVER(vidconsole) = { + .per_device_auto = sizeof(struct vidconsole_priv), + }; + +-#ifdef CONFIG_VIDEO_COPY +-int vidconsole_sync_copy(struct udevice *dev, void *from, void *to) +-{ +- struct udevice *vid = dev_get_parent(dev); +- +- return video_sync_copy(vid, from, to); +-} +- +-int vidconsole_memmove(struct udevice *dev, void *dst, const void *src, +- int size) +-{ +- memmove(dst, src, size); +- return vidconsole_sync_copy(dev, dst, dst + size); +-} +-#endif +- + int vidconsole_clear_and_reset(struct udevice *dev) + { + int ret; +diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c +index 2dffcc229f6f..eeee5d960838 100644 +--- a/drivers/video/video-uclass.c ++++ b/drivers/video/video-uclass.c +@@ -171,7 +171,7 @@ int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend, + struct video_priv *priv = dev_get_uclass_priv(dev); + void *start, *line; + int pixels = xend - xstart; +- int row, i, ret; ++ int row, i; + + start = priv->fb + ystart * priv->line_length; + start += xstart * VNBYTES(priv->bpix); +@@ -210,9 +210,6 @@ int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend, + } + line += priv->line_length; + } +- ret = video_sync_copy(dev, start, line); +- if (ret) +- return ret; + + video_damage(dev, xstart, ystart, xend - xstart, yend - ystart); + +@@ -235,7 +232,6 @@ int video_reserve_from_bloblist(struct video_handoff *ho) + int video_fill(struct udevice *dev, u32 colour) + { + struct video_priv *priv = dev_get_uclass_priv(dev); +- int ret; + + switch (priv->bpix) { + case VIDEO_BPP16: +@@ -260,9 +256,6 @@ int video_fill(struct udevice *dev, u32 colour) + memset(priv->fb, colour, priv->fb_size); + break; + } +- ret = video_sync_copy(dev, priv->fb, priv->fb + priv->fb_size); +- if (ret) +- return ret; + + video_damage(dev, 0, 0, priv->xsize, priv->ysize); + +@@ -433,6 +426,27 @@ static void video_flush_dcache(struct udevice *vid, bool use_copy) + } + #endif + ++static void video_flush_copy(struct udevice *vid) ++{ ++ struct video_priv *priv = dev_get_uclass_priv(vid); ++ ++ if (!priv->copy_fb) ++ return; ++ ++ if (priv->damage.xend && priv->damage.yend) { ++ int lstart = priv->damage.xstart * VNBYTES(priv->bpix); ++ int lend = priv->damage.xend * VNBYTES(priv->bpix); ++ int y; ++ ++ for (y = priv->damage.ystart; y < priv->damage.yend; y++) { ++ ulong offset = (y * priv->line_length) + lstart; ++ ulong len = lend - lstart; ++ ++ memcpy(priv->copy_fb + offset, priv->fb + offset, len); ++ } ++ } ++} ++ + /* Flush video activity to the caches */ + int video_sync(struct udevice *vid, bool force) + { +@@ -440,6 +454,9 @@ int video_sync(struct udevice *vid, bool force) + struct video_ops *ops = video_get_ops(vid); + int ret; + ++ if (IS_ENABLED(CONFIG_VIDEO_COPY)) ++ video_flush_copy(vid); ++ + if (ops && ops->video_sync) { + ret = ops->video_sync(vid); + if (ret) +@@ -523,69 +540,6 @@ int video_get_ysize(struct udevice *dev) + return priv->ysize; + } + +-#ifdef CONFIG_VIDEO_COPY +-int video_sync_copy(struct udevice *dev, void *from, void *to) +-{ +- struct video_priv *priv = dev_get_uclass_priv(dev); +- +- if (priv->copy_fb) { +- long offset, size; +- +- /* Find the offset of the first byte to copy */ +- if ((ulong)to > (ulong)from) { +- size = to - from; +- offset = from - priv->fb; +- } else { +- size = from - to; +- offset = to - priv->fb; +- } +- +- /* +- * Allow a bit of leeway for valid requests somewhere near the +- * frame buffer +- */ +- if (offset < -priv->fb_size || offset > 2 * priv->fb_size) { +-#ifdef DEBUG +- char str[120]; +- +- snprintf(str, sizeof(str), +- "[** FAULT sync_copy fb=%p, from=%p, to=%p, offset=%lx]", +- priv->fb, from, to, offset); +- console_puts_select_stderr(true, str); +-#endif +- return -EFAULT; +- } +- +- /* +- * Silently crop the memcpy. This allows callers to avoid doing +- * this themselves. It is common for the end pointer to go a +- * few lines after the end of the frame buffer, since most of +- * the update algorithms terminate a line after their last write +- */ +- if (offset + size > priv->fb_size) { +- size = priv->fb_size - offset; +- } else if (offset < 0) { +- size += offset; +- offset = 0; +- } +- +- memcpy(priv->copy_fb + offset, priv->fb + offset, size); +- } +- +- return 0; +-} +- +-int video_sync_copy_all(struct udevice *dev) +-{ +- struct video_priv *priv = dev_get_uclass_priv(dev); +- +- video_sync_copy(dev, priv->fb, priv->fb + priv->fb_size); +- +- return 0; +-} +- +-#endif +- + #define SPLASH_DECL(_name) \ + extern u8 __splash_ ## _name ## _begin[]; \ + extern u8 __splash_ ## _name ## _end[] +diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c +index 78de95607924..1f267d45812c 100644 +--- a/drivers/video/video_bmp.c ++++ b/drivers/video/video_bmp.c +@@ -267,7 +267,6 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, + enum video_format eformat; + struct bmp_color_table_entry *palette; + int hdr_size; +- int ret; + + if (!bmp || !(bmp->header.signature[0] == 'B' && + bmp->header.signature[1] == 'M')) { +@@ -461,11 +460,5 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, + + video_damage(dev, x, y, width, height); + +- /* Find the position of the top left of the image in the framebuffer */ +- fb = (uchar *)(priv->fb + y * priv->line_length + x * bpix / 8); +- ret = video_sync_copy(dev, start, fb); +- if (ret) +- return log_ret(ret); +- + return video_sync(dev, false); + } +diff --git a/include/video.h b/include/video.h +index 7eed112e00c4..2fe2f73a865b 100644 +--- a/include/video.h ++++ b/include/video.h +@@ -355,43 +355,6 @@ void video_set_default_colors(struct udevice *dev, bool invert); + */ + int video_default_font_height(struct udevice *dev); + +-#ifdef CONFIG_VIDEO_COPY +-/** +- * vidconsole_sync_copy() - Sync back to the copy framebuffer +- * +- * This ensures that the copy framebuffer has the same data as the framebuffer +- * for a particular region. It should be called after the framebuffer is updated +- * +- * @from and @to can be in either order. The region between them is synced. +- * +- * @dev: Vidconsole device being updated +- * @from: Start/end address within the framebuffer (->fb) +- * @to: Other address within the frame buffer +- * Return: 0 if OK, -EFAULT if the start address is before the start of the +- * frame buffer start +- */ +-int video_sync_copy(struct udevice *dev, void *from, void *to); +- +-/** +- * video_sync_copy_all() - Sync the entire framebuffer to the copy +- * +- * @dev: Vidconsole device being updated +- * Return: 0 (always) +- */ +-int video_sync_copy_all(struct udevice *dev); +-#else +-static inline int video_sync_copy(struct udevice *dev, void *from, void *to) +-{ +- return 0; +-} +- +-static inline int video_sync_copy_all(struct udevice *dev) +-{ +- return 0; +-} +- +-#endif +- + #ifdef CONFIG_VIDEO_DAMAGE + /** + * video_damage() - Notify the video subsystem about screen updates. +diff --git a/include/video_console.h b/include/video_console.h +index 17a9aa3f9295..b228c725fd80 100644 +--- a/include/video_console.h ++++ b/include/video_console.h +@@ -538,56 +538,4 @@ void vidconsole_list_fonts(struct udevice *dev); + */ + int vidconsole_get_font_size(struct udevice *dev, const char **name, uint *sizep); + +-#ifdef CONFIG_VIDEO_COPY +-/** +- * vidconsole_sync_copy() - Sync back to the copy framebuffer +- * +- * This ensures that the copy framebuffer has the same data as the framebuffer +- * for a particular region. It should be called after the framebuffer is updated +- * +- * @from and @to can be in either order. The region between them is synced. +- * +- * @dev: Vidconsole device being updated +- * @from: Start/end address within the framebuffer (->fb) +- * @to: Other address within the frame buffer +- * Return: 0 if OK, -EFAULT if the start address is before the start of the +- * frame buffer start +- */ +-int vidconsole_sync_copy(struct udevice *dev, void *from, void *to); +- +-/** +- * vidconsole_memmove() - Perform a memmove() within the frame buffer +- * +- * This handles a memmove(), e.g. for scrolling. It also updates the copy +- * framebuffer. +- * +- * @dev: Vidconsole device being updated +- * @dst: Destination address within the framebuffer (->fb) +- * @src: Source address within the framebuffer (->fb) +- * @size: Number of bytes to transfer +- * Return: 0 if OK, -EFAULT if the start address is before the start of the +- * frame buffer start +- */ +-int vidconsole_memmove(struct udevice *dev, void *dst, const void *src, +- int size); +-#else +- +-#include <string.h> +- +-static inline int vidconsole_sync_copy(struct udevice *dev, void *from, +- void *to) +-{ +- return 0; +-} +- +-static inline int vidconsole_memmove(struct udevice *dev, void *dst, +- const void *src, int size) +-{ +- memmove(dst, src, size); +- +- return 0; +-} +- +-#endif +- + #endif +diff --git a/test/dm/video.c b/test/dm/video.c +index e76fa986d359..021f4b3fa733 100644 +--- a/test/dm/video.c ++++ b/test/dm/video.c +@@ -105,6 +105,7 @@ static int check_copy_frame_buffer(struct unit_test_state *uts, + if (!IS_ENABLED(CONFIG_VIDEO_COPY)) + return 0; + ++ video_sync(dev, false); + ut_assertf(!memcmp(priv->fb, priv->copy_fb, priv->fb_size), + "Copy framebuffer does not match fb"); + +@@ -705,7 +706,7 @@ static int dm_test_video_copy(struct unit_test_state *uts) + vidconsole_put_string(con, test_string); + vidconsole_put_string(con, test_string); + ut_asserteq(7589, compress_frame_buffer(uts, dev, false)); +- ut_asserteq(5278, compress_frame_buffer(uts, dev, true)); ++ ut_asserteq(4127, compress_frame_buffer(uts, dev, true)); + + return 0; + } +-- +2.49.0 + + +From 631692ed7090a8cfd0b2a3b3f23c295644f1393e Mon Sep 17 00:00:00 2001 +From: Alexander Graf <agraf@csgraf.de> +Date: Tue, 3 Jan 2023 22:50:03 +0100 +Subject: [PATCH 12/13] video: Always compile cache flushing code + +The dcache flushing code path was conditional on ARM && !DCACHE config +options. However, dcaches exist on other platforms as well and may need +clearing if their driver requires it. + +Simplify the compile logic and always enable the dcache flush logic in +the video core. That way, drivers can always rely on it to call the arch +specific callbacks. + +This will increase code size for non-ARM platforms with CONFIG_VIDEO=y +slightly. + +Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de> +Signed-off-by: Alexander Graf <agraf@csgraf.de> +Reviewed-by: Simon Glass <sjg@chromium.org> +Link: https://lore.kernel.org/u-boot/20230821135111.3558478-13-alpernebiyasak@gmail.com/ +--- + drivers/video/video-uclass.c | 12 +++++------- + 1 file changed, 5 insertions(+), 7 deletions(-) + +diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c +index eeee5d960838..6c5a86d85dbc 100644 +--- a/drivers/video/video-uclass.c ++++ b/drivers/video/video-uclass.c +@@ -398,6 +398,9 @@ static void video_flush_dcache(struct udevice *vid, bool use_copy) + struct video_priv *priv = dev_get_uclass_priv(vid); + ulong fb = use_copy ? (ulong)priv->copy_fb : (ulong)priv->fb; + ++ if (CONFIG_IS_ENABLED(SYS_DCACHE_OFF)) ++ return; ++ + if (!priv->flush_dcache) + return; + +@@ -467,17 +470,12 @@ int video_sync(struct udevice *vid, bool force) + get_timer(priv->last_sync) < CONFIG_VIDEO_SYNC_MS) + return 0; + +- /* +- * flush_dcache_range() is declared in common.h but it seems that some +- * architectures do not actually implement it. Is there a way to find +- * out whether it exists? For now, ARM is safe. +- */ +-#if defined(CONFIG_ARM) && !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) + video_flush_dcache(vid, false); + + if (IS_ENABLED(CONFIG_VIDEO_COPY)) + video_flush_dcache(vid, true); +-#elif defined(CONFIG_VIDEO_SANDBOX_SDL) ++ ++#if defined(CONFIG_VIDEO_SANDBOX_SDL) + sandbox_sdl_sync(priv->fb); + #endif + priv->last_sync = get_timer(0); +-- +2.49.0 + + +From 08f3add44c202053f5ba882cb2f440e8e470229c Mon Sep 17 00:00:00 2001 +From: Alexander Graf <agraf@csgraf.de> +Date: Tue, 3 Jan 2023 22:50:04 +0100 +Subject: [PATCH 13/13] video: Enable VIDEO_DAMAGE for drivers that need it + +Some drivers call video_set_flush_dcache() to indicate that they want to +have the dcache flushed for the frame buffer. These drivers benefit from +our new video damage control, because we can reduce the amount of memory +that gets flushed significantly. + +This patch enables video damage control for all device drivers that call +video_set_flush_dcache() to make sure they benefit from it. + +Signed-off-by: Alexander Graf <agraf@csgraf.de> +[Alper: Add to VIDEO_TIDSS, imply instead of select] +Co-developed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Reviewed-by: Simon Glass <sjg@chromium.org> +Link: https://lore.kernel.org/u-boot/20230821135111.3558478-14-alpernebiyasak@gmail.com/ +--- + arch/arm/mach-sunxi/Kconfig | 1 + + drivers/video/Kconfig | 8 ++++++++ + drivers/video/exynos/Kconfig | 1 + + drivers/video/imx/Kconfig | 1 + + drivers/video/meson/Kconfig | 1 + + drivers/video/rockchip/Kconfig | 1 + + drivers/video/stm32/Kconfig | 1 + + drivers/video/tegra20/Kconfig | 1 + + drivers/video/tidss/Kconfig | 1 + + 9 files changed, 16 insertions(+) + +diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig +index ba1b15414379..bb1ea961704e 100644 +--- a/arch/arm/mach-sunxi/Kconfig ++++ b/arch/arm/mach-sunxi/Kconfig +@@ -882,6 +882,7 @@ config VIDEO_SUNXI + depends on !SUNXI_GEN_NCAT2 + select VIDEO + select DISPLAY ++ imply VIDEO_DAMAGE + imply VIDEO_DT_SIMPLEFB + default y + ---help--- +diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig +index 964174b01acc..6e1577ae6871 100644 +--- a/drivers/video/Kconfig ++++ b/drivers/video/Kconfig +@@ -534,6 +534,7 @@ config VIDEO_LCD_ANX9804 + + config ATMEL_LCD + bool "Atmel LCD panel support" ++ imply VIDEO_DAMAGE + depends on ARCH_AT91 + + config ATMEL_LCD_BGR555 +@@ -543,6 +544,7 @@ config ATMEL_LCD_BGR555 + + config VIDEO_BCM2835 + bool "Display support for BCM2835" ++ imply VIDEO_DAMAGE + help + The graphics processor already sets up the display so this driver + simply checks the resolution and then sets up the frame buffer with +@@ -715,6 +717,7 @@ source "drivers/video/meson/Kconfig" + + config VIDEO_MVEBU + bool "Armada XP LCD controller" ++ imply VIDEO_DAMAGE + ---help--- + Support for the LCD controller integrated in the Marvell + Armada XP SoC. +@@ -749,6 +752,7 @@ config NXP_TDA19988 + + config ATMEL_HLCD + bool "Enable ATMEL video support using HLCDC" ++ imply VIDEO_DAMAGE + help + HLCDC supports video output to an attached LCD panel. + +@@ -825,6 +829,7 @@ source "drivers/video/tidss/Kconfig" + + config VIDEO_TEGRA124 + bool "Enable video support on Tegra124" ++ imply VIDEO_DAMAGE + help + Tegra124 supports many video output options including eDP and + HDMI. At present only eDP is supported by U-Boot. This option +@@ -839,6 +844,7 @@ source "drivers/video/imx/Kconfig" + + config VIDEO_MXS + bool "Enable video support on i.MX28/i.MX6UL/i.MX7 SoCs" ++ imply VIDEO_DAMAGE + help + Enable framebuffer driver for i.MX28/i.MX6UL/i.MX7 processors + +@@ -901,6 +907,7 @@ config VIDEO_DW_MIPI_DSI + + config VIDEO_SIMPLE + bool "Simple display driver for preconfigured display" ++ imply VIDEO_DAMAGE + help + Enables a simple generic display driver which utilizes the + simple-framebuffer devicetree bindings. +@@ -919,6 +926,7 @@ config VIDEO_DT_SIMPLEFB + + config VIDEO_MCDE_SIMPLE + bool "Simple driver for ST-Ericsson MCDE with preconfigured display" ++ imply VIDEO_DAMAGE + help + Enables a simple display driver for ST-Ericsson MCDE + (Multichannel Display Engine), which reads the configuration from +diff --git a/drivers/video/exynos/Kconfig b/drivers/video/exynos/Kconfig +index 599d19d5ecc2..a2cf752aac03 100644 +--- a/drivers/video/exynos/Kconfig ++++ b/drivers/video/exynos/Kconfig +@@ -12,6 +12,7 @@ config EXYNOS_DP + + config EXYNOS_FB + bool "Exynos FIMD support" ++ imply VIDEO_DAMAGE + + config EXYNOS_MIPI_DSIM + bool "Exynos MIPI DSI support" +diff --git a/drivers/video/imx/Kconfig b/drivers/video/imx/Kconfig +index 34e8b640595b..5db3e5c0499e 100644 +--- a/drivers/video/imx/Kconfig ++++ b/drivers/video/imx/Kconfig +@@ -2,6 +2,7 @@ + config VIDEO_IPUV3 + bool "i.MX IPUv3 Core video support" + depends on VIDEO && (MX5 || MX6) ++ imply VIDEO_DAMAGE + help + This enables framebuffer driver for i.MX processors working + on the IPUv3(Image Processing Unit) internal graphic processor. +diff --git a/drivers/video/meson/Kconfig b/drivers/video/meson/Kconfig +index 3c2d72d019b8..fcf486ca0a3a 100644 +--- a/drivers/video/meson/Kconfig ++++ b/drivers/video/meson/Kconfig +@@ -8,5 +8,6 @@ config VIDEO_MESON + bool "Enable Amlogic Meson video support" + depends on VIDEO + select DISPLAY ++ imply VIDEO_DAMAGE + help + Enable Amlogic Meson Video Processing Unit video support. +diff --git a/drivers/video/rockchip/Kconfig b/drivers/video/rockchip/Kconfig +index 01804dcb1cc8..0f4550a29e38 100644 +--- a/drivers/video/rockchip/Kconfig ++++ b/drivers/video/rockchip/Kconfig +@@ -11,6 +11,7 @@ + menuconfig VIDEO_ROCKCHIP + bool "Enable Rockchip Video Support" + depends on VIDEO ++ imply VIDEO_DAMAGE + help + Rockchip SoCs provide video output capabilities for High-Definition + Multimedia Interface (HDMI), Low-voltage Differential Signalling +diff --git a/drivers/video/stm32/Kconfig b/drivers/video/stm32/Kconfig +index 48066063e4c5..c354c402c288 100644 +--- a/drivers/video/stm32/Kconfig ++++ b/drivers/video/stm32/Kconfig +@@ -8,6 +8,7 @@ + menuconfig VIDEO_STM32 + bool "Enable STM32 video support" + depends on VIDEO ++ imply VIDEO_DAMAGE + help + STM32 supports many video output options including RGB and + DSI. This option enables these supports which can be used on +diff --git a/drivers/video/tegra20/Kconfig b/drivers/video/tegra20/Kconfig +index f5c4843e1191..2232b0b3ff53 100644 +--- a/drivers/video/tegra20/Kconfig ++++ b/drivers/video/tegra20/Kconfig +@@ -1,6 +1,7 @@ + config VIDEO_TEGRA20 + bool "Enable Display Controller support on Tegra20 and Tegra 30" + depends on OF_CONTROL ++ imply VIDEO_DAMAGE + help + T20/T30 support video output to an attached LCD panel as well as + other options such as HDMI. Only the LCD is supported in U-Boot. +diff --git a/drivers/video/tidss/Kconfig b/drivers/video/tidss/Kconfig +index 95086f3a5d66..3291b3ceb8d5 100644 +--- a/drivers/video/tidss/Kconfig ++++ b/drivers/video/tidss/Kconfig +@@ -11,6 +11,7 @@ + menuconfig VIDEO_TIDSS + bool "Enable TIDSS video support" + depends on VIDEO ++ imply VIDEO_DAMAGE + help + TIDSS supports video output options LVDS and + DPI . This option enables these supports which can be used on +-- +2.49.0 + diff --git a/config/module/u-boot/default/patches/0004-HACK-Makefile-Ignore-missing-input-files-for-binman.patch b/config/module/u-boot/default/patches/0004-HACK-Makefile-Ignore-missing-input-files-for-binman.patch new file mode 100644 index 00000000..5307f378 --- /dev/null +++ b/config/module/u-boot/default/patches/0004-HACK-Makefile-Ignore-missing-input-files-for-binman.patch @@ -0,0 +1,34 @@ +From faa87ed4d2ff07e9e8cc98cd08cbb34c905c1ac6 Mon Sep 17 00:00:00 2001 +From: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Date: Wed, 10 Jul 2024 17:37:56 +0300 +Subject: [PATCH] HACK: Makefile: Ignore missing input files for binman images + +For Rockchip boards binman tries to build SPI and MMC images that +require an externally built BL31 file to be provided, and the build +fails otherwise. + +Some downstreams only care about build outputs for U-Boot proper. As a +hack to make sure they can do so without passing in a BL31 file, tell +binman to ignore missing input files. + +Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> +--- + Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index a7593e8a1680..30deb760bf8f 100644 +--- a/Makefile ++++ b/Makefile +@@ -1410,7 +1410,7 @@ cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \ + $(if $(BINMAN_VERBOSE),-v$(BINMAN_VERBOSE)) \ + build -u -d $(binman_dtb) -O . -m \ + --allow-missing --fake-ext-blobs \ +- $(if $(BINMAN_ALLOW_MISSING),--ignore-missing) \ ++ --ignore-missing \ + -I . -I $(srctree) -I $(srctree)/board/$(BOARDDIR) \ + $(foreach f,$(of_list_dirs),-I $(f)) -a of-list=$(of_list) \ + $(foreach f,$(BINMAN_INDIRS),-I $(f)) \ +-- +2.49.0 + diff --git a/config/module/u-boot/default/patches/0005-HACK-rk3399-gru-Remove-assigned-clock-dt-properties-.patch b/config/module/u-boot/default/patches/0005-HACK-rk3399-gru-Remove-assigned-clock-dt-properties-.patch new file mode 100644 index 00000000..018da338 --- /dev/null +++ b/config/module/u-boot/default/patches/0005-HACK-rk3399-gru-Remove-assigned-clock-dt-properties-.patch @@ -0,0 +1,36 @@ +From d02163324baeb817ed55df41fac863cab4be038c Mon Sep 17 00:00:00 2001 +From: Alper Nebi Yasak <alpernebiyasak@gmail.com> +Date: Wed, 10 Jul 2024 14:32:19 +0300 +Subject: [PATCH] HACK: rk3399: gru: Remove assigned clock dt properties for + EDP node + +Having the PCLK_EDP clock in the assigned-clocks property of the `edp` +node means that U-Boot tries to set its rate automatically. This clock +isn't implemented for the RK3399 clock driver, so it fails and prevents +display from being initialized. + +The display happens to work fine without it, remove the property until +the clock driver can handle the clock. + +Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> +--- + arch/arm/dts/rk3399-gru-u-boot.dtsi | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/arch/arm/dts/rk3399-gru-u-boot.dtsi b/arch/arm/dts/rk3399-gru-u-boot.dtsi +index 5517176aa4a0..9f40cf1e0208 100644 +--- a/arch/arm/dts/rk3399-gru-u-boot.dtsi ++++ b/arch/arm/dts/rk3399-gru-u-boot.dtsi +@@ -27,6 +27,9 @@ &cros_ec { + + &edp { + rockchip,panel = <&edp_panel>; ++ ++ /delete-property/ assigned-clocks; ++ /delete-property/ assigned-clock-rates; + }; + + &emmc_phy { +-- +2.49.0 + diff --git a/config/module/u-boot/default/patches/0006-Support-auto-boot-timeout-delay-bootflow-menu.patch b/config/module/u-boot/default/patches/0006-Support-auto-boot-timeout-delay-bootflow-menu.patch new file mode 100644 index 00000000..ffc7b581 --- /dev/null +++ b/config/module/u-boot/default/patches/0006-Support-auto-boot-timeout-delay-bootflow-menu.patch @@ -0,0 +1,302 @@ +From d9371422ac74ea73d1620f01300a7136a7649754 Mon Sep 17 00:00:00 2001 +From: Leah Rowe <info@minifree.org> +Date: Wed, 4 Dec 2024 06:52:39 +0000 +Subject: [PATCH 1/1] Support auto-boot timeout delay bootflow menu + +The bootflow menu cannot currently auto-boot a selected entry, +which means that the user must press enter to boot their system. +This can be a problem on headless setups; for example, it is not +currently feasible to set up a headless server with U-Boot, when +using it to boot via UEFI on a coreboot setup. + +This patch adds the following build-time configuration option: + +CONFIG_CMD_BOOTFLOW_BOOTDELAY + +This creates a timeout delay in the given number of seconds. +If an arrow key is press to navigate the menu, the timer is +disabled and the user must then press enter to boot the selected +option. When this happens, the timeout display is replaced by +the old message indicating that the user should press enter. + +The default boot delay is 30 seconds, and the timeout is enabled +by default. Setting it to zero will restore the old behaviour, +whereby no timeout is provided and the user must press enter. + +If a negative integer is provided, the timer will default to +zero. The timer value is further filtered by modulus of 100, +so that the maximum number of seconds allowed is 99 seconds. + +Signed-off-by: Leah Rowe <info@minifree.org> +--- + boot/bootflow_menu.c | 117 +++++++++++++++++++++++++++++++++++-- + cmd/Kconfig | 12 ++++ + doc/usage/cmd/bootflow.rst | 11 ++++ + include/bootflow.h | 10 +++- + 4 files changed, 143 insertions(+), 7 deletions(-) + +diff --git a/boot/bootflow_menu.c b/boot/bootflow_menu.c +index 9d0dc352f9..172139b187 100644 +--- a/boot/bootflow_menu.c ++++ b/boot/bootflow_menu.c +@@ -30,7 +30,7 @@ struct menu_priv { + int num_bootflows; + }; + +-int bootflow_menu_new(struct expo **expp) ++int bootflow_menu_new(struct expo **expp, const char *prompt) + { + struct udevice *last_bootdev; + struct scene_obj_menu *menu; +@@ -54,7 +54,7 @@ int bootflow_menu_new(struct expo **expp) + return log_msg_ret("scn", ret); + + ret |= scene_txt_str(scn, "prompt", OBJ_PROMPT, STR_PROMPT, +- "UP and DOWN to choose, ENTER to select", NULL); ++ prompt, NULL); + + ret = scene_menu(scn, "main", OBJ_MENU, &menu); + ret |= scene_obj_set_pos(scn, OBJ_MENU, MARGIN_LEFT, 100); +@@ -138,6 +138,29 @@ int bootflow_menu_new(struct expo **expp) + return 0; + } + ++int bootflow_menu_show_countdown(struct expo *exp, char *prompt, ++ char bootflow_delay) ++{ ++ char *i; ++ ++ if (prompt == NULL) ++ return 0; ++ if (strlen(prompt) < 2) ++ return 0; ++ ++ i = prompt + strlen(prompt) - 2; ++ ++ if (bootflow_delay >= 10) { ++ *(i) = 48 + (bootflow_delay / 10); ++ *(i + 1) = 48 + (bootflow_delay % 10); ++ } else { ++ *(i) = 48 + bootflow_delay; ++ *(i + 1) = ' '; ++ } ++ ++ return expo_render(exp); ++} ++ + int bootflow_menu_apply_theme(struct expo *exp, ofnode node) + { + struct menu_priv *priv = exp->priv; +@@ -184,14 +207,62 @@ int bootflow_menu_run(struct bootstd_priv *std, bool text_mode, + struct expo *exp; + uint sel_id; + bool done; +- int ret; ++ int i, ret; ++ ++ /* Auto-boot countdown */ ++ char bootflow_delay_secs, *prompt; ++ int bootflow_time, bootflow_delay; ++ bool skip_render_once = false; ++ bool bootflow_countdown = false; ++ ++ /* TODO: perhaps set based on defconfig? */ ++ /* WARNING: These two strings must be of the same length. */ ++ char promptChoice[] = "UP and DOWN to choose, ENTER to select"; ++ char promptTimeout[] = "UP and DOWN to choose. Auto-boot in "; ++/* ++ // Uncomment if the strings become configurable (defconfig): ++ // (to prevent buffer overflows) ++ char promptDefault[] = "UP and DOWN to choose, ENTER to select"; ++ if (promptTimeout = NULL) ++ promptTimeout = promptDefault; ++ if (promptChoice = NULL) ++ promptChoice = promptDefault; ++ if (strlen(promptChoice) < 2) ++ promptChoice = promptDefault; ++ if (strlen(promptTimeout) < 2) ++ promptTimeout = promptDefault; ++ if (strlen(promptChoice) != strlen(promptTimeout)) ++ promptChoice = promptTimeout; ++*/ ++ prompt = promptChoice; ++ ++ bootflow_delay_secs = 15; /* TODO: set based on defconfig. */ ++ ++#if defined(CONFIG_CMD_BOOTFLOW_BOOTDELAY) ++ /* If set to zero, the auto-boot timeout is disabled. */ ++ bootflow_delay_secs = CONFIG_CMD_BOOTFLOW_BOOTDELAY; ++#else ++ bootflow_delay_secs = 30; ++#endif ++ ++ if (bootflow_delay_secs < 0) ++ bootflow_delay_secs = 0; /* disable countdown if negative */ ++ bootflow_delay_secs %= 100; /* No higher than 99 seconds */ ++ ++ if (bootflow_delay_secs > 0) { ++ bootflow_countdown = true; /* enable auto-boot countdown */ ++ prompt = promptTimeout; ++ bootflow_time = 0; /* Time elapsed in milliseconds */ ++ bootflow_delay = ++ (int)bootflow_delay_secs * 1000; /* milliseconds */ ++ } + + cli_ch_init(cch); + + sel_bflow = NULL; + *bflowp = NULL; + +- ret = bootflow_menu_new(&exp); ++ ret = bootflow_menu_new(&exp, prompt); + if (ret) + return log_msg_ret("exp", ret); + +@@ -216,12 +287,20 @@ int bootflow_menu_run(struct bootstd_priv *std, bool text_mode, + if (text_mode) + expo_set_text_mode(exp, text_mode); + ++ if (bootflow_countdown) { ++ ret = bootflow_menu_show_countdown(exp, prompt, ++ bootflow_delay_secs); ++ skip_render_once = true; /* Don't print menu twice on start */ ++ } + done = false; + do { + struct expo_action act; + int ichar, key; + +- ret = expo_render(exp); ++ if (skip_render_once) ++ skip_render_once = false; ++ else ++ ret = expo_render(exp); + if (ret) + break; + +@@ -231,7 +310,23 @@ int bootflow_menu_run(struct bootstd_priv *std, bool text_mode, + schedule(); + mdelay(2); + ichar = cli_ch_process(cch, -ETIMEDOUT); ++ if (bootflow_countdown) { ++ bootflow_delay -= 2; ++ bootflow_time += 2; ++ if (bootflow_delay <= 0) ++ ichar='\n'; ++ if (bootflow_time < 1000) ++ continue; ++ bootflow_time = 0; ++ --bootflow_delay_secs; ++ ret = bootflow_menu_show_countdown(exp, ++ prompt, bootflow_delay_secs); ++ if (ret) ++ break; ++ } + } ++ if (ret) ++ break; + if (!ichar) { + ichar = getchar(); + ichar = cli_ch_process(cch, ichar); +@@ -265,6 +360,17 @@ int bootflow_menu_run(struct bootstd_priv *std, bool text_mode, + break; + } + } ++ if (bootflow_countdown) { ++ /* A key press interrupted the auto-boot timeout */ ++ bootflow_countdown = false; ++ if (strlen(prompt) == strlen(promptChoice)) { ++ /* "Auto-boot in" becomes "Press ENTER" */ ++ (void) memcpy(prompt, promptChoice, ++ strlen(promptChoice)); ++ ret = expo_render(exp); ++ skip_render_once = true; ++ } ++ } + } while (!done); + + if (ret) +@@ -272,7 +378,6 @@ int bootflow_menu_run(struct bootstd_priv *std, bool text_mode, + + if (sel_id) { + struct bootflow *bflow; +- int i; + + for (ret = bootflow_first_glob(&bflow), i = 0; !ret && i < 36; + ret = bootflow_next_glob(&bflow), i++) { +diff --git a/cmd/Kconfig b/cmd/Kconfig +index 978f44eda4..0303869625 100644 +--- a/cmd/Kconfig ++++ b/cmd/Kconfig +@@ -288,6 +288,7 @@ config CMD_BOOTDEV + config CMD_BOOTFLOW + bool "bootflow" + depends on BOOTSTD ++ select CMD_BOOTFLOW_BOOTDELAY + default y + help + Support scanning for bootflows available with the bootdevs. The +@@ -303,6 +304,17 @@ config CMD_BOOTFLOW_FULL + + This command is not necessary for bootstd to work. + ++config CMD_BOOTFLOW_BOOTDELAY ++ int "bootflow - delay in seconds before booting the first menu option" ++ depends on CMD_BOOTFLOW ++ default 30 ++ help ++ On the bootflow menu, wait for the defined number of seconds before ++ automatically booting. Unless interrupted, this will auto-boot the ++ first option in the generated list of boot options. ++ ++ Set this to zero if you wish to disable the auto-boot timeout. ++ + config CMD_BOOTMETH + bool "bootmeth" + depends on BOOTSTD +diff --git a/doc/usage/cmd/bootflow.rst b/doc/usage/cmd/bootflow.rst +index 5d41fe37a7..728f294274 100644 +--- a/doc/usage/cmd/bootflow.rst ++++ b/doc/usage/cmd/bootflow.rst +@@ -32,6 +32,17 @@ Note that `CONFIG_BOOTSTD_FULL` (which enables `CONFIG_CMD_BOOTFLOW_FULL) must + be enabled to obtain full functionality with this command. Otherwise, it only + supports `bootflow scan` which scans and boots the first available bootflow. + ++The `CONFIG_CMD_BOOTFLOW_BOOTDELAY` option can be set, defining (in seconds) the ++amount of time that U-Boot will wait; after this time passes, it will ++automatically boot the first item when generating a bootflow menu. If the value ++is set to zero, the timeout is disabled and the user must press enter; if it's ++negative, the timeout is disabled, and the maximum number of seconds is 99 ++seconds. If a value higher than 100 is provided, the value is changed to a ++modulus of 100 (remainder of the value divided by 100). ++ ++If the `CONFIG_BOOTFLOW_BOOTFLOW` option is undefined, the timeout will default ++to 30 seconds. ++ + bootflow scan + ~~~~~~~~~~~~~ + +diff --git a/include/bootflow.h b/include/bootflow.h +index 4d2fc7b69b..9f4245caa7 100644 +--- a/include/bootflow.h ++++ b/include/bootflow.h +@@ -452,7 +452,15 @@ int bootflow_iter_check_system(const struct bootflow_iter *iter); + * @expp: Returns the expo created + * Returns 0 on success, -ve on error + */ +-int bootflow_menu_new(struct expo **expp); ++int bootflow_menu_new(struct expo **expp, const char *prompt); ++ ++/** ++ * bootflow_menu_show_countdown() - Show countdown timer for auto-boot ++ * ++ * Returns the value of expo_render() ++ */ ++int bootflow_menu_show_countdown(struct expo *exp, char *prompt, ++ char bootflow_delay); + + /** + * bootflow_menu_apply_theme() - Apply a theme to a bootmenu +-- +2.39.5 + diff --git a/config/module/u-boot/default/patches/0007-Libreboot-branding-version-on-the-bootflow-menu.patch b/config/module/u-boot/default/patches/0007-Libreboot-branding-version-on-the-bootflow-menu.patch new file mode 100644 index 00000000..ec033187 --- /dev/null +++ b/config/module/u-boot/default/patches/0007-Libreboot-branding-version-on-the-bootflow-menu.patch @@ -0,0 +1,213 @@ +From 4ff0f509aa28eb8e85f1c0c9929c63996c646bb8 Mon Sep 17 00:00:00 2001 +From: Leah Rowe <info@minifree.org> +Date: Wed, 4 Dec 2024 18:20:19 +0000 +Subject: [PATCH 1/1] Libreboot branding/version on the bootflow menu + +Signed-off-by: Leah Rowe <info@minifree.org> +--- + boot/bootflow_menu.c | 2 +- + drivers/video/u_boot_logo.bmp | Bin 6932 -> 27350 bytes + 2 files changed, 1 insertion(+), 1 deletion(-) + +diff --git a/boot/bootflow_menu.c b/boot/bootflow_menu.c +index 84831915a2..8e26ec2aef 100644 +--- a/boot/bootflow_menu.c ++++ b/boot/bootflow_menu.c +@@ -59,7 +59,7 @@ int bootflow_menu_new(struct expo **expp, const char *prompt) + ret = scene_menu(scn, "main", OBJ_MENU, &menu); + ret |= scene_obj_set_pos(scn, OBJ_MENU, MARGIN_LEFT, 100); + ret |= scene_txt_str(scn, "title", OBJ_MENU_TITLE, STR_MENU_TITLE, +- "U-Boot - Boot Menu", NULL); ++ "Libreboot 26.01 Magnanimous Max (U-Boot menu): https://libreboot.org/", NULL); + ret |= scene_menu_set_title(scn, OBJ_MENU, OBJ_PROMPT); + + logo = video_get_u_boot_logo(); +diff --git a/drivers/video/u_boot_logo.bmp b/drivers/video/u_boot_logo.bmp +index 47f1e9b99789584d2f6dd71e954b51927b35d783..bc9ae001badb25bc900058c167a47247ef91dc7c 100644 +GIT binary patch +literal 27350 +zcmeI4X;4&Wy2qdHrW-_vf~Q+fvxtH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YOZpxCk?cp^(KpG<W9;(4{hrF2Bc_hFOUm%?`X<>hikLFEhh_m~ +ztdjJgT@K0p!#%bB6k5Ri^kIxtx0?YYJXFzs#zf;gc}3E$LwnLqDYD<kAusr*z<bB8 +zgNL@Rdh+g(T$Q>}c;RW*iaf)^CVOrm>`!AqVv^@3^pvpbW5s+&-y*je4c&6rL_@|0 +zlsQeAstKMO7yB`+T+WGU9OqHDFe{!k-it{6N~S;JxzSN>H#4UB*2gc6)bJ2<h`Q<d +zD%l{pscM?WJiC3Jd6aPz?5pUJ%)I%`%#Z)rb6X@$lcSuyh86dI(H=1FoHiwEG2R6$ +zm}UKXsD6rSlMi{`m5@3(+;i)t9u~=9mZ&7v+C%kMmYE{zO|ON>N#Vw=x*w^~EOV}? +z`s^&vog;GpNY9=BS=xNW@?%wJ?R$O_ZqWK;r}3^3fE~t5MIh3Q*N`Bj7_Te?u+{TI +zBwDi38i*~z{|rJfHW@Eo!ARu#)VrE`4NNfJ?S^2T@jf^dYm8UO5X2cTnS4{#Vnw}* +z-h-Z3*4}s5`>>EG>Ls@Kbv6tOjMv)U*V_?zUes%DIA)7_-|c<#<twn(^9szDVQq?x +wA@94_V)cG3+BniCF!%phCa^V`EuNoDjq0U&Do6FaK0m2mbu}=?pJWRCZ}IWH!~g&Q + +-- +2.39.5 + diff --git a/config/module/u-boot/default/patches/0008-u-boot-fix-build-error-on-newer-hostcc.patch b/config/module/u-boot/default/patches/0008-u-boot-fix-build-error-on-newer-hostcc.patch new file mode 100644 index 00000000..8ddf398c --- /dev/null +++ b/config/module/u-boot/default/patches/0008-u-boot-fix-build-error-on-newer-hostcc.patch @@ -0,0 +1,50 @@ +From d28edbe090d1d239530618a9142c5fee2705855f Mon Sep 17 00:00:00 2001 +From: Leah Rowe <leah@libreboot.org> +Date: Wed, 1 Apr 2026 07:39:07 +0100 +Subject: [PATCH 1/1] u-boot: fix build error on newer hostcc + +because... they changed a flag. + +because they're gnu. this fixes building +u-boot x86 on arch linux. + +Signed-off-by: Leah Rowe <leah@libreboot.org> +--- + arch/sandbox/config.mk | 4 ++-- + arch/x86/config.mk | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk +index dd9b7473fa9..d64dde93575 100644 +--- a/arch/sandbox/config.mk ++++ b/arch/sandbox/config.mk +@@ -50,10 +50,10 @@ cmd_u-boot-spl = (cd $(obj) && \ + + ifeq ($(HOST_ARCH),$(HOST_ARCH_X86_64)) + EFI_LDS := ${SRCDIR}/../../../arch/x86/lib/elf_x86_64_efi.lds +-EFI_TARGET := --target=efi-app-x86_64 ++EFI_TARGET := --output-target=efi-app-x86_64 + else ifeq ($(HOST_ARCH),$(HOST_ARCH_X86)) + EFI_LDS := ${SRCDIR}/../../../arch/x86/lib/elf_ia32_efi.lds +-EFI_TARGET := --target=efi-app-ia32 ++EFI_TARGET := --output-target=efi-app-ia32 + else ifeq ($(HOST_ARCH),$(HOST_ARCH_AARCH64)) + EFI_LDS := ${SRCDIR}/../../../arch/arm/lib/elf_aarch64_efi.lds + OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .data \ +diff --git a/arch/x86/config.mk b/arch/x86/config.mk +index 6d4839dfb38..878fd126243 100644 +--- a/arch/x86/config.mk ++++ b/arch/x86/config.mk +@@ -127,7 +127,7 @@ endif + endif + + ifdef CONFIG_X86_64 +-EFI_TARGET := --target=efi-app-x86_64 ++EFI_TARGET := --output-target=efi-app-x86_64 + else +-EFI_TARGET := --target=efi-app-ia32 ++EFI_TARGET := --output-target=efi-app-ia32 + endif +-- +2.47.3 + diff --git a/config/module/u-boot/default/target.cfg b/config/module/u-boot/default/target.cfg new file mode 100644 index 00000000..3fcb54b7 --- /dev/null +++ b/config/module/u-boot/default/target.cfg @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +rev="34820924edbc4ec7803eb89d9852f4b870fa760a" # v2025.04 + +tree="default" + +xgcctree="default" +fetch_depend="coreboot/default" |
