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