/[linux-patches]/genpatches-2.6/trunk/2.6.16/4200_fbsplash-0.9.2-r5.patch
Gentoo

Contents of /genpatches-2.6/trunk/2.6.16/4200_fbsplash-0.9.2-r5.patch

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.20