1 diff --git a/Documentation/fb/00-INDEX b/Documentation/fb/00-INDEX
2 index 92e89ae..a6cfacc 100644
3 --- a/Documentation/fb/00-INDEX
4 +++ b/Documentation/fb/00-INDEX
5 @@ -19,6 +19,8 @@ matroxfb.txt
6 - info on the Matrox frame buffer driver
8 - info on the PowerVR 2 frame buffer driver
10 + - info on the Framebuffer Splash
12 - info on the TGA (DECChip 21030) frame buffer driver
14 diff --git a/Documentation/fb/splash.txt b/Documentation/fb/splash.txt
16 index 0000000..5e3b009
18 +++ b/Documentation/fb/splash.txt
23 +The framebuffer splash is a kernel feature that allows displaying a background
24 +picture on selected consoles.
26 +What do I need to get it to work?
27 +---------------------------------
29 +To get fb splash up-and-running you will have to:
30 + 1) get a copy of splashutils [1] or a similar program
31 + 2) get some splash themes
32 + 3) build the kernel helper program
33 + 4) build your kernel with the FB_SPLASH option enabled.
35 +To get fb splash operational right after fbcon initialization is finished, you
36 +will have to include a theme and the kernel helper into your initramfs image.
37 +Please refer to splashutils documentation for instructions on how to do that.
39 +[1] The splashutils package can be downloaded from:
40 + http://dev.gentoo.org/~spock/projects/splashutils/
45 +The userspace splash helper (by default: /sbin/splash_helper) is called by the
46 +kernel whenever an important event occurs and the kernel needs some kind of
47 +job to be carried out. Important events include console switches and graphic
48 +mode switches (the kernel requests background images and configuration
49 +parameters for the current console). The splash helper must be accessible at
50 +all times. If it's not, fbsplash will be switched off automatically.
52 +It's possible to set path to the splash helper by writing it to
53 +/proc/sys/kernel/fbsplash.
55 +*****************************************************************************
57 +The information below is mostly technical stuff. There's probably no need to
58 +read it unless you plan to develop a userspace helper.
63 +The splash protocol defines a communication interface between the kernel and
64 +the userspace splash helper.
66 +The kernel side is responsible for:
68 + o rendering console text, using an image as a background (instead of a
69 + standard solid color fbcon uses),
70 + o accepting commands from the user via ioctls on the fbsplash device,
71 + o calling the userspace helper to set things up as soon as the fb subsystem
74 +The userspace helper is responsible for everything else, including parsing
75 +configuration files, decompressing the image files whenever the kernel needs
76 +it, and communicating with the kernel if necessary.
78 +The splash protocol specifies how communication is done in both ways:
79 +kernel->userspace and userspace->helper.
84 +The kernel communicates with the userspace helper by calling it and specifying
85 +the task to be done in a series of arguments.
87 +The arguments follow the pattern:
88 +<splash protocol version> <command> <parameters>
90 +All commands defined in splash protocol v2 have the following parameters:
95 +Splash protocol v1 specified an additional 'fbsplash mode' after the
96 +framebuffer number. Splash protocol v1 is deprecated and should not be used.
98 +Splash protocol v2 specifies the following commands:
102 + The kernel issues this command to request image data. It's up to the userspace
103 + helper to find a background image appropriate for the specified theme and the
104 + current resolution. The userspace helper should respond by issuing the
105 + FBIOSPLASH_SETPIC ioctl.
109 + The kernel issues this command after the fbsplash device is created and
110 + the fbsplash interface is initialized. Upon receiving 'init', the userspace
111 + helper should parse the kernel command line (/proc/cmdline) or otherwise
112 + decide whether fbsplash is to be activated.
114 + To activate fbsplash on the first console the helper should issue the
115 + FBIOSPLASH_SETCFG, FBIOSPLASH_SETPIC and FBIOSPLASH_SETSTATE commands,
116 + in the above-mentioned order.
118 + When the userspace helper is called in an early phase of the boot process
119 + (right after the initialization of fbcon), no filesystems will be mounted.
120 + The helper program should mount sysfs and then create the appropriate
121 + framebuffer, fbsplash and tty0 devices (if they don't already exist) to get
122 + current display settings and to be able to communicate with the kernel side.
123 + It should probably also mount the procfs to be able to parse the kernel
124 + command line parameters.
126 + Note that the console sem is not held when the kernel calls splash_helper
127 + with the 'init' command. The splash helper should perform all ioctls with
128 + origin set to FB_SPLASH_IO_ORIG_USER.
132 + The kernel issues this command on a mode change. The helper's response should
133 + be similar to the response to the 'init' command. Note that this time the
134 + console sem is held and all ioctls must be performed with origin set to
135 + FB_SPLASH_IO_ORIG_KERNEL.
141 +Userspace programs can communicate with fbsplash via ioctls on the fbsplash
142 +device. These ioctls are to be used by both the userspace helper (called
143 +only by the kernel) and userspace configuration tools (run by the users).
145 +The splash helper should set the origin field to FB_SPLASH_IO_ORIG_KERNEL
146 +when doing the appropriate ioctls. All userspace configuration tools should
147 +use FB_SPLASH_IO_ORIG_USER. Failure to set the appropriate value in the origin
148 +field when performing ioctls from the kernel helper will most likely result
149 +in a console deadlock.
151 +FB_SPLASH_IO_ORIG_KERNEL instructs fbsplash not to try to acquire the console
152 +semaphore. Not surprisingly, FB_SPLASH_IO_ORIG_USER instructs it to acquire
155 +The framebuffer splash provides the following ioctls (all defined in
159 +description: loads a background picture for a virtual console
160 +argument: struct fb_splash_iowrapper*; data: struct fb_image*
162 +If called for consoles other than the current foreground one, the picture data
165 +If the current virtual console is running in a 8-bpp mode, the cmap substruct
166 +of fb_image has to be filled appropriately: start should be set to 16 (first
167 +16 colors are reserved for fbcon), len to a value <= 240 and red, green and
168 +blue should point to valid cmap data. The transp field is ingored. The fields
169 +dx, dy, bg_color, fg_color in fb_image are ignored as well.
172 +description: sets the fbsplash config for a virtual console
173 +argument: struct fb_splash_iowrapper*; data: struct vc_splash*
174 +notes: The structure has to be filled with valid data.
177 +description: gets the fbsplash config for a virtual console
178 +argument: struct fb_splash_iowrapper*; data: struct vc_splash*
181 +description: sets the fbsplash state for a virtual console
182 +argument: struct fb_splash_iowrapper*; data: unsigned int*
183 + values: 0 = disabled, 1 = enabled.
186 +description: gets the fbsplash state for a virtual console
187 +argument: struct fb_splash_iowrapper*; data: unsigned int*
188 + values: as in FBIOSPLASH_SETSTATE
190 +Info on used structures:
192 +Definition of struct vc_splash can be found in linux/console_splash.h. It's
193 +heavily commented. Note that the 'theme' field should point to a string
194 +no longer than FB_SPLASH_THEME_LEN. When FBIOSPLASH_GETCFG call is
195 +performed, the theme field should point to a char buffer of length
196 +FB_SPLASH_THEME_LEN.
198 +Definition of struct fb_splash_iowrapper can be found in linux/fb.h.
199 +The fields in this struct have the following meaning:
202 +Virtual console number.
205 +Specifies if the ioctl is performed as a response to a kernel request. The
206 +splash helper should set this field to FB_SPLASH_IO_ORIG_KERNEL, userspace
207 +programs should set it to FB_SPLASH_IO_ORIG_USER. This field is necessary to
208 +avoid console semaphore deadlocks.
211 +Pointer to a data structure appropriate for the performed ioctl. Type of
212 +the data struct is specified in the ioctls description.
214 +*****************************************************************************
219 +Original 'bootsplash' project & implementation by:
220 + Volker Poplawski <volker@poplawski.de>, Stefan Reinauer <stepan@suse.de>,
221 + Steffen Winterfeldt <snwint@suse.de>, Michael Schroeder <mls@suse.de>,
222 + Ken Wimer <wimer@suse.de>.
224 +Fbsplash, splash protocol design, current implementation & docs by:
225 + Michael Januszewski <spock@gentoo.org>
227 diff --git a/drivers/Makefile b/drivers/Makefile
228 index 5c69b86..fa098bb 100644
229 --- a/drivers/Makefile
230 +++ b/drivers/Makefile
232 obj-$(CONFIG_PCI) += pci/
233 obj-$(CONFIG_PARISC) += parisc/
234 obj-$(CONFIG_RAPIDIO) += rapidio/
235 +# char/ comes before serial/ etc so that the VT console is the boot-time
239 obj-$(CONFIG_ACPI) += acpi/
240 # PnP must come after ACPI since it will eventually need to check if acpi
241 @@ -15,10 +18,6 @@ obj-$(CONFIG_ACPI) += acpi/
242 obj-$(CONFIG_PNP) += pnp/
243 obj-$(CONFIG_ARM_AMBA) += amba/
245 -# char/ comes before serial/ etc so that the VT console is the boot-time
249 obj-$(CONFIG_CONNECTOR) += connector/
251 # i810fb and intelfb depend on char/agp/
252 diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
253 index f5079c7..f4cb4a7 100644
254 --- a/drivers/video/Kconfig
255 +++ b/drivers/video/Kconfig
256 @@ -754,7 +754,6 @@ config FB_MATROX
257 select FB_CFB_FILLRECT
258 select FB_CFB_COPYAREA
259 select FB_CFB_IMAGEBLIT
260 - select FB_TILEBLITTING
261 select FB_MACMODES if PPC_PMAC
263 Say Y here if you have a Matrox Millennium, Matrox Millennium II,
264 @@ -1458,5 +1457,15 @@ if FB && SYSFS
265 source "drivers/video/backlight/Kconfig"
270 + bool "Support for the framebuffer splash"
271 + depends on FRAMEBUFFER_CONSOLE=y && !FB_TILEBLITTING
274 + This option enables support for the Linux boot-up splash screen and
275 + graphical backgrounds on consoles. Note that you will need userspace
276 + splash utilities in order to take advantage of these features. Refer
277 + to Documentation/fb/splash.txt for more information.
281 diff --git a/drivers/video/Makefile b/drivers/video/Makefile
282 index aa434e7..8a74fce 100644
283 --- a/drivers/video/Makefile
284 +++ b/drivers/video/Makefile
286 obj-$(CONFIG_VT) += console/
287 obj-$(CONFIG_LOGO) += logo/
288 obj-$(CONFIG_SYSFS) += backlight/
289 +obj-$(CONFIG_FB_SPLASH) += fbsplash.o cfbsplash.o
291 obj-$(CONFIG_FB) += fb.o
292 fb-y := fbmem.o fbmon.o fbcmap.o fbsysfs.o \
293 diff --git a/drivers/video/cfbsplash.c b/drivers/video/cfbsplash.c
295 index 0000000..4adeb2e
297 +++ b/drivers/video/cfbsplash.c
300 + * linux/drivers/video/cfbsplash.c -- Framebuffer splash render functions
302 + * Copyright (C) 2004 Michal Januszewski <spock@gentoo.org>
304 + * Code based upon "Bootsplash" (C) 2001-2003
305 + * Volker Poplawski <volker@poplawski.de>,
306 + * Stefan Reinauer <stepan@suse.de>,
307 + * Steffen Winterfeldt <snwint@suse.de>,
308 + * Michael Schroeder <mls@suse.de>,
309 + * Ken Wimer <wimer@suse.de>.
311 + * This file is subject to the terms and conditions of the GNU General Public
312 + * License. See the file COPYING in the main directory of this archive for
315 +#include <linux/config.h>
316 +#include <linux/module.h>
317 +#include <linux/types.h>
318 +#include <linux/fb.h>
319 +#include <linux/selection.h>
320 +#include <linux/vt_kern.h>
321 +#include <asm/irq.h>
322 +#include <asm/system.h>
324 +#include "console/fbcon.h"
325 +#include "fbsplash.h"
327 +#define parse_pixel(shift,bpp,type) \
329 + if (d & (0x80 >> (shift))) \
330 + dd2[(shift)] = fgx; \
332 + dd2[(shift)] = transparent ? *(type *)splash_src : bgx; \
333 + splash_src += (bpp); \
336 +extern int get_color(struct vc_data *vc, struct fb_info *info,
339 +void fbsplash_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc)
342 + int minlen = min(min(info->var.red.length, info->var.green.length),
343 + info->var.blue.length);
346 + for (j = i = 0; i < 16; i++) {
347 + k = color_table[i];
349 + col = ((vc->vc_palette[j++] >> (8-minlen))
350 + << info->var.red.offset);
351 + col |= ((vc->vc_palette[j++] >> (8-minlen))
352 + << info->var.green.offset);
353 + col |= ((vc->vc_palette[j++] >> (8-minlen))
354 + << info->var.blue.offset);
355 + ((u32 *)info->pseudo_palette)[k] = col;
359 +void fbsplash_renderc(struct fb_info *info, int ypos, int xpos, int height,
360 + int width, u8* src, u32 fgx, u32 bgx, u8 transparent)
364 + int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
365 + unsigned int d = ypos * info->fix.line_length + xpos * bytespp;
366 + unsigned int ds = (ypos * info->var.xres + xpos) * bytespp;
369 + u8* splash_src = (u8 *)(info->splash.data + ds);
370 + u8* dst = (u8 *)(info->screen_base + d);
372 + if ((ypos + height) > info->var.yres || (xpos + width) > info->var.xres)
375 + for (y = 0; y < height; y++) {
376 + switch (info->var.bits_per_pixel) {
379 + for (x = 0; x < width; x++) {
387 + *(u32 *)splash_src : bgx;
391 + fb_writel(dd, dst);
396 + for (x = 0; x < width; x++) {
404 + (*(u32 *)splash_src & 0xffffff) : bgx;
408 +#ifdef __LITTLE_ENDIAN
409 + fb_writew(dd & 0xffff, dst);
411 + fb_writeb((dd >> 16), dst);
413 + fb_writew(dd >> 8, dst);
415 + fb_writeb(dd & 0xff, dst);
421 + for (x = 0; x < width; x += 2) {
425 + parse_pixel(0, 2, u16);
426 + parse_pixel(1, 2, u16);
427 +#ifdef __LITTLE_ENDIAN
428 + dd = dd2[0] | (dd2[1] << 16);
430 + dd = dd2[1] | (dd2[0] << 16);
433 + fb_writel(dd, dst);
439 + for (x = 0; x < width; x += 4) {
443 + parse_pixel(0, 1, u8);
444 + parse_pixel(1, 1, u8);
445 + parse_pixel(2, 1, u8);
446 + parse_pixel(3, 1, u8);
448 +#ifdef __LITTLE_ENDIAN
449 + dd = dd2[0] | (dd2[1] << 8) | (dd2[2] << 16) | (dd2[3] << 24);
451 + dd = dd2[3] | (dd2[2] << 8) | (dd2[1] << 16) | (dd2[0] << 24);
454 + fb_writel(dd, dst);
459 + dst += info->fix.line_length - width * bytespp;
460 + splash_src += (info->var.xres - width) * bytespp;
465 + ((info->fix.visual == FB_VISUAL_TRUECOLOR || \
466 + info->fix.visual == FB_VISUAL_DIRECTCOLOR) ? \
467 + ((u32*)info->pseudo_palette)[a] : a)
469 +void fbsplash_putcs(struct vc_data *vc, struct fb_info *info,
470 + const unsigned short *s, int count, int yy, int xx)
472 + unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
473 + struct fbcon_ops *ops = info->fbcon_par;
474 + int fg_color, bg_color, transparent;
477 + u16 c = scr_readw(s);
479 + fg_color = get_color(vc, info, c, 1);
480 + bg_color = get_color(vc, info, c, 0);
482 + /* Don't paint the background image if console is blanked */
483 + transparent = ops->blank_state ? 0 :
484 + (vc->vc_splash.bg_color == bg_color);
486 + xx = xx * vc->vc_font.width + vc->vc_splash.tx;
487 + yy = yy * vc->vc_font.height + vc->vc_splash.ty;
489 + fgx = cc2cx(fg_color);
490 + bgx = cc2cx(bg_color);
493 + c = scr_readw(s++);
494 + src = vc->vc_font.data + (c & charmask) * vc->vc_font.height *
495 + ((vc->vc_font.width + 7) >> 3);
497 + fbsplash_renderc(info, yy, xx, vc->vc_font.height,
498 + vc->vc_font.width, src, fgx, bgx, transparent);
499 + xx += vc->vc_font.width;
503 +void fbsplash_cursor(struct fb_info *info, struct fb_cursor *cursor)
506 + unsigned int dsize, s_pitch;
507 + struct fbcon_ops *ops = info->fbcon_par;
508 + struct vc_data* vc;
511 + /* we really don't need any cursors while the console is blanked */
512 + if (info->state != FBINFO_STATE_RUNNING || ops->blank_state)
515 + vc = vc_cons[ops->currcon].d;
517 + src = kmalloc(64 + sizeof(struct fb_image), GFP_ATOMIC);
521 + s_pitch = (cursor->image.width + 7) >> 3;
522 + dsize = s_pitch * cursor->image.height;
523 + if (cursor->enable) {
524 + switch (cursor->rop) {
526 + for (i = 0; i < dsize; i++)
527 + src[i] = cursor->image.data[i] ^ cursor->mask[i];
531 + for (i = 0; i < dsize; i++)
532 + src[i] = cursor->image.data[i] & cursor->mask[i];
536 + memcpy(src, cursor->image.data, dsize);
538 + fbsplash_renderc(info,
539 + cursor->image.dy + vc->vc_splash.ty,
540 + cursor->image.dx + vc->vc_splash.tx,
541 + cursor->image.height,
542 + cursor->image.width,
544 + cc2cx(cursor->image.fg_color),
545 + cc2cx(cursor->image.bg_color),
546 + cursor->image.bg_color == vc->vc_splash.bg_color);
551 +static void splashset(u8 *dst, int height, int width, int dstbytes,
558 + if (bpp == 16 || bpp == 8)
561 + while (height-- > 0) {
567 + for (i=0; i < width; i++) {
568 + fb_writel(bgx, p); p += 4;
572 + for (i=0; i < width; i++) {
573 +#ifdef __LITTLE_ENDIAN
574 + fb_writew((bgx & 0xffff),(u16*)p); p += 2;
575 + fb_writeb((bgx >> 16),p++);
577 + fb_writew((bgx >> 8),(u16*)p); p += 2;
578 + fb_writeb((bgx & 0xff),p++);
582 + for (i=0; i < width/4; i++) {
583 + fb_writel(bgx,p); p += 4;
584 + fb_writel(bgx,p); p += 4;
587 + fb_writel(bgx,p); p += 4;
590 + fb_writew(bgx,(u16*)p);
593 + for (i=0; i < width/4; i++) {
594 + fb_writel(bgx,p); p += 4;
598 + fb_writew(bgx,p); p += 2;
601 + fb_writeb(bgx,(u8*)p);
609 +void fbsplash_copy(u8 *dst, u8 *src, int height, int width, int linebytes,
610 + int srclinebytes, int bpp)
614 + while (height-- > 0) {
615 + u32 *p = (u32 *)dst;
616 + u32 *q = (u32 *)src;
621 + for (i=0; i < width; i++)
622 + fb_writel(*q++, p++);
625 + for (i=0; i < (width*3/4); i++)
626 + fb_writel(*q++, p++);
627 + if ((width*3) % 4) {
629 + fb_writeb(*(u8*)q, (u8*)p);
630 + } else if (width & 1) {
631 + fb_writew(*(u16*)q, (u16*)p);
632 + fb_writeb(*(u8*)((u16*)q+1),(u8*)((u16*)p+2));
637 + for (i=0; i < width/4; i++) {
638 + fb_writel(*q++, p++);
639 + fb_writel(*q++, p++);
642 + fb_writel(*q++, p++);
644 + fb_writew(*(u16*)q, (u16*)p);
647 + for (i=0; i < width/4; i++)
648 + fb_writel(*q++, p++);
651 + fb_writew(*(u16*)q, (u16*)p);
652 + q = (u32*) ((u16*)q + 1);
653 + p = (u32*) ((u16*)p + 1);
656 + fb_writeb(*(u8*)q, (u8*)p);
661 + src += srclinebytes;
665 +static void splashfill(struct fb_info *info, int sy, int sx, int height,
668 + int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
669 + int d = sy * info->fix.line_length + sx * bytespp;
670 + int ds = (sy * info->var.xres + sx) * bytespp;
672 + fbsplash_copy((u8 *)(info->screen_base + d), (u8 *)(info->splash.data + ds),
673 + height, width, info->fix.line_length, info->var.xres * bytespp,
674 + info->var.bits_per_pixel);
677 +void fbsplash_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx,
678 + int height, int width)
680 + int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
681 + int bg_color = attr_bgcol_ec(bgshift, vc);
682 + int transparent = vc->vc_splash.bg_color == bg_color;
683 + struct fbcon_ops *ops = info->fbcon_par;
686 + sy = sy * vc->vc_font.height + vc->vc_splash.ty;
687 + sx = sx * vc->vc_font.width + vc->vc_splash.tx;
688 + height *= vc->vc_font.height;
689 + width *= vc->vc_font.width;
691 + /* Don't paint the background image if console is blanked */
692 + if (transparent && !ops->blank_state) {
693 + splashfill(info, sy, sx, height, width);
695 + dst = (u8 *)(info->screen_base + sy * info->fix.line_length +
696 + sx * ((info->var.bits_per_pixel + 7) >> 3));
697 + splashset(dst, height, width, info->fix.line_length, cc2cx(bg_color),
698 + info->var.bits_per_pixel);
702 +void fbsplash_clear_margins(struct vc_data *vc, struct fb_info *info,
705 + unsigned int tw = vc->vc_cols*vc->vc_font.width;
706 + unsigned int th = vc->vc_rows*vc->vc_font.height;
708 + if (!bottom_only) {
710 + splashfill(info, 0, 0, vc->vc_splash.ty, info->var.xres);
712 + splashfill(info, vc->vc_splash.ty, 0, th, vc->vc_splash.tx);
714 + splashfill(info, vc->vc_splash.ty, vc->vc_splash.tx + tw, th,
715 + info->var.xres - vc->vc_splash.tx - tw);
717 + splashfill(info, vc->vc_splash.ty + th, 0,
718 + info->var.yres - vc->vc_splash.ty - th, info->var.xres);
721 +void fbsplash_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y,
722 + int sx, int dx, int width)
724 + u16 *d = (u16 *) (vc->vc_origin + vc->vc_size_row * y + dx * 2);
725 + u16 *s = d + (dx - sx);
728 + u16 *le = d + width;
735 + if (attr != (c & 0xff00)) {
738 + fbsplash_putcs(vc, info, start, d - start, y, x);
743 + if (s >= ls && s < le && c == scr_readw(s)) {
745 + fbsplash_putcs(vc, info, start, d - start, y, x);
746 + x += d - start + 1;
757 + fbsplash_putcs(vc, info, start, d - start, y, x);
760 +void fbsplash_blank(struct vc_data *vc, struct fb_info *info, int blank)
763 + splashset((u8 *)info->screen_base, info->var.yres, info->var.xres,
764 + info->fix.line_length, 0, info->var.bits_per_pixel);
767 + fbsplash_clear_margins(vc, info, 0);
771 diff --git a/drivers/video/console/bitblit.c b/drivers/video/console/bitblit.c
772 index eea422e..f7eb288 100644
773 --- a/drivers/video/console/bitblit.c
774 +++ b/drivers/video/console/bitblit.c
776 #include <linux/console.h>
777 #include <asm/types.h>
779 +#include "../fbsplash.h"
782 * Accelerated handlers.
783 @@ -55,6 +56,13 @@ static void bit_bmove(struct vc_data *vc
784 area.height = height * vc->vc_font.height;
785 area.width = width * vc->vc_font.width;
787 + if (fbsplash_active(info, vc)) {
788 + area.sx += vc->vc_splash.tx;
789 + area.sy += vc->vc_splash.ty;
790 + area.dx += vc->vc_splash.tx;
791 + area.dy += vc->vc_splash.ty;
794 info->fbops->fb_copyarea(info, &area);
797 @@ -380,11 +388,15 @@ static void bit_cursor(struct vc_data *v
798 cursor.image.depth = 1;
799 cursor.rop = ROP_XOR;
801 - if (info->fbops->fb_cursor)
802 - err = info->fbops->fb_cursor(info, &cursor);
803 + if (fbsplash_active(info, vc)) {
804 + fbsplash_cursor(info, &cursor);
806 + if (info->fbops->fb_cursor)
807 + err = info->fbops->fb_cursor(info, &cursor);
810 - soft_cursor(info, &cursor);
812 + soft_cursor(info, &cursor);
815 ops->cursor_reset = 0;
817 diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
818 index 041d069..945b5b0 100644
819 --- a/drivers/video/console/fbcon.c
820 +++ b/drivers/video/console/fbcon.c
825 +#include "../fbsplash.h"
828 # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
829 @@ -108,7 +109,7 @@ enum {
831 static struct display fb_display[MAX_NR_CONSOLES];
833 -static signed char con2fb_map[MAX_NR_CONSOLES];
834 +signed char con2fb_map[MAX_NR_CONSOLES];
835 static signed char con2fb_map_boot[MAX_NR_CONSOLES];
836 static int logo_height;
837 static int logo_lines;
838 @@ -298,7 +299,7 @@ static inline int fbcon_is_inactive(stru
839 vc->vc_mode != KD_TEXT || ops->graphics);
842 -static inline int get_color(struct vc_data *vc, struct fb_info *info,
843 +inline int get_color(struct vc_data *vc, struct fb_info *info,
846 int depth = fb_get_color_depth(&info->var, &info->fix);
847 @@ -404,6 +405,7 @@ static void fb_flashcursor(void *private
849 ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1),
850 get_color(vc, info, c, 0));
852 release_console_sem();
855 @@ -568,6 +570,8 @@ static int fbcon_takeover(int show_logo)
864 @@ -971,6 +975,12 @@ static const char *fbcon_startup(void)
865 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
866 cols /= vc->vc_font.width;
867 rows /= vc->vc_font.height;
869 + if (fbsplash_active(info, vc)) {
870 + cols = vc->vc_splash.twidth / vc->vc_font.width;
871 + rows = vc->vc_splash.theight / vc->vc_font.height;
874 vc_resize(vc, cols, rows);
876 DPRINTK("mode: %s\n", info->fix.id);
877 @@ -1053,7 +1063,7 @@ static void fbcon_init(struct vc_data *v
880 if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
881 - (info->fix.type == FB_TYPE_TEXT))
882 + (info->fix.type == FB_TYPE_TEXT) || fbsplash_active(info, vc))
885 if (var_to_display(p, &info->var, info))
886 @@ -1193,6 +1203,11 @@ static void fbcon_clear(struct vc_data *
887 if (!height || !width)
890 + if (fbsplash_active(info, vc)) {
891 + fbsplash_clear(vc, info, sy, sx, height, width);
895 /* Split blits that cross physical y_wrap boundary */
897 y_break = p->vrows - p->yscroll;
898 @@ -1212,10 +1227,15 @@ static void fbcon_putcs(struct vc_data *
899 struct display *p = &fb_display[vc->vc_num];
900 struct fbcon_ops *ops = info->fbcon_par;
902 - if (!fbcon_is_inactive(vc, info))
903 - ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
904 - get_color(vc, info, scr_readw(s), 1),
905 - get_color(vc, info, scr_readw(s), 0));
906 + if (!fbcon_is_inactive(vc, info)) {
908 + if (fbsplash_active(info, vc))
909 + fbsplash_putcs(vc, info, s, count, ypos, xpos);
911 + ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
912 + get_color(vc, info, scr_readw(s), 1),
913 + get_color(vc, info, scr_readw(s), 0));
917 static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
918 @@ -1231,8 +1251,13 @@ static void fbcon_clear_margins(struct v
919 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
920 struct fbcon_ops *ops = info->fbcon_par;
922 - if (!fbcon_is_inactive(vc, info))
923 - ops->clear_margins(vc, info, bottom_only);
924 + if (!fbcon_is_inactive(vc, info)) {
925 + if (fbsplash_active(info, vc)) {
926 + fbsplash_clear_margins(vc, info, bottom_only);
928 + ops->clear_margins(vc, info, bottom_only);
933 static void fbcon_cursor(struct vc_data *vc, int mode)
934 @@ -1705,7 +1730,7 @@ static int fbcon_scroll(struct vc_data *
937 fbcon_softback_note(vc, t, count);
938 - if (logo_shown >= 0)
939 + if (logo_shown >= 0 || fbsplash_active(info, vc))
941 switch (p->scrollmode) {
943 @@ -1793,6 +1818,8 @@ static int fbcon_scroll(struct vc_data *
947 + if (fbsplash_active(info, vc))
949 switch (p->scrollmode) {
951 ops->bmove(vc, info, t, 0, t + count, 0,
952 @@ -1935,6 +1962,13 @@ static void fbcon_bmove_rec(struct vc_da
957 + if (fbsplash_active(info, vc) && sy == dy && height == 1) {
958 + /* must use slower redraw bmove to keep background pic intact */
959 + fbsplash_bmove_redraw(vc, info, sy, sx, dx, width);
963 ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
966 @@ -2005,8 +2039,9 @@ static int fbcon_resize(struct vc_data *
967 var.yres = virt_h * virt_fh;
968 x_diff = info->var.xres - var.xres;
969 y_diff = info->var.yres - var.yres;
970 - if (x_diff < 0 || x_diff > virt_fw ||
971 - y_diff < 0 || y_diff > virt_fh) {
973 + if ((x_diff < 0 || x_diff > virt_fw ||
974 + y_diff < 0 || y_diff > virt_fh) && !vc->vc_splash.state) {
975 struct fb_videomode *mode;
977 DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
978 @@ -2042,7 +2077,26 @@ static int fbcon_switch(struct vc_data *
980 info = registered_fb[con2fb_map[vc->vc_num]];
981 ops = info->fbcon_par;
983 + prev_console = ops->currcon;
984 + if (prev_console != -1)
985 + old_info = registered_fb[con2fb_map[prev_console]];
987 + if (fbsplash_active_vc(vc)) {
988 + struct vc_data *vc_curr = vc_cons[prev_console].d;
989 + if (!vc_curr->vc_splash.theme || strcmp(vc->vc_splash.theme, vc_curr->vc_splash.theme)) {
990 + if (fbsplash_call_helper("getpic", vc->vc_num))
991 + fbsplash_disable(vc, 0);
993 + } else if (info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
994 + struct vc_data *vc_curr = vc_cons[prev_console].d;
995 + if (vc_curr && fbsplash_active_vc(vc_curr)) {
996 + /* Clear the screen to avoid displaying funky colors during
997 + * palette updates. */
998 + memset((u8*)info->screen_base + info->fix.line_length * info->var.yoffset,
999 + 0, info->var.yres * info->fix.line_length);
1005 fbcon_set_origin(vc);
1006 @@ -2060,9 +2114,6 @@ static int fbcon_switch(struct vc_data *
1007 logo_shown = FBCON_LOGO_CANSHOW;
1010 - prev_console = ops->currcon;
1011 - if (prev_console != -1)
1012 - old_info = registered_fb[con2fb_map[prev_console]];
1014 * FIXME: If we have multiple fbdev's loaded, we need to
1015 * update all info->currcon. Perhaps, we can place this
1016 @@ -2104,6 +2155,11 @@ static int fbcon_switch(struct vc_data *
1020 + if (fbsplash_active_nores(info, vc) && !fbsplash_active(info, vc)) {
1021 + if (fbsplash_call_helper("modechange", vc->vc_num))
1022 + fbsplash_disable(vc, 0);
1025 set_blitting_type(vc, info);
1026 ops->cursor_reset = 1;
1028 @@ -2205,8 +2261,12 @@ static int fbcon_blank(struct vc_data *v
1029 fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
1030 ops->cursor_flash = (!blank);
1032 - if (fb_blank(info, blank))
1033 - fbcon_generic_blank(vc, info, blank);
1034 + if (fb_blank(info, blank)) {
1035 + if (fbsplash_active(info, vc))
1036 + fbsplash_blank(vc, info, blank);
1038 + fbcon_generic_blank(vc, info, blank);
1043 @@ -2364,13 +2424,22 @@ static int fbcon_do_set_font(struct vc_d
1047 + /* reset wrap/pan */
1050 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
1051 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1053 + info->var.xoffset = info->var.yoffset = p->yscroll = 0;
1054 + if (fbsplash_active(info, vc)) {
1055 + cols = vc->vc_splash.twidth;
1056 + rows = vc->vc_splash.theight;
1061 vc_resize(vc, cols, rows);
1063 if (CON_IS_VISIBLE(vc) && softback_buf)
1064 fbcon_update_softback(vc);
1065 } else if (CON_IS_VISIBLE(vc)
1066 @@ -2488,7 +2557,7 @@ static int fbcon_set_palette(struct vc_d
1070 - if (fbcon_is_inactive(vc, info))
1071 + if (fbcon_is_inactive(vc, info) || vc->vc_num != fg_console)
1074 if (!CON_IS_VISIBLE(vc))
1075 @@ -2514,7 +2583,49 @@ static int fbcon_set_palette(struct vc_d
1077 fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap);
1079 - return fb_set_cmap(&palette_cmap, info);
1080 + if (fbsplash_active(info, vc_cons[fg_console].d) &&
1081 + info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
1083 + u16 *red, *green, *blue;
1084 + int minlen = min(min(info->var.red.length, info->var.green.length),
1085 + info->var.blue.length);
1088 + struct fb_cmap cmap = {
1090 + .len = (1 << minlen),
1097 + red = kmalloc(256 * sizeof(u16) * 3, GFP_KERNEL);
1102 + green = red + 256;
1103 + blue = green + 256;
1105 + cmap.green = green;
1108 + for (i = 0; i < cmap.len; i++) {
1109 + red[i] = green[i] = blue[i] = (0xffff * i)/(cmap.len-1);
1112 + h = fb_set_cmap(&cmap, info);
1113 + fbsplash_fix_pseudo_pal(info, vc_cons[fg_console].d);
1118 + } else if (fbsplash_active(info, vc_cons[fg_console].d) &&
1119 + info->var.bits_per_pixel == 8 && info->splash.cmap.red != NULL)
1120 + fb_set_cmap(&info->splash.cmap, info);
1122 +out: return fb_set_cmap(&palette_cmap, info);
1125 static u16 *fbcon_screen_pos(struct vc_data *vc, int offset)
1126 @@ -2740,7 +2851,14 @@ static void fbcon_modechanged(struct fb_
1127 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1128 cols /= vc->vc_font.width;
1129 rows /= vc->vc_font.height;
1130 - vc_resize(vc, cols, rows);
1132 + if (!fbsplash_active_nores(info, vc)) {
1133 + vc_resize(vc, cols, rows);
1135 + if (fbsplash_call_helper("modechange", vc->vc_num))
1136 + fbsplash_disable(vc, 0);
1139 updatescrollmode(p, info, vc);
1141 scrollback_current = 0;
1142 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
1143 index c32a2a5..3a227fa 100644
1144 --- a/drivers/video/fbcmap.c
1145 +++ b/drivers/video/fbcmap.c
1147 #include <linux/tty.h>
1148 #include <linux/fb.h>
1149 #include <linux/slab.h>
1150 +#include "fbsplash.h"
1152 #include <asm/uaccess.h>
1154 @@ -235,14 +236,17 @@ int fb_set_cmap(struct fb_cmap *cmap, st
1156 htransp = *transp++;
1157 if (info->fbops->fb_setcolreg(start++,
1158 - hred, hgreen, hblue,
1159 + hred, hgreen, hblue,
1166 fb_copy_cmap(cmap, &info->cmap);
1168 + if (fbsplash_active(info, vc_cons[fg_console].d) &&
1169 + info->fix.visual == FB_VISUAL_DIRECTCOLOR)
1170 + fbsplash_fix_pseudo_pal(info, vc_cons[fg_console].d);
1175 @@ -250,7 +254,7 @@ int fb_set_user_cmap(struct fb_cmap_user
1177 int rc, size = cmap->len * sizeof(u16);
1178 struct fb_cmap umap;
1181 if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
1182 !info->fbops->fb_setcmap))
1184 diff --git a/drivers/video/fbsplash.c b/drivers/video/fbsplash.c
1185 new file mode 100644
1186 index 0000000..a12d5b8
1188 +++ b/drivers/video/fbsplash.c
1191 + * linux/drivers/video/fbsplash.c -- Framebuffer splash routines
1193 + * Copyright (C) 2004 Michal Januszewski <spock@gentoo.org>
1195 + * Code based upon "Bootsplash" (C) 2001-2003
1196 + * Volker Poplawski <volker@poplawski.de>,
1197 + * Stefan Reinauer <stepan@suse.de>,
1198 + * Steffen Winterfeldt <snwint@suse.de>,
1199 + * Michael Schroeder <mls@suse.de>,
1200 + * Ken Wimer <wimer@suse.de>.
1202 + * Splash render routines are located in /linux/drivers/video/cfbsplash.c
1204 + * This file is subject to the terms and conditions of the GNU General Public
1205 + * License. See the file COPYING in the main directory of this archive for
1209 +#include <linux/config.h>
1210 +#include <linux/module.h>
1211 +#include <linux/kernel.h>
1212 +#include <linux/string.h>
1213 +#include <linux/types.h>
1214 +#include <linux/fb.h>
1215 +#include <linux/vt_kern.h>
1216 +#include <linux/vmalloc.h>
1217 +#include <linux/unistd.h>
1218 +#include <linux/syscalls.h>
1219 +#include <linux/init.h>
1220 +#include <linux/proc_fs.h>
1221 +#include <linux/workqueue.h>
1222 +#include <linux/kmod.h>
1223 +#include <linux/miscdevice.h>
1224 +#include <linux/device.h>
1225 +#include <linux/fs.h>
1227 +#include <asm/uaccess.h>
1228 +#include <asm/irq.h>
1229 +#include <asm/system.h>
1231 +#include "console/fbcon.h"
1232 +#include "fbsplash.h"
1234 +#define SPLASH_VERSION "0.9.2"
1236 +extern signed char con2fb_map[];
1237 +static int fbsplash_enable(struct vc_data *vc);
1238 +char fbsplash_path[KMOD_PATH_LEN] = "/sbin/splash_helper";
1240 +int fbsplash_call_helper(char* cmd, unsigned short vc)
1244 + "PATH=/sbin:/bin",
1250 + unsigned char fb = (int) con2fb_map[vc];
1258 + vc_cons[vc].d->vc_splash.theme,
1262 + snprintf(tfb,5,"%d",fb);
1263 + snprintf(tcons,5,"%d",vc);
1265 + return call_usermodehelper(fbsplash_path, argv, envp, 1);
1268 +/* Disables fbsplash on a virtual console; called with console sem held. */
1269 +int fbsplash_disable(struct vc_data *vc, unsigned char redraw)
1271 + struct fb_info* info;
1273 + if (!vc->vc_splash.state)
1276 + info = registered_fb[(int) con2fb_map[vc->vc_num]];
1281 + vc->vc_splash.state = 0;
1282 + vc_resize(vc, info->var.xres / vc->vc_font.width,
1283 + info->var.yres / vc->vc_font.height);
1285 + if (fg_console == vc->vc_num && redraw) {
1286 + redraw_screen(vc, 0);
1287 + update_region(vc, vc->vc_origin +
1288 + vc->vc_size_row * vc->vc_top,
1289 + vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1292 + printk(KERN_INFO "fbsplash: switched splash state to 'off' on console %d\n",
1298 +/* Enables fbsplash on a virtual console; called with console sem held. */
1299 +static int fbsplash_enable(struct vc_data *vc)
1301 + struct fb_info* info;
1303 + info = registered_fb[(int) con2fb_map[vc->vc_num]];
1305 + if (vc->vc_splash.twidth == 0 || vc->vc_splash.theight == 0 ||
1306 + info == NULL || vc->vc_splash.state || (!info->splash.data &&
1307 + vc->vc_num == fg_console))
1310 + vc->vc_splash.state = 1;
1311 + vc_resize(vc, vc->vc_splash.twidth / vc->vc_font.width,
1312 + vc->vc_splash.theight / vc->vc_font.height);
1314 + if (fg_console == vc->vc_num) {
1315 + redraw_screen(vc, 0);
1316 + update_region(vc, vc->vc_origin +
1317 + vc->vc_size_row * vc->vc_top,
1318 + vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1319 + fbsplash_clear_margins(vc, info, 0);
1322 + printk(KERN_INFO "fbsplash: switched splash state to 'on' on console %d\n",
1328 +static inline int fbsplash_ioctl_dosetstate(struct vc_data *vc, unsigned int __user* state, unsigned char origin)
1332 + if (get_user(tmp, state))
1335 + if (origin == FB_SPLASH_IO_ORIG_USER)
1336 + acquire_console_sem();
1338 + ret = fbsplash_disable(vc, 1);
1340 + ret = fbsplash_enable(vc);
1341 + if (origin == FB_SPLASH_IO_ORIG_USER)
1342 + release_console_sem();
1347 +static inline int fbsplash_ioctl_dogetstate(struct vc_data *vc, unsigned int __user *state)
1349 + return put_user(vc->vc_splash.state, (unsigned int __user*) state);
1352 +static int fbsplash_ioctl_dosetcfg(struct vc_data *vc, struct vc_splash __user *arg, unsigned char origin)
1354 + struct vc_splash cfg;
1355 + struct fb_info *info;
1359 + info = registered_fb[(int) con2fb_map[vc->vc_num]];
1361 + if (copy_from_user(&cfg, arg, sizeof(struct vc_splash)))
1363 + if (info == NULL || !cfg.twidth || !cfg.theight ||
1364 + cfg.tx + cfg.twidth > info->var.xres ||
1365 + cfg.ty + cfg.theight > info->var.yres)
1368 + len = strlen_user(cfg.theme);
1369 + if (!len || len > FB_SPLASH_THEME_LEN)
1371 + tmp = kmalloc(len, GFP_KERNEL);
1374 + if (copy_from_user(tmp, (void __user *)cfg.theme, len))
1379 + /* If this ioctl is a response to a request from kernel, the console sem
1380 + * is already held; we also don't need to disable splash because either the
1381 + * new config and background picture will be successfully loaded, and the
1382 + * splash will stay on, or in case of a failure it'll be turned off in fbcon. */
1383 + if (origin == FB_SPLASH_IO_ORIG_USER) {
1384 + acquire_console_sem();
1385 + if (vc->vc_splash.state)
1386 + fbsplash_disable(vc, 1);
1389 + if (vc->vc_splash.theme)
1390 + kfree(vc->vc_splash.theme);
1392 + vc->vc_splash = cfg;
1394 + if (origin == FB_SPLASH_IO_ORIG_USER)
1395 + release_console_sem();
1397 + printk(KERN_INFO "fbsplash: console %d using theme '%s'\n",
1398 + vc->vc_num, vc->vc_splash.theme);
1402 +static int fbsplash_ioctl_dogetcfg(struct vc_data *vc, struct vc_splash __user *arg)
1404 + struct vc_splash splash;
1407 + if (get_user(tmp, &arg->theme))
1410 + splash = vc->vc_splash;
1411 + splash.theme = tmp;
1413 + if (vc->vc_splash.theme) {
1414 + if (copy_to_user(tmp, vc->vc_splash.theme, strlen(vc->vc_splash.theme) + 1))
1417 + if (put_user(0, tmp))
1420 + if (copy_to_user(arg, &splash, sizeof(struct vc_splash)))
1426 +static int fbsplash_ioctl_dosetpic(struct vc_data *vc, struct fb_image __user *arg, unsigned char origin)
1428 + struct fb_image img;
1429 + struct fb_info *info;
1433 + if (vc->vc_num != fg_console)
1436 + info = registered_fb[(int) con2fb_map[vc->vc_num]];
1441 + if (copy_from_user(&img, arg, sizeof(struct fb_image)))
1444 + if (img.width != info->var.xres || img.height != info->var.yres) {
1445 + printk(KERN_ERR "fbsplash: picture dimensions mismatch\n");
1449 + if (img.depth != info->var.bits_per_pixel) {
1450 + printk(KERN_ERR "fbsplash: picture depth mismatch\n");
1454 + if (img.depth == 8) {
1455 + if (!img.cmap.len || !img.cmap.red || !img.cmap.green ||
1459 + tmp = vmalloc(img.cmap.len * 3 * 2);
1463 + if (copy_from_user(tmp, (void __user*)img.cmap.red, img.cmap.len * 2) ||
1464 + copy_from_user(tmp + (img.cmap.len << 1),
1465 + (void __user*)img.cmap.green, (img.cmap.len << 1)) ||
1466 + copy_from_user(tmp + (img.cmap.len << 2),
1467 + (void __user*)img.cmap.blue, (img.cmap.len << 1))) {
1472 + img.cmap.transp = NULL;
1473 + img.cmap.red = (u16*)tmp;
1474 + img.cmap.green = img.cmap.red + img.cmap.len;
1475 + img.cmap.blue = img.cmap.green + img.cmap.len;
1477 + img.cmap.red = NULL;
1480 + len = ((img.depth + 7) >> 3) * img.width * img.height;
1481 + tmp = vmalloc(len);
1486 + if (copy_from_user(tmp, (void __user*)img.data, len))
1491 + /* If this ioctl is a response to a request from kernel, the console sem
1492 + * is already held. */
1493 + if (origin == FB_SPLASH_IO_ORIG_USER)
1494 + acquire_console_sem();
1496 + if (info->splash.data)
1497 + vfree((u8*)info->splash.data);
1498 + if (info->splash.cmap.red)
1499 + vfree(info->splash.cmap.red);
1501 + info->splash = img;
1503 + if (origin == FB_SPLASH_IO_ORIG_USER)
1504 + release_console_sem();
1508 +out: if (img.cmap.red)
1509 + vfree(img.cmap.red);
1515 +static int splash_ioctl(struct inode * inode, struct file *filp, u_int cmd,
1518 + struct fb_splash_iowrapper __user *wrapper = (void __user*) arg;
1519 + struct vc_data *vc = NULL;
1520 + unsigned short vc_num = 0;
1521 + unsigned char origin = 0;
1522 + void __user *data = NULL;
1524 + if (!access_ok(VERIFY_READ, wrapper,
1525 + sizeof(struct fb_splash_iowrapper)))
1528 + __get_user(vc_num, &wrapper->vc);
1529 + __get_user(origin, &wrapper->origin);
1530 + __get_user(data, &wrapper->data);
1532 + if (!vc_cons_allocated(vc_num))
1535 + vc = vc_cons[vc_num].d;
1538 + case FBIOSPLASH_SETPIC:
1539 + return fbsplash_ioctl_dosetpic(vc, (struct fb_image __user*)data, origin);
1540 + case FBIOSPLASH_SETCFG:
1541 + return fbsplash_ioctl_dosetcfg(vc, (struct vc_splash*)data, origin);
1542 + case FBIOSPLASH_GETCFG:
1543 + return fbsplash_ioctl_dogetcfg(vc, (struct vc_splash*)data);
1544 + case FBIOSPLASH_SETSTATE:
1545 + return fbsplash_ioctl_dosetstate(vc, (unsigned int *)data, origin);
1546 + case FBIOSPLASH_GETSTATE:
1547 + return fbsplash_ioctl_dogetstate(vc, (unsigned int *)data);
1549 + return -ENOIOCTLCMD;
1553 +static struct file_operations splash_ops = {
1554 + .owner = THIS_MODULE,
1555 + .ioctl = splash_ioctl
1558 +static struct miscdevice splash_dev = {
1559 + .minor = MISC_DYNAMIC_MINOR,
1560 + .name = "fbsplash",
1561 + .fops = &splash_ops
1564 +int fbsplash_init(void)
1566 + struct fb_info *info;
1567 + struct vc_data *vc;
1570 + vc = vc_cons[0].d;
1571 + info = registered_fb[0];
1573 + for (i = 0; i < num_registered_fb; i++) {
1574 + registered_fb[i]->splash.data = NULL;
1575 + registered_fb[i]->splash.cmap.red = NULL;
1578 + for (i = 0; i < MAX_NR_CONSOLES && vc_cons[i].d; i++) {
1579 + vc_cons[i].d->vc_splash.state = vc_cons[i].d->vc_splash.twidth =
1580 + vc_cons[i].d->vc_splash.theight = 0;
1581 + vc_cons[i].d->vc_splash.theme = NULL;
1584 + i = misc_register(&splash_dev);
1586 + printk(KERN_ERR "fbsplash: failed to register device\n");
1590 + fbsplash_call_helper("init", 0);
1595 +EXPORT_SYMBOL(fbsplash_path);
1596 diff --git a/drivers/video/fbsplash.h b/drivers/video/fbsplash.h
1597 new file mode 100644
1598 index 0000000..211fa23
1600 +++ b/drivers/video/fbsplash.h
1603 + * linux/drivers/video/fbsplash.h -- Framebuffer splash headers
1605 + * Copyright (C) 2004 Michal Januszewski <spock@gentoo.org>
1609 +#ifndef __FB_SPLASH_H
1610 +#define __FB_SPLASH_H
1612 +#ifndef _LINUX_FB_H
1613 +#include <linux/fb.h>
1616 +/* This is needed for vc_cons in fbcmap.c */
1617 +#include <linux/vt_kern.h>
1623 +#ifdef CONFIG_FB_SPLASH
1625 +int fbsplash_init(void);
1626 +int fbsplash_call_helper(char* cmd, unsigned short cons);
1627 +int fbsplash_disable(struct vc_data *vc, unsigned char redraw);
1630 +void fbsplash_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx);
1631 +void fbsplash_cursor(struct fb_info *info, struct fb_cursor *cursor);
1632 +void fbsplash_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width);
1633 +void fbsplash_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only);
1634 +void fbsplash_blank(struct vc_data *vc, struct fb_info *info, int blank);
1635 +void fbsplash_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width);
1636 +void fbsplash_copy(u8 *dst, u8 *src, int height, int width, int linebytes, int srclinesbytes, int bpp);
1637 +void fbsplash_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc);
1640 +void acquire_console_sem(void);
1641 +void release_console_sem(void);
1642 +void do_unblank_screen(int entering_gfx);
1644 +/* struct vc_data *y */
1645 +#define fbsplash_active_vc(y) (y->vc_splash.state && y->vc_splash.theme)
1647 +/* struct fb_info *x, struct vc_data *y */
1648 +#define fbsplash_active_nores(x,y) (x->splash.data && fbsplash_active_vc(y))
1650 +/* struct fb_info *x, struct vc_data *y */
1651 +#define fbsplash_active(x,y) (fbsplash_active_nores(x,y) && \
1652 + x->splash.width == x->var.xres && \
1653 + x->splash.height == x->var.yres && \
1654 + x->splash.depth == x->var.bits_per_pixel)
1657 +#else /* CONFIG_FB_SPLASH */
1659 +static inline void fbsplash_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx) {}
1660 +static inline void fbsplash_putc(struct vc_data *vc, struct fb_info *info, int c, int ypos, int xpos) {}
1661 +static inline void fbsplash_cursor(struct fb_info *info, struct fb_cursor *cursor) {}
1662 +static inline void fbsplash_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) {}
1663 +static inline void fbsplash_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only) {}
1664 +static inline void fbsplash_blank(struct vc_data *vc, struct fb_info *info, int blank) {}
1665 +static inline void fbsplash_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width) {}
1666 +static inline void fbsplash_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc) {}
1667 +static inline int fbsplash_call_helper(char* cmd, unsigned short cons) { return 0; }
1668 +static inline int fbsplash_init(void) { return 0; }
1669 +static inline int fbsplash_disable(struct vc_data *vc, unsigned char redraw) { return 0; }
1671 +#define fbsplash_active_vc(y) (0)
1672 +#define fbsplash_active_nores(x,y) (0)
1673 +#define fbsplash_active(x,y) (0)
1675 +#endif /* CONFIG_FB_SPLASH */
1677 +#endif /* __FB_SPLASH_H */
1678 diff --git a/include/linux/console_splash.h b/include/linux/console_splash.h
1679 new file mode 100644
1680 index 0000000..c448dd2
1682 +++ b/include/linux/console_splash.h
1684 +#ifndef _LINUX_CONSOLE_SPLASH_H_
1685 +#define _LINUX_CONSOLE_SPLASH_H_ 1
1687 +/* A structure used by the framebuffer splash code (drivers/video/fbsplash.c) */
1689 + __u8 bg_color; /* The color that is to be treated as transparent */
1690 + __u8 state; /* Current splash state: 0 = off, 1 = on */
1691 + __u16 tx, ty; /* Top left corner coordinates of the text field */
1692 + __u16 twidth, theight; /* Width and height of the text field */
1697 diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h
1698 index f8e5587..3e7f476 100644
1699 --- a/include/linux/console_struct.h
1700 +++ b/include/linux/console_struct.h
1705 +#include <linux/console_splash.h>
1708 unsigned short vc_num; /* Console number */
1709 @@ -97,6 +98,8 @@ struct vc_data {
1710 struct vc_data **vc_display_fg; /* [!] Ptr to var holding fg console for this display */
1711 unsigned long vc_uni_pagedir;
1712 unsigned long *vc_uni_pagedir_loc; /* [!] Location of uni_pagedir variable for this console */
1714 + struct vc_splash vc_splash;
1715 /* additional information is in vt_kern.h */
1718 diff --git a/include/linux/fb.h b/include/linux/fb.h
1719 index 2cb19e6..c45e177 100644
1720 --- a/include/linux/fb.h
1721 +++ b/include/linux/fb.h
1724 #define FB_MAX 32 /* sufficient for now */
1726 +struct fb_splash_iowrapper
1728 + unsigned short vc; /* Virtual console */
1729 + unsigned char origin; /* Point of origin of the request */
1735 #define FBIOGET_VSCREENINFO 0x4600
1737 #define FBIOGET_HWCINFO 0x4616
1738 #define FBIOPUT_MODEINFO 0x4617
1739 #define FBIOGET_DISPINFO 0x4618
1741 +#define FBIOSPLASH_SETCFG _IOWR('F', 0x19, struct fb_splash_iowrapper)
1742 +#define FBIOSPLASH_GETCFG _IOR('F', 0x1A, struct fb_splash_iowrapper)
1743 +#define FBIOSPLASH_SETSTATE _IOWR('F', 0x1B, struct fb_splash_iowrapper)
1744 +#define FBIOSPLASH_GETSTATE _IOR('F', 0x1C, struct fb_splash_iowrapper)
1745 +#define FBIOSPLASH_SETPIC _IOWR('F', 0x1D, struct fb_splash_iowrapper)
1747 +#define FB_SPLASH_THEME_LEN 128 /* Maximum lenght of a theme name */
1748 +#define FB_SPLASH_IO_ORIG_KERNEL 0 /* Kernel ioctl origin */
1749 +#define FB_SPLASH_IO_ORIG_USER 1 /* User ioctl origin */
1751 #define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */
1752 #define FB_TYPE_PLANES 1 /* Non interleaved planes */
1753 @@ -769,6 +784,9 @@ struct fb_info {
1754 #define FBINFO_STATE_SUSPENDED 1
1755 u32 state; /* Hardware state i.e suspend */
1756 void *fbcon_par; /* fbcon use-only private area */
1758 + struct fb_image splash;
1760 /* From here on everything is device dependent */
1763 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
1764 index bac61db..1695abc 100644
1765 --- a/include/linux/sysctl.h
1766 +++ b/include/linux/sysctl.h
1767 @@ -148,6 +148,7 @@ enum
1768 KERN_SPIN_RETRY=70, /* int: number of spinlock retries */
1769 KERN_ACPI_VIDEO_FLAGS=71, /* int: flags for setting up video after ACPI sleep */
1770 KERN_IA64_UNALIGNED=72, /* int: ia64 unaligned userland trap enable */
1771 + KERN_FBSPLASH=73, /* string: path to fbsplash helper */
1775 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
1776 index 32b48e8..bb6c528 100644
1777 --- a/kernel/sysctl.c
1778 +++ b/kernel/sysctl.c
1779 @@ -89,6 +89,9 @@ static int ngroups_max = NGROUPS_MAX;
1781 extern char modprobe_path[];
1783 +#ifdef CONFIG_FB_SPLASH
1784 +extern char fbsplash_path[];
1786 #ifdef CONFIG_CHR_DEV_SG
1787 extern int sg_big_buff;
1789 @@ -409,6 +412,17 @@ static ctl_table kern_table[] = {
1790 .strategy = &sysctl_string,
1793 +#ifdef CONFIG_FB_SPLASH
1795 + .ctl_name = KERN_FBSPLASH,
1796 + .procname = "fbsplash",
1797 + .data = &fbsplash_path,
1798 + .maxlen = KMOD_PATH_LEN,
1800 + .proc_handler = &proc_dostring,
1801 + .strategy = &sysctl_string,
1804 #ifdef CONFIG_CHR_DEV_SG
1806 .ctl_name = KERN_SG_BIG_BUFF,