Kernel based bootsplash
Subsystems (6)
v3 cover Kernel based bootsplash
Dear fbdev/fbcon/dri developers,
Thanks for all the valuable feedback.
I've looked into the suggestions you made, and found that it doesn't currently make sense to continue working on the splash code, given the low practical interest I've received on LKML. The code is, and always has been, intended primarily as a study of what can be done, and at this point it has fulfilled this requirement.
Please find attached my latest version of the patchset in which I've clarified the documentation a bit, as well as added a FAQ and To-Do section for anyone wishing to pick up the code.
The code is still based on v4.14-rc5, sorry about that.
In particular, I hope to have clarified in the FAQ why I'm building on top of fbdev and fbcon, as I think I haven't made myself clear enough in the previous discussion. If you still think that my reasoning is wrong, I'd be thankful for pointers towards a better solution.
I'll be happy to rebase it and continue to work on it if interest arises.
This project has been a valuable experience - so huge thanks to everyone involved in any way, from user feedback over code reviews and all the way to architectural discussion.
Max
RFC PATCH v3 1/13 bootsplash: Initial implementation showing black screen
This is the initial prototype for a lean Linux kernel bootsplash.
It works by replacing fbcon's FB manipulation routines (such as bitblit, tileblit) with dummy functions, effectively disabling text output, and drawing the splash directly onto the FB device.
There is a userland API via sysfs, to show/hide the splash on request by dracut, systemd, or other init systems.
As of this commit, the code will show a black screen rather than a logo, and only if manually enabled via sysfs by writing:
echo 1 > /sys/devices/platform/bootsplash.0/enabled
The reasons for implementing a bootsplash in kernel space are:
- Quieting things more and nicer than with the quiet boot option:
Currently the 'quiet' boot option does not remove the blinking cursor and errors are still printed. There are use cases where this is not desirable (such as embedded and desktop systems, digital signage, etc.) and a vendor logo is preferable.
- Showing graphics, and never text, when the GUI crashes:
This is an extension of the above use case, where recovery is meant to happen as invisibly to the user as possible. A system integrator needs the flexibility to hide "scary text" from users in all cases other than a panic.
This is especially desirable in embedded systems such as digital signage.
- Racy VT API:
Userspace bootsplashes and GUIs (e.g. plymouth and X) tend to kick each other out via the non-exclusive KDSETMODE ioctl. This can result in situations such as the user being stuck in X with chvt and Ctrl-Alt-Fx no longer working.
- Mode switching from FB to KMS:
We cannot switch from a generic framebuffer (vesafb, efifb) to a KMS driver while a userspace splash keeps /dev/fb0 open. The device will vanish, but the address space is still busy, so the KMS driver cannot reserve its VRAM.
- Simplification of userspace integration:
Right now, hooking up a splash screen in userspace is quite complex. Having it in the kernel makes this a breeze, as hooks for switch_root, remounting r/w, etc. become obsolete.
--- MAINTAINERS | 8 + drivers/video/console/Kconfig | 24 ++ drivers/video/fbdev/core/Makefile | 3 + drivers/video/fbdev/core/bootsplash.c | 294 +++++++++++++++++++++++++ drivers/video/fbdev/core/bootsplash_internal.h | 55 +++++ drivers/video/fbdev/core/bootsplash_render.c | 93 ++++++++ drivers/video/fbdev/core/dummyblit.c | 89 ++++++++ drivers/video/fbdev/core/fbcon.c | 22 ++ drivers/video/fbdev/core/fbcon.h | 5 + include/linux/bootsplash.h | 43 ++++ 10 files changed, 636 insertions(+) create mode 100644 drivers/video/fbdev/core/bootsplash.c create mode 100644 drivers/video/fbdev/core/bootsplash_internal.h create mode 100644 drivers/video/fbdev/core/bootsplash_render.c create mode 100644 drivers/video/fbdev/core/dummyblit.c create mode 100644 include/linux/bootsplash.h
MAINTAINERS +8 -0
@@ -2705,6 +2705,14 @@ S: Supported F: drivers/net/bonding/ F: include/uapi/linux/if_bonding.h +BOOTSPLASH +M: Max Staudt <[email protected]> +L: [email protected] +S: Maintained +F: drivers/video/fbdev/core/bootsplash*.* +F: drivers/video/fbdev/core/dummycon.c +F: include/linux/bootsplash.h + BPF (Safe dynamic programs and tools) M: Alexei Starovoitov <[email protected]> M: Daniel Borkmann <[email protected]>
drivers/video/console/Kconfig +24 -0
@@ -151,6 +151,30 @@ config FRAMEBUFFER_CONSOLE_ROTATION such that other users of the framebuffer will remain normally oriented. +config BOOTSPLASH + bool "Bootup splash screen" + depends on FRAMEBUFFER_CONSOLE + ---help--- + This option enables the Linux bootsplash screen. + + The bootsplash is a full-screen logo or animation indicating a + booting system. It replaces the classic scrolling text with a + graphical alternative, similar to other systems. + + Since this is technically implemented as a hook on top of fbcon, + it can only work if the FRAMEBUFFER_CONSOLE is enabled and a + framebuffer driver is active. Thus, to get a text-free boot, + the system needs to boot with vesafb, efifb, or similar. + + Once built into the kernel, the bootsplash needs to be enabled + with bootsplash.enabled=1 and a splash file needs to be supplied. + + Further documentation can be found in: + Documentation/fb/bootsplash.txt + + If unsure, say N. + This is typically used by distributors and system integrators. + config STI_CONSOLE bool "STI text console" depends on PARISC
drivers/video/fbdev/core/Makefile +3 -0
@@ -29,3 +29,6 @@ obj-$(CONFIG_FB_SYS_IMAGEBLIT) += sysimgblt.o obj-$(CONFIG_FB_SYS_FOPS) += fb_sys_fops.o obj-$(CONFIG_FB_SVGALIB) += svgalib.o obj-$(CONFIG_FB_DDC) += fb_ddc.o + +obj-$(CONFIG_BOOTSPLASH) += bootsplash.o bootsplash_render.o \ + dummyblit.o
drivers/video/fbdev/core/bootsplash.c new file +294 -0
294 lines not on this page · raw message
drivers/video/fbdev/core/bootsplash_internal.h new file +55 -0
55 lines not on this page · raw message
drivers/video/fbdev/core/bootsplash_render.c new file +93 -0
93 lines not on this page · raw message
drivers/video/fbdev/core/dummyblit.c new file +89 -0
89 lines not on this page · raw message
drivers/video/fbdev/core/fbcon.c +22 -0
@@ -80,6 +80,7 @@#include <asm/irq.h> #include "fbcon.h" +#include <linux/bootsplash.h> #ifdef FBCONDEBUG # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
@@ -542,6 +543,8 @@ static int do_fbcon_takeover(int show_logo)for (i = first_fb_vc; i <= last_fb_vc; i++) con2fb_map[i] = info_idx; +bootsplash_init (); + err =do_take_over_console (&fb_con, first_fb_vc, last_fb_vc, fbcon_is_default);
@@ -661,6 +664,9 @@ static void set_blitting_type(struct vc_data *vc, struct fb_info *info)else {fbcon_set_rotation (info);fbcon_set_bitops (ops); + +if (bootsplash_would_render_now ()) +fbcon_set_dummyops (ops); } }
@@ -683,6 +689,19 @@ static void set_blitting_type(struct vc_data *vc, struct fb_info *info) ops->p = &fb_display[vc->vc_num];fbcon_set_rotation (info);fbcon_set_bitops (ops); + +/* +* Note: +* This is *eventually correct*. +* Setting the fbcon operations and drawing the splash happen at +* different points in time. If the splash is enabled/disabled +* in between, then bootsplash_{en,dis}able will schedule a +* redraw, which will again render the splash (or not) and set +* the correct fbcon ops. +* The last run will then be the right one. +*/ +if (bootsplash_would_render_now ()) +fbcon_set_dummyops (ops); }static int fbcon_invalid_charcount (struct fb_info *info,unsigned charcount)
@@ -2184,6 +2203,9 @@ static int fbcon_switch(struct vc_data *vc) info = registered_fb[con2fb_map[vc->vc_num]]; ops = info->fbcon_par; +if (bootsplash_would_render_now ()) +bootsplash_render_full (info); +if (softback_top) {if (softback_lines)fbcon_set_origin (vc);
drivers/video/fbdev/core/fbcon.h +5 -0
@@ -214,6 +214,11 @@ static inline int attr_col_ec(int shift, struct vc_data *vc,#define SCROLL_REDRAW 0x004#define SCROLL_PAN_REDRAW 0x005 +#ifdef CONFIG_BOOTSPLASH +extern void fbcon_set_dummyops (struct fbcon_ops *ops); +#else /* CONFIG_BOOTSPLASH */ +#define fbcon_set_dummyops (x) +#endif /* CONFIG_BOOTSPLASH */ #ifdef CONFIG_FB_TILEBLITTING extern void fbcon_set_tileops (struct vc_data *vc,struct fb_info *info);#endif
include/linux/bootsplash.h new file +43 -0
43 lines not on this page · raw message
Signature · 1 line
2.12.3
RFC PATCH v3 2/13 bootsplash: Add file reading and picture rendering
In reply to Max StaudtLoad logo(s) from a file and render them in the center of the screen.
This removes the "black screen" functionality, which can now be emulated by providing a splash file with no pictures and a black background.
To enable the bootsplash at boot, provide a theme file *in the initramfs* and tell the kernel to use it as follows:
bootsplash.bootfile=mypath/myfile
Since the splash code is using request_firmware() to load the file, the path has to be beneath /lib/firmware.
--- MAINTAINERS | 1 + drivers/video/fbdev/core/Makefile | 2 +- drivers/video/fbdev/core/bootsplash.c | 36 +++- drivers/video/fbdev/core/bootsplash_internal.h | 45 ++++- drivers/video/fbdev/core/bootsplash_load.c | 225 +++++++++++++++++++++++++ drivers/video/fbdev/core/bootsplash_render.c | 103 ++++++++++- include/uapi/linux/bootsplash_file.h | 118 +++++++++++++ 7 files changed, 522 insertions(+), 8 deletions(-) create mode 100644 drivers/video/fbdev/core/bootsplash_load.c create mode 100644 include/uapi/linux/bootsplash_file.h
MAINTAINERS +1 -0
@@ -2712,6 +2712,7 @@ S: Maintained F: drivers/video/fbdev/core/bootsplash*.* F: drivers/video/fbdev/core/dummycon.c F: include/linux/bootsplash.h +F: include/uapi/linux/bootsplash_file.h BPF (Safe dynamic programs and tools) M: Alexei Starovoitov <[email protected]>
drivers/video/fbdev/core/Makefile +1 -1
@@ -31,4 +31,4 @@ obj-$(CONFIG_FB_SVGALIB) += svgalib.o obj-$(CONFIG_FB_DDC) += fb_ddc.o obj-$(CONFIG_BOOTSPLASH) += bootsplash.o bootsplash_render.o \ - dummyblit.o + bootsplash_load.o dummyblit.o
drivers/video/fbdev/core/bootsplash.c +34 -2
@@ -32,6 +32,7 @@#include <linux/workqueue.h> #include "bootsplash_internal.h" +#include "uapi/linux/bootsplash_file.h" /*
@@ -102,10 +103,17 @@ static bool is_fb_compatible(const struct fb_info *info)*/ void bootsplash_render_full (struct fb_info *info) { +mutex_lock (&splash_state.data_lock); +if (!is_fb_compatible (info)) -return ; + goto out; + +bootsplash_do_render_background (info, splash_state.file); + +bootsplash_do_render_pictures (info, splash_state.file); -bootsplash_do_render_background (info); +out: +mutex_unlock (&splash_state.data_lock); }
@@ -116,6 +124,7 @@ bool bootsplash_would_render_now(void) {return !oops_in_progress && !console_blanked + && splash_state.file &&bootsplash_is_enabled (); }
@@ -252,6 +261,7 @@ static struct platform_driver splash_driver = {void bootsplash_init (void ) {int ret; +struct splash_file_priv *fp;/* Initialized already? */ if (splash_state.splash_device)
@@ -280,8 +290,26 @@ void bootsplash_init(void) } +mutex_init (&splash_state.data_lock); +set_bit (0 , &splash_state.enabled); +INIT_WORK (&splash_state.work_redraw_vc, splash_callback_redraw_vc); + +if (!splash_state.bootfile || !strlen (splash_state.bootfile)) +return ; + + fp =bootsplash_load_firmware (&splash_state.splash_device->dev, + splash_state.bootfile); + +if (!fp) + goto err; + +mutex_lock (&splash_state.data_lock); + splash_state.splash_fb =NULL ; + splash_state.file = fp; +mutex_unlock (&splash_state.data_lock); +return ; err_device:
@@ -292,3 +320,7 @@ void bootsplash_init(void) err:pr_err ("Failed to initialize.\n" ); } + + +module_param_named (bootfile, splash_state.bootfile, charp,0444 ); +MODULE_PARM_DESC (bootfile,"Bootsplash file to load on boot" );
drivers/video/fbdev/core/bootsplash_internal.h +44 -1
71 lines not on this page · raw message
drivers/video/fbdev/core/bootsplash_load.c new file +225 -0
225 lines not on this page · raw message
drivers/video/fbdev/core/bootsplash_render.c +99 -4
124 lines not on this page · raw message
include/uapi/linux/bootsplash_file.h new file +118 -0
118 lines not on this page · raw message
Signature · 1 line
2.12.3
RFC PATCH v3 3/13 bootsplash: Flush framebuffer after drawing
In reply to Max StaudtFramebuffers with deferred I/O need to be flushed to the screen explicitly, since we use neither the mmap nor the file I/O abstractions that handle this for userspace FB clients.
Example: xenfb
Some framebuffer drivers implement lazy access to the screen without actually exposing a fbdefio interface - we also match some known ones, currently:
- ast
- cirrus
- mgag200
--- drivers/video/fbdev/core/bootsplash.c | 2 ++ drivers/video/fbdev/core/bootsplash_internal.h | 1 + drivers/video/fbdev/core/bootsplash_render.c | 33 ++++++++++++++++++++++++++ 3 files changed, 36 insertions(+)
drivers/video/fbdev/core/bootsplash.c +2 -0
@@ -112,6 +112,8 @@ void bootsplash_render_full(struct fb_info *info)bootsplash_do_render_pictures (info, splash_state.file); +bootsplash_do_render_flush (info); + out:mutex_unlock (&splash_state.data_lock); }
drivers/video/fbdev/core/bootsplash_internal.h +1 -0
@@ -89,6 +89,7 @@ void bootsplash_do_render_background(struct fb_info *info, const struct splash_file_priv *fp);void bootsplash_do_render_pictures (struct fb_info *info,const struct splash_file_priv *fp); +void bootsplash_do_render_flush (struct fb_info *info);void bootsplash_free_file (struct splash_file_priv *fp);
drivers/video/fbdev/core/bootsplash_render.c +33 -0
@@ -186,3 +186,36 @@ void bootsplash_do_render_pictures(struct fb_info *info, pp->pic_header->width, pp->pic_header->height); } } + + +void bootsplash_do_render_flush (struct fb_info *info) +{ +/* +* FB drivers using deferred_io (such as Xen) need to sync the +* screen after modifying its contents. When the FB is mmap()ed +* from userspace, this happens via a dirty pages callback, but +* when modifying the FB from the kernel, there is no such thing. +* +* So let's issue a fake fb_copyarea (copying the FB onto itself) +* to trick the FB driver into syncing the screen. +* +* A few DRM drivers' FB implementations are broken by not using +* deferred_io when they really should - we match on the known +* bad ones manually for now. +*/ +if (info->fbdefio + || !strcmp (info->fix.id,"astdrmfb" ) + || !strcmp (info->fix.id,"cirrusdrmfb" ) + || !strcmp (info->fix.id,"mgadrmfb" )) { +struct fb_copyarea area; + + area.dx =0 ; + area.dy =0 ; + area.width = info->var.xres; + area.height = info->var.yres; + area.sx =0 ; + area.sy =0 ; + + info->fbops->fb_copyarea (info, &area); + } +}
Signature · 1 line
2.12.3
RFC PATCH v3 4/13 bootsplash: Add corner positioning
In reply to Max StaudtThis allows showing multiple logos, each in its own position, relative to the eight screen corners.
--- drivers/video/fbdev/core/bootsplash_render.c | 136 ++++++++++++++++++++++++++- include/uapi/linux/bootsplash_file.h | 45 ++++++++- 2 files changed, 178 insertions(+), 3 deletions(-)
drivers/video/fbdev/core/bootsplash_render.c +134 -2
@@ -155,6 +155,7 @@ void bootsplash_do_render_pictures(struct fb_info *info,for (i =0 ; i < fp->header->num_pics; i++) {struct splash_blob_priv *bp;struct splash_pic_priv *pp = &fp->pics[i]; +const struct splash_pic_header *ph = pp->pic_header;long dst_xoff, dst_yoff;if (pp->blobs_loaded <1 )
@@ -165,8 +166,139 @@ void bootsplash_do_render_pictures(struct fb_info *info,if (!bp || bp->blob_header->type !=0 )continue ; - dst_xoff = (info->var.xres - pp->pic_header->width) /2 ; - dst_yoff = (info->var.yres - pp->pic_header->height) /2 ; +switch (ph->position) { +case SPLASH_POS_FLAG_CORNER |SPLASH_CORNER_TOP_LEFT : + dst_xoff =0 ; + dst_yoff =0 ; + + dst_xoff += ph->position_offset; + dst_yoff += ph->position_offset; +break ; +case SPLASH_POS_FLAG_CORNER |SPLASH_CORNER_TOP : + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /=2 ; + dst_yoff =0 ; + + dst_yoff += ph->position_offset; +break ; +case SPLASH_POS_FLAG_CORNER |SPLASH_CORNER_TOP_RIGHT : + dst_xoff = info->var.xres - pp->pic_header->width; + dst_yoff =0 ; + + dst_xoff -= ph->position_offset; + dst_yoff += ph->position_offset; +break ; +case SPLASH_POS_FLAG_CORNER |SPLASH_CORNER_RIGHT : + dst_xoff = info->var.xres - pp->pic_header->width; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /=2 ; + + dst_xoff -= ph->position_offset; +break ; +case SPLASH_POS_FLAG_CORNER |SPLASH_CORNER_BOTTOM_RIGHT : + dst_xoff = info->var.xres - pp->pic_header->width; + dst_yoff = info->var.yres - pp->pic_header->height; + + dst_xoff -= ph->position_offset; + dst_yoff -= ph->position_offset; +break ; +case SPLASH_POS_FLAG_CORNER |SPLASH_CORNER_BOTTOM : + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /=2 ; + dst_yoff = info->var.yres - pp->pic_header->height; + + dst_yoff -= ph->position_offset; +break ; +case SPLASH_POS_FLAG_CORNER |SPLASH_CORNER_BOTTOM_LEFT : + dst_xoff =0 + ph->position_offset; + dst_yoff = info->var.yres - pp->pic_header->height + - ph->position_offset; +break ; +case SPLASH_POS_FLAG_CORNER |SPLASH_CORNER_LEFT : + dst_xoff =0 ; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /=2 ; + + dst_xoff += ph->position_offset; +break ; + +case SPLASH_CORNER_TOP_LEFT : + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /=2 ; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /=2 ; + + dst_xoff -= ph->position_offset; + dst_yoff -= ph->position_offset; +break ; +case SPLASH_CORNER_TOP : + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /=2 ; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /=2 ; + + dst_yoff -= ph->position_offset; +break ; +case SPLASH_CORNER_TOP_RIGHT : + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /=2 ; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /=2 ; + + dst_xoff += ph->position_offset; + dst_yoff -= ph->position_offset; +break ; +case SPLASH_CORNER_RIGHT : + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /=2 ; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /=2 ; + + dst_xoff += ph->position_offset; +break ; +case SPLASH_CORNER_BOTTOM_RIGHT : + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /=2 ; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /=2 ; + + dst_xoff += ph->position_offset; + dst_yoff += ph->position_offset; +break ; +case SPLASH_CORNER_BOTTOM : + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /=2 ; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /=2 ; + + dst_yoff += ph->position_offset; +break ; +case SPLASH_CORNER_BOTTOM_LEFT : + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /=2 ; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /=2 ; + + dst_xoff -= ph->position_offset; + dst_yoff += ph->position_offset; +break ; +case SPLASH_CORNER_LEFT : + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /=2 ; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /=2 ; + + dst_xoff -= ph->position_offset; +break ; + +default : +/* As a fallback, center the picture. */ + dst_xoff = info->var.xres - pp->pic_header->width; + dst_xoff /=2 ; + dst_yoff = info->var.yres - pp->pic_header->height; + dst_yoff /=2 ; +break ; + }if (dst_xoff <0 || dst_yoff < 0
include/uapi/linux/bootsplash_file.h +44 -1
55 lines not on this page · raw message
Signature · 1 line
2.12.3
RFC PATCH v3 5/13 bootsplash: Add animation support
In reply to Max StaudtEach 'picture' in the splash file can consist of multiple 'blobs'.
If animation is enabled, these blobs become the frames of an animation, in the order in which they are stored in the file.
Note: There is only one global timer, so all animations happen at
the same frame rate. It doesn't really make sense to animate more than one object at a time anyway.
Furthermore, this patch introduces a check for reusing a framebuffer where the splash has recently been painted on - in this case, we only redraw the objects that are animated.
--- drivers/video/fbdev/core/bootsplash.c | 62 +++++++++++++++++++++++--- drivers/video/fbdev/core/bootsplash_internal.h | 13 +++++- drivers/video/fbdev/core/bootsplash_load.c | 21 +++++++++ drivers/video/fbdev/core/bootsplash_render.c | 30 ++++++++++++- include/uapi/linux/bootsplash_file.h | 35 ++++++++++++++- 5 files changed, 151 insertions(+), 10 deletions(-)
drivers/video/fbdev/core/bootsplash.c +57 -5
@@ -53,6 +53,14 @@ static void splash_callback_redraw_vc(struct work_struct *ignored)console_unlock (); } +static void splash_callback_animation (struct work_struct *ignored) +{ +if (bootsplash_would_render_now ()) { +/* This will also re-schedule this delayed worker */ +splash_callback_redraw_vc (ignored); + } +} +static bool is_fb_compatible (const struct fb_info *info) {
@@ -103,17 +111,44 @@ static bool is_fb_compatible(const struct fb_info *info)*/ void bootsplash_render_full (struct fb_info *info) { +bool is_update = false; +mutex_lock (&splash_state.data_lock); -if (!is_fb_compatible (info)) - goto out; +/* +* If we've painted on this FB recently, we don't have to do +* the sanity checks and background drawing again. +*/ +if (splash_state.splash_fb == info) + is_update = true; + + +if (!is_update) { +/* Check whether we actually support this FB. */ + splash_state.splash_fb =NULL ; + +if (!is_fb_compatible (info)) + goto out; + +/* Draw the background only once */ +bootsplash_do_render_background (info, splash_state.file); -bootsplash_do_render_background (info, splash_state.file); +/* Mark this FB as last seen */ + splash_state.splash_fb = info; + } -bootsplash_do_render_pictures (info, splash_state.file); +bootsplash_do_render_pictures (info, splash_state.file, is_update);bootsplash_do_render_flush (info); +bootsplash_do_step_animations (splash_state.file); + +/* Schedule update for animated splash screens */ +if (splash_state.file->frame_ms >0 ) +schedule_delayed_work (&splash_state.dwork_animation, +msecs_to_jiffies ( + splash_state.file->frame_ms)); + out:mutex_unlock (&splash_state.data_lock); }
@@ -169,8 +204,14 @@ void bootsplash_enable(void) was_enabled =test_and_set_bit (0 , &splash_state.enabled); -if (!was_enabled) +if (!was_enabled) { +/* Force a full redraw when the splash is re-activated */ +mutex_lock (&splash_state.data_lock); + splash_state.splash_fb =NULL ; +mutex_unlock (&splash_state.data_lock); +schedule_work (&splash_state.work_redraw_vc); + } }
@@ -227,6 +268,14 @@ ATTRIBUTE_GROUPS(splash_dev);*/ static int splash_resume (struct device *device) { +/* +* Force full redraw on resume since we've probably lost the +* framebuffer's contents meanwhile +*/ +mutex_lock (&splash_state.data_lock); + splash_state.splash_fb =NULL ; +mutex_unlock (&splash_state.data_lock); +if (bootsplash_would_render_now ())schedule_work (&splash_state.work_redraw_vc);
@@ -235,6 +284,7 @@ static int splash_resume(struct device *device)static int splash_suspend (struct device *device) { +cancel_delayed_work_sync (&splash_state.dwork_animation);cancel_work_sync (&splash_state.work_redraw_vc);return 0 ;
@@ -296,6 +346,8 @@ void bootsplash_init(void)set_bit (0 , &splash_state.enabled);INIT_WORK (&splash_state.work_redraw_vc, splash_callback_redraw_vc); +INIT_DELAYED_WORK (&splash_state.dwork_animation, + splash_callback_animation);if (!splash_state.bootfile || !strlen (splash_state.bootfile))
drivers/video/fbdev/core/bootsplash_internal.h +12 -1
@@ -37,6 +37,8 @@ struct splash_pic_priv {struct splash_blob_priv *blobs;u16 blobs_loaded; + +u16 anim_nextframe; };
@@ -45,6 +47,12 @@ struct splash_file_priv {const struct splash_file_header *header;struct splash_pic_priv *pics; + +/* +* A local copy of the frame delay in the header. +* We modify it to keep the code simple. +*/ +u16 frame_ms; };
@@ -71,6 +79,7 @@ struct splash_priv {struct platform_device *splash_device;struct work_struct work_redraw_vc; +struct delayed_work dwork_animation;/* Splash data structures including lock for everything below */ struct mutex data_lock;
@@ -88,8 +97,10 @@ struct splash_priv {void bootsplash_do_render_background (struct fb_info *info,const struct splash_file_priv *fp);void bootsplash_do_render_pictures (struct fb_info *info, -const struct splash_file_priv *fp); +const struct splash_file_priv *fp, +bool is_update);void bootsplash_do_render_flush (struct fb_info *info); +void bootsplash_do_step_animations (struct splash_file_priv *fp);void bootsplash_free_file (struct splash_file_priv *fp);
drivers/video/fbdev/core/bootsplash_load.c +21 -0
@@ -71,6 +71,7 @@ struct splash_file_priv *bootsplash_load_firmware(struct device *device, {const struct firmware *fw;struct splash_file_priv *fp; +bool have_anim = false;unsigned int i;const u8 *walker;
@@ -135,6 +136,13 @@ struct splash_file_priv *bootsplash_load_firmware(struct device *device, goto err; } +if (ph->anim_type >SPLASH_ANIM_LOOP_FORWARD ) { +pr_warn ("Picture %u: Unsupported animation type %u.\n" , + i, ph->anim_type); + + ph->anim_type =SPLASH_ANIM_NONE ; + } + pp->pic_header = ph; pp->blobs =vzalloc (ph->num_blobs *sizeof (struct splash_blob_priv ));
@@ -202,6 +210,7 @@ struct splash_file_priv *bootsplash_load_firmware(struct device *device,/* Walk over pictures and ensure all blob slots are filled */ for (i =0 ; i < fp->header->num_pics; i++) {struct splash_pic_priv *pp = &fp->pics[i]; +const struct splash_pic_header *ph = pp->pic_header;if (pp->blobs_loaded != pp->pic_header->num_blobs) { pr_err("Picture %u doesn't have all blob slots filled.\n",
@@ -209,8 +218,20 @@ struct splash_file_priv *bootsplash_load_firmware(struct device *device, goto err; } + +if (ph->anim_type + && ph->num_blobs >1 + && ph->anim_loop < pp->blobs_loaded) + have_anim = true; } +if (!have_anim) +/* Disable animation timer if there is nothing to animate */ + fp->frame_ms =0 ; +else +/* Enforce minimum delay between frames */ + fp->frame_ms =max ((u16 )20 , fp->header->frame_ms); + pr_info("Loaded (%ld bytes, %u pics, %u blobs).\n", fw->size, fp->header->num_pics,
drivers/video/fbdev/core/bootsplash_render.c +28 -2
@@ -148,7 +148,8 @@ void bootsplash_do_render_background(struct fb_info *info,void bootsplash_do_render_pictures (struct fb_info *info, -const struct splash_file_priv *fp) +const struct splash_file_priv *fp, +bool is_update) {unsigned int i;
@@ -161,7 +162,11 @@ void bootsplash_do_render_pictures(struct fb_info *info,if (pp->blobs_loaded <1 )continue ; - bp = &pp->blobs[0 ]; +/* Skip static pictures when refreshing animations */ +if (ph->anim_type ==SPLASH_ANIM_NONE && is_update) +continue ; + + bp = &pp->blobs[pp->anim_nextframe];if (!bp || bp->blob_header->type !=0 )continue ;
@@ -351,3 +356,24 @@ void bootsplash_do_render_flush(struct fb_info *info) info->fbops->fb_copyarea (info, &area); } } + + +void bootsplash_do_step_animations (struct splash_file_priv *fp) +{ +unsigned int i; + +/* Step every animation once */ +for (i =0 ; i < fp->header->num_pics; i++) { +struct splash_pic_priv *pp = &fp->pics[i]; + +if (pp->blobs_loaded <2 + || pp->pic_header->anim_loop > pp->blobs_loaded) +continue ; + +if (pp->pic_header->anim_type ==SPLASH_ANIM_LOOP_FORWARD ) { + pp->anim_nextframe++; +if (pp->anim_nextframe >= pp->pic_header->num_blobs) + pp->anim_nextframe = pp->pic_header->anim_loop; + } + } +}
include/uapi/linux/bootsplash_file.h +33 -2
@@ -77,7 +77,17 @@ struct splash_file_header {uint16_t num_blobs;uint8_t num_pics; -uint8_t padding[103 ]; +uint8_t unused_1; + +/* +* Milliseconds to wait before painting the next frame in +* an animation. +* This is actually a minimum, as the system is allowed to +* stall for longer between frames. +*/ +uint16_t frame_ms; + +uint8_t padding[100 ]; } __attribute__((__packed__));
@@ -116,7 +126,23 @@ struct splash_pic_header {*/ uint16_t position_offset; -uint8_t padding[24 ]; +/* +* Animation type. +* 0 - off +* 1 - forward loop +*/ +uint8_t anim_type; + +/* +* Animation loop point. +* Actual meaning depends on animation type: +* Type 0 - Unused +* 1 - Frame at which to restart the forward loop +* (allowing for "intro" frames) +*/ +uint8_t anim_loop; + +uint8_t padding[22 ]; } __attribute__((__packed__));
@@ -158,4 +184,9 @@ enum splash_position { SPLASH_POS_FLAG_CORNER = 0x10, }; +enum splash_anim_type { +SPLASH_ANIM_NONE =0 , +SPLASH_ANIM_LOOP_FORWARD =1 , +}; +#endif
Signature · 1 line
2.12.3
RFC PATCH v3 6/13 vt: Redraw bootsplash fully on console_unblank
In reply to Max StaudtAfter exiting a KD_GRAPHICS program and falling back to the text console, a previously enabled splash needs to be fully redrawn.
This corner case was introduced with selective re-drawing while implementing animations.
Without this patch, the following happens:
1. Switch to a text console
2. Enable splash
3. Start X (or any other KD_GRAPHICS program)
4. Exit X
5. Splash is not seen, apart from animations
--- drivers/tty/vt/vt.c | 2 ++ drivers/video/fbdev/core/bootsplash.c | 15 +++++++++------ include/linux/bootsplash.h | 4 ++++ 3 files changed, 15 insertions(+), 6 deletions(-)
drivers/tty/vt/vt.c +2 -0
@@ -102,6 +102,7 @@#include <linux/uaccess.h> #include <linux/kdb.h> #include <linux/ctype.h> +#include <linux/bootsplash.h> #define MAX_NR_CON_DRIVER 16
@@ -3903,6 +3904,7 @@ void do_unblank_screen(int leaving_gfx) } console_blanked =0 ; +bootsplash_mark_dirty ();if (vc->vc_sw->con_blank (vc,0 , leaving_gfx) ||vt_force_oops_output (vc))/* Low-level driver cannot restore -> do it ourselves */ update_screen (vc);
drivers/video/fbdev/core/bootsplash.c +9 -6
@@ -165,6 +165,13 @@ bool bootsplash_would_render_now(void) &&bootsplash_is_enabled (); } +void bootsplash_mark_dirty (void ) +{ +mutex_lock (&splash_state.data_lock); + splash_state.splash_fb =NULL ; +mutex_unlock (&splash_state.data_lock); +} +bool bootsplash_is_enabled (void ) {bool was_enabled;
@@ -206,9 +213,7 @@ void bootsplash_enable(void)if (!was_enabled) {/* Force a full redraw when the splash is re-activated */ -mutex_lock (&splash_state.data_lock); - splash_state.splash_fb =NULL ; -mutex_unlock (&splash_state.data_lock); +bootsplash_mark_dirty ();schedule_work (&splash_state.work_redraw_vc); }
@@ -272,9 +277,7 @@ static int splash_resume(struct device *device)* Force full redraw on resume since we've probably lost the * framebuffer's contents meanwhile */ -mutex_lock (&splash_state.data_lock); - splash_state.splash_fb =NULL ; -mutex_unlock (&splash_state.data_lock); +bootsplash_mark_dirty ();if (bootsplash_would_render_now ())schedule_work (&splash_state.work_redraw_vc);
include/linux/bootsplash.h +4 -0
@@ -19,6 +19,8 @@ extern void bootsplash_render_full(struct fb_info *info);extern bool bootsplash_would_render_now (void ); +extern void bootsplash_mark_dirty (void ); +extern bool bootsplash_is_enabled (void );extern void bootsplash_disable (void );extern void bootsplash_enable (void );
@@ -31,6 +33,8 @@ extern void bootsplash_init(void);#define bootsplash_would_render_now () (false) +#define bootsplash_mark_dirty () +#define bootsplash_is_enabled () (false)#define bootsplash_disable ()#define bootsplash_enable ()
Signature · 1 line
2.12.3
RFC PATCH v3 7/13 vt: Add keyboard hook to disable bootsplash
In reply to Max StaudtLet's disable the splash if the user presses ESC or F1-F12 on a VT.
The F1-F12 check is to disable the splash on VT switches.
--- drivers/tty/vt/keyboard.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/tty/vt/keyboard.c +24 -0
@@ -47,6 +47,8 @@#include <asm/irq_regs.h> +#include <linux/bootsplash.h> +extern void ctrl_alt_del (void );/*
@@ -1353,6 +1355,28 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw) }#endif +/* Trap keys when bootsplash is shown */ +if (bootsplash_would_render_now ()) { +/* Deactivate bootsplash on ESC or Alt+Fxx VT switch */ +if (keycode >=KEY_F1 && keycode <=KEY_F12 ) { +bootsplash_disable (); + +/* +* No return here since we want to actually +* perform the VT switch. +*/ + }else { +if (keycode ==KEY_ESC ) +bootsplash_disable (); + +/* +* Just drop any other keys. +* Their effect would be hidden by the splash. +*/ +return ; + } + } +if (kbd->kbdmode ==VC_MEDIUMRAW ) {/* * This is extended medium raw mode, with keys above 127
Signature · 1 line
2.12.3
RFC PATCH v3 8/13 sysrq: Disable bootsplash on SAK
In reply to Max StaudtWhen the user requests a clean TTY via the SAK SysRq, that means he really wants to use the console.
Let's disable the bootsplash, even if the request is not on a VT, as the user probably knows what he's doing and it's more helpful to get out of his way.
--- drivers/tty/sysrq.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/tty/sysrq.c +3 -0
@@ -49,6 +49,7 @@#include <linux/syscalls.h> #include <linux/of.h> #include <linux/rcupdate.h> +#include <linux/bootsplash.h> #include <asm/ptrace.h> #include <asm/irq_regs.h>
@@ -104,6 +105,8 @@ static void sysrq_handle_SAK(int key) {struct work_struct *SAK_work = &vc_cons[fg_console].SAK_work;schedule_work (SAK_work); + +bootsplash_disable (); }static struct sysrq_key_op sysrq_SAK_op = { .handler = sysrq_handle_SAK,
Signature · 1 line
2.12.3
RFC PATCH v3 9/13 fbcon: Disable bootsplash on oops
In reply to Max Staudt--- drivers/video/fbdev/core/fbcon.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/video/fbdev/core/fbcon.c +10 -0
@@ -1343,6 +1343,16 @@ static void fbcon_cursor(struct vc_data *vc, int mode)int y;int c =scr_readw ((u16 *) vc->vc_pos); +/* +* Disable the splash here so we don't have to hook into +* vt_console_print() in drivers/tty/vt/vt.c +* +* We'd disable the splash just before the call to +* hide_cursor() anyway, so this spot is just fine. +*/ +if (oops_in_progress) +bootsplash_disable (); + ops->cur_blink_jiffies =msecs_to_jiffies (vc->vc_cur_blink_ms);if (fbcon_is_inactive (vc, info) || vc->vc_deccm !=1 )
Signature · 1 line
2.12.3
RFC PATCH v3 10/13 Documentation: Add bootsplash main documentation
In reply to Max Staudt--- .../ABI/testing/sysfs-platform-bootsplash | 11 + Documentation/bootsplash.rst | 285 +++++++++++++++++++++ MAINTAINERS | 2 + 3 files changed, 298 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-platform-bootsplash create mode 100644 Documentation/bootsplash.rst
Documentation/ABI/testing/sysfs-platform-bootsplash new file +11 -0
@@ -0,0 +1,11 @@ +What: /sys/devices/platform/bootsplash.0/enabled +Date: Oct 2017 +KernelVersion: 4.14 +Contact: Max Staudt <[email protected]> +Description: + Can be set and read. + + 0: Splash is disabled. + 1: Splash is shown whenever fbcon would show a text console + (i.e. no graphical application is running), and a splash + file is loaded.
Documentation/bootsplash.rst new file +285 -0
285 lines not on this page · raw message
MAINTAINERS +2 -0
@@ -2709,6 +2709,8 @@ BOOTSPLASH M: Max Staudt <[email protected]> L: [email protected] S: Maintained +F: Documentation/ABI/testing/sysfs-platform-bootsplash +F: Documentation/bootsplash.rst F: drivers/video/fbdev/core/bootsplash*.* F: drivers/video/fbdev/core/dummycon.c F: include/linux/bootsplash.h
Signature · 1 line
2.12.3
RFC PATCH v3 11/13 bootsplash: sysfs entries to load and unload files
In reply to Max StaudtUsers can use this to replace their splash screen at runtime by writing a path and filename to /sys/devices/platform/bootsplash.0/load_file and making sure the splash is enabled.
Notes:
- The path has to be a path in /lib/firmware since request_firmware() is used to fetch the data.
- When setting the splash from the shell, echo -n has to be used as any trailing '\n' newline will be interpreted as part of the path.
Writes to /sys/devices/platform/bootsplash.0/drop_splash will cause the current splash theme to be freed and the console to switch to text mode,
--- .../ABI/testing/sysfs-platform-bootsplash | 32 +++++++++++++ Documentation/bootsplash.rst | 8 ++++ drivers/video/fbdev/core/bootsplash.c | 54 ++++++++++++++++++++++ 3 files changed, 94 insertions(+)
Documentation/ABI/testing/sysfs-platform-bootsplash +32 -0
@@ -9,3 +9,35 @@ Description: 1: Splash is shown whenever fbcon would show a text console (i.e. no graphical application is running), and a splash file is loaded. + +What: /sys/devices/platform/bootsplash.0/drop_splash +Date: Oct 2017 +KernelVersion: 4.14 +Contact: Max Staudt <[email protected]> +Description: + Can only be set. + + Any value written will cause the current splash theme file + to be unloaded and the text console to be redrawn. + +What: /sys/devices/platform/bootsplash.0/load_file +Date: Oct 2017 +KernelVersion: 4.14 +Contact: Max Staudt <[email protected]> +Description: + Can only be set. + + Any value written will cause the splash to be disabled and + internal memory structures to be freed. + + A firmware path written will cause a new theme file to be + loaded and the current bootsplash to be replaced. + The current enabled/disabled status is not touched. + If the splash is already active, it will be redrawn. + + The path has to be a path in /lib/firmware since + request_firmware() is used to fetch the data. + + When setting the splash from the shell, echo -n has to be + used as any trailing '\n' newline will be interpreted as + part of the path.
Documentation/bootsplash.rst +8 -0
@@ -67,6 +67,14 @@ sysfs run-time configuration a splash theme file is also loaded. +``/sys/devices/platform/bootsplash.0/drop_splash`` + Unload splash data and free memory. + +``/sys/devices/platform/bootsplash.0/load_file`` + Load a splash file from ``/lib/firmware/``. + Note that trailing newlines will be interpreted as part of the file name. + + Kconfig =======
drivers/video/fbdev/core/bootsplash.c +54 -0
65 lines not on this page · raw message
Signature · 1 line
2.12.3
RFC PATCH v3 12/13 tools/bootsplash: Add a basic splash file creation tool
In reply to Max Staudt--- MAINTAINERS | 1 + tools/bootsplash/.gitignore | 1 + tools/bootsplash/Makefile | 9 + tools/bootsplash/bootsplash-packer.c | 471 +++++++++++++++++++++++++++++++++++ 4 files changed, 482 insertions(+) create mode 100644 tools/bootsplash/.gitignore create mode 100644 tools/bootsplash/Makefile create mode 100644 tools/bootsplash/bootsplash-packer.c
MAINTAINERS +1 -0
@@ -2715,6 +2715,7 @@ F: drivers/video/fbdev/core/bootsplash*.* F: drivers/video/fbdev/core/dummycon.c F: include/linux/bootsplash.h F: include/uapi/linux/bootsplash_file.h +F: tools/bootsplash/* BPF (Safe dynamic programs and tools) M: Alexei Starovoitov <[email protected]>
tools/bootsplash/.gitignore new file +1 -0
@@ -0,0 +1 @@ +bootsplash-packer
tools/bootsplash/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +CC := $(CROSS_COMPILE)gcc +CFLAGS := -I../../usr/include + +PROGS := bootsplash-packer + +all: $(PROGS) + +clean: + rm -fr $(PROGS)
tools/bootsplash/bootsplash-packer.c new file +471 -0
471 lines not on this page · raw message
Signature · 1 line
2.12.3
RFC PATCH v3 13/13 tools/bootsplash: Add script and data to create sample file
In reply to Max StaudtAlso, mention this in the bootsplash documentation.
--- Documentation/bootsplash.rst | 10 ++++++ tools/bootsplash/.gitignore | 3 ++ tools/bootsplash/ajax-loader.gif | Bin 0 -> 3208 bytes tools/bootsplash/bootsplash-tux.sh | 66 +++++++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+) create mode 100644 tools/bootsplash/ajax-loader.gif create mode 100755 tools/bootsplash/bootsplash-tux.sh
Documentation/bootsplash.rst +10 -0
@@ -195,6 +195,16 @@ Hooks - how the bootsplash is integrated +Crating a bootsplash theme file +=============================== + +A simple tool for theme file creation is included in ``tools/bootsplash``. + +There is also an example shell script, as an example on how to use the tool +and in order to generate a reference bootsplash file. + + + FAQ: Frequently Asked Questions ===============================
tools/bootsplash/.gitignore +3 -0
@@ -1 +1,4 @@ bootsplash-packer +bootsplash +logo.rgb +throbber*.rgb
tools/bootsplash/ajax-loader.gif new file binary +0 -0
tools/bootsplash/bootsplash-tux.sh new file +66 -0
66 lines not on this page · raw message
Signature · 1 line
2.12.3