Boot logo supplied by the device tree
Subsystems (6)
cover Boot logo supplied by the device tree
Embedded products routinely need their own boot logo. Today the only way to get one is to replace one of the logo_*_clut224.ppm files in the kernel source tree, which bakes the image 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 "linux,boot-logo-clut224" 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 1-2) or from a reserved memory region the bootloader filled in (patches 4-5), 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 3 adds that placement.
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. This is an attempt to find out whether something along these lines is wanted upstream, and if so in what shape -- hence RFC.
I am aware of the contentious part: a bitmap is not hardware, and the device tree is not an obvious place to put one. The argument for it is that the logo identifies the board in the same way the model property does, it is available before any filesystem is mounted, and it is per board rather than per kernel. The argument against is presumably that this is policy and belongs in userspace or in the bootloader. I would rather hear that explicitly than keep the patch downstream on a guess, and if the concept is rejected I would still like to know whether a smaller subset -- say the placement properties driven from the fbcon command line, without any image in the device tree -- would be worth submitting separately.
Patches 4 and 5 are separable; the series is useful without them if the reserved memory path is thought to be one mechanism too many.
Not included, though it exists in our downstream version: a hook in drm_fb_helper so the logo is drawn when CONFIG_FRAMEBUFFER_CONSOLE is disabled, which is the common case for a product that only wants a splash screen. Today fb_show_logo() is reached from fbcon alone. That is a DRM question rather than an fbdev one and deserves a separate posting.
Notes on the binding:
- 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" 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.
- "logo-centered" overlaps with the existing fb_center_logo, but it is per device tree rather than per fbcon command line, and it composes with "logo-offset". That combination is what panels with a partially visible area need, where the usable region is not the centre of the mode; the hardware this came from is an 800x480 panel of which only the bottom 320 rows are visible.
- 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 6 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.
Testing: build tested for arm with CONFIG_LOGO_DT_CLUT224 both enabled and disabled, W=1 clean, checkpatch --strict clean, dt_binding_check clean. The schema was also checked against deliberately malformed nodes, including supplying both image sources at once and neither.
Boot tested under qemu-system-arm -M versatilepb with PL111 and fbcon, at 16bpp. A 160x120 logo placed with "logo-centered" plus a "logo-offset" of <0 120> lands at exactly the expected coordinates, and every pixel matches the source image once the source is truncated to RGB565, with identical per-colour pixel counts. Supplying the same image through a reserved region loaded at boot produces a bit for bit identical screen. Blobs with a bad magic, a geometry larger than the reservation, an out of range pixel and an oversized palette are each rejected with a warning and fall back to the built-in logo, with no crash.
That boot test earned its keep: the first version of patch 3 drew the logo correctly and then had it erased, because fb_prepare_logo() still reserved only the logo's own height while the logo itself had been moved further down. Nothing in the build or the static checks catches that.
Also boot tested on real hardware: an AM335x board (tilcdc) with an 800x480 panel, migrated from the 4.19 product kernel this derives from. Both image sources show the product logo where expected -- embedded in the device tree, and in a bootloader-loaded reserved memory region at the same address the 4.19 system already used. That system builds without CONFIG_FRAMEBUFFER_CONSOLE, so the drawing there goes through the separate drm_fb_helper hook mentioned above as not included; the parsing, validation and placement exercised are those of this series.
Max Pedraza (6):
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
.../display/linux,boot-logo-clut224.yaml | 152 +++++++ MAINTAINERS | 1 + drivers/video/fbdev/core/fb_logo.c | 174 ++++++++ drivers/video/logo/Kconfig | 13 + drivers/video/logo/Makefile | 6 +- drivers/video/logo/logo.c | 256 +++++++++++ drivers/video/logo/ppmtodtlogo.c | 402 ++++++++++++++++++ 7 files changed, 1003 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/display/linux,boot-logo-clut224.yaml create mode 100644 drivers/video/logo/ppmtodtlogo.c
Signature · 1 line
2.39.5
RFC PATCH 1/6 dt-bindings: display: add a device tree supplied boot logo
Embedded products frequently need a product specific boot logo. Today the only way to get one is to replace one of the logo_*_clut224.ppm files in the kernel source tree, which bakes the image into the kernel image: a change of branding, or a second product sharing the same board support, requires a separate kernel build.
Add a binding for a "linux,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 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.
--- .../display/linux,boot-logo-clut224.yaml | 108 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 109 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/linux,boot-logo-clut224.yaml
Documentation/devicetree/bindings/display/linux,boot-logo-clut224.yaml new file +108 -0
@@ -0,0 +1,108 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/linux,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 the only + way to get one is to replace one of the logo_*_clut224.ppm files in the + kernel source tree, which means the image is baked into the kernel image and + a new kernel has to be built and deployed to change it. + + 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. + + 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: + compatible: + const: linux,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/uint32-array + description: + X and Y coordinates, in pixels, of the top left corner of the logo. + Defaults to the top left corner of the screen. + items: + - description: X coordinate + - description: Y coordinate + + logo-offset: + $ref: /schemas/types.yaml#/definitions/int32-array + description: + X and Y displacement, in pixels, applied after the logo has been placed. + Mostly useful together with logo-centered. + items: + - description: X displacement + - description: Y displacement + + logo-centered: + type: boolean + description: + Centre the logo on the screen, overriding logo-position. + + logo-rotation: + $ref: /schemas/types.yaml#/definitions/string + description: Rotation applied to the logo before it is drawn. + enum: [none, cw, ccw, ud] + default: none + +required: + - compatible + - width + - height + - clut + - data + +additionalProperties: false + +examples: + - | + // A 4x2 logo using three colours, centred on the screen. + logo { + compatible = "linux,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-centered; + };
MAINTAINERS +1 -0
@@ -9951,6 +9951,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/linux,boot-logo-clut224.yaml F: Documentation/fb/ F: drivers/video/ F: include/linux/fb.h
Signature · 1 line
2.39.5
RFC PATCH 2/6 video: logo: allow the boot logo to come from the device tree
In reply to Max PedrazaWith CONFIG_LOGO_DT_CLUT224 enabled, look for a node compatible with "linux,boot-logo-clut224" and, when one is present and enabled, use the image it carries in preference to the logos built into the kernel image.
This lets a single kernel image serve several products, or several revisions of one product, that differ only in branding, at the cost of a larger device tree blob.
The image is validated while it is parsed: the palette must be at most 224 entries, the pixel data length must match the declared geometry, and every pixel must reference an existing palette entry. A malformed node is reported and ignored, falling back to the built-in logo.
The two allocations live for as long as the built-in logos do; they are released from fb_logo_late_init(), next to where the __initdata logos are marked as freed.
If the node is absent or disabled, behaviour is unchanged.
--- drivers/video/logo/Kconfig | 13 +++ drivers/video/logo/logo.c | 157 +++++++++++++++++++++++++++++++++++++ 2 files changed, 170 insertions(+)
drivers/video/logo/Kconfig +13 -0
@@ -70,4 +70,17 @@ config LOGO_SUPERH_CLUT224 depends on SUPERH default y +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 + "linux,boot-logo-clut224", 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, at the cost of + making the device tree blob larger. + + If no such node is present, or it is disabled, the built-in logo + selected above is used, so saying Y here is safe. If unsure, say N. + endif # LOGO
drivers/video/logo/logo.c +157 -0
181 lines not on this page · raw message
Signature · 1 line
2.39.5
RFC PATCH 3/6 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. Honour the optional "logo-position", "logo-offset", "logo-centered" and "logo-rotation" properties of the "linux,boot-logo-clut224" node.
The rotation is folded into the rotate argument at the entry points, so fb_prepare_logo() reserves the right amount of space and fb_do_show_logo() tiles in the same direction the image was rotated in.
Placement is applied after fb_rotate_logo(), since a rotation swaps the image width and height and centring needs the final dimensions.
fb_prepare_logo() has to grow its reservation to cover wherever the logo ends up, the way fb_center_logo already does: fbcon only leaves the first n rows alone, so a logo placed further down is drawn and then immediately cleared by the console.
"logo-centered" is deliberately close to the existing fb_center_logo, but it is per device tree rather than per fbcon command line, and it composes with "logo-offset" so that a logo can be centred and then nudged. That combination is what panels with a partially visible area need, where the usable region is not the centre of the mode.
--- drivers/video/fbdev/core/fb_logo.c | 174 +++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+)
drivers/video/fbdev/core/fb_logo.c +174 -0
@@ -2,12 +2,178 @@#include <linux/fb.h> #include <linux/linux_logo.h> +#include <linux/of.h> #include "fb_internal.h" bool fb_center_logo__read_mostly ;int fb_logo_count__read_mostly =-1 ; +#ifdef CONFIG_LOGO_DT_CLUT224 + +/* +* Placement of a logo supplied by the device tree. The image itself is parsed +* by drivers/video/logo/logo.c, here we only care about where it goes. +*/ +struct fb_logo_dt_placement { +bool valid; +bool centered; +bool has_position; +int rotation;/* FB_ROTATE_*, or -1 when unspecified */ +u32 x, y; +s32 offset_x, offset_y; +}; + +static struct fb_logo_dt_placement fb_logo_dt; + +static int fb_logo_dt_parse_rotation (const char *rotation) +{ +if (!strcmp (rotation,"none" )) +return FB_ROTATE_UR ; +if (!strcmp (rotation,"cw" )) +return FB_ROTATE_CW ; +if (!strcmp (rotation,"ud" )) +return FB_ROTATE_UD ; +if (!strcmp (rotation,"ccw" )) +return FB_ROTATE_CCW ; + +return -EINVAL ; +} + +static void fb_logo_dt_read (void ) +{ +struct fb_logo_dt_placement *p = &fb_logo_dt; +static bool read_done; +struct device_node *np; +const char *rotation; +u32 val[2 ]; +int rot; + +if (read_done) +return ; + + read_done = true; + + np =of_find_compatible_node (NULL ,NULL ,"linux,boot-logo-clut224" ); +if (!np) +return ; + +if (!of_device_is_available (np)) + goto out; + + p->valid = true; + p->rotation =-1 ; + p->centered =of_property_read_bool (np,"logo-centered" ); + +if (!of_property_read_u32_array (np,"logo-position" , val,2 )) { + p->has_position = true; + p->x = val[0 ]; + p->y = val[1 ]; + } + +if (!of_property_read_u32_array (np,"logo-offset" , val,2 )) { + p->offset_x = (s32 )val[0 ]; + p->offset_y = (s32 )val[1 ]; + } + +if (!of_property_read_string (np,"logo-rotation" , &rotation)) { + rot =fb_logo_dt_parse_rotation (rotation); +if (rot <0 ) +pr_warn ("fb: %pOF: unknown logo-rotation \"%s\"\n" , + np, rotation); +else + p->rotation = rot; + } + +out: +of_node_put (np); +} + +static int fb_logo_dt_rotation (int rotate) +{ +fb_logo_dt_read (); + +if (fb_logo_dt.valid && fb_logo_dt.rotation >=0 ) +return fb_logo_dt.rotation; + +return rotate; +} + +/* Top edge of the logo, in the coordinate space the caller works in */ +static int fb_logo_dt_top (unsigned int yres,unsigned int logo_height) +{ +struct fb_logo_dt_placement *p = &fb_logo_dt; +int top; + +if (p->centered) + top = ((int )yres - (int )logo_height) /2 ; +else if (p->has_position) + top = p->y; +else + top =0 ; + +return max (top + p->offset_y,0 ); +} + +static void fb_logo_dt_place (struct fb_info *info,struct fb_image *image) +{ +struct fb_logo_dt_placement *p = &fb_logo_dt; +int dx; + +fb_logo_dt_read (); + +if (!p->valid) +return ; + +if (p->centered) + dx = ((int )info->var.xres - (int )image->width) /2 ; +else if (p->has_position) + dx = p->x; +else + dx = image->dx; + + image->dx =max (dx + p->offset_x,0 ); + image->dy =fb_logo_dt_top (info->var.yres, image->height); +} + +/* +* fbcon only leaves the first @height rows of the screen alone, so a logo +* placed further down would be drawn and then immediately cleared. Grow the +* reservation to cover wherever the logo actually ends up, the same way +* fb_center_logo does. +*/ +static int fb_logo_dt_reserve (unsigned int yres,unsigned int logo_height, +int height) +{ +fb_logo_dt_read (); + +if (!fb_logo_dt.valid) +return height; + +return max (height,fb_logo_dt_top (yres, logo_height) + + (int )logo_height); +} + +#else /* !CONFIG_LOGO_DT_CLUT224 */ + +static inline int fb_logo_dt_rotation (int rotate) +{ +return rotate; +} + +static inline void fb_logo_dt_place (struct fb_info *info, +struct fb_image *image) +{ +} + +static inline int fb_logo_dt_reserve (unsigned int yres, +unsigned int logo_height,int height) +{ +return height; +} + +#endif /* CONFIG_LOGO_DT_CLUT224 */ +static inline unsigned int safe_shift (unsigned int d,int n) {return n <0 ? d >> -n : d << n;
@@ -350,6 +516,9 @@ static int fb_show_logo_line(struct fb_info *info, int rotate,fb_rotate_logo (info, logo_rotate, &image, rotate); } +/* Done last, image dimensions are only final after the rotation */ +fb_logo_dt_place (info, &image); +fb_do_show_logo (info, &image, rotate, n);kfree (palette);
@@ -423,6 +592,8 @@ int fb_prepare_logo(struct fb_info *info, int rotate)memset (&fb_logo,0 ,sizeof (struct logo_data )); + rotate =fb_logo_dt_rotation (rotate); +if (info->flags &FBINFO_MISC_TILEBLITTING || info->fbops->owner || !fb_logo_count)return 0 ;
@@ -483,6 +654,7 @@ 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 ; + height =fb_logo_dt_reserve (yres, fb_logo.logo->height, height);#ifdef CONFIG_FB_LOGO_EXTRA height =fb_prepare_extra_logos (info, height, yres);#endif
@@ -498,6 +670,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
Signature · 1 line
2.39.5
RFC PATCH 4/6 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.
--- .../display/linux,boot-logo-clut224.yaml | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/display/linux,boot-logo-clut224.yaml +48 -4
@@ -54,6 +54,23 @@ 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/uint32-array description:
@@ -85,10 +102,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
@@ -106,3 +130,23 @@ examples: 0x02 0x00 0x00 0x02>; logo-centered; }; + - | + // The same logo taken from a region the bootloader filled in, centred on + // a panel whose usable area is not the centre of the mode. + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + logo_mem: logo@9c000000 { + reg = <0x9c000000 0x100000>; + no-map; + }; + }; + + logo { + compatible = "linux,boot-logo-clut224"; + memory-region = <&logo_mem>; + logo-centered; + logo-offset = <0 120>; + };
Signature · 1 line
2.39.5
RFC PATCH 5/6 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 | 171 ++++++++++++++++++++++++++++++-------- 1 file changed, 135 insertions(+), 36 deletions(-)
drivers/video/logo/logo.c +135 -36
@@ -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,6 +40,15 @@ MODULE_PARM_DESC(nologo, "Disables startup logo");#define LOGO_DT_CLUT_OFFSET 32/* Sanity limit on the image size, a device tree is not a good place for more */ #define LOGO_DT_MAX_PIXELS SZ_32M +/* "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 ,
@@ -46,58 +57,41 @@ 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 ); + clut =kmemdup (clut_src, clutsize *3 ,GFP_KERNEL );if (!clut)return -ENOMEM ; - data =kmalloc (npixels,GFP_KERNEL ); + data =kmemdup (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 ;
@@ -124,6 +118,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
RFC PATCH 6/6 video: logo: add ppmtodtlogo host tool
In reply to Max PedrazaThe byte arrays a "linux,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 | 402 +++++++++++++++++++++++++++++++ 2 files changed, 407 insertions(+), 1 deletion(-) create mode 100644 drivers/video/logo/ppmtodtlogo.c
drivers/video/logo/Makefile +5 -1
@@ -18,7 +18,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 "linux,boot-logo-clut224" binding consumes. +always-$(CONFIG_LOGO_DT_CLUT224) += ppmtodtlogo # Create commands like "pnmtologo -t mono -n logo_mac_mono -o ..." quiet_cmd_logo = LOGO $@
drivers/video/logo/ppmtodtlogo.c new file +402 -0
402 lines not on this page · raw message
Signature · 1 line
2.39.5
Hello Max,
Quoted 28 lines · Max Pedraza
Embedded products routinely need their own boot logo. Today the only way to get one is to replace one of the logo_*_clut224.ppm files in the kernel source tree, which bakes the image 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 "linux,boot-logo-clut224" 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 1-2) or from a reserved memory region the bootloader filled in (patches 4-5), 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 3 adds that placement.
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. This is an attempt to find out whether something along these lines is wanted upstream, and if so in what shape -- hence RFC.
Quoted 10 lines
I am aware of the contentious part: a bitmap is not hardware, and the device tree is not an obvious place to put one. The argument for it is that the logo identifies the board in the same way the model property does, it is available before any filesystem is mounted, and it is per board rather than per kernel. The argument against is presumably that this is policy and belongs in userspace or in the bootloader. I would rather hear that explicitly than keep the patch downstream on a guess, and if the concept is rejected I would still like to know whether a smaller subset -- say the placement properties driven from the fbcon command line, without any image in the device tree -- would be worth submitting separately.
My 0.02€: Usually you want to use the display using drm and not fb once the machine is fully booted. If you're using fb during boot to display a logo, it's hardly possible to switch to drm later in the boot process without flicker.
So my recommendation for your usecase is to not use the kernel boot logo stuff, but something like https://github.com/pengutronix/platsch. Then all the configuration is in userspace and modifyable using kernel parameters. Or you create your own application using libplatsch that selects the image based on the actual product derived from the dt compatible or some EEPROM's content.
Best regards
Uwe
Helge Deller
maintainerHello Max,
Quoted 45 lines · Uwe Kleine-König
Quoted 28 lines · Max Pedraza
Embedded products routinely need their own boot logo. Today the only way to get one is to replace one of the logo_*_clut224.ppm files in the kernel source tree, which bakes the image 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 "linux,boot-logo-clut224" 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 1-2) or from a reserved memory region the bootloader filled in (patches 4-5), 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 3 adds that placement.
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. This is an attempt to find out whether something along these lines is wanted upstream, and if so in what shape -- hence RFC.
Quoted 10 lines
I am aware of the contentious part: a bitmap is not hardware, and the device tree is not an obvious place to put one. The argument for it is that the logo identifies the board in the same way the model property does, it is available before any filesystem is mounted, and it is per board rather than per kernel. The argument against is presumably that this is policy and belongs in userspace or in the bootloader. I would rather hear that explicitly than keep the patch downstream on a guess, and if the concept is rejected I would still like to know whether a smaller subset -- say the placement properties driven from the fbcon command line, without any image in the device tree -- would be worth submitting separately.
My 0.02€: Usually you want to use the display using drm and not fb once the machine is fully booted. If you're using fb during boot to display a logo, it's hardly possible to switch to drm later in the boot process without flicker.
Quoted 6 lines
So my recommendation for your usecase is to not use the kernel boot logo stuff, but something like https://github.com/pengutronix/platsch. Then all the configuration is in userspace and modifyable using kernel parameters. Or you create your own application using libplatsch that selects the image based on the actual product derived from the dt compatible or some EEPROM's content.
Max, is this a viable option for your usecase?
Helge
Quoted 7 lines · Uwe Kleine-König
My 0.02€: Usually you want to use the display using drm and not fb once the machine is fully booted. If you're using fb during boot to display a logo, it's hardly possible to switch to drm later in the boot process without flicker.
So my recommendation for your usecase is to not use the kernel boot logo stuff, but something like https://github.com/pengutronix/platsch.
Thanks for the pointer, I did not know platsch and it looks like a good fit for the problem it solves. It does not solve mine, though, and I think the reason is worth spelling out, because it is not about how the image gets drawn but about when.
These are industrial units, and the requirement is time to first pixel after power is applied. If the panel stays dark for more than a moment the unit reads as dead, and that is a support call. Anything running in userspace is by construction later than the kernel: it needs the kernel booted, the rootfs mounted and init far enough along to exec it. I can measure the exact difference on our hardware if that is useful for the discussion.
We do already paint a BMP from U-Boot, which is as early as we can possibly be. The problem is the gap that follows: once the display driver probes, the panel is cleared, and nothing puts anything back until userspace is running. Moving the logo further out into userspace widens that gap rather than closing it. The kernel boot logo is what fills it, and that is the whole reason this series exists.
For completeness, since it is the usual answer to the U-Boot handover
problem: a simple-framebuffer node plus simpledrm does keep the bootloader image on screen. It moves the gap rather than removing it, though, because the real driver still has to take over at some point, and it makes the logo a property of the bootloader instead of the board description. The two are complementary rather than alternatives:
simpledrm covers up to the driver handover, the boot logo covers from there.
Quoted 2 lines
If you're using fb during boot to display a logo, it's hardly possible to switch to drm later in the boot process without flicker.
You are right in the general case, but I should be precise about what happens here, because there is no fbdev to DRM switch on this hardware. The display driver is tilcdc, which is a DRM driver; the logo ends up in the fbdev emulation that drm_fb_helper provides, so DRM is scanning out from the first pixel. Userspace then takes DRM over directly. The transition that remains is the same one any solution has when the application starts.
Quoted 1 line
Max, is this a viable option for your usecase?
Not for the reason above, no. Let me also be explicit about something the cover letter only mentions in passing, because it is directly relevant to Uwe's point and I would rather raise it myself.
This series does not draw anything anywhere new. It only teaches the existing fbdev logo code where the image may come from: a device tree node instead of a built-in PPM. With CONFIG_FRAMEBUFFER_CONSOLE the drawing is still done by fbcon, exactly as it is today.
The piece that matters for a product with no text console is a separate two patch series I have deliberately not posted yet. It exports a fb_draw_logo() helper from fbdev and calls it from drm_fb_helper when fbcon is not built in. I am aware that is pushing against the direction fbdev dependencies are being removed from DRM, which is precisely why I kept it out of this series: I did not want that discussion to decide the fate of the binding.
So the honest summary of where I stand: if the device tree part is acceptable I will post the drawing part separately to dri-devel and let it be judged on its own merits. If the conclusion there is that DRM should grow its own way to put an image on screen before userspace exists, rather than reaching into fbdev, I would rather help build that than carry a hook downstream forever. What I cannot do is wait for userspace.
Thanks both for looking at this,
Max
Hello Màxim,
Quoted 14 lines · Màxim Pedraza Padilla
Quoted 7 lines · Uwe Kleine-König
My 0.02€: Usually you want to use the display using drm and not fb once the machine is fully booted. If you're using fb during boot to display a logo, it's hardly possible to switch to drm later in the boot process without flicker.
So my recommendation for your usecase is to not use the kernel boot logo stuff, but something like https://github.com/pengutronix/platsch.
Thanks for the pointer, I did not know platsch and it looks like a good fit for the problem it solves. It does not solve mine, though, and I think the reason is worth spelling out, because it is not about how the image gets drawn but about when.
Quoted 7 lines
These are industrial units, and the requirement is time to first pixel after power is applied. If the panel stays dark for more than a moment the unit reads as dead, and that is a support call. Anything running in userspace is by construction later than the kernel: it needs the kernel booted, the rootfs mounted and init far enough along to exec it. I can measure the exact difference on our hardware if that is useful for the discussion.
No need to wait for init, the idea is to use init=/usr/sbin/platsch so it starts before init (and once the display is setup execve()s /sbin/init). Also you can put it in an initramfs which gets rid of the dependency on "rootfs mounted". And if your kernel is modular apart from what is needed for the display the time difference between kernel boot image and platsch might be negligible compared to the simplification of the software architecture.
Having said that, I'm against putting boot splash info in the device tree as the pointed out alternative is IMHO good enough. But my opinion probably isn't the one that eventually counts.
Best regards
Uwe
Hi Uwe,
Quoted 3 lines · Uwe Kleine-König
No need to wait for init, the idea is to use init=/usr/sbin/platsch so it starts before init (and once the display is setup execve()s
/sbin/init).
I think I caused a misunderstanding here: when I wrote "init" I meant PID 1 itself, not the init system getting far enough to start a service. Running platsch as PID 1 does not change the part that hurts, because PID 1 is exactly what I am waiting for.
Numbers from a shipping board, our 4.19 product kernel on an AM335x:
[ 1.065931] tilcdc 4830e000.lcdc: fb0: DRM emulated frame buffer device [ 3.522118] Run /sbin/init as init process
The display is up and can be drawn on at 1.07 s. PID 1 does not exist until 3.52 s. Whatever runs as PID 1, platsch included, is roughly 2.4 s late on this hardware. That gap is the entire problem: the panel is alive and black while the customer is looking at it.
Quoted 2 lines
Also you can put it in an initramfs which gets rid of the dependency on "rootfs mounted".
Agreed, and that would remove part of those 2.4 s. But not the shape of
it: PID 1 runs after the built-in initcalls have finished, while the logo is drawn as soon as the display driver's own probe is done. Any userspace solution is structurally behind that point, and an initramfs moves it closer without crossing it.
Quoted 3 lines
And if your kernel is modular apart from what is needed for the display the time difference between kernel boot image and platsch might be negligible compared to the simplification of the software architecture.
That is worth evaluating, and it may well be the right choice for a new design. It does not change the ordering, though: the display driver has to stay built in either way, so its probe finishes before PID 1 exists. Making the rest modular moves PID 1 closer to that moment without ever reaching it. The kernel logo draws at the earliest point where there is something to draw on, and nothing in userspace can be earlier than that.
To be clear about what I am not claiming: platsch is the better answer for anything that can tolerate the delay, it is more flexible, and I will very likely use it for the parts of our UI that come after the splash. The kernel logo is not competing with it, it covers the window platsch cannot reach.
Quoted 3 lines
Having said that, I'm against putting boot splash info in the device tree as the pointed out alternative is IMHO good enough. But my opinion probably isn't the one that eventually counts.
Understood, and thanks for saying it plainly, it is useful to know where you stand. For what it is worth, the objection I expected was exactly that one and I would rather have it on the record than guess at it. If the conclusion is that a bitmap does not belong in the device tree, the fallback I would still like to explore is keeping the placement properties and the reserved memory path while dropping the in-tree image, since that removes the "bitmap in DT" part while keeping the early drawing. But that is for Helge and the DT maintainers to weigh.
Thanks for taking the time,
Max
Hi Màxim,
Quoted 17 lines · Uwe Kleine-König
Hello Max,
Quoted 14 lines · Max Pedraza
Embedded products routinely need their own boot logo. Today the only way to get one is to replace one of the logo_*_clut224.ppm files in the kernel source tree, which bakes the image 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 "linux,boot-logo-clut224" 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 1-2) [...]
independently of the specific implementation, please keep in mind that the kernel is distributed under the GPLv2, which may have implications for a proprietary image embedded in the device tree. That doesn't necessarily have to be a deal-breaker, but it's probably something that should be considered carefully.
Best regards,
Ulrich
Quoted 40 lines
Quoted 15 lines
[...] or from a reserved
memory region the bootloader filled in (patches 4-5), 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 3 adds that placement.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. This is an attempt to find out whether something along these lines is wanted upstream, and if so in what shape -- hence RFC.
Quoted 10 lines
I am aware of the contentious part: a bitmap is not hardware, and the device tree is not an obvious place to put one. The argument for it is that the logo identifies the board in the same way the model property does, it is available before any filesystem is mounted, and it is per board rather than per kernel. The argument against is presumably that this is policy and belongs in userspace or in the bootloader. I would rather hear that explicitly than keep the patch downstream on a guess, and if the concept is rejected I would still like to know whether a smaller subset -- say the placement properties driven from the fbcon command line, without any image in the device tree -- would be worth submitting separately.
My 0.02€: Usually you want to use the display using drm and not fb once the machine is fully booted. If you're using fb during boot to display a logo, it's hardly possible to switch to drm later in the boot process without flicker.
So my recommendation for your usecase is to not use the kernel boot logo stuff, but something like https://github.com/pengutronix/platsch. Then all the configuration is in userspace and modifyable using kernel parameters. Or you create your own application using libplatsch that selects the image based on the actual product derived from the dt compatible or some EEPROM's content.
Best regards
Uwe
Signature · 4 lines
Pengutronix e.K. | Ulrich Ölmann | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Quoted 5 lines · Ulrich Ölmann
independently of the specific implementation, please keep in mind that the kernel is distributed under the GPLv2, which may have implications for a proprietary image embedded in the device tree. That doesn't necessarily have to be a deal-breaker, but it's probably something that should be considered carefully.
Good point, I had not considered it.
A warning could be added to the binding documentation about the licensing implications of a proprietary logo, aimed at anyone thinking of submitting a device tree carrying one to the kernel tree. I am happy to add that in v2 if it is considered useful.
Patches 4 and 5 also avoid the question by construction: there the image is a separate binary the bootloader loads, and the device tree carries only a phandle to the reserved region.
In any case, whether such device trees are accepted is ultimately for the device tree maintainers to decide.
Best regards,
Max
Hi Max,
Quoted 8 lines · Màxim Pedraza Padilla
Quoted 5 lines · Ulrich Ölmann
independently of the specific implementation, please keep in mind that the kernel is distributed under the GPLv2, which may have implications for a proprietary image embedded in the device tree. That doesn't necessarily have to be a deal-breaker, but it's probably something that should be considered carefully.
Quoted 6 lines
Good point, I had not considered it.
A warning could be added to the binding documentation about the licensing implications of a proprietary logo, aimed at anyone thinking of submitting a device tree carrying one to the kernel tree. I am happy to add that in v2 if it is considered useful.
I think the issue is broader than upstream submissions. Once such a device tree is shipped as part of a GPL kernel in a product, the GPL obligations already apply to that distribution. Therefore, the licensing implications of embedding a proprietary logo are not limited to upstream acceptance, they also affect downstream product distributions.
Quoted 3 lines
Patches 4 and 5 also avoid the question by construction: there the image is a separate binary the bootloader loads, and the device tree carries only a phandle to the reserved region.
Right, here everything is clearly uncoupled.
Quoted 2 lines
In any case, whether such device trees are accepted is ultimately for the device tree maintainers to decide.
As mentioned above, the issue also extends to deployed products.
Those were just my thoughts on the licensing aspect.
Best regards,
Ulrich
Quoted 2 lines
Best regards,
Max
Signature · 4 lines
Pengutronix e.K. | Ulrich Ölmann | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hi Max,
Quoted 22 lines · Max Pedraza
Embedded products routinely need their own boot logo. Today the only way to get one is to replace one of the logo_*_clut224.ppm files in the kernel source tree, which bakes the image 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 "linux,boot-logo-clut224" 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 1-2) or from a reserved memory region the bootloader filled in (patches 4-5), 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 3 adds that placement.
Quoted 5 lines
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. This is an attempt to find out whether something along these lines is wanted upstream, and if so in what shape -- hence RFC.
Thanks for your series!
Quoted 10 lines
I am aware of the contentious part: a bitmap is not hardware, and the device tree is not an obvious place to put one. The argument for it is that the logo identifies the board in the same way the model property does, it is available before any filesystem is mounted, and it is per board rather than per kernel. The argument against is presumably that this is policy and belongs in userspace or in the bootloader. I would rather hear that explicitly than keep the patch downstream on a guess, and if the concept is rejected I would still like to know whether a smaller subset -- say the placement properties driven from the fbcon command line, without any image in the device tree -- would be worth submitting separately.
The standard location for configuration that is not hardware description is under /chosen...
IIRC, real Open Firmware used to have some logo configuration, too... Yep, /options/oem-logo on CHRP LongTrail[1].
And it's even documented[2], but fixed to 64x64 monochrome.
[1] http://g33rt.be/migrated/Linux/PPC/DeviceTree.html
[2] https://www.djc.id.au/2008/IEEE1275-1994.pdf
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Quoted 5 lines · Ulrich Ölmann
I think the issue is broader than upstream submissions. Once such a device tree is shipped as part of a GPL kernel in a product, the GPL obligations already apply to that distribution. Therefore, the licensing implications of embedding a proprietary logo are not limited to upstream acceptance, they also affect downstream product distributions.
Point taken, thanks for spelling it out. I am not qualified to argue the legal side and will not try to, but I follow the reasoning.
In practice it reinforces the reserved memory path, which is the one we
ship: there the device tree carries only a phandle and the placement, and the image stays a separate file with its own licensing, handled like any other asset in the product.
Max
Quoted 6 lines · Geert Uytterhoeven
The standard location for configuration that is not hardware description is under /chosen...
IIRC, real Open Firmware used to have some logo configuration, too... Yep, /options/oem-logo on CHRP LongTrail[1].
And it's even documented[2], but fixed to 64x64 monochrome.
Thank you, that is the answer I was missing. I had written the "a bitmap is not hardware" objection into the cover letter as something to defend against, and /chosen turns it into a matter of putting the node in the right place instead.
v2 moves it there, and I will post it shortly: the node is a child of /chosen and the kernel looks it up with of_get_compatible_child(of_chosen, ...). The binding now says why, and points at the oem-logo precedent. It also puts the node in the same company as simple-framebuffer, which lives under /chosen for the same reason.
Thanks as well for the references, the CHRP one was new to me.
Max
Maxime Ripard
maintainerHi,
Quoted 22 lines · Màxim Pedraza Padilla
Quoted 7 lines · Uwe Kleine-König
My 0.02€: Usually you want to use the display using drm and not fb once the machine is fully booted. If you're using fb during boot to display a logo, it's hardly possible to switch to drm later in the boot process without flicker.
So my recommendation for your usecase is to not use the kernel boot logo stuff, but something like https://github.com/pengutronix/platsch.
Thanks for the pointer, I did not know platsch and it looks like a good fit for the problem it solves. It does not solve mine, though, and I think the reason is worth spelling out, because it is not about how the image gets drawn but about when.
These are industrial units, and the requirement is time to first pixel after power is applied. If the panel stays dark for more than a moment the unit reads as dead, and that is a support call. Anything running in userspace is by construction later than the kernel: it needs the kernel booted, the rootfs mounted and init far enough along to exec it. I can measure the exact difference on our hardware if that is useful for the discussion.
Quoted 6 lines
We do already paint a BMP from U-Boot, which is as early as we can possibly be. The problem is the gap that follows: once the display driver probes, the panel is cleared, and nothing puts anything back until userspace is running. Moving the logo further out into userspace widens that gap rather than closing it. The kernel boot logo is what fills it, and that is the whole reason this series exists.
If the sole reason for this series is to keep having something on the display while the kernel boots until DRM catches up, then you probably want to check
https://lore.kernel.org/r/[email protected]
Which also does what you're trying to achieve: keep the display running with the same content while the DRM driver loads, and switch to whatever comes next without a flicker (if we can).
Maxime
Quoted 3 lines · Maxime Ripard
If the sole reason for this series is to keep having something on the display while the kernel boots until DRM catches up, then you probably want to check [drm state readout]
Thanks, I had missed it. I read it and then measured, having earlier claimed in this thread that our hardware kept no state worth reading. That was wrong.
Dumping the LCDC registers at the top of tilcdc's probe, before the driver touches anything:
RASTER_CTRL=00280081 FB=9df13cc0..9dfcf4bc
LCD_EN is set and the scanout address is exactly the framebuffer U-Boot reported, still holding the image. So readout would have something real to adopt here. tilcdc is not one of the drivers you implement, but that is work rather than a disagreement.
One observation that may be worth your time. Pointing a simple-framebuffer node at that same memory, same device tree, only the driver differing:
simplefb the image is still there afterwards
simpledrm the buffer reads back as all zeros
So where the CRTC is still scanning the bootloader's buffer, simpledrm wipes the image it was meant to carry over. I have not chased down the call that clears it.
What readout cannot cover is having no firmware splash to read. U-Boot's Falcon mode boots the kernel from SPL and skips U-Boot proper, where display init lives, so there is no image and no programmed CRTC to inherit -- and Falcon mode exists to shorten boot time, which is the same reason one cares about the logo appearing early.
So I do not think they are alternatives: readout preserves what firmware put up, this series lets the kernel put something there when firmware did not. On hardware with both, readout is the better answer for the handover and I would rather not duplicate it.
Max
Maxime Ripard
maintainerQuoted 29 lines · Màxim Pedraza Padilla
Quoted 3 lines · Maxime Ripard
If the sole reason for this series is to keep having something on the display while the kernel boots until DRM catches up, then you probably want to check [drm state readout]
Thanks, I had missed it. I read it and then measured, having earlier claimed in this thread that our hardware kept no state worth reading. That was wrong.
Dumping the LCDC registers at the top of tilcdc's probe, before the driver touches anything:
RASTER_CTRL=00280081 FB=9df13cc0..9dfcf4bc
LCD_ENis set and the scanout address is exactly the framebuffer U-Boot reported, still holding the image. So readout would have something real to adopt here. tilcdc is not one of the drivers you implement, but that is work rather than a disagreement.One observation that may be worth your time. Pointing a simple-framebuffer node at that same memory, same device tree, only the driver differing:
simplefb the image is still there afterwards
simpledrm the buffer reads back as all zerosSo where the CRTC is still scanning the bootloader's buffer, simpledrm wipes the image it was meant to carry over. I have not chased down the call that clears it.
Quoted 5 lines
What readout cannot cover is having no firmware splash to read. U-Boot's Falcon mode boots the kernel from SPL and skips U-Boot proper, where display init lives, so there is no image and no programmed CRTC to inherit -- and Falcon mode exists to shorten boot time, which is the same reason one cares about the logo appearing early.
In such a case, you can (and really should) use KMS, and you should use an initramfs and setup the splash screen there. There's no need for the kernel to do that work.
It's still significantly different from your earlier claim, since there would be no gap between uboot and DRM, and no blanking either.
Maxime
Quoted 2 lines · Maxime Ripard
In such a case, you can (and really should) use KMS, and you should use an initramfs and setup the splash screen there.
Agreed that readout is the right answer where it applies, and I am not looking to duplicate it. Three cases where it does not:
- Hardware whose only in-tree display driver is fbdev. There is no KMS state to read at all, and there are still around a hundred of those drivers.
- DRM drivers without readout implemented, which today is all of them but tidss.
- Falcon mode, where U-Boot proper never runs, so there is no image and no programmed CRTC to inherit.
On the initramfs: it moves the splash earlier, it does not close the gap. Measured on our 4.19 product kernel:
1.09 s tilcdc registers fb0, the logo can be drawn 2.68 s ubi0 starts attaching <- 1.59 s of built-in driver probes 3.39 s Run /sbin/init <- 0.70 s of UBI attach + UBIFS mount
An initramfs removes the 0.70 s of storage. It cannot remove the 1.59 s, because PID 1 does not exist until the initcalls have run. So the gap goes from 2.3 s to roughly 1.6 s, before the splash binary has loaded and drawn anything. That figure is an estimate; the breakdown it comes from is not.
It is also worth saying what this series is and is not. The kernel has drawn a boot logo for decades; this does not add that. It changes where the image comes from, so that one kernel binary can serve products that differ only in branding. If the position is that the kernel should not draw a logo at all, that is an argument about CONFIG_LOGO rather than about these patches -- and drm_panic already calls fb_find_logo(), so the logo is not purely an fbdev concern either.
On doing it through KMS: you are right, and the follow-up series should be a DRM client alongside drm_log rather than a hook in drm_fb_helper. I will rework it that way before posting it.
Max
Maxime Ripard
maintainerQuoted 10 lines · Màxim Pedraza Padilla
Quoted 2 lines · Maxime Ripard
In such a case, you can (and really should) use KMS, and you should use an initramfs and setup the splash screen there.
Agreed that readout is the right answer where it applies, and I am not looking to duplicate it. Three cases where it does not:
- Hardware whose only in-tree display driver is fbdev. There is no KMS state to read at all, and there are still around a hundred of those drivers.
Which are entirely deprecated, and kept mostly for historical reason. It's kind of irrelevant to this discussion.
Quoted 2 lines
- DRM drivers without readout implemented, which today is all of them but tidss.
The obvious answer to that being "just implement readout then". We won't merge a core feature to accomodate a driver not implementing an existing feature.
Quoted 2 lines
- Falcon mode, where U-Boot proper never runs, so there is no image and no programmed CRTC to inherit.
In this case, the first modeset is fine, and whoever does it doesn't matter, so it might as well be userspace.
Quoted 1 line
On the initramfs: it moves the splash earlier, it does not close the gap.
Which gap are you talking about?
Quoted 8 lines
Measured on our 4.19 product kernel:
1.09 s tilcdc registers fb0, the logo can be drawn 2.68 s ubi0 starts attaching <- 1.59 s of built-in driver probes 3.39 s Run /sbin/init <- 0.70 s of UBI attach + UBIFS mountAn initramfs removes the 0.70 s of storage. It cannot remove the 1.59 s, because PID 1 does not exist until the initcalls have run.
I mean, sure it can. Move built-in drivers to modules, and load them in the initramfs. It will reduce the kernel image size (so load and decompression time) and the kernel boot time itself.
I personally did a subsecond boot to userspace with Falcon Boot, UBI and a similar platform (and no initramfs). 3.4s to run init seems subobtimal to me.
Quoted 11 lines
So the gap goes from 2.3 s to roughly 1.6 s, before the splash binary has loaded and drawn anything. That figure is an estimate; the breakdown it comes from is not.
It is also worth saying what this series is and is not. The kernel has drawn a boot logo for decades; this does not add that. It changes where the image comes from, so that one kernel binary can serve products that differ only in branding. If the position is that the kernel should not draw a logo at all, that is an argument about
CONFIG_LOGOrather than about these patches -- anddrm_panicalready callsfb_find_logo(), so the logo is not purely an fbdev concern either.
I understand where you're coming from. On the flip-side, why should we add an interface we'll have to maintain forever, while making a compromise because the fact that it should be in the DT to begin with is arguable, on a deprecated subsystem, for something where we have alternatives.
Maxime
You're right, on essentially all of it, and I owe you a clearer account than I gave.
The 3.4s I put up was our 4.19 product kernel: not an SPL/Falcon build, and not one that has ever been optimized for boot time. I should have said which system it was instead of holding it up as if it were the floor. "Suboptimal" is fair.
Reaching for an initramfs purely to paint a splash early isn't free on my side either: it pushes the start of the actual application out a little, so it's a trade rather than a clean win. But that's a detail, not a rebuttal.
The case I actually care about is simpler than the one I was making. As someone building products on top of the kernel, I reach for the simplest thing that works, and the kernel already draws a boot logo — so that is what I used, the built-in CLUT224 image, from day one. What pushed me past it was not speed: it was one kernel image feeding four panel variants (two sizes, two orientations), where a single compiled-in logo no longer fits. Describing the logo per board rather than per build is the whole of it.
I'm well aware that "convenient for the product engineer" and "worth carrying in the kernel forever" are different questions, and that the second one is yours and Helge's to answer, not mine. If the verdict is that this belongs in userspace or the bootloader, I'll take it — I would just rather have it decided than keep guessing downstream.
Thanks for taking the time to push back. It was the useful kind.
Max
Hi Maxim.
Quoted 3 lines
On doing it through KMS: you are right, and the follow-up series should be a DRM client alongside
drm_lograther than a hook indrm_fb_helper. I will rework it that way before posting it.
Take a look at:
https://lkml.iu.edu/2605.1/03465.html
The work Francesco Valla did seems to overlap a lot with what you suggest.
From the intro mail:
"
in a nutshell, the splash DRM client can draw a splashscreen using:
- the BMP image supplied by the EFI BGRT;
- a BMP image loaded as firmware (either built-in or loaded from the filesystem);
- a colored background.
"
Sam
Hi Sam,
Thank you -- that's a useful pointer, and it settles the question of how a splash should be drawn without fbcon: a DRM client at drm_client_setup(), next to drm_log, not a drm_fb_helper hook.
Francesco's series is genuinely inspiring work, and it would be very useful to me if it could take a CLUT224 image -- unfortunately it can't. It only accepts an uncompressed 24-bit RGB888 BMP, whereas our logo is paletted, which is what keeps it small: 17 KiB for 800x480 rather than around a megabyte. So as it stands the format doesn't line up with what we carry.
Reading it did make the distinction clearer to me, though. drm_splash *draws* an image into a fresh buffer, which means a first modeset and the blanking that comes with it. What our hardware leaves us with is a framebuffer U-Boot has already drawn and a CRTC still scanning it out, so for our case the natural thing is to *adopt* that state rather than redraw it -- which is what hardware state readout does, with no redraw and no flicker.
Where drm_splash is the right tool is the case with no state to adopt -- Falcon boot, where U-Boot proper never runs, or a handover where the buffer doesn't survive. I'll follow Francesco's series for that.
Thanks again -- it helped me draw the line between the two.
Max
Hi Màxim.
Quoted 6 lines · Màxim Pedraza Padilla
Hi Sam,
Thank you -- that's a useful pointer, and it settles the question of how a splash should be drawn without fbcon: a DRM client at
drm_client_setup(), next todrm_log, not adrm_fb_helperhook.
Quoted 6 lines
Francesco's series is genuinely inspiring work, and it would be very useful to me if it could take a CLUT224 image -- unfortunately it can't. It only accepts an uncompressed 24-bit RGB888 BMP, whereas our logo is paletted, which is what keeps it small: 17 KiB for 800x480 rather than around a megabyte. So as it stands the format doesn't line up with what we carry.
Without looking at it in detail I would assume adding CLUT224 support would be doable. Step 1 would be to add a format conversion in drm_format_helper and use that. You may also find this useful for other purposes.
Sam
Hi Màxim,
Quoted 6 lines · Màxim Pedraza Padilla
Hi Sam,
Thank you -- that's a useful pointer, and it settles the question of how a splash should be drawn without fbcon: a DRM client at
drm_client_setup(), next todrm_log, not adrm_fb_helperhook.
Quoted 6 lines
Francesco's series is genuinely inspiring work, and it would be very useful to me if it could take a CLUT224 image -- unfortunately it can't. It only accepts an uncompressed 24-bit RGB888 BMP, whereas our logo is paletted, which is what keeps it small: 17 KiB for 800x480 rather than around a megabyte. So as it stands the format doesn't line up with what we carry.
Format concerns are - in addition to lack of time to work on it - what is keeping me from sending a new revision. Any kind of compression would need to be unwinded - probably on a per-pixel basis - making the required CPU time unreasonable for large images (at least if boot time optimization is the ultimate goal - linke in my case).
Of course, on "low-resolution" displays the size-vs-time tradeoff might be the sweet spot - but the target here was to being as much generic as possible.
Quoted 9 lines
Reading it did make the distinction clearer to me, though.
drm_splash*draws* an image into a fresh buffer, which means a first modeset and the blanking that comes with it. What our hardware leaves us with is a framebuffer U-Boot has already drawn and a CRTC still scanning it out, so for our case the natural thing is to *adopt* that state rather than redraw it -- which is what hardware state readout does, with no redraw and no flicker.
Quoted 3 lines
Where
drm_splashis the right tool is the case with no state to adopt -- Falcon boot, where U-Boot proper never runs, or a handover where the buffer doesn't survive. I'll follow Francesco's series for that.
My typical embedded setup is exactly that one - Falcon boot, a simple boot logic inside the SPL, and possibly no initramfs. I find this to be the most portable solution, as it does not require complex drivers and handover logic in the bootloader.
In case you decide to take my series for a re-spin, feel free to ask if something is unclear.
Quoted 3 lines
Thanks again -- it helped me draw the line between the two.
Max
Reagrds,
Francesco
Hi Sam, Francesco,
Sam -- thanks, and you're right that it's doable. One honest nuance on where it would live: CLUT224 isn't a DRM fourcc, it's the kernel logo's own container -- a palette plus one index byte per pixel. drm_format_helper converts between pixel formats, which is a symmetric operation; turning CLUT224 into RGB is a palette decode, not a reformat. It can certainly sit there, but it's worth calling it what it is: a decompression step in front of the scanout, not a format conversion next to the xrgb8888->rgb565 helpers.
Francesco -- that's exactly the crux, and I think we agree completely. The palette expansion is cheap for me only because the image is small and
low-resolution: one lookup per pixel at 800x480 costs nothing, so I get the 17 KiB on flash for free at boot. But that's the "low-resolution sweet spot" you describe, not the general case -- at a generic resolution the per-pixel decode stops being free, and boot time is the whole point. So I don't think paletted input belongs in a client whose goal is to stay generic; it's a trade that only pays off when the image is deliberately small.
For the case where nothing lights the panel before Linux -- Falcon boot, or a handover where the buffer doesn't survive -- I do have to draw, and there I'd rather build on your series than start from scratch. I can't use it unchanged, since my logo isn't a BMP: it's a small CLUT224 (paletted) blob carried in the device tree, so I'd add a source alongside your BGRT and firmware-BMP ones that recognises it by a magic and decodes the palette. But the client structure, the drm_client_setup() hook, the scanout path -- that's all your groundwork, and I'd be leaning on it. Thanks for the offer to help on a respin, and for the series, which is what made the distinction clear to me.
Max
Quoted 56 lines · Francesco Valla
Hi Màxim,
Quoted 6 lines · Màxim Pedraza Padilla
Hi Sam,
Thank you -- that's a useful pointer, and it settles the question of how a splash should be drawn without fbcon: a DRM client at
drm_client_setup(), next todrm_log, not adrm_fb_helperhook.Quoted 6 lines
Francesco's series is genuinely inspiring work, and it would be very useful to me if it could take a CLUT224 image -- unfortunately it can't. It only accepts an uncompressed 24-bit RGB888 BMP, whereas our logo is paletted, which is what keeps it small: 17 KiB for 800x480 rather than around a megabyte. So as it stands the format doesn't line up with what we carry.
Format concerns are - in addition to lack of time to work on it - what is keeping me from sending a new revision. Any kind of compression would need to be unwinded - probably on a per-pixel basis - making the required CPU time unreasonable for large images (at least if boot time optimization is the ultimate goal - linke in my case).
Of course, on "low-resolution" displays the size-vs-time tradeoff might be the sweet spot - but the target here was to being as much generic as possible.
Quoted 9 lines
Reading it did make the distinction clearer to me, though.
drm_splash*draws* an image into a fresh buffer, which means a first modeset and the blanking that comes with it. What our hardware leaves us with is a framebuffer U-Boot has already drawn and a CRTC still scanning it out, so for our case the natural thing is to *adopt* that state rather than redraw it -- which is what hardware state readout does, with no redraw and no flicker.Quoted 3 lines
Where
drm_splashis the right tool is the case with no state to adopt -- Falcon boot, where U-Boot proper never runs, or a handover where the buffer doesn't survive. I'll follow Francesco's series for that.My typical embedded setup is exactly that one - Falcon boot, a simple boot logic inside the SPL, and possibly no initramfs. I find this to be the most portable solution, as it does not require complex drivers and handover logic in the bootloader.
In case you decide to take my series for a re-spin, feel free to ask if something is unclear.
Quoted 3 lines
Thanks again -- it helped me draw the line between the two.
Max
Reagrds,
Francesco