/[linux-patches]/genpatches-2.6/tags/2.6.13-4/4500_fbsplash-0.9.2-r4.patch
Gentoo

Contents of /genpatches-2.6/tags/2.6.13-4/4500_fbsplash-0.9.2-r4.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 168 - (show annotations) (download)
Sun Sep 18 11:19:29 2005 UTC (8 years, 11 months ago) by dsd
File size: 51202 byte(s)
2.6.13-4 release
1 diff --git a/Documentation/fb/00-INDEX b/Documentation/fb/00-INDEX
2 --- a/Documentation/fb/00-INDEX
3 +++ b/Documentation/fb/00-INDEX
4 @@ -19,6 +19,8 @@ matroxfb.txt
5 - info on the Matrox frame buffer driver
6 pvr2fb.txt
7 - info on the PowerVR 2 frame buffer driver
8 +splash.txt
9 + - info on the Framebuffer Splash
10 tgafb.txt
11 - info on the TGA (DECChip 21030) frame buffer driver
12 vesafb.txt
13 diff --git a/Documentation/fb/splash.txt b/Documentation/fb/splash.txt
14 new file mode 100644
15 --- /dev/null
16 +++ b/Documentation/fb/splash.txt
17 @@ -0,0 +1,207 @@
18 +What is it?
19 +-----------
20 +
21 +The framebuffer splash is a kernel feature that allows displaying a background
22 +picture on selected consoles.
23 +
24 +What do I need to get it to work?
25 +---------------------------------
26 +
27 +To get fb splash up-and-running you will have to:
28 + 1) get a copy of splashutils [1] or a similar program
29 + 2) get some splash themes
30 + 3) build the kernel helper program
31 + 4) build your kernel with the FB_SPLASH option enabled.
32 +
33 +To get fb splash operational right after fbcon initialization is finished, you
34 +will have to include a theme and the kernel helper into your initramfs image.
35 +Please refer to splashutils documentation for instructions on how to do that.
36 +
37 +[1] The splashutils package can be downloaded from:
38 + http://dev.gentoo.org/~spock/projects/splashutils/
39 +
40 +The userspace helper
41 +--------------------
42 +
43 +The userspace splash helper (by default: /sbin/splash_helper) is called by the
44 +kernel whenever an important event occurs and the kernel needs some kind of
45 +job to be carried out. Important events include console switches and graphic
46 +mode switches (the kernel requests background images and configuration
47 +parameters for the current console). The splash helper must be accessible at
48 +all times. If it's not, fbsplash will be switched off automatically.
49 +
50 +It's possible to set path to the splash helper by writing it to
51 +/proc/sys/kernel/fbsplash.
52 +
53 +*****************************************************************************
54 +
55 +The information below is mostly technical stuff. There's probably no need to
56 +read it unless you plan to develop a userspace helper.
57 +
58 +The splash protocol
59 +-------------------
60 +
61 +The splash protocol defines a communication interface between the kernel and
62 +the userspace splash helper.
63 +
64 +The kernel side is responsible for:
65 +
66 + o rendering console text, using an image as a background (instead of a
67 + standard solid color fbcon uses),
68 + o accepting commands from the user via ioctls on the fbsplash device,
69 + o calling the userspace helper to set things up as soon as the fb subsystem
70 + is initialized.
71 +
72 +The userspace helper is responsible for everything else, including parsing
73 +configuration files, decompressing the image files whenever the kernel needs
74 +it, and communicating with the kernel if necessary.
75 +
76 +The splash protocol specifies how communication is done in both ways:
77 +kernel->userspace and userspace->helper.
78 +
79 +Kernel -> Userspace
80 +-------------------
81 +
82 +The kernel communicates with the userspace helper by calling it and specifying
83 +the task to be done in a series of arguments.
84 +
85 +The arguments follow the pattern:
86 +<splash protocol version> <command> <parameters>
87 +
88 +All commands defined in splash protocol v2 have the following parameters:
89 + virtual console
90 + framebuffer number
91 + theme
92 +
93 +Splash protocol v1 specified an additional 'fbsplash mode' after the
94 +framebuffer number. Splash protocol v1 is deprecated and should not be used.
95 +
96 +Splash protocol v2 specifies the following commands:
97 +
98 +getpic
99 +------
100 + The kernel issues this command to request image data. It's up to the userspace
101 + helper to find a background image appropriate for the specified theme and the
102 + current resolution. The userspace helper should respond by issuing the
103 + FBIOSPLASH_SETPIC ioctl.
104 +
105 +init
106 +----
107 + The kernel issues this command after the fbsplash device is created and
108 + the fbsplash interface is initialized. Upon receiving 'init', the userspace
109 + helper should parse the kernel command line (/proc/cmdline) or otherwise
110 + decide whether fbsplash is to be activated.
111 +
112 + To activate fbsplash on the first console the helper should issue the
113 + FBIOSPLASH_SETCFG, FBIOSPLASH_SETPIC and FBIOSPLASH_SETSTATE commands,
114 + in the above-mentioned order.
115 +
116 + When the userspace helper is called in an early phase of the boot process
117 + (right after the initialization of fbcon), no filesystems will be mounted.
118 + The helper program should mount sysfs and then create the appropriate
119 + framebuffer, fbsplash and tty0 devices (if they don't already exist) to get
120 + current display settings and to be able to communicate with the kernel side.
121 + It should probably also mount the procfs to be able to parse the kernel
122 + command line parameters.
123 +
124 + Note that the console sem is not held when the kernel calls splash_helper
125 + with the 'init' command. The splash helper should perform all ioctls with
126 + origin set to FB_SPLASH_IO_ORIG_USER.
127 +
128 +modechange
129 +----------
130 + The kernel issues this command on a mode change. The helper's response should
131 + be similar to the response to the 'init' command. Note that this time the
132 + console sem is held and all ioctls must be performed with origin set to
133 + FB_SPLASH_IO_ORIG_KERNEL.
134 +
135 +
136 +Userspace -> Kernel
137 +-------------------
138 +
139 +Userspace programs can communicate with fbsplash via ioctls on the fbsplash
140 +device. These ioctls are to be used by both the userspace helper (called
141 +only by the kernel) and userspace configuration tools (run by the users).
142 +
143 +The splash helper should set the origin field to FB_SPLASH_IO_ORIG_KERNEL
144 +when doing the appropriate ioctls. All userspace configuration tools should
145 +use FB_SPLASH_IO_ORIG_USER. Failure to set the appropriate value in the origin
146 +field when performing ioctls from the kernel helper will most likely result
147 +in a console deadlock.
148 +
149 +FB_SPLASH_IO_ORIG_KERNEL instructs fbsplash not to try to acquire the console
150 +semaphore. Not surprisingly, FB_SPLASH_IO_ORIG_USER instructs it to acquire
151 +the console sem.
152 +
153 +The framebuffer splash provides the following ioctls (all defined in
154 +linux/fb.h):
155 +
156 +FBIOSPLASH_SETPIC
157 +description: loads a background picture for a virtual console
158 +argument: struct fb_splash_iowrapper*; data: struct fb_image*
159 +notes:
160 +If called for consoles other than the current foreground one, the picture data
161 +will be ignored.
162 +
163 +If the current virtual console is running in a 8-bpp mode, the cmap substruct
164 +of fb_image has to be filled appropriately: start should be set to 16 (first
165 +16 colors are reserved for fbcon), len to a value <= 240 and red, green and
166 +blue should point to valid cmap data. The transp field is ingored. The fields
167 +dx, dy, bg_color, fg_color in fb_image are ignored as well.
168 +
169 +FBIOSPLASH_SETCFG
170 +description: sets the fbsplash config for a virtual console
171 +argument: struct fb_splash_iowrapper*; data: struct vc_splash*
172 +notes: The structure has to be filled with valid data.
173 +
174 +FBIOSPLASH_GETCFG
175 +description: gets the fbsplash config for a virtual console
176 +argument: struct fb_splash_iowrapper*; data: struct vc_splash*
177 +
178 +FBIOSPLASH_SETSTATE
179 +description: sets the fbsplash state for a virtual console
180 +argument: struct fb_splash_iowrapper*; data: unsigned int*
181 + values: 0 = disabled, 1 = enabled.
182 +
183 +FBIOSPLASH_GETSTATE
184 +description: gets the fbsplash state for a virtual console
185 +argument: struct fb_splash_iowrapper*; data: unsigned int*
186 + values: as in FBIOSPLASH_SETSTATE
187 +
188 +Info on used structures:
189 +
190 +Definition of struct vc_splash can be found in linux/console_splash.h. It's
191 +heavily commented. Note that the 'theme' field should point to a string
192 +no longer than FB_SPLASH_THEME_LEN. When FBIOSPLASH_GETCFG call is
193 +performed, the theme field should point to a char buffer of length
194 +FB_SPLASH_THEME_LEN.
195 +
196 +Definition of struct fb_splash_iowrapper can be found in linux/fb.h.
197 +The fields in this struct have the following meaning:
198 +
199 +vc:
200 +Virtual console number.
201 +
202 +origin:
203 +Specifies if the ioctl is performed as a response to a kernel request. The
204 +splash helper should set this field to FB_SPLASH_IO_ORIG_KERNEL, userspace
205 +programs should set it to FB_SPLASH_IO_ORIG_USER. This field is necessary to
206 +avoid console semaphore deadlocks.
207 +
208 +data:
209 +Pointer to a data structure appropriate for the performed ioctl. Type of
210 +the data struct is specified in the ioctls description.
211 +
212 +*****************************************************************************
213 +
214 +Credit
215 +------
216 +
217 +Original 'bootsplash' project & implementation by:
218 + Volker Poplawski <volker@poplawski.de>, Stefan Reinauer <stepan@suse.de>,
219 + Steffen Winterfeldt <snwint@suse.de>, Michael Schroeder <mls@suse.de>,
220 + Ken Wimer <wimer@suse.de>.
221 +
222 +Fbsplash, splash protocol design, current implementation & docs by:
223 + Michael Januszewski <spock@gentoo.org>
224 +
225 diff --git a/drivers/Makefile b/drivers/Makefile
226 --- a/drivers/Makefile
227 +++ b/drivers/Makefile
228 @@ -7,16 +7,15 @@
229
230 obj-$(CONFIG_PCI) += pci/
231 obj-$(CONFIG_PARISC) += parisc/
232 +# char/ comes before serial/ etc so that the VT console is the boot-time
233 +# default.
234 +obj-y += char/
235 obj-y += video/
236 obj-$(CONFIG_ACPI_BOOT) += acpi/
237 # PnP must come after ACPI since it will eventually need to check if acpi
238 # was used and do nothing if so
239 obj-$(CONFIG_PNP) += pnp/
240
241 -# char/ comes before serial/ etc so that the VT console is the boot-time
242 -# default.
243 -obj-y += char/
244 -
245 # i810fb and intelfb depend on char/agp/
246 obj-$(CONFIG_FB_I810) += video/i810/
247 obj-$(CONFIG_FB_INTEL) += video/intelfb/
248 diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
249 --- a/drivers/video/Kconfig
250 +++ b/drivers/video/Kconfig
251 @@ -787,7 +787,6 @@ config FB_MATROX
252 select FB_CFB_COPYAREA
253 select FB_CFB_IMAGEBLIT
254 select FB_SOFT_CURSOR
255 - select FB_TILEBLITTING
256 select FB_MACMODES if PPC_PMAC
257 ---help---
258 Say Y here if you have a Matrox Millennium, Matrox Millennium II,
259 @@ -1517,5 +1516,15 @@ if FB && SYSFS
260 source "drivers/video/backlight/Kconfig"
261 endif
262
263 -endmenu
264 +config FB_SPLASH
265 + bool "Support for the framebuffer splash"
266 + depends on FRAMEBUFFER_CONSOLE=y && !FB_TILEBLITTING
267 + default n
268 + ---help---
269 + This option enables support for the Linux boot-up splash screen and
270 + graphical backgrounds on consoles. Note that you will need userspace
271 + splash utilities in order to take advantage of these features. Refer
272 + to Documentation/fb/splash.txt for more information.
273
274 + If unsure, say N.
275 +endmenu
276 diff --git a/drivers/video/Makefile b/drivers/video/Makefile
277 --- a/drivers/video/Makefile
278 +++ b/drivers/video/Makefile
279 @@ -7,6 +7,7 @@
280 obj-$(CONFIG_VT) += console/
281 obj-$(CONFIG_LOGO) += logo/
282 obj-$(CONFIG_SYSFS) += backlight/
283 +obj-$(CONFIG_FB_SPLASH) += fbsplash.o cfbsplash.o
284
285 obj-$(CONFIG_FB) += fb.o
286 fb-y := fbmem.o fbmon.o fbcmap.o fbsysfs.o modedb.o
287 diff --git a/drivers/video/cfbsplash.c b/drivers/video/cfbsplash.c
288 new file mode 100644
289 --- /dev/null
290 +++ b/drivers/video/cfbsplash.c
291 @@ -0,0 +1,472 @@
292 +/*
293 + * linux/drivers/video/cfbsplash.c -- Framebuffer splash render functions
294 + *
295 + * Copyright (C) 2004 Michal Januszewski <spock@gentoo.org>
296 + *
297 + * Code based upon "Bootsplash" (C) 2001-2003
298 + * Volker Poplawski <volker@poplawski.de>,
299 + * Stefan Reinauer <stepan@suse.de>,
300 + * Steffen Winterfeldt <snwint@suse.de>,
301 + * Michael Schroeder <mls@suse.de>,
302 + * Ken Wimer <wimer@suse.de>.
303 + *
304 + * This file is subject to the terms and conditions of the GNU General Public
305 + * License. See the file COPYING in the main directory of this archive for
306 + * more details.
307 + */
308 +#include <linux/config.h>
309 +#include <linux/module.h>
310 +#include <linux/types.h>
311 +#include <linux/fb.h>
312 +#include <linux/selection.h>
313 +#include <linux/vt_kern.h>
314 +#include <asm/irq.h>
315 +#include <asm/system.h>
316 +
317 +#include "console/fbcon.h"
318 +#include "fbsplash.h"
319 +
320 +#define parse_pixel(shift,bpp,type) \
321 + do { \
322 + if (d & (0x80 >> (shift))) \
323 + dd2[(shift)] = fgx; \
324 + else \
325 + dd2[(shift)] = transparent ? *(type *)splash_src : bgx; \
326 + splash_src += (bpp); \
327 + } while (0) \
328 +
329 +extern int get_color(struct vc_data *vc, struct fb_info *info,
330 + u16 c, int is_fg);
331 +
332 +void fbsplash_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc)
333 +{
334 + int i, j, k;
335 + int minlen = min(min(info->var.red.length, info->var.green.length),
336 + info->var.blue.length);
337 + u32 col;
338 +
339 + for (j = i = 0; i < 16; i++) {
340 + k = color_table[i];
341 +
342 + col = ((vc->vc_palette[j++] >> (8-minlen))
343 + << info->var.red.offset);
344 + col |= ((vc->vc_palette[j++] >> (8-minlen))
345 + << info->var.green.offset);
346 + col |= ((vc->vc_palette[j++] >> (8-minlen))
347 + << info->var.blue.offset);
348 + ((u32 *)info->pseudo_palette)[k] = col;
349 + }
350 +}
351 +
352 +void fbsplash_renderc(struct fb_info *info, int ypos, int xpos, int height,
353 + int width, u8* src, u32 fgx, u32 bgx, u8 transparent)
354 +{
355 + unsigned int x, y;
356 + u32 dd;
357 + int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
358 + unsigned int d = ypos * info->fix.line_length + xpos * bytespp;
359 + unsigned int ds = (ypos * info->var.xres + xpos) * bytespp;
360 + u16 dd2[4];
361 +
362 + u8* splash_src = (u8 *)(info->splash.data + ds);
363 + u8* dst = (u8 *)(info->screen_base + d);
364 +
365 + if ((ypos + height) > info->var.yres || (xpos + width) > info->var.xres)
366 + return;
367 +
368 + for (y = 0; y < height; y++) {
369 + switch (info->var.bits_per_pixel) {
370 +
371 + case 32:
372 + for (x = 0; x < width; x++) {
373 +
374 + if ((x & 7) == 0)
375 + d = *src++;
376 + if (d & 0x80)
377 + dd = fgx;
378 + else
379 + dd = transparent ?
380 + *(u32 *)splash_src : bgx;
381 +
382 + d <<= 1;
383 + splash_src += 4;
384 + fb_writel(dd, dst);
385 + dst += 4;
386 + }
387 + break;
388 + case 24:
389 + for (x = 0; x < width; x++) {
390 +
391 + if ((x & 7) == 0)
392 + d = *src++;
393 + if (d & 0x80)
394 + dd = fgx;
395 + else
396 + dd = transparent ?
397 + (*(u32 *)splash_src & 0xffffff) : bgx;
398 +
399 + d <<= 1;
400 + splash_src += 3;
401 +#ifdef __LITTLE_ENDIAN
402 + fb_writew(dd & 0xffff, dst);
403 + dst += 2;
404 + fb_writeb((dd >> 16), dst);
405 +#else
406 + fb_writew(dd >> 8, dst);
407 + dst += 2;
408 + fb_writeb(dd & 0xff, dst);
409 +#endif
410 + dst++;
411 + }
412 + break;
413 + case 16:
414 + for (x = 0; x < width; x += 2) {
415 + if ((x & 7) == 0)
416 + d = *src++;
417 +
418 + parse_pixel(0, 2, u16);
419 + parse_pixel(1, 2, u16);
420 +#ifdef __LITTLE_ENDIAN
421 + dd = dd2[0] | (dd2[1] << 16);
422 +#else
423 + dd = dd2[1] | (dd2[0] << 16);
424 +#endif
425 + d <<= 2;
426 + fb_writel(dd, dst);
427 + dst += 4;
428 + }
429 + break;
430 +
431 + case 8:
432 + for (x = 0; x < width; x += 4) {
433 + if ((x & 7) == 0)
434 + d = *src++;
435 +
436 + parse_pixel(0, 1, u8);
437 + parse_pixel(1, 1, u8);
438 + parse_pixel(2, 1, u8);
439 + parse_pixel(3, 1, u8);
440 +
441 +#ifdef __LITTLE_ENDIAN
442 + dd = dd2[0] | (dd2[1] << 8) | (dd2[2] << 16) | (dd2[3] << 24);
443 +#else
444 + dd = dd2[3] | (dd2[2] << 8) | (dd2[1] << 16) | (dd2[0] << 24);
445 +#endif
446 + d <<= 4;
447 + fb_writel(dd, dst);
448 + dst += 4;
449 + }
450 + }
451 +
452 + dst += info->fix.line_length - width * bytespp;
453 + splash_src += (info->var.xres - width) * bytespp;
454 + }
455 +}
456 +
457 +#define cc2cx(a) \
458 + ((info->fix.visual == FB_VISUAL_TRUECOLOR || \
459 + info->fix.visual == FB_VISUAL_DIRECTCOLOR) ? \
460 + ((u32*)info->pseudo_palette)[a] : a)
461 +
462 +void fbsplash_putcs(struct vc_data *vc, struct fb_info *info,
463 + const unsigned short *s, int count, int yy, int xx)
464 +{
465 + unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
466 + struct fbcon_ops *ops = info->fbcon_par;
467 + int fg_color, bg_color, transparent;
468 + u8 *src;
469 + u32 bgx, fgx;
470 + u16 c = scr_readw(s);
471 +
472 + fg_color = get_color(vc, info, c, 1);
473 + bg_color = get_color(vc, info, c, 0);
474 +
475 + /* Don't paint the background image if console is blanked */
476 + transparent = ops->blank_state ? 0 :
477 + (vc->vc_splash.bg_color == bg_color);
478 +
479 + xx = xx * vc->vc_font.width + vc->vc_splash.tx;
480 + yy = yy * vc->vc_font.height + vc->vc_splash.ty;
481 +
482 + fgx = cc2cx(fg_color);
483 + bgx = cc2cx(bg_color);
484 +
485 + while (count--) {
486 + c = scr_readw(s++);
487 + src = vc->vc_font.data + (c & charmask) * vc->vc_font.height *
488 + ((vc->vc_font.width + 7) >> 3);
489 +
490 + fbsplash_renderc(info, yy, xx, vc->vc_font.height,
491 + vc->vc_font.width, src, fgx, bgx, transparent);
492 + xx += vc->vc_font.width;
493 + }
494 +}
495 +
496 +void fbsplash_cursor(struct fb_info *info, struct fb_cursor *cursor)
497 +{
498 + int i;
499 + unsigned int dsize, s_pitch;
500 + struct fbcon_ops *ops = info->fbcon_par;
501 + struct vc_data* vc;
502 + u8 *src;
503 +
504 + /* we really don't need any cursors while the console is blanked */
505 + if (info->state != FBINFO_STATE_RUNNING || ops->blank_state)
506 + return;
507 +
508 + vc = vc_cons[ops->currcon].d;
509 +
510 + src = kmalloc(64 + sizeof(struct fb_image), GFP_ATOMIC);
511 + if (!src)
512 + return;
513 +
514 + s_pitch = (cursor->image.width + 7) >> 3;
515 + dsize = s_pitch * cursor->image.height;
516 + if (cursor->enable) {
517 + switch (cursor->rop) {
518 + case ROP_XOR:
519 + for (i = 0; i < dsize; i++)
520 + src[i] = cursor->image.data[i] ^ cursor->mask[i];
521 + break;
522 + case ROP_COPY:
523 + default:
524 + for (i = 0; i < dsize; i++)
525 + src[i] = cursor->image.data[i] & cursor->mask[i];
526 + break;
527 + }
528 + } else
529 + memcpy(src, cursor->image.data, dsize);
530 +
531 + fbsplash_renderc(info,
532 + cursor->image.dy + vc->vc_splash.ty,
533 + cursor->image.dx + vc->vc_splash.tx,
534 + cursor->image.height,
535 + cursor->image.width,
536 + (u8*)src,
537 + cc2cx(cursor->image.fg_color),
538 + cc2cx(cursor->image.bg_color),
539 + cursor->image.bg_color == vc->vc_splash.bg_color);
540 +
541 + kfree(src);
542 +}
543 +
544 +static void splashset(u8 *dst, int height, int width, int dstbytes,
545 + u32 bgx, int bpp)
546 +{
547 + int i;
548 +
549 + if (bpp == 8)
550 + bgx |= bgx << 8;
551 + if (bpp == 16 || bpp == 8)
552 + bgx |= bgx << 16;
553 +
554 + while (height-- > 0) {
555 + u8 *p = dst;
556 +
557 + switch (bpp) {
558 +
559 + case 32:
560 + for (i=0; i < width; i++) {
561 + fb_writel(bgx, p); p += 4;
562 + }
563 + break;
564 + case 24:
565 + for (i=0; i < width; i++) {
566 +#ifdef __LITTLE_ENDIAN
567 + fb_writew((bgx & 0xffff),(u16*)p); p += 2;
568 + fb_writeb((bgx >> 16),p++);
569 +#else
570 + fb_writew((bgx >> 8),(u16*)p); p += 2;
571 + fb_writeb((bgx & 0xff),p++);
572 +#endif
573 + }
574 + case 16:
575 + for (i=0; i < width/4; i++) {
576 + fb_writel(bgx,p); p += 4;
577 + fb_writel(bgx,p); p += 4;
578 + }
579 + if (width & 2) {
580 + fb_writel(bgx,p); p += 4;
581 + }
582 + if (width & 1)
583 + fb_writew(bgx,(u16*)p);
584 + break;
585 + case 8:
586 + for (i=0; i < width/4; i++) {
587 + fb_writel(bgx,p); p += 4;
588 + }
589 +
590 + if (width & 2) {
591 + fb_writew(bgx,p); p += 2;
592 + }
593 + if (width & 1)
594 + fb_writeb(bgx,(u8*)p);
595 + break;
596 +
597 + }
598 + dst += dstbytes;
599 + }
600 +}
601 +
602 +void fbsplash_copy(u8 *dst, u8 *src, int height, int width, int linebytes,
603 + int srclinebytes, int bpp)
604 +{
605 + int i;
606 +
607 + while (height-- > 0) {
608 + u32 *p = (u32 *)dst;
609 + u32 *q = (u32 *)src;
610 +
611 + switch (bpp) {
612 +
613 + case 32:
614 + for (i=0; i < width; i++)
615 + fb_writel(*q++, p++);
616 + break;
617 + case 24:
618 + for (i=0; i < (width*3/4); i++)
619 + fb_writel(*q++, p++);
620 + if ((width*3) % 4) {
621 + if (width & 2) {
622 + fb_writeb(*(u8*)q, (u8*)p);
623 + } else if (width & 1) {
624 + fb_writew(*(u16*)q, (u16*)p);
625 + fb_writeb(*(u8*)((u16*)q+1),(u8*)((u16*)p+2));
626 + }
627 + }
628 + break;
629 + case 16:
630 + for (i=0; i < width/4; i++) {
631 + fb_writel(*q++, p++);
632 + fb_writel(*q++, p++);
633 + }
634 + if (width & 2)
635 + fb_writel(*q++, p++);
636 + if (width & 1)
637 + fb_writew(*(u16*)q, (u16*)p);
638 + break;
639 + case 8:
640 + for (i=0; i < width/4; i++)
641 + fb_writel(*q++, p++);
642 +
643 + if (width & 2) {
644 + fb_writew(*(u16*)q, (u16*)p);
645 + q = (u32*) ((u16*)q + 1);
646 + p = (u32*) ((u16*)p + 1);
647 + }
648 + if (width & 1)
649 + fb_writeb(*(u8*)q, (u8*)p);
650 + break;
651 + }
652 +
653 + dst += linebytes;
654 + src += srclinebytes;
655 + }
656 +}
657 +
658 +static void splashfill(struct fb_info *info, int sy, int sx, int height,
659 + int width)
660 +{
661 + int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
662 + int d = sy * info->fix.line_length + sx * bytespp;
663 + int ds = (sy * info->var.xres + sx) * bytespp;
664 +
665 + fbsplash_copy((u8 *)(info->screen_base + d), (u8 *)(info->splash.data + ds),
666 + height, width, info->fix.line_length, info->var.xres * bytespp,
667 + info->var.bits_per_pixel);
668 +}
669 +
670 +void fbsplash_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx,
671 + int height, int width)
672 +{
673 + int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
674 + int bg_color = attr_bgcol_ec(bgshift, vc);
675 + int transparent = vc->vc_splash.bg_color == bg_color;
676 + struct fbcon_ops *ops = info->fbcon_par;
677 + u8 *dst;
678 +
679 + sy = sy * vc->vc_font.height + vc->vc_splash.ty;
680 + sx = sx * vc->vc_font.width + vc->vc_splash.tx;
681 + height *= vc->vc_font.height;
682 + width *= vc->vc_font.width;
683 +
684 + /* Don't paint the background image if console is blanked */
685 + if (transparent && !ops->blank_state) {
686 + splashfill(info, sy, sx, height, width);
687 + } else {
688 + dst = (u8 *)(info->screen_base + sy * info->fix.line_length +
689 + sx * ((info->var.bits_per_pixel + 7) >> 3));
690 + splashset(dst, height, width, info->fix.line_length, cc2cx(bg_color),
691 + info->var.bits_per_pixel);
692 + }
693 +}
694 +
695 +void fbsplash_clear_margins(struct vc_data *vc, struct fb_info *info,
696 + int bottom_only)
697 +{
698 + unsigned int tw = vc->vc_cols*vc->vc_font.width;
699 + unsigned int th = vc->vc_rows*vc->vc_font.height;
700 +
701 + if (!bottom_only) {
702 + /* top margin */
703 + splashfill(info, 0, 0, vc->vc_splash.ty, info->var.xres);
704 + /* left margin */
705 + splashfill(info, vc->vc_splash.ty, 0, th, vc->vc_splash.tx);
706 + /* right margin */
707 + splashfill(info, vc->vc_splash.ty, vc->vc_splash.tx + tw, th,
708 + info->var.xres - vc->vc_splash.tx - tw);
709 + }
710 + splashfill(info, vc->vc_splash.ty + th, 0,
711 + info->var.yres - vc->vc_splash.ty - th, info->var.xres);
712 +}
713 +
714 +void fbsplash_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y,
715 + int sx, int dx, int width)
716 +{
717 + u16 *d = (u16 *) (vc->vc_origin + vc->vc_size_row * y + dx * 2);
718 + u16 *s = d + (dx - sx);
719 + u16 *start = d;
720 + u16 *ls = d;
721 + u16 *le = d + width;
722 + u16 c;
723 + int x = dx;
724 + u16 attr = 1;
725 +
726 + do {
727 + c = scr_readw(d);
728 + if (attr != (c & 0xff00)) {
729 + attr = c & 0xff00;
730 + if (d > start) {
731 + fbsplash_putcs(vc, info, start, d - start, y, x);
732 + x += d - start;
733 + start = d;
734 + }
735 + }
736 + if (s >= ls && s < le && c == scr_readw(s)) {
737 + if (d > start) {
738 + fbsplash_putcs(vc, info, start, d - start, y, x);
739 + x += d - start + 1;
740 + start = d + 1;
741 + } else {
742 + x++;
743 + start++;
744 + }
745 + }
746 + s++;
747 + d++;
748 + } while (d < le);
749 + if (d > start)
750 + fbsplash_putcs(vc, info, start, d - start, y, x);
751 +}
752 +
753 +void fbsplash_blank(struct vc_data *vc, struct fb_info *info, int blank)
754 +{
755 + if (blank) {
756 + splashset((u8 *)info->screen_base, info->var.yres, info->var.xres,
757 + info->fix.line_length, 0, info->var.bits_per_pixel);
758 + } else {
759 + update_screen(vc);
760 + fbsplash_clear_margins(vc, info, 0);
761 + }
762 +}
763 +
764 diff --git a/drivers/video/console/bitblit.c b/drivers/video/console/bitblit.c
765 --- a/drivers/video/console/bitblit.c
766 +++ b/drivers/video/console/bitblit.c
767 @@ -18,6 +18,7 @@
768 #include <linux/console.h>
769 #include <asm/types.h>
770 #include "fbcon.h"
771 +#include "../fbsplash.h"
772
773 /*
774 * Accelerated handlers.
775 @@ -84,6 +85,13 @@ static void bit_bmove(struct vc_data *vc
776 area.height = height * vc->vc_font.height;
777 area.width = width * vc->vc_font.width;
778
779 + if (fbsplash_active(info, vc)) {
780 + area.sx += vc->vc_splash.tx;
781 + area.sy += vc->vc_splash.ty;
782 + area.dx += vc->vc_splash.tx;
783 + area.dy += vc->vc_splash.ty;
784 + }
785 +
786 info->fbops->fb_copyarea(info, &area);
787 }
788
789 @@ -368,7 +376,11 @@ static void bit_cursor(struct vc_data *v
790 cursor.image.depth = 1;
791 cursor.rop = ROP_XOR;
792
793 - info->fbops->fb_cursor(info, &cursor);
794 + if (fbsplash_active(info, vc)) {
795 + fbsplash_cursor(info, &cursor);
796 + } else {
797 + info->fbops->fb_cursor(info, &cursor);
798 + }
799
800 ops->cursor_reset = 0;
801 }
802 diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
803 --- a/drivers/video/console/fbcon.c
804 +++ b/drivers/video/console/fbcon.c
805 @@ -93,6 +93,7 @@
806 #endif
807
808 #include "fbcon.h"
809 +#include "../fbsplash.h"
810
811 #ifdef FBCONDEBUG
812 # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
813 @@ -107,7 +108,7 @@ enum {
814 };
815
816 struct display fb_display[MAX_NR_CONSOLES];
817 -static signed char con2fb_map[MAX_NR_CONSOLES];
818 +signed char con2fb_map[MAX_NR_CONSOLES];
819 static signed char con2fb_map_boot[MAX_NR_CONSOLES];
820 static int logo_height;
821 static int logo_lines;
822 @@ -212,7 +213,7 @@ static inline int fbcon_is_inactive(stru
823 vc->vc_mode != KD_TEXT || ops->graphics);
824 }
825
826 -static inline int get_color(struct vc_data *vc, struct fb_info *info,
827 +inline int get_color(struct vc_data *vc, struct fb_info *info,
828 u16 c, int is_fg)
829 {
830 int depth = fb_get_color_depth(&info->var);
831 @@ -285,6 +287,7 @@ static void fb_flashcursor(void *private
832 CM_ERASE : CM_DRAW;
833 ops->cursor(vc, info, p, mode, softback_lines, get_color(vc, info, c, 1),
834 get_color(vc, info, c, 0));
835 +
836 release_console_sem();
837 }
838
839 @@ -412,6 +415,8 @@ static int fbcon_takeover(int show_logo)
840 info_idx = -1;
841 }
842
843 + fbsplash_init();
844 +
845 return err;
846 }
847
848 @@ -816,6 +821,12 @@ static const char *fbcon_startup(void)
849
850 cols = info->var.xres / vc->vc_font.width;
851 rows = info->var.yres / vc->vc_font.height;
852 +
853 + if (fbsplash_active(info, vc)) {
854 + cols = vc->vc_splash.twidth / vc->vc_font.width;
855 + rows = vc->vc_splash.theight / vc->vc_font.height;
856 + }
857 +
858 vc_resize(vc, cols, rows);
859
860 DPRINTK("mode: %s\n", info->fix.id);
861 @@ -914,7 +925,7 @@ static void fbcon_init(struct vc_data *v
862 cap = info->flags;
863
864 if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
865 - (info->fix.type == FB_TYPE_TEXT))
866 + (info->fix.type == FB_TYPE_TEXT) || fbsplash_active(info, vc))
867 logo = 0;
868
869 info->var.xoffset = info->var.yoffset = p->yscroll = 0; /* reset wrap/pan */
870 @@ -1062,6 +1073,11 @@ static void fbcon_clear(struct vc_data *
871 if (!height || !width)
872 return;
873
874 + if (fbsplash_active(info, vc)) {
875 + fbsplash_clear(vc, info, sy, sx, height, width);
876 + return;
877 + }
878 +
879 /* Split blits that cross physical y_wrap boundary */
880
881 y_break = p->vrows - p->yscroll;
882 @@ -1081,10 +1097,15 @@ static void fbcon_putcs(struct vc_data *
883 struct display *p = &fb_display[vc->vc_num];
884 struct fbcon_ops *ops = info->fbcon_par;
885
886 - if (!fbcon_is_inactive(vc, info))
887 - ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
888 - get_color(vc, info, scr_readw(s), 1),
889 - get_color(vc, info, scr_readw(s), 0));
890 + if (!fbcon_is_inactive(vc, info)) {
891 +
892 + if (fbsplash_active(info, vc))
893 + fbsplash_putcs(vc, info, s, count, ypos, xpos);
894 + else
895 + ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
896 + get_color(vc, info, scr_readw(s), 1),
897 + get_color(vc, info, scr_readw(s), 0));
898 + }
899 }
900
901 static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
902 @@ -1100,8 +1121,13 @@ static void fbcon_clear_margins(struct v
903 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
904 struct fbcon_ops *ops = info->fbcon_par;
905
906 - if (!fbcon_is_inactive(vc, info))
907 - ops->clear_margins(vc, info, bottom_only);
908 + if (!fbcon_is_inactive(vc, info)) {
909 + if (fbsplash_active(info, vc)) {
910 + fbsplash_clear_margins(vc, info, bottom_only);
911 + } else {
912 + ops->clear_margins(vc, info, bottom_only);
913 + }
914 + }
915 }
916
917 static void fbcon_cursor(struct vc_data *vc, int mode)
918 @@ -1581,7 +1607,7 @@ static int fbcon_scroll(struct vc_data *
919 count = vc->vc_rows;
920 if (softback_top)
921 fbcon_softback_note(vc, t, count);
922 - if (logo_shown >= 0)
923 + if (logo_shown >= 0 || fbsplash_active(info, vc))
924 goto redraw_up;
925 switch (p->scrollmode) {
926 case SCROLL_MOVE:
927 @@ -1667,6 +1693,8 @@ static int fbcon_scroll(struct vc_data *
928 case SM_DOWN:
929 if (count > vc->vc_rows) /* Maximum realistic size */
930 count = vc->vc_rows;
931 + if (fbsplash_active(info, vc))
932 + goto redraw_down;
933 switch (p->scrollmode) {
934 case SCROLL_MOVE:
935 ops->bmove(vc, info, t, 0, t + count, 0,
936 @@ -1809,6 +1837,13 @@ static void fbcon_bmove_rec(struct vc_da
937 }
938 return;
939 }
940 +
941 + if (fbsplash_active(info, vc) && sy == dy && height == 1) {
942 + /* must use slower redraw bmove to keep background pic intact */
943 + fbsplash_bmove_redraw(vc, info, sy, sx, dx, width);
944 + return;
945 + }
946 +
947 ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
948 height, width);
949 }
950 @@ -1863,7 +1898,8 @@ static int fbcon_resize(struct vc_data *
951 var.yres = height * fh;
952 x_diff = info->var.xres - var.xres;
953 y_diff = info->var.yres - var.yres;
954 - if (x_diff < 0 || x_diff > fw || (y_diff < 0 || y_diff > fh)) {
955 +
956 + if ((x_diff < 0 || x_diff > fw || (y_diff < 0 || y_diff > fh)) && !vc->vc_splash.state) {
957 struct fb_videomode *mode;
958
959 DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
960 @@ -1909,7 +1945,17 @@ static int fbcon_switch(struct vc_data *
961 int i, prev_console;
962
963 info = registered_fb[con2fb_map[vc->vc_num]];
964 + prev_console = ((struct fbcon_ops *)info->fbcon_par)->currcon;
965 +
966 + if (fbsplash_active_vc(vc)) {
967 + struct vc_data *vc_curr = vc_cons[prev_console].d;
968
969 + if (!vc_curr->vc_splash.theme || strcmp(vc->vc_splash.theme, vc_curr->vc_splash.theme)) {
970 + if (fbsplash_call_helper("getpic", vc->vc_num))
971 + fbsplash_disable(vc, 0);
972 + }
973 + }
974 +
975 if (softback_top) {
976 int l = fbcon_softback_size / vc->vc_size_row;
977 if (softback_lines)
978 @@ -1935,8 +1981,6 @@ static int fbcon_switch(struct vc_data *
979 logo_shown = FBCON_LOGO_CANSHOW;
980 }
981
982 - prev_console = ((struct fbcon_ops *)info->fbcon_par)->currcon;
983 -
984 /*
985 * FIXME: If we have multiple fbdev's loaded, we need to
986 * update all info->currcon. Perhaps, we can place this
987 @@ -1969,6 +2013,11 @@ static int fbcon_switch(struct vc_data *
988 info->fbops->fb_set_par)
989 info->fbops->fb_set_par(info);
990
991 + if (fbsplash_active_nores(info, vc) && !fbsplash_active(info, vc)) {
992 + if (fbsplash_call_helper("modechange", vc->vc_num))
993 + fbsplash_disable(vc, 0);
994 + }
995 +
996 set_blitting_type(vc, info, p);
997 ((struct fbcon_ops *)info->fbcon_par)->cursor_reset = 1;
998
999 @@ -2049,7 +2098,9 @@ static int fbcon_blank(struct vc_data *v
1000 fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
1001 ops->cursor_flash = (!blank);
1002
1003 - if (fb_blank(info, blank))
1004 + if (fbsplash_active(info, vc))
1005 + fbsplash_blank(vc, info, blank);
1006 + else
1007 fbcon_generic_blank(vc, info, blank);
1008 }
1009
1010 @@ -2203,8 +2254,14 @@ static int fbcon_do_set_font(struct vc_d
1011
1012 if (resize) {
1013 /* reset wrap/pan */
1014 - info->var.xoffset = info->var.yoffset = p->yscroll = 0;
1015 - vc_resize(vc, info->var.xres / w, info->var.yres / h);
1016 + u32 xres = info->var.xres, yres = info->var.yres;
1017 + info->var.xoffset = info->var.yoffset = p->yscroll = 0;
1018 + if (fbsplash_active(info, vc)) {
1019 + xres = vc->vc_splash.twidth;
1020 + yres = vc->vc_splash.theight;
1021 + }
1022 + vc_resize(vc, xres / w, yres / h);
1023 +
1024 if (CON_IS_VISIBLE(vc) && softback_buf) {
1025 int l = fbcon_softback_size / vc->vc_size_row;
1026 if (l > 5)
1027 @@ -2331,7 +2388,7 @@ static int fbcon_set_palette(struct vc_d
1028 int i, j, k, depth;
1029 u8 val;
1030
1031 - if (fbcon_is_inactive(vc, info))
1032 + if (fbcon_is_inactive(vc, info) || vc->vc_num != fg_console)
1033 return -EINVAL;
1034
1035 if (!CON_IS_VISIBLE(vc))
1036 @@ -2357,7 +2414,49 @@ static int fbcon_set_palette(struct vc_d
1037 } else
1038 fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap);
1039
1040 - return fb_set_cmap(&palette_cmap, info);
1041 + if (fbsplash_active(info, vc_cons[fg_console].d) &&
1042 + info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
1043 +
1044 + u16 *red, *green, *blue;
1045 + int minlen = min(min(info->var.red.length, info->var.green.length),
1046 + info->var.blue.length);
1047 + int h;
1048 +
1049 + struct fb_cmap cmap = {
1050 + .start = 0,
1051 + .len = (1 << minlen),
1052 + .red = NULL,
1053 + .green = NULL,
1054 + .blue = NULL,
1055 + .transp = NULL
1056 + };
1057 +
1058 + red = kmalloc(256 * sizeof(u16) * 3, GFP_KERNEL);
1059 +
1060 + if (!red)
1061 + goto out;
1062 +
1063 + green = red + 256;
1064 + blue = green + 256;
1065 + cmap.red = red;
1066 + cmap.green = green;
1067 + cmap.blue = blue;
1068 +
1069 + for (i = 0; i < cmap.len; i++) {
1070 + red[i] = green[i] = blue[i] = (0xffff * i)/(cmap.len-1);
1071 + }
1072 +
1073 + h = fb_set_cmap(&cmap, info);
1074 + fbsplash_fix_pseudo_pal(info, vc_cons[fg_console].d);
1075 + kfree(red);
1076 +
1077 + return h;
1078 +
1079 + } else if (fbsplash_active(info, vc_cons[fg_console].d) &&
1080 + info->var.bits_per_pixel == 8 && info->splash.cmap.red != NULL)
1081 + fb_set_cmap(&info->splash.cmap, info);
1082 +
1083 +out: return fb_set_cmap(&palette_cmap, info);
1084 }
1085
1086 static u16 *fbcon_screen_pos(struct vc_data *vc, int offset)
1087 @@ -2578,7 +2677,14 @@ static void fbcon_modechanged(struct fb_
1088 var_to_display(p, &info->var, info);
1089 cols = info->var.xres / vc->vc_font.width;
1090 rows = info->var.yres / vc->vc_font.height;
1091 - vc_resize(vc, cols, rows);
1092 +
1093 + if (!fbsplash_active_nores(info, vc)) {
1094 + vc_resize(vc, cols, rows);
1095 + } else {
1096 + if (fbsplash_call_helper("modechange", vc->vc_num))
1097 + fbsplash_disable(vc, 0);
1098 + }
1099 +
1100 updatescrollmode(p, info, vc);
1101 scrollback_max = 0;
1102 scrollback_current = 0;
1103 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
1104 --- a/drivers/video/fbcmap.c
1105 +++ b/drivers/video/fbcmap.c
1106 @@ -16,6 +16,7 @@
1107 #include <linux/tty.h>
1108 #include <linux/fb.h>
1109 #include <linux/slab.h>
1110 +#include "fbsplash.h"
1111
1112 #include <asm/uaccess.h>
1113
1114 diff --git a/drivers/video/fbsplash.c b/drivers/video/fbsplash.c
1115 new file mode 100644
1116 --- /dev/null
1117 +++ b/drivers/video/fbsplash.c
1118 @@ -0,0 +1,406 @@
1119 +/*
1120 + * linux/drivers/video/fbsplash.c -- Framebuffer splash routines
1121 + *
1122 + * Copyright (C) 2004 Michal Januszewski <spock@gentoo.org>
1123 + *
1124 + * Code based upon "Bootsplash" (C) 2001-2003
1125 + * Volker Poplawski <volker@poplawski.de>,
1126 + * Stefan Reinauer <stepan@suse.de>,
1127 + * Steffen Winterfeldt <snwint@suse.de>,
1128 + * Michael Schroeder <mls@suse.de>,
1129 + * Ken Wimer <wimer@suse.de>.
1130 + *
1131 + * Splash render routines are located in /linux/drivers/video/cfbsplash.c
1132 + *
1133 + * This file is subject to the terms and conditions of the GNU General Public
1134 + * License. See the file COPYING in the main directory of this archive for
1135 + * more details.
1136 + *
1137 + */
1138 +#include <linux/config.h>
1139 +#include <linux/module.h>
1140 +#include <linux/kernel.h>
1141 +#include <linux/string.h>
1142 +#include <linux/types.h>
1143 +#include <linux/fb.h>
1144 +#include <linux/vt_kern.h>
1145 +#include <linux/vmalloc.h>
1146 +#include <linux/unistd.h>
1147 +#include <linux/syscalls.h>
1148 +#include <linux/init.h>
1149 +#include <linux/proc_fs.h>
1150 +#include <linux/workqueue.h>
1151 +#include <linux/kmod.h>
1152 +#include <linux/miscdevice.h>
1153 +#include <linux/device.h>
1154 +#include <linux/fs.h>
1155 +
1156 +#include <asm/uaccess.h>
1157 +#include <asm/irq.h>
1158 +#include <asm/system.h>
1159 +
1160 +#include "console/fbcon.h"
1161 +#include "fbsplash.h"
1162 +
1163 +#define SPLASH_VERSION "0.9.2"
1164 +
1165 +extern signed char con2fb_map[];
1166 +static int fbsplash_enable(struct vc_data *vc);
1167 +char fbsplash_path[KMOD_PATH_LEN] = "/sbin/splash_helper";
1168 +
1169 +int fbsplash_call_helper(char* cmd, unsigned short vc)
1170 +{
1171 + char *envp[] = {
1172 + "HOME=/",
1173 + "PATH=/sbin:/bin",
1174 + NULL
1175 + };
1176 +
1177 + char tfb[5];
1178 + char tcons[5];
1179 + unsigned char fb = (int) con2fb_map[vc];
1180 +
1181 + char *argv[] = {
1182 + fbsplash_path,
1183 + "2",
1184 + cmd,
1185 + tcons,
1186 + tfb,
1187 + vc_cons[vc].d->vc_splash.theme,
1188 + NULL
1189 + };
1190 +
1191 + snprintf(tfb,5,"%d",fb);
1192 + snprintf(tcons,5,"%d",vc);
1193 +
1194 + return call_usermodehelper(fbsplash_path, argv, envp, 1);
1195 +}
1196 +
1197 +/* Disables fbsplash on a virtual console; called with console sem held. */
1198 +int fbsplash_disable(struct vc_data *vc, unsigned char redraw)
1199 +{
1200 + struct fb_info* info;
1201 +
1202 + if (!vc->vc_splash.state)
1203 + return -EINVAL;
1204 +
1205 + info = registered_fb[(int) con2fb_map[vc->vc_num]];
1206 +
1207 + if (info == NULL)
1208 + return -EINVAL;
1209 +
1210 + vc->vc_splash.state = 0;
1211 + vc_resize(vc, info->var.xres / vc->vc_font.width,
1212 + info->var.yres / vc->vc_font.height);
1213 +
1214 + if (fg_console == vc->vc_num && redraw) {
1215 + redraw_screen(vc, 0);
1216 + update_region(vc, vc->vc_origin +
1217 + vc->vc_size_row * vc->vc_top,
1218 + vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1219 + }
1220 +
1221 + printk(KERN_INFO "fbsplash: switched splash state to 'off' on console %d\n",
1222 + vc->vc_num);
1223 +
1224 + return 0;
1225 +}
1226 +
1227 +/* Enables fbsplash on a virtual console; called with console sem held. */
1228 +static int fbsplash_enable(struct vc_data *vc)
1229 +{
1230 + struct fb_info* info;
1231 +
1232 + info = registered_fb[(int) con2fb_map[vc->vc_num]];
1233 +
1234 + if (vc->vc_splash.twidth == 0 || vc->vc_splash.theight == 0 ||
1235 + info == NULL || vc->vc_splash.state || (!info->splash.data &&
1236 + vc->vc_num == fg_console))
1237 + return -EINVAL;
1238 +
1239 + vc->vc_splash.state = 1;
1240 + vc_resize(vc, vc->vc_splash.twidth / vc->vc_font.width,
1241 + vc->vc_splash.theight / vc->vc_font.height);
1242 +
1243 + if (fg_console == vc->vc_num) {
1244 + redraw_screen(vc, 0);
1245 + update_region(vc, vc->vc_origin +
1246 + vc->vc_size_row * vc->vc_top,
1247 + vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1248 + fbsplash_clear_margins(vc, info, 0);
1249 + }
1250 +
1251 + printk(KERN_INFO "fbsplash: switched splash state to 'on' on console %d\n",
1252 + vc->vc_num);
1253 +
1254 + return 0;
1255 +}
1256 +
1257 +static inline int fbsplash_ioctl_dosetstate(struct vc_data *vc, unsigned int __user* state, unsigned char origin)
1258 +{
1259 + int tmp, ret;
1260 +
1261 + if (get_user(tmp, state))
1262 + return -EFAULT;
1263 +
1264 + if (origin == FB_SPLASH_IO_ORIG_USER)
1265 + acquire_console_sem();
1266 + if (!tmp)
1267 + ret = fbsplash_disable(vc, 1);
1268 + else
1269 + ret = fbsplash_enable(vc);
1270 + if (origin == FB_SPLASH_IO_ORIG_USER)
1271 + release_console_sem();
1272 +
1273 + return ret;
1274 +}
1275 +
1276 +static inline int fbsplash_ioctl_dogetstate(struct vc_data *vc, unsigned int __user *state)
1277 +{
1278 + return put_user(vc->vc_splash.state, (unsigned int __user*) state);
1279 +}
1280 +
1281 +static int fbsplash_ioctl_dosetcfg(struct vc_data *vc, struct vc_splash __user *arg, unsigned char origin)
1282 +{
1283 + struct vc_splash cfg;
1284 + struct fb_info *info;
1285 + int len;
1286 + char *tmp;
1287 +
1288 + info = registered_fb[(int) con2fb_map[vc->vc_num]];
1289 +
1290 + if (copy_from_user(&cfg, arg, sizeof(struct vc_splash)))
1291 + return -EFAULT;
1292 + if (info == NULL || !cfg.twidth || !cfg.theight ||
1293 + cfg.tx + cfg.twidth > info->var.xres ||
1294 + cfg.ty + cfg.theight > info->var.yres)
1295 + return -EINVAL;
1296 +
1297 + len = strlen_user(cfg.theme);
1298 + if (!len || len > FB_SPLASH_THEME_LEN)
1299 + return -EINVAL;
1300 + tmp = kmalloc(len, GFP_KERNEL);
1301 + if (!tmp)
1302 + return -ENOMEM;
1303 + if (copy_from_user(tmp, (void __user *)cfg.theme, len))
1304 + return -EFAULT;
1305 + cfg.theme = tmp;
1306 + cfg.state = 0;
1307 +
1308 + /* If this ioctl is a response to a request from kernel, the console sem
1309 + * is already held; we also don't need to disable splash because either the
1310 + * new config and background picture will be successfully loaded, and the
1311 + * splash will stay on, or in case of a failure it'll be turned off in fbcon. */
1312 + if (origin == FB_SPLASH_IO_ORIG_USER) {
1313 + acquire_console_sem();
1314 + if (vc->vc_splash.state)
1315 + fbsplash_disable(vc, 1);
1316 + }
1317 +
1318 + if (vc->vc_splash.theme)
1319 + kfree(vc->vc_splash.theme);
1320 +
1321 + vc->vc_splash = cfg;
1322 +
1323 + if (origin == FB_SPLASH_IO_ORIG_USER)
1324 + release_console_sem();
1325 +
1326 + printk(KERN_INFO "fbsplash: console %d using theme '%s'\n",
1327 + vc->vc_num, vc->vc_splash.theme);
1328 + return 0;
1329 +}
1330 +
1331 +static int fbsplash_ioctl_dogetcfg(struct vc_data *vc, struct vc_splash __user *arg)
1332 +{
1333 + struct vc_splash splash;
1334 + char __user *tmp;
1335 +
1336 + if (get_user(tmp, &arg->theme))
1337 + return -EFAULT;
1338 +
1339 + splash = vc->vc_splash;
1340 + splash.theme = tmp;
1341 +
1342 + if (vc->vc_splash.theme) {
1343 + if (copy_to_user(tmp, vc->vc_splash.theme, strlen(vc->vc_splash.theme) + 1))
1344 + return -EFAULT;
1345 + } else
1346 + if (put_user(0, tmp))
1347 + return -EFAULT;
1348 +
1349 + if (copy_to_user(arg, &splash, sizeof(struct vc_splash)))
1350 + return -EFAULT;
1351 +
1352 + return 0;
1353 +}
1354 +
1355 +static int fbsplash_ioctl_dosetpic(struct vc_data *vc, struct fb_image __user *arg, unsigned char origin)
1356 +{
1357 + struct fb_image img;
1358 + struct fb_info *info;
1359 + int len;
1360 + u8 *tmp;
1361 +
1362 + if (vc->vc_num != fg_console)
1363 + return -EINVAL;
1364 +
1365 + info = registered_fb[(int) con2fb_map[vc->vc_num]];
1366 +
1367 + if (info == NULL)
1368 + return -EINVAL;
1369 +
1370 + if (copy_from_user(&img, arg, sizeof(struct fb_image)))
1371 + return -EFAULT;
1372 +
1373 + if (img.width != info->var.xres || img.height != info->var.yres) {
1374 + printk(KERN_ERR "fbsplash: picture dimensions mismatch\n");
1375 + return -EINVAL;
1376 + }
1377 +
1378 + if (img.depth != info->var.bits_per_pixel) {
1379 + printk(KERN_ERR "fbsplash: picture depth mismatch\n");
1380 + return -EINVAL;
1381 + }
1382 +
1383 + if (img.depth == 8) {
1384 + if (!img.cmap.len || !img.cmap.red || !img.cmap.green ||
1385 + !img.cmap.blue)
1386 + return -EINVAL;
1387 +
1388 + tmp = vmalloc(img.cmap.len * 3 * 2);
1389 + if (!tmp)
1390 + return -ENOMEM;
1391 +
1392 + if (copy_from_user(tmp, (void __user*)img.cmap.red, img.cmap.len * 2) ||
1393 + copy_from_user(tmp + (img.cmap.len << 1),
1394 + (void __user*)img.cmap.green, (img.cmap.len << 1)) ||
1395 + copy_from_user(tmp + (img.cmap.len << 2),
1396 + (void __user*)img.cmap.blue, (img.cmap.len << 1))) {
1397 + vfree(tmp);
1398 + return -EFAULT;
1399 + }
1400 +
1401 + img.cmap.transp = NULL;
1402 + img.cmap.red = (u16*)tmp;
1403 + img.cmap.green = img.cmap.red + img.cmap.len;
1404 + img.cmap.blue = img.cmap.green + img.cmap.len;
1405 + } else {
1406 + img.cmap.red = NULL;
1407 + }
1408 +
1409 + len = ((img.depth + 7) >> 3) * img.width * img.height;
1410 + tmp = vmalloc(len);
1411 +
1412 + if (!tmp)
1413 + goto out;
1414 +
1415 + if (copy_from_user(tmp, (void __user*)img.data, len))
1416 + goto out;
1417 +
1418 + img.data = tmp;
1419 +
1420 + /* If this ioctl is a response to a request from kernel, the console sem
1421 + * is already held. */
1422 + if (origin == FB_SPLASH_IO_ORIG_USER)
1423 + acquire_console_sem();
1424 +
1425 + if (info->splash.data)
1426 + vfree((u8*)info->splash.data);
1427 + if (info->splash.cmap.red)
1428 + vfree(info->splash.cmap.red);
1429 +
1430 + info->splash = img;
1431 +
1432 + if (origin == FB_SPLASH_IO_ORIG_USER)
1433 + release_console_sem();
1434 +
1435 + return 0;
1436 +
1437 +out: if (img.cmap.red)
1438 + vfree(img.cmap.red);
1439 + if (tmp)
1440 + vfree(tmp);
1441 + return -ENOMEM;
1442 +}
1443 +
1444 +static int splash_ioctl(struct inode * inode, struct file *filp, u_int cmd,
1445 + u_long arg)
1446 +{
1447 + struct fb_splash_iowrapper __user *wrapper = (void __user*) arg;
1448 + struct vc_data *vc = NULL;
1449 + unsigned short vc_num = 0;
1450 + unsigned char origin = 0;
1451 + void __user *data = NULL;
1452 +
1453 + if (!access_ok(VERIFY_READ, wrapper,
1454 + sizeof(struct fb_splash_iowrapper)))
1455 + return -EFAULT;
1456 +
1457 + __get_user(vc_num, &wrapper->vc);
1458 + __get_user(origin, &wrapper->origin);
1459 + __get_user(data, &wrapper->data);
1460 +
1461 + if (!vc_cons_allocated(vc_num))
1462 + return -EINVAL;
1463 +
1464 + vc = vc_cons[vc_num].d;
1465 +
1466 + switch (cmd) {
1467 + case FBIOSPLASH_SETPIC:
1468 + return fbsplash_ioctl_dosetpic(vc, (struct fb_image __user*)data, origin);
1469 + case FBIOSPLASH_SETCFG:
1470 + return fbsplash_ioctl_dosetcfg(vc, (struct vc_splash*)data, origin);
1471 + case FBIOSPLASH_GETCFG:
1472 + return fbsplash_ioctl_dogetcfg(vc, (struct vc_splash*)data);
1473 + case FBIOSPLASH_SETSTATE:
1474 + return fbsplash_ioctl_dosetstate(vc, (unsigned int *)data, origin);
1475 + case FBIOSPLASH_GETSTATE:
1476 + return fbsplash_ioctl_dogetstate(vc, (unsigned int *)data);
1477 + default:
1478 + return -ENOIOCTLCMD;
1479 + }
1480 +}
1481 +
1482 +static struct file_operations splash_ops = {
1483 + .owner = THIS_MODULE,
1484 + .ioctl = splash_ioctl
1485 +};
1486 +
1487 +static struct miscdevice splash_dev = {
1488 + .minor = MISC_DYNAMIC_MINOR,
1489 + .name = "fbsplash",
1490 + .fops = &splash_ops
1491 +};
1492 +
1493 +int fbsplash_init(void)
1494 +{
1495 + struct fb_info *info;
1496 + struct vc_data *vc;
1497 + int i;
1498 +
1499 + vc = vc_cons[0].d;
1500 + info = registered_fb[0];
1501 +
1502 + for (i = 0; i < num_registered_fb; i++) {
1503 + registered_fb[i]->splash.data = NULL;
1504 + registered_fb[i]->splash.cmap.red = NULL;
1505 + }
1506 +
1507 + for (i = 0; i < MAX_NR_CONSOLES && vc_cons[i].d; i++) {
1508 + vc_cons[i].d->vc_splash.state = vc_cons[i].d->vc_splash.twidth =
1509 + vc_cons[i].d->vc_splash.theight = 0;
1510 + vc_cons[i].d->vc_splash.theme = NULL;
1511 + }
1512 +
1513 + i = misc_register(&splash_dev);
1514 + if (i) {
1515 + printk(KERN_ERR "fbsplash: failed to register device\n");
1516 + return i;
1517 + }
1518 +
1519 + fbsplash_call_helper("init", 0);
1520 +
1521 + return 0;
1522 +}
1523 +
1524 +EXPORT_SYMBOL(fbsplash_path);
1525 diff --git a/drivers/video/fbsplash.h b/drivers/video/fbsplash.h
1526 new file mode 100644
1527 --- /dev/null
1528 +++ b/drivers/video/fbsplash.h
1529 @@ -0,0 +1,76 @@
1530 +/*
1531 + * linux/drivers/video/fbsplash.h -- Framebuffer splash headers
1532 + *
1533 + * Copyright (C) 2004 Michal Januszewski <spock@gentoo.org>
1534 + *
1535 + */
1536 +
1537 +#ifndef __FB_SPLASH_H
1538 +#define __FB_SPLASH_H
1539 +
1540 +#ifndef _LINUX_FB_H
1541 +#include <linux/fb.h>
1542 +#endif
1543 +
1544 +/* This is needed for vc_cons in fbcmap.c */
1545 +#include <linux/vt_kern.h>
1546 +
1547 +struct fb_cursor;
1548 +struct fb_info;
1549 +struct vc_data;
1550 +
1551 +#ifdef CONFIG_FB_SPLASH
1552 +/* fbsplash.c */
1553 +int fbsplash_init(void);
1554 +int fbsplash_call_helper(char* cmd, unsigned short cons);
1555 +int fbsplash_disable(struct vc_data *vc, unsigned char redraw);
1556 +
1557 +/* cfbsplash.c */
1558 +void fbsplash_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx);
1559 +void fbsplash_cursor(struct fb_info *info, struct fb_cursor *cursor);
1560 +void fbsplash_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width);
1561 +void fbsplash_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only);
1562 +void fbsplash_blank(struct vc_data *vc, struct fb_info *info, int blank);
1563 +void fbsplash_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width);
1564 +void fbsplash_copy(u8 *dst, u8 *src, int height, int width, int linebytes, int srclinesbytes, int bpp);
1565 +void fbsplash_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc);
1566 +
1567 +/* vt.c */
1568 +void acquire_console_sem(void);
1569 +void release_console_sem(void);
1570 +void do_unblank_screen(int entering_gfx);
1571 +
1572 +/* struct vc_data *y */
1573 +#define fbsplash_active_vc(y) (y->vc_splash.state && y->vc_splash.theme)
1574 +
1575 +/* struct fb_info *x, struct vc_data *y */
1576 +#define fbsplash_active_nores(x,y) (x->splash.data && fbsplash_active_vc(y))
1577 +
1578 +/* struct fb_info *x, struct vc_data *y */
1579 +#define fbsplash_active(x,y) (fbsplash_active_nores(x,y) && \
1580 + x->splash.width == x->var.xres && \
1581 + x->splash.height == x->var.yres && \
1582 + x->splash.depth == x->var.bits_per_pixel)
1583 +
1584 +
1585 +#else /* CONFIG_FB_SPLASH */
1586 +
1587 +static inline void fbsplash_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx) {}
1588 +static inline void fbsplash_putc(struct vc_data *vc, struct fb_info *info, int c, int ypos, int xpos) {}
1589 +static inline void fbsplash_cursor(struct fb_info *info, struct fb_cursor *cursor) {}
1590 +static inline void fbsplash_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) {}
1591 +static inline void fbsplash_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only) {}
1592 +static inline void fbsplash_blank(struct vc_data *vc, struct fb_info *info, int blank) {}
1593 +static inline void fbsplash_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width) {}
1594 +static inline void fbsplash_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc) {}
1595 +static inline int fbsplash_call_helper(char* cmd, unsigned short cons) { return 0; }
1596 +static inline int fbsplash_init(void) { return 0; }
1597 +static inline int fbsplash_disable(struct vc_data *vc, unsigned char redraw) { return 0; }
1598 +
1599 +#define fbsplash_active_vc(y) (0)
1600 +#define fbsplash_active_nores(x,y) (0)
1601 +#define fbsplash_active(x,y) (0)
1602 +
1603 +#endif /* CONFIG_FB_SPLASH */
1604 +
1605 +#endif /* __FB_SPLASH_H */
1606 diff --git a/include/linux/console_splash.h b/include/linux/console_splash.h
1607 new file mode 100644
1608 --- /dev/null
1609 +++ b/include/linux/console_splash.h
1610 @@ -0,0 +1,13 @@
1611 +#ifndef _LINUX_CONSOLE_SPLASH_H_
1612 +#define _LINUX_CONSOLE_SPLASH_H_ 1
1613 +
1614 +/* A structure used by the framebuffer splash code (drivers/video/fbsplash.c) */
1615 +struct vc_splash {
1616 + __u8 bg_color; /* The color that is to be treated as transparent */
1617 + __u8 state; /* Current splash state: 0 = off, 1 = on */
1618 + __u16 tx, ty; /* Top left corner coordinates of the text field */
1619 + __u16 twidth, theight; /* Width and height of the text field */
1620 + char* theme;
1621 +};
1622 +
1623 +#endif
1624 diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h
1625 --- a/include/linux/console_struct.h
1626 +++ b/include/linux/console_struct.h
1627 @@ -12,6 +12,7 @@
1628 struct vt_struct;
1629
1630 #define NPAR 16
1631 +#include <linux/console_splash.h>
1632
1633 struct vc_data {
1634 unsigned short vc_num; /* Console number */
1635 @@ -95,6 +96,8 @@ struct vc_data {
1636 struct vc_data **vc_display_fg; /* [!] Ptr to var holding fg console for this display */
1637 unsigned long vc_uni_pagedir;
1638 unsigned long *vc_uni_pagedir_loc; /* [!] Location of uni_pagedir variable for this console */
1639 +
1640 + struct vc_splash vc_splash;
1641 /* additional information is in vt_kern.h */
1642 };
1643
1644 diff --git a/include/linux/fb.h b/include/linux/fb.h
1645 --- a/include/linux/fb.h
1646 +++ b/include/linux/fb.h
1647 @@ -8,6 +8,13 @@
1648 #define FB_MAJOR 29
1649 #define FB_MAX 32 /* sufficient for now */
1650
1651 +struct fb_splash_iowrapper
1652 +{
1653 + unsigned short vc; /* Virtual console */
1654 + unsigned char origin; /* Point of origin of the request */
1655 + void *data;
1656 +};
1657 +
1658 /* ioctls
1659 0x46 is 'F' */
1660 #define FBIOGET_VSCREENINFO 0x4600
1661 @@ -35,7 +42,15 @@
1662 #define FBIOGET_HWCINFO 0x4616
1663 #define FBIOPUT_MODEINFO 0x4617
1664 #define FBIOGET_DISPINFO 0x4618
1665 -
1666 +#define FBIOSPLASH_SETCFG _IOWR('F', 0x19, struct fb_splash_iowrapper)
1667 +#define FBIOSPLASH_GETCFG _IOR('F', 0x1A, struct fb_splash_iowrapper)
1668 +#define FBIOSPLASH_SETSTATE _IOWR('F', 0x1B, struct fb_splash_iowrapper)
1669 +#define FBIOSPLASH_GETSTATE _IOR('F', 0x1C, struct fb_splash_iowrapper)
1670 +#define FBIOSPLASH_SETPIC _IOWR('F', 0x1D, struct fb_splash_iowrapper)
1671 +
1672 +#define FB_SPLASH_THEME_LEN 128 /* Maximum lenght of a theme name */
1673 +#define FB_SPLASH_IO_ORIG_KERNEL 0 /* Kernel ioctl origin */
1674 +#define FB_SPLASH_IO_ORIG_USER 1 /* User ioctl origin */
1675
1676 #define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */
1677 #define FB_TYPE_PLANES 1 /* Non interleaved planes */
1678 @@ -732,6 +747,9 @@ struct fb_info {
1679 #define FBINFO_STATE_SUSPENDED 1
1680 u32 state; /* Hardware state i.e suspend */
1681 void *fbcon_par; /* fbcon use-only private area */
1682 +
1683 + struct fb_image splash;
1684 +
1685 /* From here on everything is device dependent */
1686 void *par;
1687 };
1688 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
1689 --- a/include/linux/sysctl.h
1690 +++ b/include/linux/sysctl.h
1691 @@ -137,6 +137,7 @@ enum
1692 KERN_RANDOMIZE=68, /* int: randomize virtual address space */
1693 KERN_SETUID_DUMPABLE=69, /* int: behaviour of dumps for setuid core */
1694 KERN_SPIN_RETRY=70, /* int: number of spinlock retries */
1695 + KERN_FBSPLASH=71, /* string: path to fbsplash helper */
1696 };
1697
1698
1699 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
1700 --- a/kernel/sysctl.c
1701 +++ b/kernel/sysctl.c
1702 @@ -85,6 +85,9 @@ extern char modprobe_path[];
1703 #ifdef CONFIG_HOTPLUG
1704 extern char hotplug_path[];
1705 #endif
1706 +#ifdef CONFIG_FB_SPLASH
1707 +extern char fbsplash_path[];
1708 +#endif
1709 #ifdef CONFIG_CHR_DEV_SG
1710 extern int sg_big_buff;
1711 #endif
1712 @@ -401,6 +404,17 @@ static ctl_table kern_table[] = {
1713 .strategy = &sysctl_string,
1714 },
1715 #endif
1716 +#ifdef CONFIG_FB_SPLASH
1717 + {
1718 + .ctl_name = KERN_FBSPLASH,
1719 + .procname = "fbsplash",
1720 + .data = &fbsplash_path,
1721 + .maxlen = KMOD_PATH_LEN,
1722 + .mode = 0644,
1723 + .proc_handler = &proc_dostring,
1724 + .strategy = &sysctl_string,
1725 + },
1726 +#endif
1727 #ifdef CONFIG_CHR_DEV_SG
1728 {
1729 .ctl_name = KERN_SG_BIG_BUFF,

  ViewVC Help
Powered by ViewVC 1.1.20