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