Annotation of /trunk/kernel26-alx/patches-2.6.21-r14/0150-2.6.21-fbsplash-0.9.2-r5.patch
Parent Directory | Revision Log
Revision 447 -
(hide annotations)
(download)
Tue Jan 22 17:55:52 2008 UTC (16 years, 9 months ago) by niro
File size: 53801 byte(s)
Tue Jan 22 17:55:52 2008 UTC (16 years, 9 months ago) by niro
File size: 53801 byte(s)
-2.6.21-alx-r14 - fixed some natsemi errors on wys terminals
1 | niro | 447 | Index: linux-2.6.21/Documentation/fb/00-INDEX |
2 | =================================================================== | ||
3 | --- linux-2.6.21.orig/Documentation/fb/00-INDEX | ||
4 | +++ linux-2.6.21/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-2.6.21/Documentation/fb/splash.txt | ||
15 | =================================================================== | ||
16 | --- /dev/null | ||
17 | +++ linux-2.6.21/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 fbsplash 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 video | ||
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 | + * rendering console text, using an image as a background (instead of a | ||
68 | + standard solid color fbcon uses), | ||
69 | + * accepting commands from the user via ioctls on the fbsplash device, | ||
70 | + * 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 | ||
102 | + userspace helper to find a background image appropriate for the specified | ||
103 | + theme and the current resolution. The userspace helper should respond by | ||
104 | + issuing the 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 | + Michal Januszewski <spock@gentoo.org> | ||
225 | + | ||
226 | Index: linux-2.6.21/drivers/Makefile | ||
227 | =================================================================== | ||
228 | --- linux-2.6.21.orig/drivers/Makefile | ||
229 | +++ linux-2.6.21/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-2.6.21/drivers/video/Kconfig | ||
252 | =================================================================== | ||
253 | --- linux-2.6.21.orig/drivers/video/Kconfig | ||
254 | +++ linux-2.6.21/drivers/video/Kconfig | ||
255 | @@ -1663,5 +1663,15 @@ if FB || SGI_NEWPORT_CONSOLE | ||
256 | source "drivers/video/logo/Kconfig" | ||
257 | endif | ||
258 | |||
259 | -endmenu | ||
260 | +config FB_SPLASH | ||
261 | + bool "Support for the framebuffer splash" | ||
262 | + depends on FRAMEBUFFER_CONSOLE=y && !FB_TILEBLITTING | ||
263 | + default n | ||
264 | + ---help--- | ||
265 | + This option enables support for the Linux boot-up splash screen and | ||
266 | + graphical backgrounds on consoles. Note that you will need userspace | ||
267 | + splash utilities in order to take advantage of these features. Refer | ||
268 | + to Documentation/fb/splash.txt for more information. | ||
269 | |||
270 | + If unsure, say N. | ||
271 | +endmenu | ||
272 | Index: linux-2.6.21/drivers/video/Makefile | ||
273 | =================================================================== | ||
274 | --- linux-2.6.21.orig/drivers/video/Makefile | ||
275 | +++ linux-2.6.21/drivers/video/Makefile | ||
276 | @@ -13,6 +13,7 @@ fb-objs := $(f | ||
277 | obj-$(CONFIG_VT) += console/ | ||
278 | obj-$(CONFIG_LOGO) += logo/ | ||
279 | obj-y += backlight/ | ||
280 | +obj-$(CONFIG_FB_SPLASH) += fbsplash.o cfbsplash.o | ||
281 | |||
282 | obj-$(CONFIG_FB_CFB_FILLRECT) += cfbfillrect.o | ||
283 | obj-$(CONFIG_FB_CFB_COPYAREA) += cfbcopyarea.o | ||
284 | Index: linux-2.6.21/drivers/video/cfbsplash.c | ||
285 | =================================================================== | ||
286 | --- /dev/null | ||
287 | +++ linux-2.6.21/drivers/video/cfbsplash.c | ||
288 | @@ -0,0 +1,471 @@ | ||
289 | +/* | ||
290 | + * linux/drivers/video/cfbsplash.c -- Framebuffer splash render functions | ||
291 | + * | ||
292 | + * Copyright (C) 2004 Michal Januszewski <spock@gentoo.org> | ||
293 | + * | ||
294 | + * Code based upon "Bootsplash" (C) 2001-2003 | ||
295 | + * Volker Poplawski <volker@poplawski.de>, | ||
296 | + * Stefan Reinauer <stepan@suse.de>, | ||
297 | + * Steffen Winterfeldt <snwint@suse.de>, | ||
298 | + * Michael Schroeder <mls@suse.de>, | ||
299 | + * Ken Wimer <wimer@suse.de>. | ||
300 | + * | ||
301 | + * This file is subject to the terms and conditions of the GNU General Public | ||
302 | + * License. See the file COPYING in the main directory of this archive for | ||
303 | + * more details. | ||
304 | + */ | ||
305 | +#include <linux/module.h> | ||
306 | +#include <linux/types.h> | ||
307 | +#include <linux/fb.h> | ||
308 | +#include <linux/selection.h> | ||
309 | +#include <linux/vt_kern.h> | ||
310 | +#include <asm/irq.h> | ||
311 | +#include <asm/system.h> | ||
312 | + | ||
313 | +#include "console/fbcon.h" | ||
314 | +#include "fbsplash.h" | ||
315 | + | ||
316 | +#define parse_pixel(shift,bpp,type) \ | ||
317 | + do { \ | ||
318 | + if (d & (0x80 >> (shift))) \ | ||
319 | + dd2[(shift)] = fgx; \ | ||
320 | + else \ | ||
321 | + dd2[(shift)] = transparent ? *(type *)splash_src : bgx; \ | ||
322 | + splash_src += (bpp); \ | ||
323 | + } while (0) \ | ||
324 | + | ||
325 | +extern int get_color(struct vc_data *vc, struct fb_info *info, | ||
326 | + u16 c, int is_fg); | ||
327 | + | ||
328 | +void fbsplash_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc) | ||
329 | +{ | ||
330 | + int i, j, k; | ||
331 | + int minlen = min(min(info->var.red.length, info->var.green.length), | ||
332 | + info->var.blue.length); | ||
333 | + u32 col; | ||
334 | + | ||
335 | + for (j = i = 0; i < 16; i++) { | ||
336 | + k = color_table[i]; | ||
337 | + | ||
338 | + col = ((vc->vc_palette[j++] >> (8-minlen)) | ||
339 | + << info->var.red.offset); | ||
340 | + col |= ((vc->vc_palette[j++] >> (8-minlen)) | ||
341 | + << info->var.green.offset); | ||
342 | + col |= ((vc->vc_palette[j++] >> (8-minlen)) | ||
343 | + << info->var.blue.offset); | ||
344 | + ((u32 *)info->pseudo_palette)[k] = col; | ||
345 | + } | ||
346 | +} | ||
347 | + | ||
348 | +void fbsplash_renderc(struct fb_info *info, int ypos, int xpos, int height, | ||
349 | + int width, u8* src, u32 fgx, u32 bgx, u8 transparent) | ||
350 | +{ | ||
351 | + unsigned int x, y; | ||
352 | + u32 dd; | ||
353 | + int bytespp = ((info->var.bits_per_pixel + 7) >> 3); | ||
354 | + unsigned int d = ypos * info->fix.line_length + xpos * bytespp; | ||
355 | + unsigned int ds = (ypos * info->var.xres + xpos) * bytespp; | ||
356 | + u16 dd2[4]; | ||
357 | + | ||
358 | + u8* splash_src = (u8 *)(info->splash.data + ds); | ||
359 | + u8* dst = (u8 *)(info->screen_base + d); | ||
360 | + | ||
361 | + if ((ypos + height) > info->var.yres || (xpos + width) > info->var.xres) | ||
362 | + return; | ||
363 | + | ||
364 | + for (y = 0; y < height; y++) { | ||
365 | + switch (info->var.bits_per_pixel) { | ||
366 | + | ||
367 | + case 32: | ||
368 | + for (x = 0; x < width; x++) { | ||
369 | + | ||
370 | + if ((x & 7) == 0) | ||
371 | + d = *src++; | ||
372 | + if (d & 0x80) | ||
373 | + dd = fgx; | ||
374 | + else | ||
375 | + dd = transparent ? | ||
376 | + *(u32 *)splash_src : bgx; | ||
377 | + | ||
378 | + d <<= 1; | ||
379 | + splash_src += 4; | ||
380 | + fb_writel(dd, dst); | ||
381 | + dst += 4; | ||
382 | + } | ||
383 | + break; | ||
384 | + case 24: | ||
385 | + for (x = 0; x < width; x++) { | ||
386 | + | ||
387 | + if ((x & 7) == 0) | ||
388 | + d = *src++; | ||
389 | + if (d & 0x80) | ||
390 | + dd = fgx; | ||
391 | + else | ||
392 | + dd = transparent ? | ||
393 | + (*(u32 *)splash_src & 0xffffff) : bgx; | ||
394 | + | ||
395 | + d <<= 1; | ||
396 | + splash_src += 3; | ||
397 | +#ifdef __LITTLE_ENDIAN | ||
398 | + fb_writew(dd & 0xffff, dst); | ||
399 | + dst += 2; | ||
400 | + fb_writeb((dd >> 16), dst); | ||
401 | +#else | ||
402 | + fb_writew(dd >> 8, dst); | ||
403 | + dst += 2; | ||
404 | + fb_writeb(dd & 0xff, dst); | ||
405 | +#endif | ||
406 | + dst++; | ||
407 | + } | ||
408 | + break; | ||
409 | + case 16: | ||
410 | + for (x = 0; x < width; x += 2) { | ||
411 | + if ((x & 7) == 0) | ||
412 | + d = *src++; | ||
413 | + | ||
414 | + parse_pixel(0, 2, u16); | ||
415 | + parse_pixel(1, 2, u16); | ||
416 | +#ifdef __LITTLE_ENDIAN | ||
417 | + dd = dd2[0] | (dd2[1] << 16); | ||
418 | +#else | ||
419 | + dd = dd2[1] | (dd2[0] << 16); | ||
420 | +#endif | ||
421 | + d <<= 2; | ||
422 | + fb_writel(dd, dst); | ||
423 | + dst += 4; | ||
424 | + } | ||
425 | + break; | ||
426 | + | ||
427 | + case 8: | ||
428 | + for (x = 0; x < width; x += 4) { | ||
429 | + if ((x & 7) == 0) | ||
430 | + d = *src++; | ||
431 | + | ||
432 | + parse_pixel(0, 1, u8); | ||
433 | + parse_pixel(1, 1, u8); | ||
434 | + parse_pixel(2, 1, u8); | ||
435 | + parse_pixel(3, 1, u8); | ||
436 | + | ||
437 | +#ifdef __LITTLE_ENDIAN | ||
438 | + dd = dd2[0] | (dd2[1] << 8) | (dd2[2] << 16) | (dd2[3] << 24); | ||
439 | +#else | ||
440 | + dd = dd2[3] | (dd2[2] << 8) | (dd2[1] << 16) | (dd2[0] << 24); | ||
441 | +#endif | ||
442 | + d <<= 4; | ||
443 | + fb_writel(dd, dst); | ||
444 | + dst += 4; | ||
445 | + } | ||
446 | + } | ||
447 | + | ||
448 | + dst += info->fix.line_length - width * bytespp; | ||
449 | + splash_src += (info->var.xres - width) * bytespp; | ||
450 | + } | ||
451 | +} | ||
452 | + | ||
453 | +#define cc2cx(a) \ | ||
454 | + ((info->fix.visual == FB_VISUAL_TRUECOLOR || \ | ||
455 | + info->fix.visual == FB_VISUAL_DIRECTCOLOR) ? \ | ||
456 | + ((u32*)info->pseudo_palette)[a] : a) | ||
457 | + | ||
458 | +void fbsplash_putcs(struct vc_data *vc, struct fb_info *info, | ||
459 | + const unsigned short *s, int count, int yy, int xx) | ||
460 | +{ | ||
461 | + unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; | ||
462 | + struct fbcon_ops *ops = info->fbcon_par; | ||
463 | + int fg_color, bg_color, transparent; | ||
464 | + u8 *src; | ||
465 | + u32 bgx, fgx; | ||
466 | + u16 c = scr_readw(s); | ||
467 | + | ||
468 | + fg_color = get_color(vc, info, c, 1); | ||
469 | + bg_color = get_color(vc, info, c, 0); | ||
470 | + | ||
471 | + /* Don't paint the background image if console is blanked */ | ||
472 | + transparent = ops->blank_state ? 0 : | ||
473 | + (vc->vc_splash.bg_color == bg_color); | ||
474 | + | ||
475 | + xx = xx * vc->vc_font.width + vc->vc_splash.tx; | ||
476 | + yy = yy * vc->vc_font.height + vc->vc_splash.ty; | ||
477 | + | ||
478 | + fgx = cc2cx(fg_color); | ||
479 | + bgx = cc2cx(bg_color); | ||
480 | + | ||
481 | + while (count--) { | ||
482 | + c = scr_readw(s++); | ||
483 | + src = vc->vc_font.data + (c & charmask) * vc->vc_font.height * | ||
484 | + ((vc->vc_font.width + 7) >> 3); | ||
485 | + | ||
486 | + fbsplash_renderc(info, yy, xx, vc->vc_font.height, | ||
487 | + vc->vc_font.width, src, fgx, bgx, transparent); | ||
488 | + xx += vc->vc_font.width; | ||
489 | + } | ||
490 | +} | ||
491 | + | ||
492 | +void fbsplash_cursor(struct fb_info *info, struct fb_cursor *cursor) | ||
493 | +{ | ||
494 | + int i; | ||
495 | + unsigned int dsize, s_pitch; | ||
496 | + struct fbcon_ops *ops = info->fbcon_par; | ||
497 | + struct vc_data* vc; | ||
498 | + u8 *src; | ||
499 | + | ||
500 | + /* we really don't need any cursors while the console is blanked */ | ||
501 | + if (info->state != FBINFO_STATE_RUNNING || ops->blank_state) | ||
502 | + return; | ||
503 | + | ||
504 | + vc = vc_cons[ops->currcon].d; | ||
505 | + | ||
506 | + src = kmalloc(64 + sizeof(struct fb_image), GFP_ATOMIC); | ||
507 | + if (!src) | ||
508 | + return; | ||
509 | + | ||
510 | + s_pitch = (cursor->image.width + 7) >> 3; | ||
511 | + dsize = s_pitch * cursor->image.height; | ||
512 | + if (cursor->enable) { | ||
513 | + switch (cursor->rop) { | ||
514 | + case ROP_XOR: | ||
515 | + for (i = 0; i < dsize; i++) | ||
516 | + src[i] = cursor->image.data[i] ^ cursor->mask[i]; | ||
517 | + break; | ||
518 | + case ROP_COPY: | ||
519 | + default: | ||
520 | + for (i = 0; i < dsize; i++) | ||
521 | + src[i] = cursor->image.data[i] & cursor->mask[i]; | ||
522 | + break; | ||
523 | + } | ||
524 | + } else | ||
525 | + memcpy(src, cursor->image.data, dsize); | ||
526 | + | ||
527 | + fbsplash_renderc(info, | ||
528 | + cursor->image.dy + vc->vc_splash.ty, | ||
529 | + cursor->image.dx + vc->vc_splash.tx, | ||
530 | + cursor->image.height, | ||
531 | + cursor->image.width, | ||
532 | + (u8*)src, | ||
533 | + cc2cx(cursor->image.fg_color), | ||
534 | + cc2cx(cursor->image.bg_color), | ||
535 | + cursor->image.bg_color == vc->vc_splash.bg_color); | ||
536 | + | ||
537 | + kfree(src); | ||
538 | +} | ||
539 | + | ||
540 | +static void splashset(u8 *dst, int height, int width, int dstbytes, | ||
541 | + u32 bgx, int bpp) | ||
542 | +{ | ||
543 | + int i; | ||
544 | + | ||
545 | + if (bpp == 8) | ||
546 | + bgx |= bgx << 8; | ||
547 | + if (bpp == 16 || bpp == 8) | ||
548 | + bgx |= bgx << 16; | ||
549 | + | ||
550 | + while (height-- > 0) { | ||
551 | + u8 *p = dst; | ||
552 | + | ||
553 | + switch (bpp) { | ||
554 | + | ||
555 | + case 32: | ||
556 | + for (i=0; i < width; i++) { | ||
557 | + fb_writel(bgx, p); p += 4; | ||
558 | + } | ||
559 | + break; | ||
560 | + case 24: | ||
561 | + for (i=0; i < width; i++) { | ||
562 | +#ifdef __LITTLE_ENDIAN | ||
563 | + fb_writew((bgx & 0xffff),(u16*)p); p += 2; | ||
564 | + fb_writeb((bgx >> 16),p++); | ||
565 | +#else | ||
566 | + fb_writew((bgx >> 8),(u16*)p); p += 2; | ||
567 | + fb_writeb((bgx & 0xff),p++); | ||
568 | +#endif | ||
569 | + } | ||
570 | + case 16: | ||
571 | + for (i=0; i < width/4; i++) { | ||
572 | + fb_writel(bgx,p); p += 4; | ||
573 | + fb_writel(bgx,p); p += 4; | ||
574 | + } | ||
575 | + if (width & 2) { | ||
576 | + fb_writel(bgx,p); p += 4; | ||
577 | + } | ||
578 | + if (width & 1) | ||
579 | + fb_writew(bgx,(u16*)p); | ||
580 | + break; | ||
581 | + case 8: | ||
582 | + for (i=0; i < width/4; i++) { | ||
583 | + fb_writel(bgx,p); p += 4; | ||
584 | + } | ||
585 | + | ||
586 | + if (width & 2) { | ||
587 | + fb_writew(bgx,p); p += 2; | ||
588 | + } | ||
589 | + if (width & 1) | ||
590 | + fb_writeb(bgx,(u8*)p); | ||
591 | + break; | ||
592 | + | ||
593 | + } | ||
594 | + dst += dstbytes; | ||
595 | + } | ||
596 | +} | ||
597 | + | ||
598 | +void fbsplash_copy(u8 *dst, u8 *src, int height, int width, int linebytes, | ||
599 | + int srclinebytes, int bpp) | ||
600 | +{ | ||
601 | + int i; | ||
602 | + | ||
603 | + while (height-- > 0) { | ||
604 | + u32 *p = (u32 *)dst; | ||
605 | + u32 *q = (u32 *)src; | ||
606 | + | ||
607 | + switch (bpp) { | ||
608 | + | ||
609 | + case 32: | ||
610 | + for (i=0; i < width; i++) | ||
611 | + fb_writel(*q++, p++); | ||
612 | + break; | ||
613 | + case 24: | ||
614 | + for (i=0; i < (width*3/4); i++) | ||
615 | + fb_writel(*q++, p++); | ||
616 | + if ((width*3) % 4) { | ||
617 | + if (width & 2) { | ||
618 | + fb_writeb(*(u8*)q, (u8*)p); | ||
619 | + } else if (width & 1) { | ||
620 | + fb_writew(*(u16*)q, (u16*)p); | ||
621 | + fb_writeb(*(u8*)((u16*)q+1),(u8*)((u16*)p+2)); | ||
622 | + } | ||
623 | + } | ||
624 | + break; | ||
625 | + case 16: | ||
626 | + for (i=0; i < width/4; i++) { | ||
627 | + fb_writel(*q++, p++); | ||
628 | + fb_writel(*q++, p++); | ||
629 | + } | ||
630 | + if (width & 2) | ||
631 | + fb_writel(*q++, p++); | ||
632 | + if (width & 1) | ||
633 | + fb_writew(*(u16*)q, (u16*)p); | ||
634 | + break; | ||
635 | + case 8: | ||
636 | + for (i=0; i < width/4; i++) | ||
637 | + fb_writel(*q++, p++); | ||
638 | + | ||
639 | + if (width & 2) { | ||
640 | + fb_writew(*(u16*)q, (u16*)p); | ||
641 | + q = (u32*) ((u16*)q + 1); | ||
642 | + p = (u32*) ((u16*)p + 1); | ||
643 | + } | ||
644 | + if (width & 1) | ||
645 | + fb_writeb(*(u8*)q, (u8*)p); | ||
646 | + break; | ||
647 | + } | ||
648 | + | ||
649 | + dst += linebytes; | ||
650 | + src += srclinebytes; | ||
651 | + } | ||
652 | +} | ||
653 | + | ||
654 | +static void splashfill(struct fb_info *info, int sy, int sx, int height, | ||
655 | + int width) | ||
656 | +{ | ||
657 | + int bytespp = ((info->var.bits_per_pixel + 7) >> 3); | ||
658 | + int d = sy * info->fix.line_length + sx * bytespp; | ||
659 | + int ds = (sy * info->var.xres + sx) * bytespp; | ||
660 | + | ||
661 | + fbsplash_copy((u8 *)(info->screen_base + d), (u8 *)(info->splash.data + ds), | ||
662 | + height, width, info->fix.line_length, info->var.xres * bytespp, | ||
663 | + info->var.bits_per_pixel); | ||
664 | +} | ||
665 | + | ||
666 | +void fbsplash_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, | ||
667 | + int height, int width) | ||
668 | +{ | ||
669 | + int bgshift = (vc->vc_hi_font_mask) ? 13 : 12; | ||
670 | + int bg_color = attr_bgcol_ec(bgshift, vc); | ||
671 | + int transparent = vc->vc_splash.bg_color == bg_color; | ||
672 | + struct fbcon_ops *ops = info->fbcon_par; | ||
673 | + u8 *dst; | ||
674 | + | ||
675 | + sy = sy * vc->vc_font.height + vc->vc_splash.ty; | ||
676 | + sx = sx * vc->vc_font.width + vc->vc_splash.tx; | ||
677 | + height *= vc->vc_font.height; | ||
678 | + width *= vc->vc_font.width; | ||
679 | + | ||
680 | + /* Don't paint the background image if console is blanked */ | ||
681 | + if (transparent && !ops->blank_state) { | ||
682 | + splashfill(info, sy, sx, height, width); | ||
683 | + } else { | ||
684 | + dst = (u8 *)(info->screen_base + sy * info->fix.line_length + | ||
685 | + sx * ((info->var.bits_per_pixel + 7) >> 3)); | ||
686 | + splashset(dst, height, width, info->fix.line_length, cc2cx(bg_color), | ||
687 | + info->var.bits_per_pixel); | ||
688 | + } | ||
689 | +} | ||
690 | + | ||
691 | +void fbsplash_clear_margins(struct vc_data *vc, struct fb_info *info, | ||
692 | + int bottom_only) | ||
693 | +{ | ||
694 | + unsigned int tw = vc->vc_cols*vc->vc_font.width; | ||
695 | + unsigned int th = vc->vc_rows*vc->vc_font.height; | ||
696 | + | ||
697 | + if (!bottom_only) { | ||
698 | + /* top margin */ | ||
699 | + splashfill(info, 0, 0, vc->vc_splash.ty, info->var.xres); | ||
700 | + /* left margin */ | ||
701 | + splashfill(info, vc->vc_splash.ty, 0, th, vc->vc_splash.tx); | ||
702 | + /* right margin */ | ||
703 | + splashfill(info, vc->vc_splash.ty, vc->vc_splash.tx + tw, th, | ||
704 | + info->var.xres - vc->vc_splash.tx - tw); | ||
705 | + } | ||
706 | + splashfill(info, vc->vc_splash.ty + th, 0, | ||
707 | + info->var.yres - vc->vc_splash.ty - th, info->var.xres); | ||
708 | +} | ||
709 | + | ||
710 | +void fbsplash_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, | ||
711 | + int sx, int dx, int width) | ||
712 | +{ | ||
713 | + u16 *d = (u16 *) (vc->vc_origin + vc->vc_size_row * y + dx * 2); | ||
714 | + u16 *s = d + (dx - sx); | ||
715 | + u16 *start = d; | ||
716 | + u16 *ls = d; | ||
717 | + u16 *le = d + width; | ||
718 | + u16 c; | ||
719 | + int x = dx; | ||
720 | + u16 attr = 1; | ||
721 | + | ||
722 | + do { | ||
723 | + c = scr_readw(d); | ||
724 | + if (attr != (c & 0xff00)) { | ||
725 | + attr = c & 0xff00; | ||
726 | + if (d > start) { | ||
727 | + fbsplash_putcs(vc, info, start, d - start, y, x); | ||
728 | + x += d - start; | ||
729 | + start = d; | ||
730 | + } | ||
731 | + } | ||
732 | + if (s >= ls && s < le && c == scr_readw(s)) { | ||
733 | + if (d > start) { | ||
734 | + fbsplash_putcs(vc, info, start, d - start, y, x); | ||
735 | + x += d - start + 1; | ||
736 | + start = d + 1; | ||
737 | + } else { | ||
738 | + x++; | ||
739 | + start++; | ||
740 | + } | ||
741 | + } | ||
742 | + s++; | ||
743 | + d++; | ||
744 | + } while (d < le); | ||
745 | + if (d > start) | ||
746 | + fbsplash_putcs(vc, info, start, d - start, y, x); | ||
747 | +} | ||
748 | + | ||
749 | +void fbsplash_blank(struct vc_data *vc, struct fb_info *info, int blank) | ||
750 | +{ | ||
751 | + if (blank) { | ||
752 | + splashset((u8 *)info->screen_base, info->var.yres, info->var.xres, | ||
753 | + info->fix.line_length, 0, info->var.bits_per_pixel); | ||
754 | + } else { | ||
755 | + update_screen(vc); | ||
756 | + fbsplash_clear_margins(vc, info, 0); | ||
757 | + } | ||
758 | +} | ||
759 | + | ||
760 | Index: linux-2.6.21/drivers/video/console/bitblit.c | ||
761 | =================================================================== | ||
762 | --- linux-2.6.21.orig/drivers/video/console/bitblit.c | ||
763 | +++ linux-2.6.21/drivers/video/console/bitblit.c | ||
764 | @@ -17,6 +17,7 @@ | ||
765 | #include <linux/console.h> | ||
766 | #include <asm/types.h> | ||
767 | #include "fbcon.h" | ||
768 | +#include "../fbsplash.h" | ||
769 | |||
770 | /* | ||
771 | * Accelerated handlers. | ||
772 | @@ -54,6 +55,13 @@ static void bit_bmove(struct vc_data *vc | ||
773 | area.height = height * vc->vc_font.height; | ||
774 | area.width = width * vc->vc_font.width; | ||
775 | |||
776 | + if (fbsplash_active(info, vc)) { | ||
777 | + area.sx += vc->vc_splash.tx; | ||
778 | + area.sy += vc->vc_splash.ty; | ||
779 | + area.dx += vc->vc_splash.tx; | ||
780 | + area.dy += vc->vc_splash.ty; | ||
781 | + } | ||
782 | + | ||
783 | info->fbops->fb_copyarea(info, &area); | ||
784 | } | ||
785 | |||
786 | @@ -379,11 +387,15 @@ static void bit_cursor(struct vc_data *v | ||
787 | cursor.image.depth = 1; | ||
788 | cursor.rop = ROP_XOR; | ||
789 | |||
790 | - if (info->fbops->fb_cursor) | ||
791 | - err = info->fbops->fb_cursor(info, &cursor); | ||
792 | + if (fbsplash_active(info, vc)) { | ||
793 | + fbsplash_cursor(info, &cursor); | ||
794 | + } else { | ||
795 | + if (info->fbops->fb_cursor) | ||
796 | + err = info->fbops->fb_cursor(info, &cursor); | ||
797 | |||
798 | - if (err) | ||
799 | - soft_cursor(info, &cursor); | ||
800 | + if (err) | ||
801 | + soft_cursor(info, &cursor); | ||
802 | + } | ||
803 | |||
804 | ops->cursor_reset = 0; | ||
805 | } | ||
806 | Index: linux-2.6.21/drivers/video/console/fbcon.c | ||
807 | =================================================================== | ||
808 | --- linux-2.6.21.orig/drivers/video/console/fbcon.c | ||
809 | +++ linux-2.6.21/drivers/video/console/fbcon.c | ||
810 | @@ -90,6 +90,7 @@ | ||
811 | #endif | ||
812 | |||
813 | #include "fbcon.h" | ||
814 | +#include "../fbsplash.h" | ||
815 | |||
816 | #ifdef FBCONDEBUG | ||
817 | # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args) | ||
818 | @@ -105,7 +106,7 @@ enum { | ||
819 | |||
820 | static struct display fb_display[MAX_NR_CONSOLES]; | ||
821 | |||
822 | -static signed char con2fb_map[MAX_NR_CONSOLES]; | ||
823 | +signed char con2fb_map[MAX_NR_CONSOLES]; | ||
824 | static signed char con2fb_map_boot[MAX_NR_CONSOLES]; | ||
825 | static int logo_height; | ||
826 | static int logo_lines; | ||
827 | @@ -300,7 +301,7 @@ static inline int fbcon_is_inactive(stru | ||
828 | vc->vc_mode != KD_TEXT || ops->graphics); | ||
829 | } | ||
830 | |||
831 | -static inline int get_color(struct vc_data *vc, struct fb_info *info, | ||
832 | +inline int get_color(struct vc_data *vc, struct fb_info *info, | ||
833 | u16 c, int is_fg) | ||
834 | { | ||
835 | int depth = fb_get_color_depth(&info->var, &info->fix); | ||
836 | @@ -408,6 +409,7 @@ static void fb_flashcursor(struct work_s | ||
837 | CM_ERASE : CM_DRAW; | ||
838 | ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1), | ||
839 | get_color(vc, info, c, 0)); | ||
840 | + | ||
841 | release_console_sem(); | ||
842 | } | ||
843 | |||
844 | @@ -573,6 +575,8 @@ static int fbcon_takeover(int show_logo) | ||
845 | info_idx = -1; | ||
846 | } | ||
847 | |||
848 | + fbsplash_init(); | ||
849 | + | ||
850 | return err; | ||
851 | } | ||
852 | |||
853 | @@ -979,6 +983,12 @@ static const char *fbcon_startup(void) | ||
854 | rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); | ||
855 | cols /= vc->vc_font.width; | ||
856 | rows /= vc->vc_font.height; | ||
857 | + | ||
858 | + if (fbsplash_active(info, vc)) { | ||
859 | + cols = vc->vc_splash.twidth / vc->vc_font.width; | ||
860 | + rows = vc->vc_splash.theight / vc->vc_font.height; | ||
861 | + } | ||
862 | + | ||
863 | vc_resize(vc, cols, rows); | ||
864 | |||
865 | DPRINTK("mode: %s\n", info->fix.id); | ||
866 | @@ -1062,7 +1072,7 @@ static void fbcon_init(struct vc_data *v | ||
867 | cap = info->flags; | ||
868 | |||
869 | if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW || | ||
870 | - (info->fix.type == FB_TYPE_TEXT)) | ||
871 | + (info->fix.type == FB_TYPE_TEXT) || fbsplash_active(info, vc)) | ||
872 | logo = 0; | ||
873 | |||
874 | if (var_to_display(p, &info->var, info)) | ||
875 | @@ -1256,6 +1266,11 @@ static void fbcon_clear(struct vc_data * | ||
876 | if (!height || !width) | ||
877 | return; | ||
878 | |||
879 | + if (fbsplash_active(info, vc)) { | ||
880 | + fbsplash_clear(vc, info, sy, sx, height, width); | ||
881 | + return; | ||
882 | + } | ||
883 | + | ||
884 | /* Split blits that cross physical y_wrap boundary */ | ||
885 | |||
886 | y_break = p->vrows - p->yscroll; | ||
887 | @@ -1275,10 +1290,15 @@ static void fbcon_putcs(struct vc_data * | ||
888 | struct display *p = &fb_display[vc->vc_num]; | ||
889 | struct fbcon_ops *ops = info->fbcon_par; | ||
890 | |||
891 | - if (!fbcon_is_inactive(vc, info)) | ||
892 | - ops->putcs(vc, info, s, count, real_y(p, ypos), xpos, | ||
893 | - get_color(vc, info, scr_readw(s), 1), | ||
894 | - get_color(vc, info, scr_readw(s), 0)); | ||
895 | + if (!fbcon_is_inactive(vc, info)) { | ||
896 | + | ||
897 | + if (fbsplash_active(info, vc)) | ||
898 | + fbsplash_putcs(vc, info, s, count, ypos, xpos); | ||
899 | + else | ||
900 | + ops->putcs(vc, info, s, count, real_y(p, ypos), xpos, | ||
901 | + get_color(vc, info, scr_readw(s), 1), | ||
902 | + get_color(vc, info, scr_readw(s), 0)); | ||
903 | + } | ||
904 | } | ||
905 | |||
906 | static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos) | ||
907 | @@ -1294,8 +1314,13 @@ static void fbcon_clear_margins(struct v | ||
908 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
909 | struct fbcon_ops *ops = info->fbcon_par; | ||
910 | |||
911 | - if (!fbcon_is_inactive(vc, info)) | ||
912 | - ops->clear_margins(vc, info, bottom_only); | ||
913 | + if (!fbcon_is_inactive(vc, info)) { | ||
914 | + if (fbsplash_active(info, vc)) { | ||
915 | + fbsplash_clear_margins(vc, info, bottom_only); | ||
916 | + } else { | ||
917 | + ops->clear_margins(vc, info, bottom_only); | ||
918 | + } | ||
919 | + } | ||
920 | } | ||
921 | |||
922 | static void fbcon_cursor(struct vc_data *vc, int mode) | ||
923 | @@ -1768,7 +1793,7 @@ static int fbcon_scroll(struct vc_data * | ||
924 | count = vc->vc_rows; | ||
925 | if (softback_top) | ||
926 | fbcon_softback_note(vc, t, count); | ||
927 | - if (logo_shown >= 0) | ||
928 | + if (logo_shown >= 0 || fbsplash_active(info, vc)) | ||
929 | goto redraw_up; | ||
930 | switch (p->scrollmode) { | ||
931 | case SCROLL_MOVE: | ||
932 | @@ -1856,6 +1881,8 @@ static int fbcon_scroll(struct vc_data * | ||
933 | count = vc->vc_rows; | ||
934 | if (logo_shown >= 0) | ||
935 | goto redraw_down; | ||
936 | + if (fbsplash_active(info, vc)) | ||
937 | + goto redraw_down; | ||
938 | switch (p->scrollmode) { | ||
939 | case SCROLL_MOVE: | ||
940 | ops->bmove(vc, info, t, 0, t + count, 0, | ||
941 | @@ -1998,6 +2025,13 @@ static void fbcon_bmove_rec(struct vc_da | ||
942 | } | ||
943 | return; | ||
944 | } | ||
945 | + | ||
946 | + if (fbsplash_active(info, vc) && sy == dy && height == 1) { | ||
947 | + /* must use slower redraw bmove to keep background pic intact */ | ||
948 | + fbsplash_bmove_redraw(vc, info, sy, sx, dx, width); | ||
949 | + return; | ||
950 | + } | ||
951 | + | ||
952 | ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx, | ||
953 | height, width); | ||
954 | } | ||
955 | @@ -2068,8 +2102,9 @@ static int fbcon_resize(struct vc_data * | ||
956 | var.yres = virt_h * virt_fh; | ||
957 | x_diff = info->var.xres - var.xres; | ||
958 | y_diff = info->var.yres - var.yres; | ||
959 | - if (x_diff < 0 || x_diff > virt_fw || | ||
960 | - y_diff < 0 || y_diff > virt_fh) { | ||
961 | + | ||
962 | + if ((x_diff < 0 || x_diff > virt_fw || | ||
963 | + y_diff < 0 || y_diff > virt_fh) && !vc->vc_splash.state) { | ||
964 | const struct fb_videomode *mode; | ||
965 | |||
966 | DPRINTK("attempting resize %ix%i\n", var.xres, var.yres); | ||
967 | @@ -2105,6 +2140,25 @@ static int fbcon_switch(struct vc_data * | ||
968 | |||
969 | info = registered_fb[con2fb_map[vc->vc_num]]; | ||
970 | ops = info->fbcon_par; | ||
971 | + prev_console = ops->currcon; | ||
972 | + if (prev_console != -1) | ||
973 | + old_info = registered_fb[con2fb_map[prev_console]]; | ||
974 | + | ||
975 | + if (fbsplash_active_vc(vc)) { | ||
976 | + struct vc_data *vc_curr = vc_cons[prev_console].d; | ||
977 | + if (!vc_curr->vc_splash.theme || strcmp(vc->vc_splash.theme, vc_curr->vc_splash.theme)) { | ||
978 | + if (fbsplash_call_helper("getpic", vc->vc_num)) | ||
979 | + fbsplash_disable(vc, 0); | ||
980 | + } | ||
981 | + } else if (info->fix.visual == FB_VISUAL_DIRECTCOLOR) { | ||
982 | + struct vc_data *vc_curr = vc_cons[prev_console].d; | ||
983 | + if (vc_curr && fbsplash_active_vc(vc_curr)) { | ||
984 | + /* Clear the screen to avoid displaying funky colors during | ||
985 | + * palette updates. */ | ||
986 | + memset((u8*)info->screen_base + info->fix.line_length * info->var.yoffset, | ||
987 | + 0, info->var.yres * info->fix.line_length); | ||
988 | + } | ||
989 | + } | ||
990 | |||
991 | if (softback_top) { | ||
992 | if (softback_lines) | ||
993 | @@ -2123,9 +2177,6 @@ static int fbcon_switch(struct vc_data * | ||
994 | logo_shown = FBCON_LOGO_CANSHOW; | ||
995 | } | ||
996 | |||
997 | - prev_console = ops->currcon; | ||
998 | - if (prev_console != -1) | ||
999 | - old_info = registered_fb[con2fb_map[prev_console]]; | ||
1000 | /* | ||
1001 | * FIXME: If we have multiple fbdev's loaded, we need to | ||
1002 | * update all info->currcon. Perhaps, we can place this | ||
1003 | @@ -2164,6 +2215,11 @@ static int fbcon_switch(struct vc_data * | ||
1004 | if (old_info != info) | ||
1005 | fbcon_del_cursor_timer(old_info); | ||
1006 | } | ||
1007 | + | ||
1008 | + if (fbsplash_active_nores(info, vc) && !fbsplash_active(info, vc)) { | ||
1009 | + if (fbsplash_call_helper("modechange", vc->vc_num)) | ||
1010 | + fbsplash_disable(vc, 0); | ||
1011 | + } | ||
1012 | |||
1013 | if (fbcon_is_inactive(vc, info) || | ||
1014 | ops->blank_state != FB_BLANK_UNBLANK) | ||
1015 | @@ -2279,8 +2335,12 @@ static int fbcon_blank(struct vc_data *v | ||
1016 | fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW); | ||
1017 | ops->cursor_flash = (!blank); | ||
1018 | |||
1019 | - if (fb_blank(info, blank)) | ||
1020 | - fbcon_generic_blank(vc, info, blank); | ||
1021 | + if (fb_blank(info, blank)) { | ||
1022 | + if (fbsplash_active(info, vc)) | ||
1023 | + fbsplash_blank(vc, info, blank); | ||
1024 | + else | ||
1025 | + fbcon_generic_blank(vc, info, blank); | ||
1026 | + } | ||
1027 | } | ||
1028 | |||
1029 | if (!blank) | ||
1030 | @@ -2431,13 +2491,22 @@ static int fbcon_do_set_font(struct vc_d | ||
1031 | } | ||
1032 | |||
1033 | if (resize) { | ||
1034 | + /* reset wrap/pan */ | ||
1035 | int cols, rows; | ||
1036 | |||
1037 | cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres); | ||
1038 | rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); | ||
1039 | + | ||
1040 | + info->var.xoffset = info->var.yoffset = p->yscroll = 0; | ||
1041 | + if (fbsplash_active(info, vc)) { | ||
1042 | + cols = vc->vc_splash.twidth; | ||
1043 | + rows = vc->vc_splash.theight; | ||
1044 | + } | ||
1045 | cols /= w; | ||
1046 | rows /= h; | ||
1047 | + | ||
1048 | vc_resize(vc, cols, rows); | ||
1049 | + | ||
1050 | if (CON_IS_VISIBLE(vc) && softback_buf) | ||
1051 | fbcon_update_softback(vc); | ||
1052 | } else if (CON_IS_VISIBLE(vc) | ||
1053 | @@ -2555,7 +2624,7 @@ static int fbcon_set_palette(struct vc_d | ||
1054 | int i, j, k, depth; | ||
1055 | u8 val; | ||
1056 | |||
1057 | - if (fbcon_is_inactive(vc, info)) | ||
1058 | + if (fbcon_is_inactive(vc, info) || vc->vc_num != fg_console) | ||
1059 | return -EINVAL; | ||
1060 | |||
1061 | if (!CON_IS_VISIBLE(vc)) | ||
1062 | @@ -2581,7 +2650,49 @@ static int fbcon_set_palette(struct vc_d | ||
1063 | } else | ||
1064 | fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap); | ||
1065 | |||
1066 | - return fb_set_cmap(&palette_cmap, info); | ||
1067 | + if (fbsplash_active(info, vc_cons[fg_console].d) && | ||
1068 | + info->fix.visual == FB_VISUAL_DIRECTCOLOR) { | ||
1069 | + | ||
1070 | + u16 *red, *green, *blue; | ||
1071 | + int minlen = min(min(info->var.red.length, info->var.green.length), | ||
1072 | + info->var.blue.length); | ||
1073 | + int h; | ||
1074 | + | ||
1075 | + struct fb_cmap cmap = { | ||
1076 | + .start = 0, | ||
1077 | + .len = (1 << minlen), | ||
1078 | + .red = NULL, | ||
1079 | + .green = NULL, | ||
1080 | + .blue = NULL, | ||
1081 | + .transp = NULL | ||
1082 | + }; | ||
1083 | + | ||
1084 | + red = kmalloc(256 * sizeof(u16) * 3, GFP_KERNEL); | ||
1085 | + | ||
1086 | + if (!red) | ||
1087 | + goto out; | ||
1088 | + | ||
1089 | + green = red + 256; | ||
1090 | + blue = green + 256; | ||
1091 | + cmap.red = red; | ||
1092 | + cmap.green = green; | ||
1093 | + cmap.blue = blue; | ||
1094 | + | ||
1095 | + for (i = 0; i < cmap.len; i++) { | ||
1096 | + red[i] = green[i] = blue[i] = (0xffff * i)/(cmap.len-1); | ||
1097 | + } | ||
1098 | + | ||
1099 | + h = fb_set_cmap(&cmap, info); | ||
1100 | + fbsplash_fix_pseudo_pal(info, vc_cons[fg_console].d); | ||
1101 | + kfree(red); | ||
1102 | + | ||
1103 | + return h; | ||
1104 | + | ||
1105 | + } else if (fbsplash_active(info, vc_cons[fg_console].d) && | ||
1106 | + info->var.bits_per_pixel == 8 && info->splash.cmap.red != NULL) | ||
1107 | + fb_set_cmap(&info->splash.cmap, info); | ||
1108 | + | ||
1109 | +out: return fb_set_cmap(&palette_cmap, info); | ||
1110 | } | ||
1111 | |||
1112 | static u16 *fbcon_screen_pos(struct vc_data *vc, int offset) | ||
1113 | @@ -2807,7 +2918,14 @@ static void fbcon_modechanged(struct fb_ | ||
1114 | rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); | ||
1115 | cols /= vc->vc_font.width; | ||
1116 | rows /= vc->vc_font.height; | ||
1117 | - vc_resize(vc, cols, rows); | ||
1118 | + | ||
1119 | + if (!fbsplash_active_nores(info, vc)) { | ||
1120 | + vc_resize(vc, cols, rows); | ||
1121 | + } else { | ||
1122 | + if (fbsplash_call_helper("modechange", vc->vc_num)) | ||
1123 | + fbsplash_disable(vc, 0); | ||
1124 | + } | ||
1125 | + | ||
1126 | updatescrollmode(p, info, vc); | ||
1127 | scrollback_max = 0; | ||
1128 | scrollback_current = 0; | ||
1129 | @@ -3265,6 +3383,7 @@ static void fbcon_exit(void) | ||
1130 | } | ||
1131 | } | ||
1132 | |||
1133 | + fbsplash_exit(); | ||
1134 | fbcon_has_exited = 1; | ||
1135 | } | ||
1136 | |||
1137 | Index: linux-2.6.21/drivers/video/fbcmap.c | ||
1138 | =================================================================== | ||
1139 | --- linux-2.6.21.orig/drivers/video/fbcmap.c | ||
1140 | +++ linux-2.6.21/drivers/video/fbcmap.c | ||
1141 | @@ -15,6 +15,7 @@ | ||
1142 | #include <linux/module.h> | ||
1143 | #include <linux/fb.h> | ||
1144 | #include <linux/slab.h> | ||
1145 | +#include "fbsplash.h" | ||
1146 | |||
1147 | #include <asm/uaccess.h> | ||
1148 | |||
1149 | @@ -235,14 +236,17 @@ int fb_set_cmap(struct fb_cmap *cmap, st | ||
1150 | if (transp) | ||
1151 | htransp = *transp++; | ||
1152 | if (info->fbops->fb_setcolreg(start++, | ||
1153 | - hred, hgreen, hblue, | ||
1154 | + hred, hgreen, hblue, | ||
1155 | htransp, info)) | ||
1156 | break; | ||
1157 | } | ||
1158 | } | ||
1159 | - if (rc == 0) | ||
1160 | + if (rc == 0) { | ||
1161 | fb_copy_cmap(cmap, &info->cmap); | ||
1162 | - | ||
1163 | + if (fbsplash_active(info, vc_cons[fg_console].d) && | ||
1164 | + info->fix.visual == FB_VISUAL_DIRECTCOLOR) | ||
1165 | + fbsplash_fix_pseudo_pal(info, vc_cons[fg_console].d); | ||
1166 | + } | ||
1167 | return rc; | ||
1168 | } | ||
1169 | |||
1170 | @@ -250,7 +254,7 @@ int fb_set_user_cmap(struct fb_cmap_user | ||
1171 | { | ||
1172 | int rc, size = cmap->len * sizeof(u16); | ||
1173 | struct fb_cmap umap; | ||
1174 | - | ||
1175 | + | ||
1176 | if (cmap->start < 0 || (!info->fbops->fb_setcolreg && | ||
1177 | !info->fbops->fb_setcmap)) | ||
1178 | return -EINVAL; | ||
1179 | Index: linux-2.6.21/drivers/video/fbsplash.c | ||
1180 | =================================================================== | ||
1181 | --- /dev/null | ||
1182 | +++ linux-2.6.21/drivers/video/fbsplash.c | ||
1183 | @@ -0,0 +1,424 @@ | ||
1184 | +/* | ||
1185 | + * linux/drivers/video/fbsplash.c -- Framebuffer splash routines | ||
1186 | + * | ||
1187 | + * Copyright (C) 2004 Michal Januszewski <spock@gentoo.org> | ||
1188 | + * | ||
1189 | + * Code based upon "Bootsplash" (C) 2001-2003 | ||
1190 | + * Volker Poplawski <volker@poplawski.de>, | ||
1191 | + * Stefan Reinauer <stepan@suse.de>, | ||
1192 | + * Steffen Winterfeldt <snwint@suse.de>, | ||
1193 | + * Michael Schroeder <mls@suse.de>, | ||
1194 | + * Ken Wimer <wimer@suse.de>. | ||
1195 | + * | ||
1196 | + * Splash render routines are located in /linux/drivers/video/cfbsplash.c | ||
1197 | + * | ||
1198 | + * This file is subject to the terms and conditions of the GNU General Public | ||
1199 | + * License. See the file COPYING in the main directory of this archive for | ||
1200 | + * more details. | ||
1201 | + * | ||
1202 | + */ | ||
1203 | +#include <linux/module.h> | ||
1204 | +#include <linux/kernel.h> | ||
1205 | +#include <linux/string.h> | ||
1206 | +#include <linux/types.h> | ||
1207 | +#include <linux/fb.h> | ||
1208 | +#include <linux/vt_kern.h> | ||
1209 | +#include <linux/vmalloc.h> | ||
1210 | +#include <linux/unistd.h> | ||
1211 | +#include <linux/syscalls.h> | ||
1212 | +#include <linux/init.h> | ||
1213 | +#include <linux/proc_fs.h> | ||
1214 | +#include <linux/workqueue.h> | ||
1215 | +#include <linux/kmod.h> | ||
1216 | +#include <linux/miscdevice.h> | ||
1217 | +#include <linux/device.h> | ||
1218 | +#include <linux/fs.h> | ||
1219 | + | ||
1220 | +#include <asm/uaccess.h> | ||
1221 | +#include <asm/irq.h> | ||
1222 | +#include <asm/system.h> | ||
1223 | + | ||
1224 | +#include "console/fbcon.h" | ||
1225 | +#include "fbsplash.h" | ||
1226 | + | ||
1227 | +#define SPLASH_VERSION "0.9.2" | ||
1228 | + | ||
1229 | +extern signed char con2fb_map[]; | ||
1230 | +static int fbsplash_enable(struct vc_data *vc); | ||
1231 | +char fbsplash_path[KMOD_PATH_LEN] = "/sbin/splash_helper"; | ||
1232 | +static int initialized = 0; | ||
1233 | + | ||
1234 | +int fbsplash_call_helper(char* cmd, unsigned short vc) | ||
1235 | +{ | ||
1236 | + char *envp[] = { | ||
1237 | + "HOME=/", | ||
1238 | + "PATH=/sbin:/bin", | ||
1239 | + NULL | ||
1240 | + }; | ||
1241 | + | ||
1242 | + char tfb[5]; | ||
1243 | + char tcons[5]; | ||
1244 | + unsigned char fb = (int) con2fb_map[vc]; | ||
1245 | + | ||
1246 | + char *argv[] = { | ||
1247 | + fbsplash_path, | ||
1248 | + "2", | ||
1249 | + cmd, | ||
1250 | + tcons, | ||
1251 | + tfb, | ||
1252 | + vc_cons[vc].d->vc_splash.theme, | ||
1253 | + NULL | ||
1254 | + }; | ||
1255 | + | ||
1256 | + snprintf(tfb,5,"%d",fb); | ||
1257 | + snprintf(tcons,5,"%d",vc); | ||
1258 | + | ||
1259 | + return call_usermodehelper(fbsplash_path, argv, envp, 1); | ||
1260 | +} | ||
1261 | + | ||
1262 | +/* Disables fbsplash on a virtual console; called with console sem held. */ | ||
1263 | +int fbsplash_disable(struct vc_data *vc, unsigned char redraw) | ||
1264 | +{ | ||
1265 | + struct fb_info* info; | ||
1266 | + | ||
1267 | + if (!vc->vc_splash.state) | ||
1268 | + return -EINVAL; | ||
1269 | + | ||
1270 | + info = registered_fb[(int) con2fb_map[vc->vc_num]]; | ||
1271 | + | ||
1272 | + if (info == NULL) | ||
1273 | + return -EINVAL; | ||
1274 | + | ||
1275 | + vc->vc_splash.state = 0; | ||
1276 | + vc_resize(vc, info->var.xres / vc->vc_font.width, | ||
1277 | + info->var.yres / vc->vc_font.height); | ||
1278 | + | ||
1279 | + if (fg_console == vc->vc_num && redraw) { | ||
1280 | + redraw_screen(vc, 0); | ||
1281 | + update_region(vc, vc->vc_origin + | ||
1282 | + vc->vc_size_row * vc->vc_top, | ||
1283 | + vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2); | ||
1284 | + } | ||
1285 | + | ||
1286 | + printk(KERN_INFO "fbsplash: switched splash state to 'off' on console %d\n", | ||
1287 | + vc->vc_num); | ||
1288 | + | ||
1289 | + return 0; | ||
1290 | +} | ||
1291 | + | ||
1292 | +/* Enables fbsplash on a virtual console; called with console sem held. */ | ||
1293 | +static int fbsplash_enable(struct vc_data *vc) | ||
1294 | +{ | ||
1295 | + struct fb_info* info; | ||
1296 | + | ||
1297 | + info = registered_fb[(int) con2fb_map[vc->vc_num]]; | ||
1298 | + | ||
1299 | + if (vc->vc_splash.twidth == 0 || vc->vc_splash.theight == 0 || | ||
1300 | + info == NULL || vc->vc_splash.state || (!info->splash.data && | ||
1301 | + vc->vc_num == fg_console)) | ||
1302 | + return -EINVAL; | ||
1303 | + | ||
1304 | + vc->vc_splash.state = 1; | ||
1305 | + vc_resize(vc, vc->vc_splash.twidth / vc->vc_font.width, | ||
1306 | + vc->vc_splash.theight / vc->vc_font.height); | ||
1307 | + | ||
1308 | + if (fg_console == vc->vc_num) { | ||
1309 | + redraw_screen(vc, 0); | ||
1310 | + update_region(vc, vc->vc_origin + | ||
1311 | + vc->vc_size_row * vc->vc_top, | ||
1312 | + vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2); | ||
1313 | + fbsplash_clear_margins(vc, info, 0); | ||
1314 | + } | ||
1315 | + | ||
1316 | + printk(KERN_INFO "fbsplash: switched splash state to 'on' on console %d\n", | ||
1317 | + vc->vc_num); | ||
1318 | + | ||
1319 | + return 0; | ||
1320 | +} | ||
1321 | + | ||
1322 | +static inline int fbsplash_ioctl_dosetstate(struct vc_data *vc, unsigned int __user* state, unsigned char origin) | ||
1323 | +{ | ||
1324 | + int tmp, ret; | ||
1325 | + | ||
1326 | + if (get_user(tmp, state)) | ||
1327 | + return -EFAULT; | ||
1328 | + | ||
1329 | + if (origin == FB_SPLASH_IO_ORIG_USER) | ||
1330 | + acquire_console_sem(); | ||
1331 | + if (!tmp) | ||
1332 | + ret = fbsplash_disable(vc, 1); | ||
1333 | + else | ||
1334 | + ret = fbsplash_enable(vc); | ||
1335 | + if (origin == FB_SPLASH_IO_ORIG_USER) | ||
1336 | + release_console_sem(); | ||
1337 | + | ||
1338 | + return ret; | ||
1339 | +} | ||
1340 | + | ||
1341 | +static inline int fbsplash_ioctl_dogetstate(struct vc_data *vc, unsigned int __user *state) | ||
1342 | +{ | ||
1343 | + return put_user(vc->vc_splash.state, (unsigned int __user*) state); | ||
1344 | +} | ||
1345 | + | ||
1346 | +static int fbsplash_ioctl_dosetcfg(struct vc_data *vc, struct vc_splash __user *arg, unsigned char origin) | ||
1347 | +{ | ||
1348 | + struct vc_splash cfg; | ||
1349 | + struct fb_info *info; | ||
1350 | + int len; | ||
1351 | + char *tmp; | ||
1352 | + | ||
1353 | + info = registered_fb[(int) con2fb_map[vc->vc_num]]; | ||
1354 | + | ||
1355 | + if (copy_from_user(&cfg, arg, sizeof(struct vc_splash))) | ||
1356 | + return -EFAULT; | ||
1357 | + if (info == NULL || !cfg.twidth || !cfg.theight || | ||
1358 | + cfg.tx + cfg.twidth > info->var.xres || | ||
1359 | + cfg.ty + cfg.theight > info->var.yres) | ||
1360 | + return -EINVAL; | ||
1361 | + | ||
1362 | + len = strlen_user(cfg.theme); | ||
1363 | + if (!len || len > FB_SPLASH_THEME_LEN) | ||
1364 | + return -EINVAL; | ||
1365 | + tmp = kmalloc(len, GFP_KERNEL); | ||
1366 | + if (!tmp) | ||
1367 | + return -ENOMEM; | ||
1368 | + if (copy_from_user(tmp, (void __user *)cfg.theme, len)) | ||
1369 | + return -EFAULT; | ||
1370 | + cfg.theme = tmp; | ||
1371 | + cfg.state = 0; | ||
1372 | + | ||
1373 | + /* If this ioctl is a response to a request from kernel, the console sem | ||
1374 | + * is already held; we also don't need to disable splash because either the | ||
1375 | + * new config and background picture will be successfully loaded, and the | ||
1376 | + * splash will stay on, or in case of a failure it'll be turned off in fbcon. */ | ||
1377 | + if (origin == FB_SPLASH_IO_ORIG_USER) { | ||
1378 | + acquire_console_sem(); | ||
1379 | + if (vc->vc_splash.state) | ||
1380 | + fbsplash_disable(vc, 1); | ||
1381 | + } | ||
1382 | + | ||
1383 | + if (vc->vc_splash.theme) | ||
1384 | + kfree(vc->vc_splash.theme); | ||
1385 | + | ||
1386 | + vc->vc_splash = cfg; | ||
1387 | + | ||
1388 | + if (origin == FB_SPLASH_IO_ORIG_USER) | ||
1389 | + release_console_sem(); | ||
1390 | + | ||
1391 | + printk(KERN_INFO "fbsplash: console %d using theme '%s'\n", | ||
1392 | + vc->vc_num, vc->vc_splash.theme); | ||
1393 | + return 0; | ||
1394 | +} | ||
1395 | + | ||
1396 | +static int fbsplash_ioctl_dogetcfg(struct vc_data *vc, struct vc_splash __user *arg) | ||
1397 | +{ | ||
1398 | + struct vc_splash splash; | ||
1399 | + char __user *tmp; | ||
1400 | + | ||
1401 | + if (get_user(tmp, &arg->theme)) | ||
1402 | + return -EFAULT; | ||
1403 | + | ||
1404 | + splash = vc->vc_splash; | ||
1405 | + splash.theme = tmp; | ||
1406 | + | ||
1407 | + if (vc->vc_splash.theme) { | ||
1408 | + if (copy_to_user(tmp, vc->vc_splash.theme, strlen(vc->vc_splash.theme) + 1)) | ||
1409 | + return -EFAULT; | ||
1410 | + } else | ||
1411 | + if (put_user(0, tmp)) | ||
1412 | + return -EFAULT; | ||
1413 | + | ||
1414 | + if (copy_to_user(arg, &splash, sizeof(struct vc_splash))) | ||
1415 | + return -EFAULT; | ||
1416 | + | ||
1417 | + return 0; | ||
1418 | +} | ||
1419 | + | ||
1420 | +static int fbsplash_ioctl_dosetpic(struct vc_data *vc, struct fb_image __user *arg, unsigned char origin) | ||
1421 | +{ | ||
1422 | + struct fb_image img; | ||
1423 | + struct fb_info *info; | ||
1424 | + int len; | ||
1425 | + u8 *tmp; | ||
1426 | + | ||
1427 | + if (vc->vc_num != fg_console) | ||
1428 | + return -EINVAL; | ||
1429 | + | ||
1430 | + info = registered_fb[(int) con2fb_map[vc->vc_num]]; | ||
1431 | + | ||
1432 | + if (info == NULL) | ||
1433 | + return -EINVAL; | ||
1434 | + | ||
1435 | + if (copy_from_user(&img, arg, sizeof(struct fb_image))) | ||
1436 | + return -EFAULT; | ||
1437 | + | ||
1438 | + if (img.width != info->var.xres || img.height != info->var.yres) { | ||
1439 | + printk(KERN_ERR "fbsplash: picture dimensions mismatch\n"); | ||
1440 | + return -EINVAL; | ||
1441 | + } | ||
1442 | + | ||
1443 | + if (img.depth != info->var.bits_per_pixel) { | ||
1444 | + printk(KERN_ERR "fbsplash: picture depth mismatch\n"); | ||
1445 | + return -EINVAL; | ||
1446 | + } | ||
1447 | + | ||
1448 | + if (img.depth == 8) { | ||
1449 | + if (!img.cmap.len || !img.cmap.red || !img.cmap.green || | ||
1450 | + !img.cmap.blue) | ||
1451 | + return -EINVAL; | ||
1452 | + | ||
1453 | + tmp = vmalloc(img.cmap.len * 3 * 2); | ||
1454 | + if (!tmp) | ||
1455 | + return -ENOMEM; | ||
1456 | + | ||
1457 | + if (copy_from_user(tmp, (void __user*)img.cmap.red, img.cmap.len * 2) || | ||
1458 | + copy_from_user(tmp + (img.cmap.len << 1), | ||
1459 | + (void __user*)img.cmap.green, (img.cmap.len << 1)) || | ||
1460 | + copy_from_user(tmp + (img.cmap.len << 2), | ||
1461 | + (void __user*)img.cmap.blue, (img.cmap.len << 1))) { | ||
1462 | + vfree(tmp); | ||
1463 | + return -EFAULT; | ||
1464 | + } | ||
1465 | + | ||
1466 | + img.cmap.transp = NULL; | ||
1467 | + img.cmap.red = (u16*)tmp; | ||
1468 | + img.cmap.green = img.cmap.red + img.cmap.len; | ||
1469 | + img.cmap.blue = img.cmap.green + img.cmap.len; | ||
1470 | + } else { | ||
1471 | + img.cmap.red = NULL; | ||
1472 | + } | ||
1473 | + | ||
1474 | + len = ((img.depth + 7) >> 3) * img.width * img.height; | ||
1475 | + tmp = vmalloc(len); | ||
1476 | + | ||
1477 | + if (!tmp) | ||
1478 | + goto out; | ||
1479 | + | ||
1480 | + if (copy_from_user(tmp, (void __user*)img.data, len)) | ||
1481 | + goto out; | ||
1482 | + | ||
1483 | + img.data = tmp; | ||
1484 | + | ||
1485 | + /* If this ioctl is a response to a request from kernel, the console sem | ||
1486 | + * is already held. */ | ||
1487 | + if (origin == FB_SPLASH_IO_ORIG_USER) | ||
1488 | + acquire_console_sem(); | ||
1489 | + | ||
1490 | + if (info->splash.data) | ||
1491 | + vfree((u8*)info->splash.data); | ||
1492 | + if (info->splash.cmap.red) | ||
1493 | + vfree(info->splash.cmap.red); | ||
1494 | + | ||
1495 | + info->splash = img; | ||
1496 | + | ||
1497 | + if (origin == FB_SPLASH_IO_ORIG_USER) | ||
1498 | + release_console_sem(); | ||
1499 | + | ||
1500 | + return 0; | ||
1501 | + | ||
1502 | +out: if (img.cmap.red) | ||
1503 | + vfree(img.cmap.red); | ||
1504 | + if (tmp) | ||
1505 | + vfree(tmp); | ||
1506 | + return -ENOMEM; | ||
1507 | +} | ||
1508 | + | ||
1509 | +static int splash_ioctl(struct inode * inode, struct file *filp, u_int cmd, | ||
1510 | + u_long arg) | ||
1511 | +{ | ||
1512 | + struct fb_splash_iowrapper __user *wrapper = (void __user*) arg; | ||
1513 | + struct vc_data *vc = NULL; | ||
1514 | + unsigned short vc_num = 0; | ||
1515 | + unsigned char origin = 0; | ||
1516 | + void __user *data = NULL; | ||
1517 | + | ||
1518 | + if (!access_ok(VERIFY_READ, wrapper, | ||
1519 | + sizeof(struct fb_splash_iowrapper))) | ||
1520 | + return -EFAULT; | ||
1521 | + | ||
1522 | + __get_user(vc_num, &wrapper->vc); | ||
1523 | + __get_user(origin, &wrapper->origin); | ||
1524 | + __get_user(data, &wrapper->data); | ||
1525 | + | ||
1526 | + if (!vc_cons_allocated(vc_num)) | ||
1527 | + return -EINVAL; | ||
1528 | + | ||
1529 | + vc = vc_cons[vc_num].d; | ||
1530 | + | ||
1531 | + switch (cmd) { | ||
1532 | + case FBIOSPLASH_SETPIC: | ||
1533 | + return fbsplash_ioctl_dosetpic(vc, (struct fb_image __user*)data, origin); | ||
1534 | + case FBIOSPLASH_SETCFG: | ||
1535 | + return fbsplash_ioctl_dosetcfg(vc, (struct vc_splash*)data, origin); | ||
1536 | + case FBIOSPLASH_GETCFG: | ||
1537 | + return fbsplash_ioctl_dogetcfg(vc, (struct vc_splash*)data); | ||
1538 | + case FBIOSPLASH_SETSTATE: | ||
1539 | + return fbsplash_ioctl_dosetstate(vc, (unsigned int *)data, origin); | ||
1540 | + case FBIOSPLASH_GETSTATE: | ||
1541 | + return fbsplash_ioctl_dogetstate(vc, (unsigned int *)data); | ||
1542 | + default: | ||
1543 | + return -ENOIOCTLCMD; | ||
1544 | + } | ||
1545 | +} | ||
1546 | + | ||
1547 | +static struct file_operations splash_ops = { | ||
1548 | + .owner = THIS_MODULE, | ||
1549 | + .ioctl = splash_ioctl | ||
1550 | +}; | ||
1551 | + | ||
1552 | +static struct miscdevice splash_dev = { | ||
1553 | + .minor = MISC_DYNAMIC_MINOR, | ||
1554 | + .name = "fbsplash", | ||
1555 | + .fops = &splash_ops | ||
1556 | +}; | ||
1557 | + | ||
1558 | +void fbsplash_reset(void) | ||
1559 | +{ | ||
1560 | + struct fb_info *info; | ||
1561 | + struct vc_data *vc; | ||
1562 | + int i; | ||
1563 | + | ||
1564 | + vc = vc_cons[0].d; | ||
1565 | + info = registered_fb[0]; | ||
1566 | + | ||
1567 | + for (i = 0; i < num_registered_fb; i++) { | ||
1568 | + registered_fb[i]->splash.data = NULL; | ||
1569 | + registered_fb[i]->splash.cmap.red = NULL; | ||
1570 | + } | ||
1571 | + | ||
1572 | + for (i = 0; i < MAX_NR_CONSOLES && vc_cons[i].d; i++) { | ||
1573 | + vc_cons[i].d->vc_splash.state = vc_cons[i].d->vc_splash.twidth = | ||
1574 | + vc_cons[i].d->vc_splash.theight = 0; | ||
1575 | + vc_cons[i].d->vc_splash.theme = NULL; | ||
1576 | + } | ||
1577 | + | ||
1578 | + return; | ||
1579 | +} | ||
1580 | + | ||
1581 | +int fbsplash_init(void) | ||
1582 | +{ | ||
1583 | + int i; | ||
1584 | + | ||
1585 | + fbsplash_reset(); | ||
1586 | + | ||
1587 | + if (initialized) | ||
1588 | + return 0; | ||
1589 | + | ||
1590 | + i = misc_register(&splash_dev); | ||
1591 | + if (i) { | ||
1592 | + printk(KERN_ERR "fbsplash: failed to register device\n"); | ||
1593 | + return i; | ||
1594 | + } | ||
1595 | + | ||
1596 | + fbsplash_call_helper("init", 0); | ||
1597 | + initialized = 1; | ||
1598 | + return 0; | ||
1599 | +} | ||
1600 | + | ||
1601 | +int fbsplash_exit(void) | ||
1602 | +{ | ||
1603 | + fbsplash_reset(); | ||
1604 | + return 0; | ||
1605 | +} | ||
1606 | + | ||
1607 | +EXPORT_SYMBOL(fbsplash_path); | ||
1608 | Index: linux-2.6.21/drivers/video/fbsplash.h | ||
1609 | =================================================================== | ||
1610 | --- /dev/null | ||
1611 | +++ linux-2.6.21/drivers/video/fbsplash.h | ||
1612 | @@ -0,0 +1,78 @@ | ||
1613 | +/* | ||
1614 | + * linux/drivers/video/fbsplash.h -- Framebuffer splash headers | ||
1615 | + * | ||
1616 | + * Copyright (C) 2004 Michal Januszewski <spock@gentoo.org> | ||
1617 | + * | ||
1618 | + */ | ||
1619 | + | ||
1620 | +#ifndef __FB_SPLASH_H | ||
1621 | +#define __FB_SPLASH_H | ||
1622 | + | ||
1623 | +#ifndef _LINUX_FB_H | ||
1624 | +#include <linux/fb.h> | ||
1625 | +#endif | ||
1626 | + | ||
1627 | +/* This is needed for vc_cons in fbcmap.c */ | ||
1628 | +#include <linux/vt_kern.h> | ||
1629 | + | ||
1630 | +struct fb_cursor; | ||
1631 | +struct fb_info; | ||
1632 | +struct vc_data; | ||
1633 | + | ||
1634 | +#ifdef CONFIG_FB_SPLASH | ||
1635 | +/* fbsplash.c */ | ||
1636 | +int fbsplash_init(void); | ||
1637 | +int fbsplash_exit(void); | ||
1638 | +int fbsplash_call_helper(char* cmd, unsigned short cons); | ||
1639 | +int fbsplash_disable(struct vc_data *vc, unsigned char redraw); | ||
1640 | + | ||
1641 | +/* cfbsplash.c */ | ||
1642 | +void fbsplash_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx); | ||
1643 | +void fbsplash_cursor(struct fb_info *info, struct fb_cursor *cursor); | ||
1644 | +void fbsplash_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width); | ||
1645 | +void fbsplash_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only); | ||
1646 | +void fbsplash_blank(struct vc_data *vc, struct fb_info *info, int blank); | ||
1647 | +void fbsplash_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width); | ||
1648 | +void fbsplash_copy(u8 *dst, u8 *src, int height, int width, int linebytes, int srclinesbytes, int bpp); | ||
1649 | +void fbsplash_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc); | ||
1650 | + | ||
1651 | +/* vt.c */ | ||
1652 | +void acquire_console_sem(void); | ||
1653 | +void release_console_sem(void); | ||
1654 | +void do_unblank_screen(int entering_gfx); | ||
1655 | + | ||
1656 | +/* struct vc_data *y */ | ||
1657 | +#define fbsplash_active_vc(y) (y->vc_splash.state && y->vc_splash.theme) | ||
1658 | + | ||
1659 | +/* struct fb_info *x, struct vc_data *y */ | ||
1660 | +#define fbsplash_active_nores(x,y) (x->splash.data && fbsplash_active_vc(y)) | ||
1661 | + | ||
1662 | +/* struct fb_info *x, struct vc_data *y */ | ||
1663 | +#define fbsplash_active(x,y) (fbsplash_active_nores(x,y) && \ | ||
1664 | + x->splash.width == x->var.xres && \ | ||
1665 | + x->splash.height == x->var.yres && \ | ||
1666 | + x->splash.depth == x->var.bits_per_pixel) | ||
1667 | + | ||
1668 | + | ||
1669 | +#else /* CONFIG_FB_SPLASH */ | ||
1670 | + | ||
1671 | +static inline void fbsplash_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx) {} | ||
1672 | +static inline void fbsplash_putc(struct vc_data *vc, struct fb_info *info, int c, int ypos, int xpos) {} | ||
1673 | +static inline void fbsplash_cursor(struct fb_info *info, struct fb_cursor *cursor) {} | ||
1674 | +static inline void fbsplash_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) {} | ||
1675 | +static inline void fbsplash_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only) {} | ||
1676 | +static inline void fbsplash_blank(struct vc_data *vc, struct fb_info *info, int blank) {} | ||
1677 | +static inline void fbsplash_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width) {} | ||
1678 | +static inline void fbsplash_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc) {} | ||
1679 | +static inline int fbsplash_call_helper(char* cmd, unsigned short cons) { return 0; } | ||
1680 | +static inline int fbsplash_init(void) { return 0; } | ||
1681 | +static inline int fbsplash_exit(void) { return 0; } | ||
1682 | +static inline int fbsplash_disable(struct vc_data *vc, unsigned char redraw) { return 0; } | ||
1683 | + | ||
1684 | +#define fbsplash_active_vc(y) (0) | ||
1685 | +#define fbsplash_active_nores(x,y) (0) | ||
1686 | +#define fbsplash_active(x,y) (0) | ||
1687 | + | ||
1688 | +#endif /* CONFIG_FB_SPLASH */ | ||
1689 | + | ||
1690 | +#endif /* __FB_SPLASH_H */ | ||
1691 | Index: linux-2.6.21/include/linux/console_splash.h | ||
1692 | =================================================================== | ||
1693 | --- /dev/null | ||
1694 | +++ linux-2.6.21/include/linux/console_splash.h | ||
1695 | @@ -0,0 +1,13 @@ | ||
1696 | +#ifndef _LINUX_CONSOLE_SPLASH_H_ | ||
1697 | +#define _LINUX_CONSOLE_SPLASH_H_ 1 | ||
1698 | + | ||
1699 | +/* A structure used by the framebuffer splash code (drivers/video/fbsplash.c) */ | ||
1700 | +struct vc_splash { | ||
1701 | + __u8 bg_color; /* The color that is to be treated as transparent */ | ||
1702 | + __u8 state; /* Current splash state: 0 = off, 1 = on */ | ||
1703 | + __u16 tx, ty; /* Top left corner coordinates of the text field */ | ||
1704 | + __u16 twidth, theight; /* Width and height of the text field */ | ||
1705 | + char* theme; | ||
1706 | +}; | ||
1707 | + | ||
1708 | +#endif | ||
1709 | Index: linux-2.6.21/include/linux/console_struct.h | ||
1710 | =================================================================== | ||
1711 | --- linux-2.6.21.orig/include/linux/console_struct.h | ||
1712 | +++ linux-2.6.21/include/linux/console_struct.h | ||
1713 | @@ -16,6 +16,7 @@ | ||
1714 | struct vt_struct; | ||
1715 | |||
1716 | #define NPAR 16 | ||
1717 | +#include <linux/console_splash.h> | ||
1718 | |||
1719 | struct vc_data { | ||
1720 | unsigned short vc_num; /* Console number */ | ||
1721 | @@ -99,6 +100,8 @@ struct vc_data { | ||
1722 | struct vc_data **vc_display_fg; /* [!] Ptr to var holding fg console for this display */ | ||
1723 | unsigned long vc_uni_pagedir; | ||
1724 | unsigned long *vc_uni_pagedir_loc; /* [!] Location of uni_pagedir variable for this console */ | ||
1725 | + | ||
1726 | + struct vc_splash vc_splash; | ||
1727 | /* additional information is in vt_kern.h */ | ||
1728 | }; | ||
1729 | |||
1730 | Index: linux-2.6.21/include/linux/fb.h | ||
1731 | =================================================================== | ||
1732 | --- linux-2.6.21.orig/include/linux/fb.h | ||
1733 | +++ linux-2.6.21/include/linux/fb.h | ||
1734 | @@ -9,6 +9,13 @@ | ||
1735 | #define FB_MAJOR 29 | ||
1736 | #define FB_MAX 32 /* sufficient for now */ | ||
1737 | |||
1738 | +struct fb_splash_iowrapper | ||
1739 | +{ | ||
1740 | + unsigned short vc; /* Virtual console */ | ||
1741 | + unsigned char origin; /* Point of origin of the request */ | ||
1742 | + void *data; | ||
1743 | +}; | ||
1744 | + | ||
1745 | /* ioctls | ||
1746 | 0x46 is 'F' */ | ||
1747 | #define FBIOGET_VSCREENINFO 0x4600 | ||
1748 | @@ -36,7 +43,15 @@ | ||
1749 | #define FBIOGET_HWCINFO 0x4616 | ||
1750 | #define FBIOPUT_MODEINFO 0x4617 | ||
1751 | #define FBIOGET_DISPINFO 0x4618 | ||
1752 | - | ||
1753 | +#define FBIOSPLASH_SETCFG _IOWR('F', 0x19, struct fb_splash_iowrapper) | ||
1754 | +#define FBIOSPLASH_GETCFG _IOR('F', 0x1A, struct fb_splash_iowrapper) | ||
1755 | +#define FBIOSPLASH_SETSTATE _IOWR('F', 0x1B, struct fb_splash_iowrapper) | ||
1756 | +#define FBIOSPLASH_GETSTATE _IOR('F', 0x1C, struct fb_splash_iowrapper) | ||
1757 | +#define FBIOSPLASH_SETPIC _IOWR('F', 0x1D, struct fb_splash_iowrapper) | ||
1758 | + | ||
1759 | +#define FB_SPLASH_THEME_LEN 128 /* Maximum lenght of a theme name */ | ||
1760 | +#define FB_SPLASH_IO_ORIG_KERNEL 0 /* Kernel ioctl origin */ | ||
1761 | +#define FB_SPLASH_IO_ORIG_USER 1 /* User ioctl origin */ | ||
1762 | |||
1763 | #define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */ | ||
1764 | #define FB_TYPE_PLANES 1 /* Non interleaved planes */ | ||
1765 | @@ -793,6 +808,9 @@ struct fb_info { | ||
1766 | #define FBINFO_STATE_SUSPENDED 1 | ||
1767 | u32 state; /* Hardware state i.e suspend */ | ||
1768 | void *fbcon_par; /* fbcon use-only private area */ | ||
1769 | + | ||
1770 | + struct fb_image splash; | ||
1771 | + | ||
1772 | /* From here on everything is device dependent */ | ||
1773 | void *par; | ||
1774 | }; | ||
1775 | Index: linux-2.6.21/include/linux/sysctl.h | ||
1776 | =================================================================== | ||
1777 | --- linux-2.6.21.orig/include/linux/sysctl.h | ||
1778 | +++ linux-2.6.21/include/linux/sysctl.h | ||
1779 | @@ -165,6 +165,7 @@ enum | ||
1780 | KERN_MAX_LOCK_DEPTH=74, | ||
1781 | KERN_NMI_WATCHDOG=75, /* int: enable/disable nmi watchdog */ | ||
1782 | KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */ | ||
1783 | + KERN_FBSPLASH=77, /* string: path to fbsplash helper */ | ||
1784 | }; | ||
1785 | |||
1786 | |||
1787 | Index: linux-2.6.21/kernel/sysctl.c | ||
1788 | =================================================================== | ||
1789 | --- linux-2.6.21.orig/kernel/sysctl.c | ||
1790 | +++ linux-2.6.21/kernel/sysctl.c | ||
1791 | @@ -87,6 +87,9 @@ static int ngroups_max = NGROUPS_MAX; | ||
1792 | #ifdef CONFIG_KMOD | ||
1793 | extern char modprobe_path[]; | ||
1794 | #endif | ||
1795 | +#ifdef CONFIG_FB_SPLASH | ||
1796 | +extern char fbsplash_path[]; | ||
1797 | +#endif | ||
1798 | #ifdef CONFIG_CHR_DEV_SG | ||
1799 | extern int sg_big_buff; | ||
1800 | #endif | ||
1801 | @@ -341,6 +344,17 @@ static ctl_table kern_table[] = { | ||
1802 | .strategy = &sysctl_string, | ||
1803 | }, | ||
1804 | #endif | ||
1805 | +#ifdef CONFIG_FB_SPLASH | ||
1806 | + { | ||
1807 | + .ctl_name = KERN_FBSPLASH, | ||
1808 | + .procname = "fbsplash", | ||
1809 | + .data = &fbsplash_path, | ||
1810 | + .maxlen = KMOD_PATH_LEN, | ||
1811 | + .mode = 0644, | ||
1812 | + .proc_handler = &proc_dostring, | ||
1813 | + .strategy = &sysctl_string, | ||
1814 | + }, | ||
1815 | +#endif | ||
1816 | #ifdef CONFIG_CHR_DEV_SG | ||
1817 | { | ||
1818 | .ctl_name = KERN_SG_BIG_BUFF, |