Boot logo supplied by the device tree
Subsystems (6)
v3 cover Boot logo supplied by the device tree
Embedded products routinely need their own boot logo. Today that means pointing CONFIG_LOGO_LINUX_CLUT224_FILE at a different image, which bakes it into the kernel image. Two products that share a board support package but differ in branding therefore need two kernel builds, and rebranding an existing product means rebuilding and requalifying a kernel for what is purely a cosmetic change.
This series lets the logo be described by the device tree instead: a node compatible with "boot-logo-clut224" under /chosen supplies the image in the same paletted format the built-in CLUT224 logos already use, and the kernel prefers it over the built-in ones when it is present and enabled. If the node is absent or disabled, nothing changes.
The image can come from the node itself (patches 2-3) or from a reserved memory region the bootloader filled in (patches 5-6), because the image and its placement are independent axes of variation. One board sold to several customers wants several device trees differing in the logo. One customer with several products built on that board, with different panels, wants the same logo placed differently on each: there the image belongs in a shared binary and only the placement belongs in the device tree.
Patch 1 is a cleanup that stands on its own. fb_prepare_logo() works out how many rows to keep clear for the logo and fb_show_logo_line() works out where to draw it, and both open code the same decision; nothing makes them agree, even though fbcon erases whatever falls outside the rows that were reserved. It gives the position a structure of its own, in linux_logo.h, with -1 on an axis meaning centre on that axis, so that fb_center_logo becomes a value rather than a second code path and both callers share one calculation. No functional change. The device tree placement in patch 4 then only fills the same structure in from the node, which is parsed in logo.c next to the image that comes from it, so that everything that knows the binding lives in one place and the frame buffer code only asks for the result.
We have been carrying a cruder version of this downstream on an AM335x product since 2020, across a handful of board revisions, and it has removed a real maintenance burden for us.
Where this fits
---------------
There are already ways to get a picture on the screen early, and this does not replace any of them. A bootloader splash handed over through a simple-framebuffer node is the earliest of all. A userspace splash is the most flexible, and is what most systems end up using. What neither covers is the case where nothing initialises the display before the kernel does.
That case is not exotic. U-Boot's SPL can boot the kernel directly, and display initialisation lives in U-Boot proper, which then never runs:
there is no splash to hand over and nothing for a simple-framebuffer node to point at. Falcon mode exists to cut boot time, which is the same reason one cares about how early the logo appears, so the two tend to arrive together. Userspace is far too late to fill that gap: on the board I tested, the kernel has the panel up at 3.2 seconds.
Rob Herring asked in v2 why a simple-framebuffer handover would not do, and I answered that it did not work on our hardware. That was wrong, and I am correcting it here: the node I had measured it with was incomplete, and with a complete one it does work. What it does not do is help where there is no splash to hand over in the first place, and it does not survive the native driver.
simplefb registers fb0 at 1.79 seconds with the bootloader's image; tilcdc initialises at 3.16 seconds, registers its own fb1 and reprograms the controller to scan that buffer, which starts empty, so the screen goes black. Nothing is evicted and nothing is cleared: the two frame buffers coexist, and cat /dev/fb0 > /dev/fb1 brings the picture straight back. It is only that nobody does it, and by the time anything could, userspace is already up, which is the moment a splash was there to cover. With simpledrm it does not even survive in memory, since it hands its clients shmem buffers and blits them onto the firmware framebuffer, so the first frame any client commits overwrites what the bootloader drew. A logo the kernel draws itself has none of this: there is nothing to carry across.
Notes on the binding
--------------------
- The compatible has no "linux," prefix. Rob asked why it was Linux specific, and nothing in the node is: it describes an image and where it goes, which any consumer can read. A bootloader drawing the same logo before the kernel starts is the obvious other one. The 224 is the palette limit of the format, which is what lets the kernel use the image the way it already uses its built-in logos, without converting it.
- The palette size is derived from the length of the "clut" property instead of being a separate property, so it cannot disagree with the palette actually supplied.
- "data" holds plain palette indices. The 32 entry offset the frame buffer layer reserves for the console is an implementation detail and is applied by the kernel.
- "logo-position" takes -1 on an axis to mean centre on that axis, which is what fb_center_logo already meant. A boolean could only centre both axes or neither, and next to explicit coordinates it would have to override them silently.
- "logo-rotation" turns the logo, not the screen. "logo-position" and "logo-offset" are screen pixels whatever the rotation says, and a quarter turn only changes how much room the logo takes up.
- "logo-position" and "logo-offset" are spelled with the prefix because plain "position" and "offset" are already used elsewhere in the tree with an incompatible type, which dtschema rejects.
- The reserved memory path takes a "memory-region" phandle rather than a bare address. The reservation is what makes the memory safe to read at all, and it is what gives the kernel a size to bounds check against.
The byte arrays are not written by hand: patch 7 adds ppmtodtlogo, a host tool along the lines of the existing pnmtologo -- plain C, no dependencies, no quantization of its own -- that turns a PPM image into the node or into the memory region blob. It is what produced everything tested below.
Until chosen.yaml knows about the node, dtbs_check rejects it on any board that uses it: it allows only ^framebuffer under /chosen. I sent that one line change as dt-schema pull request 204, and Rob closed it saying he expects it is either not needed or will change, given this discussion. That seems like the right order to me, so I am not asking for it again
here: once the shape of the binding is settled, the schema change follows from it, and I will send it then.
On a system that has DRM but no frame buffer device, nothing draws the logo at all: fbcon is what draws it today, and without it there is no consumer. Showing it there needs an in-kernel DRM client, which I have working on top of this series and will send separately. I mention it because it is the reason the node is parsed in logo.c rather than in fb_logo.c: the same node then puts the logo on the same pixel whichever of the two draws it, rotated or not, which I checked on the same board.
Testing: built for arm with CONFIG_LOGO_DT_CLUT224 both enabled and disabled, and each of the seven patches builds on its own, with the option enabled from the patch that introduces it. Also built for x86_64 with CONFIG_OF=n, where nothing is left unresolved and the placement data is dropped from the image, and for powerpc Cell -- where SPU_BASE makes CONFIG_FB_LOGO_EXTRA real -- to a linked vmlinux. No compiler warnings, W=1 clean on the files touched, checkpatch --strict clean apart from the MAINTAINERS reminder for the new tool, which the existing drivers/video/ entry already covers. A full dt_binding_check has one complaint for this binding and none other in the whole tree: the chosen.yaml rejection described above.
Boot tested under qemu-system-arm -M versatilepb with PL111 and fbcon, at 16bpp, over a 26 case matrix: absolute positions, per axis centring, all four corners, offsets including negative ones, out of range values, the three rotations, and each rotation combined with an offset and with an absolute position, each compared pixel by pixel against the source image rotated to match. A position out of range on both axes is clamped to the corner, and the console text then overwrites the rows below what fbcon reserved. Supplying the same image through a reserved region instead produces an identical logo area. Blobs with a bad magic, a geometry larger than the reservation and an out of range pixel are each rejected with a warning, with no logo drawn and no crash.
Also boot tested on real hardware: an AM335x board (tilcdc) with an 800x480 panel at 16bpp. The product logo comes up where the node asks, both carried in the device tree and taken from a bootloader-loaded reserved memory region, and the two produce a frame buffer that is identical byte for byte. Dumping /dev/fb0 and comparing it against the source image, the logo lands on exactly the pixel the binding predicts:
16836 of 16836 pixels match, and one pixel of displacement in any direction drops that to about 90%. With logo-rotation = "ccw" it lands on the rotated position the same way, every pixel.
Changes since v2:
- Rebased onto current mainline (v7.3-rc3).
- Dropped the "linux," prefix from the compatible, and renamed the binding to match, per Rob.
- A rotation asked for by the device tree now turns the logo and not the
screen: "logo-position" and "logo-offset" stay in screen pixels, and a quarter turn only changes how much room the logo takes up. v2 fed the device tree rotation into the path fbcon uses for a rotated console, which places the logo in the console's own frame and maps the result back, so a vertical offset came out horizontal on a screen that was not rotated. Found by testing it on the panel. fb_rotate_logo() is split into the part that turns the image and the part that moves the placement, and the console path is unchanged.
- The placement properties are read in logo.c, next to the image, and the frame buffer code only asks for the result, so that the binding is parsed in a single place.
- Added patch 1, which pulls the logo position out into something both fb_prepare_logo() and fb_show_logo_line() share, after Helge pointed out that the placement patch was stamped in rather than merged with the existing code. That turned up a real bug: the reservation took the larger of the console position and the device tree one while the drawing took only the device tree one.
- IS_ENABLED() instead of #ifdef, per Helge, so the code is compile checked whatever the configuration.
- The device tree is read once, from fb_prepare_logo(), rather than from every accessor.
- Dropped "logo-centered" for -1 in "logo-position", per Helge.
- The position and offset are added in 64 bits and both are bounded in the binding; in int, a large pair from the device tree wrapped instead of landing against an edge.
- The copy of the image is no longer freed from a late initcall, which ran before async_synchronize_full() and so could pull it out from under a display driver still probing. Pixels are allocated with kvmalloc().
- The example declares compatible and model on the root node, and the binding no longer requires the image properties unconditionally, which made the reserved memory form unreachable. Both found by Rob's bot.
- Extra logos are not drawn when the device tree supplied the logo; they stack up from an arbitrary point once it has been placed.
Max Pedraza (7):
fbdev: describe where the boot logo goes in one place
dt-bindings: display: add a device tree supplied boot logo
video: logo: allow the boot logo to come from the device tree
fbdev: honour the device tree boot logo placement properties
dt-bindings: display: allow the boot logo in a reserved memory region
video: logo: allow the boot logo to come from a reserved memory region
video: logo: add ppmtodtlogo host tool
.../bindings/display/boot-logo-clut224.yaml | 161 +++++++ MAINTAINERS | 1 + drivers/video/fbdev/core/fb_logo.c | 221 ++++++++-- drivers/video/logo/Kconfig | 12 + drivers/video/logo/Makefile | 6 +- drivers/video/logo/logo.c | 332 +++++++++++++- drivers/video/logo/ppmtodtlogo.c | 416 ++++++++++++++++++ include/linux/linux_logo.h | 59 +++ 8 files changed, 1170 insertions(+), 38 deletions(-) create mode 100644 Documentation/devicetree/bindings/display/boot-logo-clut224.yaml create mode 100644 drivers/video/logo/ppmtodtlogo.c
Signature · 1 line
2.39.5
PATCH v3 1/7 fbdev: describe where the boot logo goes in one place
fb_prepare_logo() works out how many rows to keep clear for the logo and fb_show_logo_line() works out where to draw it, and both of them open code the same decision: centred if fb_center_logo, top left otherwise. The two calculations have to agree, because fbcon erases whatever falls outside the rows that were reserved, and nothing makes them.
Give the position a small structure of its own, with -1 on an axis meaning centre on that axis, and have both callers ask for it. fb_center_logo becomes {-1, -1} rather than a second path, and the arithmetic lives in one function that both use, so they cannot end up disagreeing.
The structure and logo_place_axis() go in linux_logo.h rather than in the frame buffer code, since where a logo goes is a property of the logo, not of the one thing that draws it today.
logo_place_axis() also clamps, which the open coded version did not: the result is now always a position at which the logo lies entirely on screen. That is not reachable today, since the only positions are the two the console offers, but it stops being something the next caller has to remember.
No functional change intended.
--- drivers/video/fbdev/core/fb_logo.c | 58 +++++++++++++++++++----------- include/linux/linux_logo.h | 29 +++++++++++++++ 2 files changed, 67 insertions(+), 20 deletions(-)
drivers/video/fbdev/core/fb_logo.c +38 -20
@@ -8,6 +8,17 @@bool fb_center_logo__read_mostly ;int fb_logo_count__read_mostly =-1 ; +/* +* The placement in effect, as asked for on the console command line. +*/ +static const struct logo_placement *fb_logo_placement (void ) +{ +static const struct logo_placement centred = { .x =-1 , .y =-1 }; +static const struct logo_placement top_left = { }; + +return fb_center_logo ? ¢red : &top_left; +} +static inline unsigned int safe_shift (unsigned int d,int n) {return n <0 ? d >> -n : d << n;
@@ -281,7 +292,11 @@ static int fb_show_logo_line(struct fb_info *info, int rotate, {u32 *palette =NULL , *saved_pseudo_palette =NULL ;unsigned char *logo_new =NULL , *logo_rotate =NULL ; +const struct logo_placement *p; +unsigned int xres = info->var.xres; +unsigned int yres = info->var.yres;struct fb_image image; +unsigned int block;/* Return if the frame buffer is not mapped or suspended */ if (logo == NULL || info->state != FBINFO_STATE_RUNNING ||
@@ -322,26 +337,22 @@ static int fb_show_logo_line(struct fb_info *info, int rotate,fb_set_logo (info, logo, logo_new, fb_logo.depth); } -if (fb_center_logo) { -int xres = info->var.xres; -int yres = info->var.yres; + image.width = logo->width; + image.height = logo->height; -if (rotate ==FB_ROTATE_CW || rotate ==FB_ROTATE_CCW ) { - xres = info->var.yres; - yres = info->var.xres; - } +if (rotate ==FB_ROTATE_CW || rotate ==FB_ROTATE_CCW ) +swap (xres, yres); -while (n && (n * (logo->width +8 ) -8 > xres)) - --n; - image.dx = (xres - (n * (logo->width +8 ) -8 )) /2 ; - image.dy = y ?: (yres - logo->height) /2 ; - }else { - image.dx =0 ; - image.dy = y; - } +while (n && (n * (logo->width +8 ) -8 > xres)) + --n; - image.width = logo->width; - image.height = logo->height; +/* The copies are drawn in a row, so they are centred as one block */ + block = n ? n * (logo->width +8 ) -8 : logo->width; + + p =fb_logo_placement (); + image.dx =logo_place_axis (p->x, xres, block); +/* A stacked logo goes where the caller put it */ + image.dy = y ? y :logo_place_axis (p->y, yres, image.height);if (rotate) { logo_rotate = kmalloc_array(logo->width, logo->height,
@@ -418,6 +429,7 @@ static int fb_show_extra_logos(struct fb_info *info, int y, int rotate)int fb_prepare_logo (struct fb_info *info,int rotate) {int depth =fb_get_color_depth (&info->var, &info->fix); +const struct logo_placement *p;unsigned int yres;int height;
@@ -480,9 +492,15 @@ int fb_prepare_logo(struct fb_info *info, int rotate) } } - height = fb_logo.logo->height; -if (fb_center_logo) - height += (yres - fb_logo.logo->height) /2 ; +/* +* fbcon only leaves the first @height rows of the screen alone, so a +* logo placed further down would be drawn and then immediately +* cleared. Ask the same placement fb_show_logo_line() will use, so +* that the two cannot disagree. +*/ + p =fb_logo_placement (); + height =logo_place_axis (p->y, yres, fb_logo.logo->height) + + fb_logo.logo->height;#ifdef CONFIG_FB_LOGO_EXTRA height =fb_prepare_extra_logos (info, height, yres);#endif
include/linux/linux_logo.h +29 -0
@@ -13,6 +13,8 @@*/ #include <linux/init.h> +#include <linux/minmax.h> +#include <linux/types.h> #define LINUX_LOGO_MONO 1/* monochrome black/white */
@@ -36,6 +38,33 @@ extern const struct linux_logo logo_linux_clut224;extern const struct linux_logo logo_spe_clut224;extern const struct linux_logo *fb_find_logo (int depth); + +/* +* Where a boot logo goes. A coordinate of -1 centres the logo on that axis. +* Whatever draws the logo describes its placement this way and computes it +* with logo_place_axis(), so that no two places can end up disagreeing about +* where the logo is. +*/ +struct logo_placement { +s32 x, y; +}; + +/* +* Place a logo along one axis. @pos is the coordinate asked for, or -1 to +* centre on that axis. The result is clamped so that the logo always lies +* entirely within the screen: the drawing code does not clip, so asking for +* more than that would otherwise scribble past the end of the frame buffer. +*/ +static inline int logo_place_axis (s32 pos,unsigned int span,unsigned int size) +{ +int last = (int )span - (int )size; + +if (size > span) +return 0 ; + +return pos ==-1 ? last /2 :clamp (pos,0 , last); +} +#ifdef CONFIG_FB_LOGO_EXTRA extern void fb_append_extra_logo (const struct linux_logo *logo,unsigned int n);
Signature · 1 line
2.39.5
Thomas Zimmermann
maintainerRe: [PATCH v3 1/7] fbdev: describe where the boot logo goes in one place
Hi
Am 23.09.26 um 22:10 schrieb Max Pedraza:
Quoted 6 lines
fb_prepare_logo()works out how many rows to keep clear for the logo andfb_show_logo_line()works out where to draw it, and both of them open code the same decision: centred iffb_center_logo, top left otherwise. The two calculations have to agree, because fbcon erases whatever falls outside the rows that were reserved, and nothing makes them.
Quoted 8 lines
Give the position a small structure of its own, with -1 on an axis meaning centre on that axis, and have both callers ask for it.
fb_center_logobecomes {-1, -1} rather than a second path, and the arithmetic lives in one function that both use, so they cannot end up disagreeing.The structure and
logo_place_axis()go inlinux_logo.hrather than in the frame buffer code, since where a logo goes is a property of the logo, not of the one thing that draws it today.
No, the position is not a property of the logo. The code in linux_logo.h is only about the image itself.
In the case of fbdev, the policy for drawin the the image should be part of fbcon.
Best regards
Thomas
Quoted 163 lines
logo_place_axis()also clamps, which the open coded version did not: the result is now always a position at which the logo lies entirely on screen. That is not reachable today, since the only positions are the two the console offers, but it stops being something the next caller has to remember.No functional change intended.
Signed-off-by Max Pedraza <[email protected]>--- drivers/video/fbdev/core/fb_logo.c | 58 +++++++++++++++++++----------- include/linux/linux_logo.h | 29 +++++++++++++++ 2 files changed, 67 insertions(+), 20 deletions(-)drivers/video/fbdev/core/fb_logo.c +38
-20@@ -8,6 +8,17 @@bool fb_center_logo__read_mostly ;int fb_logo_count__read_mostly =-1 ; +/* +* The placement in effect, as asked for on the console command line. +*/ +static const struct logo_placement *fb_logo_placement (void ) +{ +static const struct logo_placement centred = { .x =-1 , .y =-1 }; +static const struct logo_placement top_left = { }; + +return fb_center_logo ? ¢red : &top_left; +} +static inline unsigned int safe_shift (unsigned int d,int n) {return n <0 ? d >> -n : d << n;@@ -281,7 +292,11 @@ static int fb_show_logo_line(struct fb_info *info, int rotate, {u32 *palette =NULL , *saved_pseudo_palette =NULL ;unsigned char *logo_new =NULL , *logo_rotate =NULL ; +const struct logo_placement *p; +unsigned int xres = info->var.xres; +unsigned int yres = info->var.yres;struct fb_image image; +unsigned int block;/* Return if the frame buffer is not mapped or suspended */ if (logo == NULL || info->state != FBINFO_STATE_RUNNING ||@@ -322,26 +337,22 @@ static int fb_show_logo_line(struct fb_info *info, int rotate,fb_set_logo (info, logo, logo_new, fb_logo.depth); } -if (fb_center_logo) { -int xres = info->var.xres; -int yres = info->var.yres; + image.width = logo->width; + image.height = logo->height; -if (rotate ==FB_ROTATE_CW || rotate ==FB_ROTATE_CCW ) { - xres = info->var.yres; - yres = info->var.xres; - } +if (rotate ==FB_ROTATE_CW || rotate ==FB_ROTATE_CCW ) +swap (xres, yres); -while (n && (n * (logo->width +8 ) -8 > xres)) - --n; - image.dx = (xres - (n * (logo->width +8 ) -8 )) /2 ; - image.dy = y ?: (yres - logo->height) /2 ; - }else { - image.dx =0 ; - image.dy = y; - } +while (n && (n * (logo->width +8 ) -8 > xres)) + --n; - image.width = logo->width; - image.height = logo->height; +/* The copies are drawn in a row, so they are centred as one block */ + block = n ? n * (logo->width +8 ) -8 : logo->width; + + p =fb_logo_placement (); + image.dx =logo_place_axis (p->x, xres, block); +/* A stacked logo goes where the caller put it */ + image.dy = y ? y :logo_place_axis (p->y, yres, image.height);if (rotate) { logo_rotate = kmalloc_array(logo->width, logo->height,@@ -418,6 +429,7 @@ static int fb_show_extra_logos(struct fb_info *info, int y, int rotate)int fb_prepare_logo (struct fb_info *info,int rotate) {int depth =fb_get_color_depth (&info->var, &info->fix); +const struct logo_placement *p;unsigned int yres;int height;@@ -480,9 +492,15 @@ int fb_prepare_logo(struct fb_info *info, int rotate) } } - height = fb_logo.logo->height; -if (fb_center_logo) - height += (yres - fb_logo.logo->height) /2 ; +/* +* fbcon only leaves the first @height rows of the screen alone, so a +* logo placed further down would be drawn and then immediately +* cleared. Ask the same placement fb_show_logo_line() will use, so +* that the two cannot disagree. +*/ + p =fb_logo_placement (); + height =logo_place_axis (p->y, yres, fb_logo.logo->height) + + fb_logo.logo->height;#ifdef CONFIG_FB_LOGO_EXTRA height =fb_prepare_extra_logos (info, height, yres);#endif include/linux/linux_logo.h +29
-0@@ -13,6 +13,8 @@*/ #include <linux/init.h> +#include <linux/minmax.h> +#include <linux/types.h> #define LINUX_LOGO_MONO 1/* monochrome black/white */ @@ -36,6 +38,33 @@ extern const struct linux_logo logo_linux_clut224;extern const struct linux_logo logo_spe_clut224;extern const struct linux_logo *fb_find_logo (int depth); + +/* +* Where a boot logo goes. A coordinate of -1 centres the logo on that axis. +* Whatever draws the logo describes its placement this way and computes it +* with logo_place_axis(), so that no two places can end up disagreeing about +* where the logo is. +*/ +struct logo_placement { +s32 x, y; +}; + +/* +* Place a logo along one axis. @pos is the coordinate asked for, or -1 to +* centre on that axis. The result is clamped so that the logo always lies +* entirely within the screen: the drawing code does not clip, so asking for +* more than that would otherwise scribble past the end of the frame buffer. +*/ +static inline int logo_place_axis (s32 pos,unsigned int span,unsigned int size) +{ +int last = (int )span - (int )size; + +if (size > span) +return 0 ; + +return pos ==-1 ? last /2 :clamp (pos,0 , last); +} +#ifdef CONFIG_FB_LOGO_EXTRA extern void fb_append_extra_logo (const struct linux_logo *logo,unsigned int n);
Signature · 6 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)
PATCH v3 2/7 dt-bindings: display: add a device tree supplied boot logo
In reply to Max PedrazaEmbedded products frequently need a product specific boot logo. Today that means pointing CONFIG_LOGO_LINUX_CLUT224_FILE at a different image, which bakes it into the kernel image: a change of branding, or a second product sharing the same board support package, requires a separate kernel build, and requalifying that kernel for what is a cosmetic change.
Add a binding for a "boot-logo-clut224" node, which carries the logo in the same paletted format the built-in CLUT224 logos already use, plus a few optional properties describing where on the screen it is drawn.
The node lives under /chosen because a logo is configuration handed over by firmware rather than a description of the hardware. Open Firmware, which the device tree descends from, carried a boot logo in the same spirit as the oem-logo variable under /options, and simple-framebuffer nodes live under /chosen today for the same reason.
The palette size is derived from the length of the "clut" property rather than spelled out separately, and "data" holds plain palette indices; the 32 entry offset the frame buffer layer reserves for the console is an implementation detail and is applied by the kernel, not by the binding.
"logo-position" takes -1 on an axis to mean centre on that axis rather than carrying a separate boolean for it. A boolean can only centre both axes or neither, and next to explicit coordinates it would have to override them silently when a device tree gave both.
A rotation turns the logo, not the screen. "logo-position" and "logo-offset" are screen pixels whatever "logo-rotation" says, and a quarter turn only changes how much room the logo takes up. Placing the logo in a frame that turns with it would make the same pair of coordinates mean different places on the same panel, decided by a property that is meant to describe the image.
Every coordinate is bounded. The kernel clamps them anyway, since it cannot trust a device tree, but a value that cannot possibly be meant is worth catching in dtbs_check rather than on the panel.
--- .../bindings/display/boot-logo-clut224.yaml | 135 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 136 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/boot-logo-clut224.yaml
Documentation/devicetree/bindings/display/boot-logo-clut224.yaml new file +135 -0
@@ -0,0 +1,135 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/boot-logo-clut224.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Boot logo supplied by the device tree + +maintainers: + - Max Pedraza <[email protected]> + +description: | + Embedded systems commonly need a product specific boot logo. Today that + means pointing CONFIG_LOGO_LINUX_CLUT224_FILE at a different image, which + bakes it into the kernel image: changing the logo means building and + deploying a new kernel. + + This node lets the boot logo be described by the device tree instead, so that + a single kernel image can serve several products, or several revisions of the + same product, that only differ in branding. + + Since a logo is configuration rather than a description of the hardware, the + node lives under /chosen, next to the other things firmware hands to the + operating system. Open Firmware, which the device tree descends from, carried + a boot logo in the same spirit as the oem-logo variable under /options. + + The image is stored in the same paletted format the in-kernel CLUT224 logos + use: a palette of at most 224 RGB entries plus one palette index per pixel. + +properties: + $nodename: + const: logo + + compatible: + const: boot-logo-clut224 + + width: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Logo width in pixels. + minimum: 1 + maximum: 65535 + + height: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Logo height in pixels. + minimum: 1 + maximum: 65535 + + clut: + $ref: /schemas/types.yaml#/definitions/uint8-array + description: + Colour lookup table, as consecutive red, green and blue bytes per entry. + The number of entries is derived from the property length and must not + exceed 224. + minItems: 3 + maxItems: 672 + + data: + $ref: /schemas/types.yaml#/definitions/uint8-array + description: + One byte per pixel, left to right and top to bottom, each byte being an + index into the colour lookup table. The property length must be equal to + width multiplied by height. + + logo-position: + $ref: /schemas/types.yaml#/definitions/int32-array + description: + X and Y coordinates, in pixels, of the top left corner of the logo. + A value of -1 on an axis centres the logo on that axis instead. + Defaults to the top left corner of the screen. + items: + - description: X coordinate, or -1 to centre horizontally + minimum: -1 + maximum: 65535 + - description: Y coordinate, or -1 to centre vertically + minimum: -1 + maximum: 65535 + + logo-offset: + $ref: /schemas/types.yaml#/definitions/int32-array + description: + X and Y displacement, in screen pixels, applied after the logo has been + placed. + Mostly useful together with a centred axis, to land the logo somewhere + other than the middle of a panel whose usable area is not its centre. + items: + - description: X displacement + minimum: -65535 + maximum: 65535 + - description: Y displacement + minimum: -65535 + maximum: 65535 + + logo-rotation: + $ref: /schemas/types.yaml#/definitions/string + description: + Rotation applied to the logo before it is drawn. It turns the logo and + not the screen, so a quarter turn swaps how much room the logo takes + up, but logo-position and logo-offset stay in screen pixels either + way. + enum: [none, cw, ccw, ud] + default: none + +required: + - compatible + - width + - height + - clut + - data + +additionalProperties: false + +examples: + - | + // A 4x2 logo using three colours, centred on both axes. + / { + compatible = "foo"; + model = "foo"; + #address-cells = <1>; + #size-cells = <1>; + + chosen { + logo { + compatible = "boot-logo-clut224"; + width = <4>; + height = <2>; + clut = /bits/ 8 <0xff 0x00 0x00 + 0x00 0xff 0x00 + 0x00 0x00 0xff>; + data = /bits/ 8 <0x00 0x01 0x01 0x00 + 0x02 0x00 0x00 0x02>; + logo-position = <(-1) (-1)>; + }; + }; + };
MAINTAINERS +1 -0
@@ -10339,6 +10339,7 @@ L: [email protected] S: Maintained Q: http://patchwork.kernel.org/project/linux-fbdev/list/ T: git git://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev.git +F: Documentation/devicetree/bindings/display/boot-logo-clut224.yaml F: Documentation/fb/ F: drivers/video/ F: include/linux/fb.h
Signature · 1 line
2.39.5
[email protected]
AI reviewRe: [PATCH v3 2/7] dt-bindings: display: add a device tree supplied boot logo
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] dt-bindings: embedding raw image payloads in DT violates design principles - [Low] dt-bindings…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] dt-bindings: embedding raw image payloads in DT violates design principles
- [Low] dt-bindings: logo-rotation uses non-standard string enum instead of integer --
commit 7c49827223c484baa96e766e2d19b7e319290579
Author: Max Pedraza <[email protected]>
dt-bindings: display: add a device tree supplied boot logo
This commit introduces a device tree binding for providing a boot logo from firmware, placing a "boot-logo-clut224" node under /chosen. It defines properties for dimensions, color lookup table, image data, positioning, and rotation.
Quoted 6 lines
Documentation/devicetree/bindings/display/boot-logo-clut224.yaml new file +0
-0@@ -0,0 +1,135 @@
[ ... ]
Quoted 5 lines
Documentation/devicetree/bindings/display/boot-logo-clut224.yaml new file +5
-0+ clut: + $ref: /schemas/types.yaml#/definitions/uint8-array + description: + Colour lookup table, as consecutive red, green and blue bytes per entry. + The number of entries is derived from the property length and must not
Documentation/devicetree/bindings/display/boot-logo-clut224.yaml line 63
Quoted 10 lines
Documentation/devicetree/bindings/display/boot-logo-clut224.yaml new file +10
-0+ exceed 224. + minItems: 3 + maxItems: 672 + + data: + $ref: /schemas/types.yaml#/definitions/uint8-array + description: + One byte per pixel, left to right and top to bottom, each byte being an + index into the colour lookup table. The property length must be equal to + width multiplied by height.
[Severity: Medium]
Does this code introduce a regression by allowing large binary payloads to be embedded directly in the device tree?
The Device Tree is intended for hardware description and minimal configuration, not for delivering large binary files. Embedding an uncompressed image directly via the 'data' property can permanently waste un-reclaimable kernel memory, as the unflattened DT remains in memory indefinitely. It also risks exceeding bootloader DTB size limits.
While follow-up work might provide a 'memory-region' alternative, the schema still explicitly permits and supports embedding the binary payload directly via this property.
[ ... ]
Quoted 14 lines
Documentation/devicetree/bindings/display/boot-logo-clut224.yaml new file +14
-0+ logo-offset: + $ref: /schemas/types.yaml#/definitions/int32-array + description: + X and Y displacement, in screen pixels, applied after the logo has been + placed. + Mostly useful together with a centred axis, to land the logo somewhere + other than the middle of a panel whose usable area is not its centre. + items: + - description: X displacement + minimum: -65535 + maximum: 65535 + - description: Y displacement + minimum: -65535 + maximum: 65535
Documentation/devicetree/bindings/display/boot-logo-clut224.yaml line 102
Quoted 10 lines
Documentation/devicetree/bindings/display/boot-logo-clut224.yaml new file +10
-0+ + logo-rotation: + $ref: /schemas/types.yaml#/definitions/string + description: + Rotation applied to the logo before it is drawn. It turns the logo and + not the screen, so a quarter turn swaps how much room the logo takes + up, but logo-position and logo-offset stay in screen pixels either + way. + enum: [none, cw, ccw, ud] + default: none
[Severity: Low]
Is this non-standard string enum a regression from established device tree conventions?
Using a custom string enum ('none', 'cw', 'ccw', 'ud') violates the established convention for rotation. Existing bindings like panel-common.yaml and video-interface-devices.yaml dictate using a standard integer 'rotation' property with degree values (0, 90, 180, 270). This custom format fragments parsing logic in drivers.
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Rob Herring (Arm)
maintainerRe: [PATCH v3 2/7] dt-bindings: display: add a device tree supplied boot logo
In reply to Max PedrazaQuoted 37 lines · Max Pedraza
Embedded products frequently need a product specific boot logo. Today that means pointing
CONFIG_LOGO_LINUX_CLUT224_FILEat a different image, which bakes it into the kernel image: a change of branding, or a second product sharing the same board support package, requires a separate kernel build, and requalifying that kernel for what is a cosmetic change.Add a binding for a "boot-logo-clut224" node, which carries the logo in the same paletted format the built-in CLUT224 logos already use, plus a few optional properties describing where on the screen it is drawn.
The node lives under /chosen because a logo is configuration handed over by firmware rather than a description of the hardware. Open Firmware, which the device tree descends from, carried a boot logo in the same spirit as the oem-logo variable under /options, and simple-framebuffer nodes live under /chosen today for the same reason.
The palette size is derived from the length of the "clut" property rather than spelled out separately, and "data" holds plain palette indices; the 32 entry offset the frame buffer layer reserves for the console is an implementation detail and is applied by the kernel, not by the binding.
"logo-position" takes -1 on an axis to mean centre on that axis rather than carrying a separate boolean for it. A boolean can only centre both axes or neither, and next to explicit coordinates it would have to override them silently when a device tree gave both.
A rotation turns the logo, not the screen. "logo-position" and "logo-offset" are screen pixels whatever "logo-rotation" says, and a quarter turn only changes how much room the logo takes up. Placing the logo in a frame that turns with it would make the same pair of coordinates mean different places on the same panel, decided by a property that is meant to describe the image.
Every coordinate is bounded. The kernel clamps them anyway, since it cannot trust a device tree, but a value that cannot possibly be meant is worth catching in
dtbs_checkrather than on the panel.
Quoted 7 lines
Signed-off-by Max Pedraza <[email protected]>--- .../bindings/display/boot-logo-clut224.yaml | 135 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 136 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/boot-logo-clut224.yaml
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:Documentation/devicetree/bindings/display/boot-logo-clut224.example.dtb: chosen: 'logo' does not match any of the regexes: '^framebuffer', '^pinctrl-[0-9]+$'
from schema $id: http://devicetree.org/schemas/chosen.yaml
doc reference errors (make refcheckdocs):
See https://patchwork.kernel.org/project/devicetree/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
Re: [PATCH v3 2/7] dt-bindings: display: add a device tree supplied boot logo
Hi Rob,
Quoted 2 lines
Documentation/devicetree/bindings/display/boot-logo-clut224.example.dtb: chosen: 'logo' does not match any of the regexes: '^framebuffer', '^pinctrl-[0-9]+$' from schema $id: http://devicetree.org/schemas/chosen.yaml
Expected: chosen.yaml only allows framebuffer nodes under /chosen. You closed pull request 204 until the binding settles, so I will send a new one for the node as it ends up.
Quoted 1 line
The base for the series is generally the latest rc1.
Noted.
The binding is going to change, though. Thomas asked for the logo to go through the DRM splash client [1] rather than fbdev [2], and that client takes BMP images. Before reworking it, would a BMP in a property be acceptable to you:
chosen {
logo {
compatible = "boot-logo";
image = /incbin/("logo.bmp");
logo-position = <(-1) (-1)>;
};
};
with memory-region as the alternative to image, exactly one of the two, or would you rather have the pixels described the way simple-framebuffer does, with width, height, stride and format? The BMP keeps the kernel side small, since the client already parses BMP headers, and the header gives it a size to check against the property length. The raw form is closer to what DT already describes, at the cost of a second drawing path in the client.
[1] https://lore.kernel.org/dri-devel/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
Max
Quoted 73 lines · Rob Herring (Arm)
Quoted 37 lines · Max Pedraza
Embedded products frequently need a product specific boot logo. Today that means pointing
CONFIG_LOGO_LINUX_CLUT224_FILEat a different image, which bakes it into the kernel image: a change of branding, or a second product sharing the same board support package, requires a separate kernel build, and requalifying that kernel for what is a cosmetic change.Add a binding for a "boot-logo-clut224" node, which carries the logo in the same paletted format the built-in CLUT224 logos already use, plus a few optional properties describing where on the screen it is drawn.
The node lives under /chosen because a logo is configuration handed over by firmware rather than a description of the hardware. Open Firmware, which the device tree descends from, carried a boot logo in the same spirit as the oem-logo variable under /options, and simple-framebuffer nodes live under /chosen today for the same reason.
The palette size is derived from the length of the "clut" property rather than spelled out separately, and "data" holds plain palette indices; the 32 entry offset the frame buffer layer reserves for the console is an implementation detail and is applied by the kernel, not by the binding.
"logo-position" takes -1 on an axis to mean centre on that axis rather than carrying a separate boolean for it. A boolean can only centre both axes or neither, and next to explicit coordinates it would have to override them silently when a device tree gave both.
A rotation turns the logo, not the screen. "logo-position" and "logo-offset" are screen pixels whatever "logo-rotation" says, and a quarter turn only changes how much room the logo takes up. Placing the logo in a frame that turns with it would make the same pair of coordinates mean different places on the same panel, decided by a property that is meant to describe the image.
Every coordinate is bounded. The kernel clamps them anyway, since it cannot trust a device tree, but a value that cannot possibly be meant is worth catching in
dtbs_checkrather than on the panel.Quoted 7 lines
Signed-off-by Max Pedraza <[email protected]>--- .../bindings/display/boot-logo-clut224.yaml | 135 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 136 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/boot-logo-clut224.yamlMy bot found errors running 'make
dt_binding_check' on your patch:yamllint warnings/errors:
dtschema/dtc warnings/errors:
Documentation/devicetree/bindings/display/boot-logo-clut224.example.dtb: chosen: 'logo' does not match any of the regexes: '^framebuffer', '^pinctrl-[0-9]+$'
from schema $id: http://devicetree.org/schemas/chosen.yamldoc reference errors (make refcheckdocs):
See https://patchwork.kernel.org/project/devicetree/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make
dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that
DT_SCHEMA_FILEScan be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
PATCH v3 3/7 video: logo: allow the boot logo to come from the device tree
In reply to Max PedrazaAdd CONFIG_LOGO_DT_CLUT224, which makes fb_find_logo() look for a node compatible with "boot-logo-clut224" under /chosen before falling back to the logos built into the kernel image.
The image is validated before it is used: the palette must have at most 224 entries, the pixel data length must match the geometry, and every pixel must reference an entry that exists. A malformed node is reported and ignored rather than drawn, so a bad device tree cannot take the display down with it.
The image is copied out of the device tree so that the 32 entry offset the frame buffer layer reserves for the console can be applied to the pixels. The pixels are allocated with kvmalloc(), since a full screen image is larger than kmalloc() will comfortably serve.
Unlike the built-in logos the copy is never freed. Those are initdata and go away in free_initmem(), which runs after async_synchronize_full(); anything this code could hook into runs before that, so releasing the image here would pull it out from under a display driver whose probe is still in flight. It is a modest allocation and it lives as long as the device tree it came from, which also means fb_find_logo() can still hand it out after the built-in logos are gone.
The node lives under /chosen because a logo is configuration handed over by firmware rather than a description of the hardware, which is also where simple-framebuffer nodes live for the same reason.
The lookup is guarded with IS_ENABLED() rather than wrapped in an #ifdef, so that the code is compile checked whatever the configuration and the compiler drops it when the option is off. Built for x86_64 with CONFIG_OF=n the object is left with no unresolved of_* symbol and none of the data.
--- drivers/video/logo/Kconfig | 12 +++ drivers/video/logo/logo.c | 154 ++++++++++++++++++++++++++++++++++++- include/linux/linux_logo.h | 3 + 3 files changed, 168 insertions(+), 1 deletion(-)
drivers/video/logo/Kconfig +12 -0
@@ -76,4 +76,16 @@ config LOGO_LINUX_CLUT224_FILE magick source_image -compress none -colors 224 destination.ppm +config LOGO_DT_CLUT224 + bool "224-color logo supplied by the device tree" + depends on OF + help + Look for a boot logo in the device tree, in a node compatible with + "boot-logo-clut224" under /chosen, instead of using one of + the logos built into the kernel image. This allows a single kernel + image to be used by several products that only differ in branding. + + If no such node is present, or it is disabled, the built-in logo + selected above is used, so saying Y here is safe. + endif # LOGO
drivers/video/logo/logo.c +153 -1
172 lines not on this page · raw message
include/linux/linux_logo.h +3 -0
@@ -22,6 +22,9 @@#define LINUX_LOGO_CLUT224 3/* 224 colors */ #define LINUX_LOGO_GRAY256 4/* 256 levels grayscale */ +/* Compatible of the /chosen child describing a device tree supplied logo */ +#define LOGO_DT_COMPATIBLE "boot-logo-clut224" +struct linux_logo {int type;/* one of LINUX_LOGO_* */
Signature · 1 line
2.39.5
PATCH v3 4/7 fbdev: honour the device tree boot logo placement properties
In reply to Max PedrazaA logo supplied by the device tree describes a specific product, so where it lands on the panel matters in a way it does not for the built-in Tux. Fill in the placement added earlier from the optional "logo-position", "logo-offset" and "logo-rotation" properties of the "boot-logo-clut224" node, so that it takes the place of what the console command line would otherwise have asked for.
"logo-position" gives the top left corner, with -1 on an axis meaning centre on that axis, which is what fb_center_logo already meant. "logo-offset" is added afterwards, and is the reason the offset joins the structure here. Centring and then displacing is what panels with a partially visible area need, where the usable region is not the centre of the mode, and it is the only way to express it when the image comes from a reserved memory region and the device tree therefore does not know the logo size. Both come straight from the device tree, so the sum is done in 64 bits and clamped, and a silly pair of values lands the logo against an edge rather than off the screen.
The properties are read by logo_dt_placement(), in logo.c next to the parser of the image that comes from the same node, so that everything that knows the binding lives in one place. The frame buffer code only asks for the result.
The rotation values match FB_ROTATE_*, but they do not mean what a rotated console means. fbcon turns the screen, so it looks at the panel sideways, places the logo in the console's own frame and maps the result back. A rotation asked for by the device tree turns the logo alone, on a screen that stays where it is, so the placement stays in screen pixels and only the room the logo takes up changes. fb_rotate_logo() is split into the part that turns the image and the part that moves the placement, and a device tree rotation uses only the former.
A logo placed by the device tree is drawn once rather than once per CPU:
the device tree names one position, and repeating the image from there would either overlap the copies or walk them off the reserved region.
For the same reason the extra logos appended by fb_append_extra_logo() are not drawn when the device tree supplied the logo. They stack up from wherever the previous logo ended, which is an arbitrary point once the device tree has placed the first one, so the two do not compose. Only PowerPC Cell appends any, and a message is printed if there was anything to drop. The space fb_prepare_extra_logos() reserves for them is left alone, so that combination keeps a gap it no longer fills.
The node is read once, from fb_prepare_logo(), since fb_show_logo() is only ever reached after that has run. The read is guarded with IS_ENABLED() rather than an #ifdef so that the code is compile checked whatever the configuration, and optimised away when the option is off.
A node whose image is rejected still has its placement honoured, so a malformed node yields the built-in logo drawn where the device tree asked for it.
--- drivers/video/fbdev/core/fb_logo.c | 189 ++++++++++++++++++++++++----- drivers/video/logo/logo.c | 78 ++++++++++++ include/linux/linux_logo.h | 45 +++++-- 3 files changed, 274 insertions(+), 38 deletions(-)
drivers/video/fbdev/core/fb_logo.c +160 -29
@@ -9,13 +9,72 @@ bool fb_center_logo __read_mostly;int fb_logo_count__read_mostly =-1 ;/* -* The placement in effect, as asked for on the console command line. +* Placement of a logo supplied by the device tree. Both the image and its +* placement are parsed by drivers/video/logo/logo.c, here we only keep a copy +* of where it goes. +*/ +static struct { +struct logo_placement pos; +bool valid; +int rotation;/* LOGO_ROTATE_* (== FB_ROTATE_*), or -1 */ +} fb_logo_dt; + +/* +* Read the placement out of the device tree. Called once, from +* fb_prepare_logo(): fb_show_logo() is only ever reached after that has run, +* so everything below can just look at fb_logo_dt. +*/ +static void fb_logo_dt_read (void ) +{ +static bool read_done; + +/* +* logo_dt_placement() checks the option too, but it lives in another +* translation unit, so without the check here the compiler would have +* to keep fb_logo_dt around for a call that can only fail. +*/ +if (!IS_ENABLED (CONFIG_LOGO_DT_CLUT224 ) || read_done) +return ; + + fb_logo_dt.valid = !logo_dt_placement (&fb_logo_dt.pos, + &fb_logo_dt.rotation); +/* Last, so that nothing can observe a half filled in placement */ + read_done = true; +} + +/* +* A rotation asked for by the device tree turns the logo, not the screen, so +* it is placed in screen pixels. A rotated console turns the screen, and the +* logo is placed in the console's own frame. Telling the two apart is what +* this is for. +*/ +static bool fb_logo_dt_rotated (void ) +{ +return IS_ENABLED (CONFIG_LOGO_DT_CLUT224 ) && fb_logo_dt.valid && + fb_logo_dt.rotation >=0 ; +} + +static int fb_logo_dt_rotation (int rotate) +{ +if (fb_logo_dt_rotated ()) +return fb_logo_dt.rotation; + +return rotate; +} + +/* +* The placement in effect: what the device tree asked for if it supplied a +* logo, otherwise what the console command line asked for. fb_prepare_logo() +* has already called fb_logo_dt_read() by the time anything gets here. */ static const struct logo_placement *fb_logo_placement (void ) {static const struct logo_placement centred = { .x =-1 , .y =-1 };static const struct logo_placement top_left = { }; +if (IS_ENABLED (CONFIG_LOGO_DT_CLUT224 ) && fb_logo_dt.valid) +return &fb_logo_dt.pos; +return fb_center_logo ? ¢red : &top_left; }
@@ -218,35 +277,45 @@ static void fb_rotate_logo_ccw(const u8 *in, u8 *out, u32 width, u32 height) out[height * (w - j) + i] = *in++; } -static void fb_rotate_logo (struct fb_info *info,u8 *dst, -struct fb_image *image,int rotate) +/* Turn the image itself, leaving @image->dx and @image->dy alone */ +static void fb_rotate_logo_image (u8 *dst,struct fb_image *image,int rotate) { -u32 tmp; -if (rotate ==FB_ROTATE_UD ) {fb_rotate_logo_ud (image->data, dst, image->width, image->height); - image->dx = info->var.xres - image->width - image->dx; - image->dy = info->var.yres - image->height - image->dy; }else if (rotate ==FB_ROTATE_CW ) {fb_rotate_logo_cw (image->data, dst, image->width, image->height);swap (image->width, image->height); - tmp = image->dy; - image->dy = image->dx; - image->dx = info->var.xres - image->width - tmp; }else if (rotate ==FB_ROTATE_CCW ) {fb_rotate_logo_ccw (image->data, dst, image->width, image->height);swap (image->width, image->height); - tmp = image->dx; - image->dx = image->dy; - image->dy = info->var.yres - image->height - tmp; } image->data = dst; } +/* As above, and map the placement from the console's frame to the screen */ +static void fb_rotate_logo (struct fb_info *info,u8 *dst, +struct fb_image *image,int rotate) +{ +u32 tmp = rotate ==FB_ROTATE_CW ? image->dy : image->dx; + +fb_rotate_logo_image (dst, image, rotate); + +if (rotate ==FB_ROTATE_UD ) { + image->dx = info->var.xres - image->width - image->dx; + image->dy = info->var.yres - image->height - image->dy; + }else if (rotate ==FB_ROTATE_CW ) { + image->dy = image->dx; + image->dx = info->var.xres - image->width - tmp; + }else if (rotate ==FB_ROTATE_CCW ) { + image->dx = image->dy; + image->dy = info->var.yres - image->height - tmp; + } +} +static void fb_do_show_logo (struct fb_info *info,struct fb_image *image,int rotate,unsigned int num) {
@@ -295,6 +364,8 @@ static int fb_show_logo_line(struct fb_info *info, int rotate,const struct logo_placement *p;unsigned int xres = info->var.xres;unsigned int yres = info->var.yres; +bool dt_rotated =fb_logo_dt_rotated (); +unsigned int fw, fh;struct fb_image image;unsigned int block;
@@ -340,28 +411,60 @@ static int fb_show_logo_line(struct fb_info *info, int rotate, image.width = logo->width; image.height = logo->height; -if (rotate ==FB_ROTATE_CW || rotate ==FB_ROTATE_CCW ) -swap (xres, yres); +/* How much of the screen the logo covers once it has been turned */ + fw = image.width; + fh = image.height; +if (rotate ==FB_ROTATE_CW || rotate ==FB_ROTATE_CCW ) { +swap (fw, fh); +/* A turned console is looked at sideways, a turned logo is not */ +if (!dt_rotated) +swap (xres, yres); + } -while (n && (n * (logo->width +8 ) -8 > xres)) - --n; +if (IS_ENABLED (CONFIG_LOGO_DT_CLUT224 ) && fb_logo_dt.valid) { +/* +* The device tree asks for the logo at one place, so draw it +* once. Repeating it per CPU would either overlap the copies +* or walk them out of the region reserved for the logo. +*/ + n =1 ; + }else { +while (n && (n * (logo->width +8 ) -8 > xres)) + --n; + }/* The copies are drawn in a row, so they are centred as one block */ block = n ? n * (logo->width +8 ) -8 : logo->width; p =fb_logo_placement (); - image.dx =logo_place_axis (p->x, xres, block); -/* A stacked logo goes where the caller put it */ - image.dy = y ? y :logo_place_axis (p->y, yres, image.height); +if (dt_rotated) { +/* +* The device tree names a place on the screen, so the logo is +* placed by the room it takes up there and drawn as it lies. +*/ + image.dx =logo_place_axis (p->x, p->offset_x, xres, fw); + image.dy =logo_place_axis (p->y, p->offset_y, yres, fh); + }else { + image.dx =logo_place_axis (p->x, p->offset_x, xres, block); +/* A stacked logo goes where the caller put it */ + image.dy = y ? y :logo_place_axis (p->y, p->offset_y, yres, + image.height); + }if (rotate) { logo_rotate =kmalloc_array (logo->width, logo->height,GFP_KERNEL ); -if (logo_rotate) -fb_rotate_logo (info, logo_rotate, &image, rotate); +if (logo_rotate) { +if (dt_rotated) +fb_rotate_logo_image (logo_rotate, &image, + rotate); +else +fb_rotate_logo (info, logo_rotate, &image, + rotate); + } } -fb_do_show_logo (info, &image, rotate, n); +fb_do_show_logo (info, &image, dt_rotated ?FB_ROTATE_UR : rotate, n);kfree (palette);if (saved_pseudo_palette !=NULL )
@@ -414,10 +517,23 @@ static int fb_prepare_extra_logos(struct fb_info *info, unsigned int height,return height; } +/* +* A logo supplied by the device tree is placed where the device tree asks, +* and the extra logos stack up from wherever the previous one ended. Those +* two do not compose: the stack would start at an arbitrary point and walk +* off the screen. The device tree wins, and says so if anything is dropped. +*/ static int fb_show_extra_logos (struct fb_info *info,int y,int rotate) {unsigned int i; +if (IS_ENABLED (CONFIG_LOGO_DT_CLUT224 ) && fb_logo_dt.valid) { +if (fb_logo_ex_num) +pr_info ("fb: device tree logo in use, %u extra logo(s) not drawn\n" , + fb_logo_ex_num); +return y; + } +for (i =0 ; i < fb_logo_ex_num; i++) y =fb_show_logo_line (info, rotate, fb_logo_ex[i].logo, y, fb_logo_ex[i].n);
@@ -430,11 +546,14 @@ int fb_prepare_logo(struct fb_info *info, int rotate) {int depth =fb_get_color_depth (&info->var, &info->fix);const struct logo_placement *p; -unsigned int yres; +unsigned int yres, fh;int height;memset (&fb_logo,0 ,sizeof (struct logo_data )); +fb_logo_dt_read (); + rotate =fb_logo_dt_rotation (rotate); +if (info->flags &FBINFO_MISC_TILEBLITTING || info->fbops->owner || !fb_logo_count)return 0 ;
@@ -458,12 +577,23 @@ int fb_prepare_logo(struct fb_info *info, int rotate)if (!fb_logo.logo)return 0 ; -if (rotate ==FB_ROTATE_UR || rotate ==FB_ROTATE_UD ) +/* +* A turned console is looked at sideways, so the logo is measured +* against the console's own frame. A logo turned by the device tree +* leaves the screen alone, and only covers a different part of it. +*/ + fh = fb_logo.logo->height; +if (fb_logo_dt_rotated ()) { yres = info->var.yres; -else +if (rotate ==FB_ROTATE_CW || rotate ==FB_ROTATE_CCW ) + fh = fb_logo.logo->width; + }else if (rotate ==FB_ROTATE_UR || rotate ==FB_ROTATE_UD ) { + yres = info->var.yres; + }else { yres = info->var.xres; + } -if (fb_logo.logo->height > yres) { +if (fh > yres) { fb_logo.logo =NULL ;return 0 ; }
@@ -499,8 +629,7 @@ int fb_prepare_logo(struct fb_info *info, int rotate)* that the two cannot disagree. */ p =fb_logo_placement (); - height =logo_place_axis (p->y, yres, fb_logo.logo->height) + - fb_logo.logo->height; + height =logo_place_axis (p->y, p->offset_y, yres, fh) + fh;#ifdef CONFIG_FB_LOGO_EXTRA height =fb_prepare_extra_logos (info, height, yres);#endif
@@ -516,6 +645,8 @@ int fb_show_logo(struct fb_info *info, int rotate)if (!fb_logo_count)return 0 ; + rotate =fb_logo_dt_rotation (rotate); + count = fb_logo_count <0 ?num_online_cpus () : fb_logo_count; y =fb_show_logo_line (info, rotate, fb_logo.logo,0 , count);#ifdef CONFIG_FB_LOGO_EXTRA
drivers/video/logo/logo.c +78 -0
84 lines not on this page · raw message
include/linux/linux_logo.h +36 -9
71 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH v3 5/7 dt-bindings: display: allow the boot logo in a reserved memory region
In reply to Max PedrazaCarrying the image in the device tree ties it to the device tree, but the image and where it goes on screen are independent axes of variation. One board sold to several customers wants several device trees that differ in the logo; one customer with several products built on that board wants the same logo placed differently on each panel. The second case would otherwise mean duplicating the same image into every device tree.
Let the node point at a reserved memory region filled in by the bootloader instead, so one image can be shared by device trees that differ only in placement. The region starts with a small header carrying a magic number and the geometry, so the kernel can tell a logo from an empty or stale region and bounds check everything against the reservation.
A phandle to a declared region is used rather than a bare address: the reservation is what makes the memory safe to read and what gives the kernel a size to validate against.
The two ways of supplying the image are mutually exclusive, which is what the oneOf introduced here says. Until now the image properties were simply required, since they were the only way to supply one.
--- .../bindings/display/boot-logo-clut224.yaml | 40 +++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/display/boot-logo-clut224.yaml +33 -7
@@ -62,12 +62,31 @@ properties: index into the colour lookup table. The property length must be equal to width multiplied by height. + memory-region: + maxItems: 1 + description: | + Reserved memory region holding the logo, as an alternative to carrying + it in the width, height, clut and data properties. The bootloader is + expected to have placed the image there before starting the kernel. + + This lets one image be shared by several device trees that differ only + in where the logo goes, which is what a family of products built on the + same board but with different panels needs. + + The region starts with a header of four little endian 32 bit words: + the magic number 0x4f474f4c ("LOGO"), the width, the height and the + number of palette entries. The palette follows, as consecutive red, + green and blue bytes per entry, and then one byte per pixel, each an + index into that palette. + logo-position: $ref: /schemas/types.yaml#/definitions/int32-array description: - X and Y coordinates, in pixels, of the top left corner of the logo. - A value of -1 on an axis centres the logo on that axis instead. - Defaults to the top left corner of the screen. + X and Y coordinates, in screen pixels, of the top left corner of the + logo once it has been rotated. A value of -1 on an axis centres the + logo on that axis instead, which is the only way to say it when the + logo size is not known to the device tree, as is the case for the + memory-region form. Defaults to the top left corner of the screen. items: - description: X coordinate, or -1 to centre horizontally minimum: -1
@@ -103,10 +122,17 @@ properties: required: - compatible - - width - - height - - clut - - data + +# The image either lives in the device tree or in a reserved memory region, +# never both. +oneOf: + - required: + - width + - height + - clut + - data + - required: + - memory-region additionalProperties: false
Signature · 1 line
2.39.5
[email protected]
AI reviewRe: [PATCH v3 5/7] dt-bindings: display: allow the boot logo in a reserved memory region
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] dt-bindings: oneOf allows partial image properties with memory-region --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] dt-bindings: oneOf allows partial image properties with memory-region --
commit 9a7a18d6778dd2101e7f626e61f0b37dcf103451
Author: Max Pedraza <[email protected]>
Subject: dt-bindings: display: allow the boot logo in a reserved memory region
This commit allows the boot logo to be specified via a reserved memory region instead of inline properties, enabling the image to be shared across multiple device trees. It introduces a oneOf constraint intended to make the two methods mutually exclusive.
Quoted 4 lines
Documentation/devicetree/bindings/display/boot-logo-clut224.yaml +0
-0
[ ... ]
Quoted 9 lines
Documentation/devicetree/bindings/display/boot-logo-clut224.yaml +1
-4@@ -103,10 +122,17 @@ properties: required: - compatible - - width - - height - - clut - - data +
Documentation/devicetree/bindings/display/boot-logo-clut224.yaml properties: · line 135
Quoted 10 lines
Documentation/devicetree/bindings/display/boot-logo-clut224.yaml +10
-0+# The image either lives in the device tree or in a reserved memory region, +# never both. +oneOf: + - required: + - width + - height + - clut + - data + - required: + - memory-region
[Severity: Low]
Does this schema validation fully enforce the intended mutual exclusivity if partial image properties are provided?
If a device tree includes memory-region alongside just a few of the image properties (for example, accidentally including width and height but not clut), the first branch of the oneOf evaluates to false. The second branch evaluates to true.
Since exactly one branch is true, the overall oneOf constraint succeeds. This allows invalid device trees with overlapping configurations to silently pass dt_binding_check.
Should the schema explicitly disallow the other properties when memory-region is present to prevent this?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
PATCH v3 6/7 video: logo: allow the boot logo to come from a reserved memory region
In reply to Max PedrazaTake the image from the region a "memory-region" phandle points at, when the node has one, instead of from the width, height, clut and data properties.
Only a declared region is accepted, never a bare physical address. That matters for more than tidiness: the region is reserved before the allocator starts, so the logo code can never be pointed at memory the kernel is using for something else, and a size is known, so every field can be bounds checked. The region is mapped with memremap(), which copes with a no-map reservation and fails cleanly instead of handing back a bogus pointer the way phys_to_virt() on an arbitrary address would.
The image is validated and copied out rather than used in place: the magic number has to match, the geometry has to be sane, the palette and pixels have to fit inside the reserved region, and every pixel has to reference an existing palette entry. Anything else is reported and ignored, falling back to the built-in logo. Copying also means nothing that happens to the region afterwards can affect what has already been validated, and it keeps the pixel data in the same shape both paths produce.
--- drivers/video/logo/logo.c | 176 ++++++++++++++++++++++++++++++-------- 1 file changed, 138 insertions(+), 38 deletions(-)
drivers/video/logo/logo.c +138 -38
@@ -10,8 +10,10 @@* Copyright (C) 2003 Geert Uytterhoeven <[email protected]> */ +#include <linux/io.h> #include <linux/linux_logo.h> #include <linux/of.h> +#include <linux/of_reserved_mem.h> #include <linux/sizes.h> #include <linux/slab.h> #include <linux/stddef.h>
@@ -38,9 +40,19 @@ MODULE_PARM_DESC(nologo, "Disables startup logo");/* * Sanity limit on the image size, a device tree is not a good place for more: * a 4K screen is 8.3M pixels, and the copy is kept for the life of the kernel. -* One byte per pixel, so this is a byte count as well. +* One byte per pixel, so this is a byte count as well. Keep in step with +* MAX_PIXELS in ppmtodtlogo. */ #define LOGO_DT_MAX_PIXELS SZ_16M +/* "LOGO", little endian, at the start of a handed over memory region */ +#define LOGO_DT_MAGIC 0x4f474f4c + +struct logo_dt_header { +__le32 magic; +__le32 width; +__le32 height; +__le32 clutsize; +};static struct linux_logo logo_dt_clut224 = { .type =LINUX_LOGO_CLUT224 ,
@@ -49,59 +61,42 @@ static struct linux_logo logo_dt_clut224 = {static unsigned char *logo_dt_clut;static unsigned char *logo_dt_data; -static int logo_dt_parse (struct device_node *np) +/* Reject geometries that cannot describe a sane image before using them */ +static int logo_dt_check_geometry (u32 width,u32 height,u32 clutsize) { -unsigned int clutsize, npixels, i; -unsigned char *clut, *data; -u32 width, height; -int len, ret; - - ret =of_property_read_u32 (np,"width" , &width); -if (ret) -return ret; - - ret =of_property_read_u32 (np,"height" , &height); -if (ret) -return ret; -if (!width || !height || (u64 )width * height >LOGO_DT_MAX_PIXELS )return -EINVAL ; - npixels = width * height; - - len =of_property_count_u8_elems (np,"clut" ); -if (len <3 || len %3 ) +if (!clutsize || clutsize >LOGO_DT_MAX_CLUT )return -EINVAL ; - clutsize = len /3 ; -if (clutsize >LOGO_DT_MAX_CLUT ) -return -EINVAL ; +return 0 ; +} - ret =of_property_count_u8_elems (np,"data" ); -if (ret <0 ) -return ret; -if ((unsigned int )ret != npixels) -return -EINVAL ; +/* +* Take a private copy of an image that has already been range checked, so +* that nothing else can change it under us, and shift the pixels into the +* palette slots the frame buffer layer leaves to the logo. +*/ +static int logo_dt_store (u32 width,u32 height,u32 clutsize, +const u8 *clut_src,const u8 *data_src) +{ +unsigned int npixels = width * height; +unsigned char *clut, *data; +unsigned int i; +int ret; - clut =kmalloc (len,GFP_KERNEL ); +/* The palette is at most 672 bytes, the pixels can be megabytes */ + clut =kmemdup (clut_src, clutsize *3 ,GFP_KERNEL );if (!clut)return -ENOMEM ; -/* The palette is at most 672 bytes, the pixels can be megabytes */ - data =kvmalloc (npixels,GFP_KERNEL ); + data =kvmemdup (data_src, npixels,GFP_KERNEL );if (!data) { ret = -ENOMEM ; goto err_free_clut; } - ret =of_property_read_u8_array (np,"clut" , clut, len); -if (ret) - goto err_free_data; - - ret =of_property_read_u8_array (np,"data" , data, npixels); -if (ret) - goto err_free_data; -for (i =0 ; i < npixels; i++) {if (data[i] >= clutsize) { ret = -ERANGE ;
@@ -128,6 +123,111 @@ static int logo_dt_parse(struct device_node *np)return ret; } +static int logo_dt_parse_properties (struct device_node *np) +{ +const u8 *clut, *data; +u32 width, height; +int len, ret; + + ret =of_property_read_u32 (np,"width" , &width); +if (ret) +return ret; + + ret =of_property_read_u32 (np,"height" , &height); +if (ret) +return ret; + + len =of_property_count_u8_elems (np,"clut" ); +if (len <3 || len %3 ) +return -EINVAL ; + + ret =logo_dt_check_geometry (width, height, len /3 ); +if (ret) +return ret; + +if (of_property_count_u8_elems (np,"data" ) != width * height) +return -EINVAL ; + + clut =of_get_property (np,"clut" ,NULL ); + data =of_get_property (np,"data" ,NULL ); +if (!clut || !data) +return -EINVAL ; + +return logo_dt_store (width, height, len /3 , clut, data); +} + +/* +* Image handed over by the bootloader in a reserved memory region. Only a +* region the device tree declared is accepted, never a bare address, so the +* kernel can never be pointed at memory it is using for something else, and +* so that a size is known and every access can be bounds checked. +*/ +static int logo_dt_parse_memory_region (struct device_node *np) +{ +u32 width, height, clutsize; +const struct logo_dt_header *hdr; +struct device_node *mem_np; +struct reserved_mem *rmem; +size_t clutlen, datalen; +const u8 *payload; +void *mem; +int ret; + + mem_np =of_parse_phandle (np,"memory-region" ,0 ); +if (!mem_np) +return -ENOENT ; + + rmem =of_reserved_mem_lookup (mem_np); +of_node_put (mem_np); +if (!rmem) +return -EINVAL ; + +if (rmem->size <sizeof (*hdr)) +return -EINVAL ; + + mem =memremap (rmem->base, rmem->size,MEMREMAP_WB ); +if (!mem) +return -ENOMEM ; + + hdr = mem; +if (le32_to_cpu (hdr->magic) !=LOGO_DT_MAGIC ) { + ret = -EINVAL ; + goto out_unmap; + } + + width =le32_to_cpu (hdr->width); + height =le32_to_cpu (hdr->height); + clutsize =le32_to_cpu (hdr->clutsize); + + ret =logo_dt_check_geometry (width, height, clutsize); +if (ret) + goto out_unmap; + + clutlen = (size_t )clutsize *3 ; + datalen = (size_t )width * height; + +/* Everything the header promises has to fit inside the region */ +if (sizeof (*hdr) + clutlen + datalen > rmem->size) { + ret = -EINVAL ; + goto out_unmap; + } + + payload = (const u8 *)(hdr +1 ); + ret =logo_dt_store (width, height, clutsize, payload, payload + clutlen); + +out_unmap: +memunmap (mem); +return ret; +} + +static int logo_dt_parse (struct device_node *np) +{ +if (of_property_present (np,"memory-region" )) +return logo_dt_parse_memory_region (np); + +return logo_dt_parse_properties (np); +} +static const struct linux_logo *logo_dt_find (void ) {static bool probed;
Signature · 1 line
2.39.5
PATCH v3 7/7 video: logo: add ppmtodtlogo host tool
In reply to Max PedrazaThe byte arrays a "boot-logo-clut224" node carries are not meant to be written by hand. Add a host tool that converts a PPM image into the node, along the lines of the existing pnmtologo: plain C, no dependencies, and no quantization of its own -- the image must already use at most 224 distinct colours, and the tool points at ImageMagick when it does not.
Three output flavours:
ppmtodtlogo logo.ppm a complete overlay ppmtodtlogo -t dtsi logo.ppm a bare node, for inclusion ppmtodtlogo -t bin -o logo.bin ... the blob for a reserved memory
region, header included
The devicetree outputs also carry the optional placement properties, commented out unless requested on the command line, so the generated file documents what can be tuned without regenerating the image.
The tool is built when CONFIG_LOGO_DT_CLUT224 is enabled but is not used by the kernel build itself.
--- drivers/video/logo/Makefile | 6 +- drivers/video/logo/ppmtodtlogo.c | 416 +++++++++++++++++++++++++++++++ 2 files changed, 421 insertions(+), 1 deletion(-) create mode 100644 drivers/video/logo/ppmtodtlogo.c
drivers/video/logo/Makefile +5 -1
@@ -10,7 +10,11 @@ obj-$(CONFIG_SPU_BASE) += logo_spe_clut224.o # How to generate logo's -hostprogs := pnmtologo +hostprogs := pnmtologo ppmtodtlogo + +# Not used by the build itself: converts a user's image into the devicetree +# node or memory blob the "boot-logo-clut224" binding consumes. +always-$(CONFIG_LOGO_DT_CLUT224) += ppmtodtlogo # Create commands like "pnmtologo -t mono -n logo_linux_mono -o ..." quiet_cmd_logo = LOGO $@
drivers/video/logo/ppmtodtlogo.c new file +416 -0
416 lines not on this page · raw message
Signature · 1 line
2.39.5
[email protected]
AI reviewRe: [PATCH v3 7/7] video: logo: add ppmtodtlogo host tool
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] ppmtodtlogo: silent output corruption due to unchecked file writes --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] ppmtodtlogo: silent output corruption due to unchecked file writes --
commit 4ad00a19ffae8a59e9289c4ee762366d9f29a5de
Author: Max Pedraza <[email protected]>
video: logo: add ppmtodtlogo host tool
This commit adds a host tool that converts a PPM image into a devicetree boot logo node or a binary blob for a reserved memory region.
Quoted 5 lines
drivers/video/logo/ppmtodtlogo.c new file +0
-0
[ ... ]
drivers/video/logo/ppmtodtlogo.c line 329
Quoted 8 lines
drivers/video/logo/ppmtodtlogo.c new file +8
-0+static void write_bin (void ) +{ +put_le32 (BLOB_MAGIC ); +put_le32 (logo_width); +put_le32 (logo_height); +put_le32 (logo_clutsize); +fwrite (logo_clut,3 , logo_clutsize, out); +fwrite (logo_data,1 , logo_width * logo_height, out);
[Severity: Low]
Are we missing error checks on these writes? If the tool runs under a disk-full condition or encounters another write error, it looks like it will silently produce truncated binary blobs without reporting an error or returning a non-zero exit status.
Quoted 1 line
+}
[ ... ]
Quoted 2 lines
drivers/video/logo/ppmtodtlogo.c new file +2
-0+int main (int argc,char *argv[]) +{
[ ... ]
drivers/video/logo/ppmtodtlogo.c line 410
Quoted 2 lines
drivers/video/logo/ppmtodtlogo.c new file +2
-0+if (outputname) +fclose (out);
[Severity: Low]
Could failing to check the return value here ignore buffered write failures? If a flush fails at the end of the program, it might obscure disk space issues and leave a corrupted output file while still exiting with a zero status code.
Quoted 6 lines
drivers/video/logo/ppmtodtlogo.c new file +6
-0+ +fprintf (stderr,"%s: %ux%u pixels, %u colours\n" , filename, logo_width, + logo_height, logo_clutsize); + +return 0 ; +}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
Thomas Zimmermann
maintainerHi,
the whole Linux logo on the console is somewhat gimmicky and IMHO should not be further extended. Also fbdev as a whole has realistically run its course. We fix bugs and occasionally clean up the code, but it is questionable whether new feature make much sense. Even more so as the drivers your system uses appear to be DRM ones.
There is a proposal for a DRM splash screen at [1]. It retrieves the device vendor's logo from the firmware and displays it at the given coordinates. IMHO you should start with this series and add DT support there.
Best regards
Thomas
[1] https://lore.kernel.org/dri-devel/[email protected]/
Am 23.09.26 um 22:10 schrieb Max Pedraza:
Quoted 221 lines
Embedded products routinely need their own boot logo. Today that means pointing
CONFIG_LOGO_LINUX_CLUT224_FILEat a different image, which bakes it into the kernel image. Two products that share a board support package but differ in branding therefore need two kernel builds, and rebranding an existing product means rebuilding and requalifying a kernel for what is purely a cosmetic change.This series lets the logo be described by the device tree instead: a node compatible with "boot-logo-clut224" under /chosen supplies the image in the same paletted format the built-in CLUT224 logos already use, and the kernel prefers it over the built-in ones when it is present and enabled. If the node is absent or disabled, nothing changes.
The image can come from the node itself (patches 2-3) or from a reserved memory region the bootloader filled in (patches 5-6), because the image and its placement are independent axes of variation. One board sold to several customers wants several device trees differing in the logo. One customer with several products built on that board, with different panels, wants the same logo placed differently on each: there the image belongs in a shared binary and only the placement belongs in the device tree.
Patch 1 is a cleanup that stands on its own.
fb_prepare_logo()works out how many rows to keep clear for the logo andfb_show_logo_line()works out where to draw it, and both open code the same decision; nothing makes them agree, even though fbcon erases whatever falls outside the rows that were reserved. It gives the position a structure of its own, inlinux_logo.h, with -1 on an axis meaning centre on that axis, so thatfb_center_logobecomes a value rather than a second code path and both callers share one calculation. No functional change. The device tree placement in patch 4 then only fills the same structure in from the node, which is parsed inlogo.cnext to the image that comes from it, so that everything that knows the binding lives in one place and the frame buffer code only asks for the result.We have been carrying a cruder version of this downstream on an AM335x product since 2020, across a handful of board revisions, and it has removed a real maintenance burden for us.
Where this fits
---------------There are already ways to get a picture on the screen early, and this does not replace any of them. A bootloader splash handed over through a simple-framebuffer node is the earliest of all. A userspace splash is the most flexible, and is what most systems end up using. What neither covers is the case where nothing initialises the display before the kernel does.
That case is not exotic. U-Boot's SPL can boot the kernel directly, and display initialisation lives in U-Boot proper, which then never runs:
there is no splash to hand over and nothing for a simple-framebuffer node to point at. Falcon mode exists to cut boot time, which is the same reason one cares about how early the logo appears, so the two tend to arrive together. Userspace is far too late to fill that gap: on the board I tested, the kernel has the panel up at 3.2 seconds.Rob Herring asked in v2 why a simple-framebuffer handover would not do, and I answered that it did not work on our hardware. That was wrong, and I am correcting it here: the node I had measured it with was incomplete, and with a complete one it does work. What it does not do is help where there is no splash to hand over in the first place, and it does not survive the native driver.
simplefb registers fb0 at 1.79 seconds with the bootloader's image; tilcdc initialises at 3.16 seconds, registers its own fb1 and reprograms the controller to scan that buffer, which starts empty, so the screen goes black. Nothing is evicted and nothing is cleared: the two frame buffers coexist, and cat
/dev/fb0>/dev/fb1brings the picture straight back. It is only that nobody does it, and by the time anything could, userspace is already up, which is the moment a splash was there to cover. With simpledrm it does not even survive in memory, since it hands its clients shmem buffers and blits them onto the firmware framebuffer, so the first frame any client commits overwrites what the bootloader drew. A logo the kernel draws itself has none of this: there is nothing to carry across.Notes on the binding
--------------------- The compatible has no "linux," prefix. Rob asked why it was Linux specific, and nothing in the node is: it describes an image and where it goes, which any consumer can read. A bootloader drawing the same logo before the kernel starts is the obvious other one. The 224 is the palette limit of the format, which is what lets the kernel use the image the way it already uses its built-in logos, without converting it.
- The palette size is derived from the length of the "clut" property instead of being a separate property, so it cannot disagree with the palette actually supplied.
- "data" holds plain palette indices. The 32 entry offset the frame buffer layer reserves for the console is an implementation detail and is applied by the kernel.
- "logo-position" takes -1 on an axis to mean centre on that axis, which is whatfb_center_logoalready meant. A boolean could only centre both axes or neither, and next to explicit coordinates it would have to override them silently.
- "logo-rotation" turns the logo, not the screen. "logo-position" and "logo-offset" are screen pixels whatever the rotation says, and a quarter turn only changes how much room the logo takes up.
- "logo-position" and "logo-offset" are spelled with the prefix because plain "position" and "offset" are already used elsewhere in the tree with an incompatible type, which dtschema rejects.
- The reserved memory path takes a "memory-region" phandle rather than a bare address. The reservation is what makes the memory safe to read at all, and it is what gives the kernel a size to bounds check against.The byte arrays are not written by hand: patch 7 adds ppmtodtlogo, a host tool along the lines of the existing pnmtologo -- plain C, no dependencies, no quantization of its own -- that turns a PPM image into the node or into the memory region blob. It is what produced everything tested below.
Until
chosen.yamlknows about the node,dtbs_checkrejects it on any board that uses it: it allows only ^framebuffer under /chosen. I sent that one line change as dt-schema pull request 204, and Rob closed it saying he expects it is either not needed or will change, given this discussion. That seems like the right order to me, so I am not asking for it again
here: once the shape of the binding is settled, the schema change follows from it, and I will send it then.On a system that has DRM but no frame buffer device, nothing draws the logo at all: fbcon is what draws it today, and without it there is no consumer. Showing it there needs an in-kernel DRM client, which I have working on top of this series and will send separately. I mention it because it is the reason the node is parsed in
logo.crather than infb_logo.c: the same node then puts the logo on the same pixel whichever of the two draws it, rotated or not, which I checked on the same board.Testing: built for arm with
CONFIG_LOGO_DT_CLUT224both enabled and disabled, and each of the seven patches builds on its own, with the option enabled from the patch that introduces it. Also built forx86_64withCONFIG_OF=n, where nothing is left unresolved and the placement data is dropped from the image, and for powerpc Cell -- whereSPU_BASEmakesCONFIG_FB_LOGO_EXTRAreal -- to a linked vmlinux. No compiler warnings, W=1 clean on the files touched, checkpatch --strict clean apart from theMAINTAINERSreminder for the new tool, which the existingdrivers/video/entry already covers. A fulldt_binding_checkhas one complaint for this binding and none other in the whole tree: thechosen.yamlrejection described above.Boot tested under qemu-system-arm -M versatilepb with PL111 and fbcon, at 16bpp, over a 26 case matrix: absolute positions, per axis centring, all four corners, offsets including negative ones, out of range values, the three rotations, and each rotation combined with an offset and with an absolute position, each compared pixel by pixel against the source image rotated to match. A position out of range on both axes is clamped to the corner, and the console text then overwrites the rows below what fbcon reserved. Supplying the same image through a reserved region instead produces an identical logo area. Blobs with a bad magic, a geometry larger than the reservation and an out of range pixel are each rejected with a warning, with no logo drawn and no crash.
Also boot tested on real hardware: an AM335x board (tilcdc) with an 800x480 panel at 16bpp. The product logo comes up where the node asks, both carried in the device tree and taken from a bootloader-loaded reserved memory region, and the two produce a frame buffer that is identical byte for byte. Dumping
/dev/fb0and comparing it against the source image, the logo lands on exactly the pixel the binding predicts:
16836 of 16836 pixels match, and one pixel of displacement in any direction drops that to about 90%. With logo-rotation = "ccw" it lands on the rotated position the same way, every pixel.Changes since v2:
- Rebased onto current mainline (v7.3-rc3).
- Dropped the "linux," prefix from the compatible, and renamed the binding to match, per Rob.
- A rotation asked for by the device tree now turns the logo and not the
screen: "logo-position" and "logo-offset" stay in screen pixels, and a quarter turn only changes how much room the logo takes up. v2 fed the device tree rotation into the path fbcon uses for a rotated console, which places the logo in the console's own frame and maps the result back, so a vertical offset came out horizontal on a screen that was not rotated. Found by testing it on the panel.fb_rotate_logo()is split into the part that turns the image and the part that moves the placement, and the console path is unchanged.
- The placement properties are read inlogo.c, next to the image, and the frame buffer code only asks for the result, so that the binding is parsed in a single place.
- Added patch 1, which pulls the logo position out into something bothfb_prepare_logo()andfb_show_logo_line()share, after Helge pointed out that the placement patch was stamped in rather than merged with the existing code. That turned up a real bug: the reservation took the larger of the console position and the device tree one while the drawing took only the device tree one.
-IS_ENABLED()instead of #ifdef, per Helge, so the code is compile checked whatever the configuration.
- The device tree is read once, fromfb_prepare_logo(), rather than from every accessor.
- Dropped "logo-centered" for -1 in "logo-position", per Helge.
- The position and offset are added in 64 bits and both are bounded in the binding; in int, a large pair from the device tree wrapped instead of landing against an edge.
- The copy of the image is no longer freed from a late initcall, which ran beforeasync_synchronize_full()and so could pull it out from under a display driver still probing. Pixels are allocated withkvmalloc().
- The example declares compatible and model on the root node, and the binding no longer requires the image properties unconditionally, which made the reserved memory form unreachable. Both found by Rob's bot.
- Extra logos are not drawn when the device tree supplied the logo; they stack up from an arbitrary point once it has been placed.Max Pedraza (7):
fbdev: describe where the boot logo goes in one place
dt-bindings: display: add a device tree supplied boot logo
video: logo: allow the boot logo to come from the device tree
fbdev: honour the device tree boot logo placement properties
dt-bindings: display: allow the boot logo in a reserved memory region
video: logo: allow the boot logo to come from a reserved memory region
video: logo: add ppmtodtlogo host tool.../bindings/display/boot-logo-clut224.yaml | 161 +++++++ MAINTAINERS | 1 + drivers/video/fbdev/core/fb_logo.c | 221 ++++++++-- drivers/video/logo/Kconfig | 12 + drivers/video/logo/Makefile | 6 +- drivers/video/logo/logo.c | 332 +++++++++++++- drivers/video/logo/ppmtodtlogo.c | 416 ++++++++++++++++++ include/linux/linux_logo.h | 59 +++ 8 files changed, 1170 insertions(+), 38 deletions(-)create mode 100644
Documentation/devicetree/bindings/display/boot-logo-clut224.yamlcreate mode 100644drivers/video/logo/ppmtodtlogo.c
Signature · 6 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)
Hi Thomas,
Quoted 5 lines
the whole Linux logo on the console is somewhat gimmicky and IMHO should not be further extended. Also fbdev as a whole has realistically run its course. We fix bugs and occasionally clean up the code, but it is questionable whether new feature make much sense. Even more so as the drivers your system uses appear to be DRM ones.
They are, it is tilcdc. Understood, I will drop the fbdev side, which also settles your comment on patch 1.
Quoted 4 lines
There is a proposal for a DRM splash screen at [1]. It retrieves the device vendor's logo from the firmware and displays it at the given coordinates. IMHO you should start with this series and add DT support there.
Agreed. I have been following Francesco's series since Sam pointed me at it, and it is where the DRM follow-up I mentioned in the cover letter belongs, rather than in a client of my own.
A device tree source fits next to the BGRT one. The BGRT is the firmware handing the kernel an image and where to put it, and a DT system has no such table. The BMP loaded as firmware only helps if the file is built into the kernel, or if a filesystem is already there when the display comes up. With U-Boot's Falcon mode, the device tree is the only thing that reaches the kernel.
So the plan would be a node under /chosen carrying a BMP, either in the node itself or in a reserved memory region the bootloader loaded it into, with the placement properties from this series. The region is the same memremap() the BGRT source already does, only with the address coming from the device tree.
Rotation too: the client skips a BGRT image with the orientation bits set today, and it could turn it instead. I will ask Rob separately how he wants the image described, since that is what the binding hinges on.
Francesco, is a v4 on the way? Would you take a DT source as patches on top of your series, or would you rather I wait until it lands?
Max
Quoted 253 lines · Thomas Zimmermann
Hi,
the whole Linux logo on the console is somewhat gimmicky and IMHO should not be further extended. Also fbdev as a whole has realistically run its course. We fix bugs and occasionally clean up the code, but it is questionable whether new feature make much sense. Even more so as the drivers your system uses appear to be DRM ones.
There is a proposal for a DRM splash screen at [1]. It retrieves the device vendor's logo from the firmware and displays it at the given coordinates. IMHO you should start with this series and add DT support there.
Best regards
Thomas[1]
https://lore.kernel.org/dri-devel/[email protected]/Am 23.09.26 um 22:10 schrieb Max Pedraza:
Quoted 218 lines
Embedded products routinely need their own boot logo. Today that means pointing
CONFIG_LOGO_LINUX_CLUT224_FILEat a different image, which bakes it into the kernel image. Two products that share a board support package but differ in branding therefore need two kernel builds, and rebranding an existing product means rebuilding and requalifying a kernel for what is purely a cosmetic change.This series lets the logo be described by the device tree instead: a node compatible with "boot-logo-clut224" under /chosen supplies the image in the same paletted format the built-in CLUT224 logos already use, and the kernel prefers it over the built-in ones when it is present and enabled. If the node is absent or disabled, nothing changes.
The image can come from the node itself (patches 2-3) or from a reserved memory region the bootloader filled in (patches 5-6), because the image and its placement are independent axes of variation. One board sold to several customers wants several device trees differing in the logo. One customer with several products built on that board, with different panels, wants the same logo placed differently on each: there the image belongs in a shared binary and only the placement belongs in the device tree.
Patch 1 is a cleanup that stands on its own.
fb_prepare_logo()works out how many rows to keep clear for the logo andfb_show_logo_line()works out where to draw it, and both open code the same decision; nothing makes them agree, even though fbcon erases whatever falls outside the rows that were reserved. It gives the position a structure of its own, inlinux_logo.h, with -1 on an axis meaning centre on that axis, so thatfb_center_logobecomes a value rather than a second code path and both callers share one calculation. No functional change. The device tree placement in patch 4 then only fills the same structure in from the node, which is parsed inlogo.cnext to the image that comes from it, so that everything that knows the binding lives in one place and the frame buffer code only asks for the result.We have been carrying a cruder version of this downstream on an AM335x product since 2020, across a handful of board revisions, and it has removed a real maintenance burden for us.
Where this fits
---------------There are already ways to get a picture on the screen early, and this does not replace any of them. A bootloader splash handed over through a simple-framebuffer node is the earliest of all. A userspace splash is the most flexible, and is what most systems end up using. What neither covers is the case where nothing initialises the display before the kernel does.
That case is not exotic. U-Boot's SPL can boot the kernel directly, and display initialisation lives in U-Boot proper, which then never runs:
there is no splash to hand over and nothing for a simple-framebuffer node to point at. Falcon mode exists to cut boot time, which is the same reason one cares about how early the logo appears, so the two tend to arrive together. Userspace is far too late to fill that gap: on the board I tested, the kernel has the panel up at 3.2 seconds.Rob Herring asked in v2 why a simple-framebuffer handover would not do, and I answered that it did not work on our hardware. That was wrong, and I am correcting it here: the node I had measured it with was incomplete, and with a complete one it does work. What it does not do is help where there is no splash to hand over in the first place, and it does not survive the native driver.
simplefb registers fb0 at 1.79 seconds with the bootloader's image; tilcdc initialises at 3.16 seconds, registers its own fb1 and reprograms the controller to scan that buffer, which starts empty, so the screen goes black. Nothing is evicted and nothing is cleared: the two frame buffers coexist, and cat
/dev/fb0>/dev/fb1brings the picture straight back. It is only that nobody does it, and by the time anything could, userspace is already up, which is the moment a splash was there to cover. With simpledrm it does not even survive in memory, since it hands its clients shmem buffers and blits them onto the firmware framebuffer, so the first frame any client commits overwrites what the bootloader drew. A logo the kernel draws itself has none of this: there is nothing to carry across.Notes on the binding
--------------------- The compatible has no "linux," prefix. Rob asked why it was Linux specific, and nothing in the node is: it describes an image and where it goes, which any consumer can read. A bootloader drawing the same logo before the kernel starts is the obvious other one. The 224 is the palette limit of the format, which is what lets the kernel use the image the way it already uses its built-in logos, without converting it.
- The palette size is derived from the length of the "clut" property instead of being a separate property, so it cannot disagree with the palette actually supplied.
- "data" holds plain palette indices. The 32 entry offset the frame buffer layer reserves for the console is an implementation detail and is applied by the kernel.
- "logo-position" takes -1 on an axis to mean centre on that axis, which is whatfb_center_logoalready meant. A boolean could only centre both axes or neither, and next to explicit coordinates it would have to override them silently.
- "logo-rotation" turns the logo, not the screen. "logo-position" and "logo-offset" are screen pixels whatever the rotation says, and a quarter turn only changes how much room the logo takes up.
- "logo-position" and "logo-offset" are spelled with the prefix because plain "position" and "offset" are already used elsewhere in the tree with an incompatible type, which dtschema rejects.
- The reserved memory path takes a "memory-region" phandle rather than a bare address. The reservation is what makes the memory safe to read at all, and it is what gives the kernel a size to bounds check against.The byte arrays are not written by hand: patch 7 adds ppmtodtlogo, a host tool along the lines of the existing pnmtologo -- plain C, no dependencies, no quantization of its own -- that turns a PPM image into the node or into the memory region blob. It is what produced everything tested below.
Until
chosen.yamlknows about the node,dtbs_checkrejects it on any board that uses it: it allows only ^framebuffer under /chosen. I sent that one line change as dt-schema pull request 204, and Rob closed it saying he expects it is either not needed or will change, given this discussion. That seems like the right order to me, so I am not asking for it again
here: once the shape of the binding is settled, the schema change follows from it, and I will send it then.On a system that has DRM but no frame buffer device, nothing draws the logo at all: fbcon is what draws it today, and without it there is no consumer. Showing it there needs an in-kernel DRM client, which I have working on top of this series and will send separately. I mention it because it is the reason the node is parsed in
logo.crather than infb_logo.c: the same node then puts the logo on the same pixel whichever of the two draws it, rotated or not, which I checked on the same board.Testing: built for arm with
CONFIG_LOGO_DT_CLUT224both enabled and disabled, and each of the seven patches builds on its own, with the option enabled from the patch that introduces it. Also built forx86_64withCONFIG_OF=n, where nothing is left unresolved and the placement data is dropped from the image, and for powerpc Cell -- whereSPU_BASEmakesCONFIG_FB_LOGO_EXTRAreal -- to a linked vmlinux. No compiler warnings, W=1 clean on the files touched, checkpatch --strict clean apart from theMAINTAINERSreminder for the new tool, which the existingdrivers/video/entry already covers. A fulldt_binding_checkhas one complaint for this binding and none other in the whole tree: thechosen.yamlrejection described above.Boot tested under qemu-system-arm -M versatilepb with PL111 and fbcon, at 16bpp, over a 26 case matrix: absolute positions, per axis centring, all four corners, offsets including negative ones, out of range values, the three rotations, and each rotation combined with an offset and with an absolute position, each compared pixel by pixel against the source image rotated to match. A position out of range on both axes is clamped to the corner, and the console text then overwrites the rows below what fbcon reserved. Supplying the same image through a reserved region instead produces an identical logo area. Blobs with a bad magic, a geometry larger than the reservation and an out of range pixel are each rejected with a warning, with no logo drawn and no crash.
Also boot tested on real hardware: an AM335x board (tilcdc) with an 800x480 panel at 16bpp. The product logo comes up where the node asks, both carried in the device tree and taken from a bootloader-loaded reserved memory region, and the two produce a frame buffer that is identical byte for byte. Dumping
/dev/fb0and comparing it against the source image, the logo lands on exactly the pixel the binding predicts:
16836 of 16836 pixels match, and one pixel of displacement in any direction drops that to about 90%. With logo-rotation = "ccw" it lands on the rotated position the same way, every pixel.Changes since v2:
- Rebased onto current mainline (v7.3-rc3).
- Dropped the "linux," prefix from the compatible, and renamed the binding to match, per Rob.
- A rotation asked for by the device tree now turns the logo and not the
screen: "logo-position" and "logo-offset" stay in screen pixels, and a quarter turn only changes how much room the logo takes up. v2 fed the device tree rotation into the path fbcon uses for a rotated console, which places the logo in the console's own frame and maps the result back, so a vertical offset came out horizontal on a screen that was not rotated. Found by testing it on the panel.fb_rotate_logo()is split into the part that turns the image and the part that moves the placement, and the console path is unchanged.
- The placement properties are read inlogo.c, next to the image, and the frame buffer code only asks for the result, so that the binding is parsed in a single place.
- Added patch 1, which pulls the logo position out into something bothfb_prepare_logo()andfb_show_logo_line()share, after Helge pointed out that the placement patch was stamped in rather than merged with the existing code. That turned up a real bug: the reservation took the larger of the console position and the device tree one while the drawing took only the device tree one.
-IS_ENABLED()instead of #ifdef, per Helge, so the code is compile checked whatever the configuration.
- The device tree is read once, fromfb_prepare_logo(), rather than from every accessor.
- Dropped "logo-centered" for -1 in "logo-position", per Helge.
- The position and offset are added in 64 bits and both are bounded in the binding; in int, a large pair from the device tree wrapped instead of landing against an edge.
- The copy of the image is no longer freed from a late initcall, which ran beforeasync_synchronize_full()and so could pull it out from under a display driver still probing. Pixels are allocated withkvmalloc().
- The example declares compatible and model on the root node, and the binding no longer requires the image properties unconditionally, which made the reserved memory form unreachable. Both found by Rob's bot.
- Extra logos are not drawn when the device tree supplied the logo; they stack up from an arbitrary point once it has been placed.Max Pedraza (7):
fbdev: describe where the boot logo goes in one place
dt-bindings: display: add a device tree supplied boot logo
video: logo: allow the boot logo to come from the device tree
fbdev: honour the device tree boot logo placement properties
dt-bindings: display: allow the boot logo in a reserved memory region
video: logo: allow the boot logo to come from a reserved memory region
video: logo: add ppmtodtlogo host tool.../bindings/display/boot-logo-clut224.yaml | 161 +++++++ MAINTAINERS | 1 + drivers/video/fbdev/core/fb_logo.c | 221 ++++++++-- drivers/video/logo/Kconfig | 12 + drivers/video/logo/Makefile | 6 +- drivers/video/logo/logo.c | 332 +++++++++++++- drivers/video/logo/ppmtodtlogo.c | 416 ++++++++++++++++++ include/linux/linux_logo.h | 59 +++ 8 files changed, 1170 insertions(+), 38 deletions(-)Quoted 3 lines
create mode 100644
Documentation/devicetree/bindings/display/boot-logo-clut224.yamlcreate mode 100644drivers/video/logo/ppmtodtlogo.c--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)
Hi Màxim,
Quoted 33 lines · Màxim Pedraza Padilla
Hi Thomas,
Quoted 5 lines
the whole Linux logo on the console is somewhat gimmicky and IMHO should not be further extended. Also fbdev as a whole has realistically run its course. We fix bugs and occasionally clean up the code, but it is questionable whether new feature make much sense. Even more so as the drivers your system uses appear to be DRM ones.
They are, it is tilcdc. Understood, I will drop the fbdev side, which also settles your comment on patch 1.
Quoted 4 lines
There is a proposal for a DRM splash screen at [1]. It retrieves the device vendor's logo from the firmware and displays it at the given coordinates. IMHO you should start with this series and add DT support there.
Agreed. I have been following Francesco's series since Sam pointed me at it, and it is where the DRM follow-up I mentioned in the cover letter belongs, rather than in a client of my own.
A device tree source fits next to the BGRT one. The BGRT is the firmware handing the kernel an image and where to put it, and a DT system has no such table. The BMP loaded as firmware only helps if the file is built into the kernel, or if a filesystem is already there when the display comes up. With U-Boot's Falcon mode, the device tree is the only thing that reaches the kernel.
So the plan would be a node under /chosen carrying a BMP, either in the node itself or in a reserved memory region the bootloader loaded it into, with the placement properties from this series. The region is the same
memremap()the BGRT source already does, only with the address coming from the device tree.
Quoted 7 lines
Rotation too: the client skips a BGRT image with the orientation bits set today, and it could turn it instead. I will ask Rob separately how he wants the image described, since that is what the binding hinges on.
Francesco, is a v4 on the way? Would you take a DT source as patches on top of your series, or would you rather I wait until it lands?
v4 is planned but has been preempted by other activities - I am not able to give you an ETA at the moment. If you have capacity, feel free to take over.
Quoted 2 lines
Max
Regards,
Francesco
Hi Francesco,
Quoted 3 lines
v4 is planned but has been preempted by other activities - I am not able to give you an ETA at the moment. If you have capacity, feel free to take over.
Thanks, I appreciate it. Since it is your series, I would like to run past you what I would change before taking it on.
The v4 would still be an RFC, based on drm-misc-next. Your patches keep your authorship, with any fix to them folded in and noted in the commit message.
Fixes to what is in v3:
- the BGRT symbols exported, as in your patch for Mario, but with
EXPORT_SYMBOL_GPL;
- drm_splash_init_client() indexes modeset_mask by the number of
modesets added in the first loop and by the number walked in the
second, so an output without a mode ahead of a connected one gets
the buffer instead;
- for a tiled group, the first loop dereferences tiled->buffer before
any buffer exists, and the width and height look swapped;
- if the BMP firmware never arrives, the callback returns without
waking the render thread, which is left in TASK_UNINTERRUPTIBLE for
good;
- the 24 bit blitters read each pixel as an unaligned u32, one byte
past the image when the rows have no padding;
- the image cleanup always calls memunmap(), which will need to know
where the image came from once there is a third source; - the spaces in DRM_CLIENT_DEFAULT, in a patch of its own.
The modeset, tiling and render thread ones come from reading the code, so I will reproduce them in qemu first. Tiling I cannot test at all.
Additions:
- a device tree image source: a node under /chosen with the BMP either in the node itself (dtc's /incbin/) or in a reserved memory region, mapped with the same memremap() as the BGRT;
- placement from that node, a position with -1 centring an axis plus
an offset, instead of always centring;
- rotation, for the DT image and for BGRT images with the orientation
bits set, which are skipped today; - the background colour coming from the same place as the image: the DT node can carry its own, splash_color goes with splash_bmp, and the Kconfig colour stays the default for everything else, BGRT included.
The sources would be tried in the order DT, BGRT, BMP firmware, and then just the colour. A DT node is only there if someone put it there for that board, so it seemed right to let it win.
Does that match what you had in mind? And how would you like to appear in MAINTAINERS, as a maintainer next to me or as a reviewer?
If you are happy with it, I'll take you up on your offer.
Màxim
Quoted 55 lines · Francesco Valla
Hi Màxim,
Quoted 33 lines · Màxim Pedraza Padilla
Hi Thomas,
Quoted 5 lines
the whole Linux logo on the console is somewhat gimmicky and IMHO should not be further extended. Also fbdev as a whole has realistically run its course. We fix bugs and occasionally clean up the code, but it is questionable whether new feature make much sense. Even more so as the drivers your system uses appear to be DRM ones.
They are, it is tilcdc. Understood, I will drop the fbdev side, which also settles your comment on patch 1.
Quoted 4 lines
There is a proposal for a DRM splash screen at [1]. It retrieves the device vendor's logo from the firmware and displays it at the given coordinates. IMHO you should start with this series and add DT support there.
Agreed. I have been following Francesco's series since Sam pointed me at it, and it is where the DRM follow-up I mentioned in the cover letter belongs, rather than in a client of my own.
A device tree source fits next to the BGRT one. The BGRT is the firmware handing the kernel an image and where to put it, and a DT system has no such table. The BMP loaded as firmware only helps if the file is built into the kernel, or if a filesystem is already there when the display comes up. With U-Boot's Falcon mode, the device tree is the only thing that reaches the kernel.
So the plan would be a node under /chosen carrying a BMP, either in the node itself or in a reserved memory region the bootloader loaded it into, with the placement properties from this series. The region is the same
memremap()the BGRT source already does, only with the address coming from the device tree.Quoted 7 lines
Rotation too: the client skips a BGRT image with the orientation bits set today, and it could turn it instead. I will ask Rob separately how he wants the image described, since that is what the binding hinges on.
Francesco, is a v4 on the way? Would you take a DT source as patches on top of your series, or would you rather I wait until it lands?
v4 is planned but has been preempted by other activities - I am not able to give you an ETA at the moment. If you have capacity, feel free to take over.
Quoted 2 lines
Max
Regards,
Francesco
Hi Màxim,
Quoted 30 lines · Màxim Pedraza Padilla
Hi Francesco,
Quoted 3 lines
v4 is planned but has been preempted by other activities - I am not able to give you an ETA at the moment. If you have capacity, feel free to take over.
Thanks, I appreciate it. Since it is your series, I would like to run past you what I would change before taking it on.
The v4 would still be an RFC, based on drm-misc-next. Your patches keep your authorship, with any fix to them folded in and noted in the commit message.
Fixes to what is in v3:
- the BGRT symbols exported, as in your patch for Mario, but with
EXPORT_SYMBOL_GPL; - drm_splash_init_client() indexes modeset_mask by the number of modesets added in the first loop and by the number walked in the second, so an output without a mode ahead of a connected one gets the buffer instead; - for a tiled group, the first loop dereferences tiled->buffer before any buffer exists, and the width and height look swapped; - if the BMP firmware never arrives, the callback returns without waking the render thread, which is left in TASK_UNINTERRUPTIBLE for good; - the 24 bit blitters read each pixel as an unaligned u32, one byte past the image when the rows have no padding; - the image cleanup always calls memunmap(), which will need to know where the image came from once there is a third source;
Quoted 2 lines
- the spaces in
DRM_CLIENT_DEFAULT, in a patch of its own.
I suggest you also take at look at the review sashiko did for the V3 [1], as it contains some good suggestions (some of them are already present in your list).
Quoted 3 lines
The modeset, tiling and render thread ones come from reading the code, so I will reproduce them in qemu first. Tiling I cannot test at all.
I did not test tiling as well - I think it's a mode limited to some Intel cards?
Quoted 5 lines
Additions:
- a device tree image source: a node under /chosen with the BMP either in the node itself (dtc's /incbin/) or in a reserved memory region, mapped with the same
memremap()as the BGRT;
A reserved memory region is (probably) a better idea, to allow change the splash without recompiling the devicetree.
A possible usecase would be:
- bootloader reads the BMP image from a dedicated partition and loads it to the reserved memory (very much like the BGRT path);
- splash client parses the devicetree, finds the memory region and loads the image from there;
- userspace updates the dedicated partition with a different image.
Quoted 9 lines
- placement from that node, a position with -1 centring an axis plus
an offset, instead of always centring; - rotation, for the DT image and for BGRT images with the orientation bits set, which are skipped today;- the background colour coming from the same place as the image: the DT node can carry its own,
splash_colorgoes withsplash_bmp, and theKconfigcolour stays the default for everything else, BGRT included.
Quoted 7 lines
The sources would be tried in the order DT, BGRT, BMP firmware, and then just the colour. A DT node is only there if someone put it there for that board, so it seemed right to let it win.
Does that match what you had in mind? And how would you like to appear in
MAINTAINERS, as a maintainer next to me or as a reviewer?
Yes, please, either as a co-maintainer or as a reviewer, as you see fit.
Quoted 2 lines
If you are happy with it, I'll take you up on your offer.
Thank you for continuing the effort on this - I still believe it's useful, but currently is not fitting inside my schedule.
Quoted 2 lines
Màxim
Regards,
Francesco
[1] https://sashiko.dev/#/patchset/20260510-drm_client_splash-v3-0-a9aee9f0b2fc%40valla.it
Quoted 57 lines
Quoted 55 lines · Francesco Valla
Hi Màxim,
Quoted 33 lines · Màxim Pedraza Padilla
Hi Thomas,
Quoted 5 lines
the whole Linux logo on the console is somewhat gimmicky and IMHO should not be further extended. Also fbdev as a whole has realistically run its course. We fix bugs and occasionally clean up the code, but it is questionable whether new feature make much sense. Even more so as the drivers your system uses appear to be DRM ones.
They are, it is tilcdc. Understood, I will drop the fbdev side, which also settles your comment on patch 1.
Quoted 4 lines
There is a proposal for a DRM splash screen at [1]. It retrieves the device vendor's logo from the firmware and displays it at the given coordinates. IMHO you should start with this series and add DT support there.
Agreed. I have been following Francesco's series since Sam pointed me at it, and it is where the DRM follow-up I mentioned in the cover letter belongs, rather than in a client of my own.
A device tree source fits next to the BGRT one. The BGRT is the firmware handing the kernel an image and where to put it, and a DT system has no such table. The BMP loaded as firmware only helps if the file is built into the kernel, or if a filesystem is already there when the display comes up. With U-Boot's Falcon mode, the device tree is the only thing that reaches the kernel.
So the plan would be a node under /chosen carrying a BMP, either in the node itself or in a reserved memory region the bootloader loaded it into, with the placement properties from this series. The region is the same
memremap()the BGRT source already does, only with the address coming from the device tree.Quoted 7 lines
Rotation too: the client skips a BGRT image with the orientation bits set today, and it could turn it instead. I will ask Rob separately how he wants the image described, since that is what the binding hinges on.
Francesco, is a v4 on the way? Would you take a DT source as patches on top of your series, or would you rather I wait until it lands?
v4 is planned but has been preempted by other activities - I am not able to give you an ETA at the moment. If you have capacity, feel free to take over.
Quoted 2 lines
Max
Regards,
Francesco
Hi,
This series is superseded by RFC v4 of the DRM splash client, which adds the device tree support there, as Thomas suggested:
https://lore.kernel.org/all/[email protected]/
The node placement and the reserved memory region carried over; the clut224 format and the ppmtodtlogo tool did not, as the client takes BMP images. Helge, please drop this one.
Thanks to everyone who reviewed it.
Màxim
Quoted 156 lines · Francesco Valla
Hi Màxim,
Quoted 30 lines · Màxim Pedraza Padilla
Hi Francesco,
Quoted 3 lines
v4 is planned but has been preempted by other activities - I am not able to give you an ETA at the moment. If you have capacity, feel free to take over.
Thanks, I appreciate it. Since it is your series, I would like to run past you what I would change before taking it on.
The v4 would still be an RFC, based on drm-misc-next. Your patches keep your authorship, with any fix to them folded in and noted in the commit message.
Fixes to what is in v3:
- the BGRT symbols exported, as in your patch for Mario, but with
EXPORT_SYMBOL_GPL; - drm_splash_init_client() indexes modeset_mask by the number of modesets added in the first loop and by the number walked in the second, so an output without a mode ahead of a connected one gets the buffer instead; - for a tiled group, the first loop dereferences tiled->buffer before any buffer exists, and the width and height look swapped; - if the BMP firmware never arrives, the callback returns without waking the render thread, which is left in TASK_UNINTERRUPTIBLE for good; - the 24 bit blitters read each pixel as an unaligned u32, one byte past the image when the rows have no padding; - the image cleanup always calls memunmap(), which will need to know where the image came from once there is a third source;Quoted 2 lines
- the spaces in
DRM_CLIENT_DEFAULT, in a patch of its own.I suggest you also take at look at the review sashiko did for the V3 [1], as it contains some good suggestions (some of them are already present in your list).
Quoted 3 lines
The modeset, tiling and render thread ones come from reading the code, so I will reproduce them in qemu first. Tiling I cannot test at all.
I did not test tiling as well - I think it's a mode limited to some Intel cards?
Quoted 5 lines
Additions:
- a device tree image source: a node under /chosen with the BMP either in the node itself (dtc's /incbin/) or in a reserved memory region, mapped with the same
memremap()as the BGRT;A reserved memory region is (probably) a better idea, to allow change the splash without recompiling the devicetree.
A possible usecase would be:
- bootloader reads the BMP image from a dedicated partition and loads it to the reserved memory (very much like the BGRT path);
- splash client parses the devicetree, finds the memory region and loads the image from there;
- userspace updates the dedicated partition with a different image.Quoted 9 lines
- placement from that node, a position with -1 centring an axis plus
an offset, instead of always centring; - rotation, for the DT image and for BGRT images with the orientation bits set, which are skipped today;- the background colour coming from the same place as the image: the DT node can carry its own,
splash_colorgoes withsplash_bmp, and theKconfigcolour stays the default for everything else, BGRT included.Quoted 7 lines
The sources would be tried in the order DT, BGRT, BMP firmware, and then just the colour. A DT node is only there if someone put it there for that board, so it seemed right to let it win.
Does that match what you had in mind? And how would you like to appear in
MAINTAINERS, as a maintainer next to me or as a reviewer?Yes, please, either as a co-maintainer or as a reviewer, as you see fit.
Quoted 2 lines
If you are happy with it, I'll take you up on your offer.
Thank you for continuing the effort on this - I still believe it's useful, but currently is not fitting inside my schedule.
Quoted 2 lines
Màxim
Regards,
Francesco[1] https://sashiko.dev/#/patchset/20260510-drm_client_splash-v3-0-a9aee9f0b2fc%40valla.it
Quoted 57 lines
Quoted 55 lines · Francesco Valla
Hi Màxim,
Quoted 33 lines · Màxim Pedraza Padilla
Hi Thomas,
Quoted 5 lines
the whole Linux logo on the console is somewhat gimmicky and IMHO should not be further extended. Also fbdev as a whole has realistically run its course. We fix bugs and occasionally clean up the code, but it is questionable whether new feature make much sense. Even more so as the drivers your system uses appear to be DRM ones.
They are, it is tilcdc. Understood, I will drop the fbdev side, which also settles your comment on patch 1.
Quoted 4 lines
There is a proposal for a DRM splash screen at [1]. It retrieves the device vendor's logo from the firmware and displays it at the given coordinates. IMHO you should start with this series and add DT support there.
Agreed. I have been following Francesco's series since Sam pointed me at it, and it is where the DRM follow-up I mentioned in the cover letter belongs, rather than in a client of my own.
A device tree source fits next to the BGRT one. The BGRT is the firmware handing the kernel an image and where to put it, and a DT system has no such table. The BMP loaded as firmware only helps if the file is built into the kernel, or if a filesystem is already there when the display comes up. With U-Boot's Falcon mode, the device tree is the only thing that reaches the kernel.
So the plan would be a node under /chosen carrying a BMP, either in the node itself or in a reserved memory region the bootloader loaded it into, with the placement properties from this series. The region is the same
memremap()the BGRT source already does, only with the address coming from the device tree.Quoted 7 lines
Rotation too: the client skips a BGRT image with the orientation bits set today, and it could turn it instead. I will ask Rob separately how he wants the image described, since that is what the binding hinges on.
Francesco, is a v4 on the way? Would you take a DT source as patches on top of your series, or would you rather I wait until it lands?
v4 is planned but has been preempted by other activities - I am not able to give you an ETA at the moment. If you have capacity, feel free to take over.
Quoted 2 lines
Max
Regards,
Francesco