Magellan Linux

Contents of /trunk/kernel26-magellan/patches-2.6.35-r3/0150-2.6.35-fbcondecor-0.9.6.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1136 - (show annotations) (download)
Sat Sep 18 11:01:49 2010 UTC (13 years, 7 months ago) by niro
File size: 62763 byte(s)
-2.6.35-magellan-r3; added patch to fix CVE-2010-3301
1 diff --git a/Documentation/fb/00-INDEX b/Documentation/fb/00-INDEX
2 index a618fd9..6eb4dc4 100644
3 --- a/Documentation/fb/00-INDEX
4 +++ b/Documentation/fb/00-INDEX
5 @@ -15,6 +15,8 @@ deferred_io.txt
6 - an introduction to deferred IO.
7 fbcon.txt
8 - intro to and usage guide for the framebuffer console (fbcon).
9 +fbcondecor.txt
10 + - info on the Framebuffer Console Decoration
11 framebuffer.txt
12 - introduction to frame buffer devices.
13 imacfb.txt
14 diff --git a/Documentation/fb/fbcondecor.txt b/Documentation/fb/fbcondecor.txt
15 new file mode 100644
16 index 0000000..15889f3
17 --- /dev/null
18 +++ b/Documentation/fb/fbcondecor.txt
19 @@ -0,0 +1,207 @@
20 +What is it?
21 +-----------
22 +
23 +The framebuffer decorations are a kernel feature which allows displaying a
24 +background picture on selected consoles.
25 +
26 +What do I need to get it to work?
27 +---------------------------------
28 +
29 +To get fbcondecor up-and-running you will have to:
30 + 1) get a copy of splashutils [1] or a similar program
31 + 2) get some fbcondecor themes
32 + 3) build the kernel helper program
33 + 4) build your kernel with the FB_CON_DECOR option enabled.
34 +
35 +To get fbcondecor 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 fbcondecor helper (by default: /sbin/fbcondecor_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 fbcondecor helper must be accessible at
50 +all times. If it's not, fbcondecor will be switched off automatically.
51 +
52 +It's possible to set path to the fbcondecor helper by writing it to
53 +/proc/sys/kernel/fbcondecor.
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 fbcondecor protocol
61 +-----------------------
62 +
63 +The fbcondecor protocol defines a communication interface between the kernel and
64 +the userspace fbcondecor 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 fbcondecor 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 fbcondecor 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 +<fbcondecor protocol version> <command> <parameters>
89 +
90 +All commands defined in fbcondecor protocol v2 have the following parameters:
91 + virtual console
92 + framebuffer number
93 + theme
94 +
95 +Fbcondecor protocol v1 specified an additional 'fbcondecor mode' after the
96 +framebuffer number. Fbcondecor protocol v1 is deprecated and should not be used.
97 +
98 +Fbcondecor 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 FBIOCONDECOR_SETPIC ioctl.
106 +
107 +init
108 +----
109 + The kernel issues this command after the fbcondecor device is created and
110 + the fbcondecor interface is initialized. Upon receiving 'init', the userspace
111 + helper should parse the kernel command line (/proc/cmdline) or otherwise
112 + decide whether fbcondecor is to be activated.
113 +
114 + To activate fbcondecor on the first console the helper should issue the
115 + FBIOCONDECOR_SETCFG, FBIOCONDECOR_SETPIC and FBIOCONDECOR_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, fbcondecor 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 fbcondecor_helper
127 + with the 'init' command. The fbcondecor helper should perform all ioctls with
128 + origin set to FBCON_DECOR_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 + FBCON_DECOR_IO_ORIG_KERNEL.
136 +
137 +
138 +Userspace -> Kernel
139 +-------------------
140 +
141 +Userspace programs can communicate with fbcondecor via ioctls on the
142 +fbcondecor device. These ioctls are to be used by both the userspace helper
143 +(called only by the kernel) and userspace configuration tools (run by the users).
144 +
145 +The fbcondecor helper should set the origin field to FBCON_DECOR_IO_ORIG_KERNEL
146 +when doing the appropriate ioctls. All userspace configuration tools should
147 +use FBCON_DECOR_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 +FBCON_DECOR_IO_ORIG_KERNEL instructs fbcondecor not to try to acquire the console
152 +semaphore. Not surprisingly, FBCON_DECOR_IO_ORIG_USER instructs it to acquire
153 +the console sem.
154 +
155 +The framebuffer console decoration provides the following ioctls (all defined in
156 +linux/fb.h):
157 +
158 +FBIOCONDECOR_SETPIC
159 +description: loads a background picture for a virtual console
160 +argument: struct fbcon_decor_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 +FBIOCONDECOR_SETCFG
172 +description: sets the fbcondecor config for a virtual console
173 +argument: struct fbcon_decor_iowrapper*; data: struct vc_decor*
174 +notes: The structure has to be filled with valid data.
175 +
176 +FBIOCONDECOR_GETCFG
177 +description: gets the fbcondecor config for a virtual console
178 +argument: struct fbcon_decor_iowrapper*; data: struct vc_decor*
179 +
180 +FBIOCONDECOR_SETSTATE
181 +description: sets the fbcondecor state for a virtual console
182 +argument: struct fbcon_decor_iowrapper*; data: unsigned int*
183 + values: 0 = disabled, 1 = enabled.
184 +
185 +FBIOCONDECOR_GETSTATE
186 +description: gets the fbcondecor state for a virtual console
187 +argument: struct fbcon_decor_iowrapper*; data: unsigned int*
188 + values: as in FBIOCONDECOR_SETSTATE
189 +
190 +Info on used structures:
191 +
192 +Definition of struct vc_decor can be found in linux/console_decor.h. It's
193 +heavily commented. Note that the 'theme' field should point to a string
194 +no longer than FBCON_DECOR_THEME_LEN. When FBIOCONDECOR_GETCFG call is
195 +performed, the theme field should point to a char buffer of length
196 +FBCON_DECOR_THEME_LEN.
197 +
198 +Definition of struct fbcon_decor_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 +fbcondecor helper should set this field to FBCON_DECOR_IO_ORIG_KERNEL, userspace
207 +programs should set it to FBCON_DECOR_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 +Fbcondecor, fbcondecor protocol design, current implementation & docs by:
225 + Michal Januszewski <spock@gentoo.org>
226 +
227 diff --git a/drivers/Makefile b/drivers/Makefile
228 index 91874e0..dc7663b 100644
229 --- a/drivers/Makefile
230 +++ b/drivers/Makefile
231 @@ -9,6 +9,9 @@ obj-y += gpio/
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-y += idle/
240 obj-$(CONFIG_ACPI) += acpi/
241 @@ -24,10 +27,6 @@ obj-$(CONFIG_XEN) += xen/
242 # regulators early, since some subsystems rely on them to initialize
243 obj-$(CONFIG_REGULATOR) += regulator/
244
245 -# char/ comes before serial/ etc so that the VT console is the boot-time
246 -# default.
247 -obj-y += char/
248 -
249 # gpu/ comes after char for AGP vs DRM startup
250 obj-y += gpu/
251
252 diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
253 index 3d94a14..54e113d 100644
254 --- a/drivers/video/Kconfig
255 +++ b/drivers/video/Kconfig
256 @@ -1195,7 +1195,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 diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
265 index 8e8f18d..86875c3 100644
266 --- a/drivers/video/console/Kconfig
267 +++ b/drivers/video/console/Kconfig
268 @@ -122,6 +122,19 @@ config FRAMEBUFFER_CONSOLE_ROTATION
269 such that other users of the framebuffer will remain normally
270 oriented.
271
272 +config FB_CON_DECOR
273 + bool "Support for the Framebuffer Console Decorations"
274 + depends on FRAMEBUFFER_CONSOLE=y && !FB_TILEBLITTING
275 + default n
276 + ---help---
277 + This option enables support for framebuffer console decorations which
278 + makes it possible to display images in the background of the system
279 + consoles. Note that userspace utilities are necessary in order to take
280 + advantage of these features. Refer to Documentation/fb/fbcondecor.txt
281 + for more information.
282 +
283 + If unsure, say N.
284 +
285 config STI_CONSOLE
286 bool "STI text console"
287 depends on PARISC
288 diff --git a/drivers/video/console/Makefile b/drivers/video/console/Makefile
289 index a862e91..86bfcff 100644
290 --- a/drivers/video/console/Makefile
291 +++ b/drivers/video/console/Makefile
292 @@ -34,6 +34,7 @@ obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += fbcon_rotate.o fbcon_cw.o fbcon_ud.o \
293 fbcon_ccw.o
294 endif
295
296 +obj-$(CONFIG_FB_CON_DECOR) += fbcondecor.o cfbcondecor.o
297 obj-$(CONFIG_FB_STI) += sticore.o font.o
298
299 ifeq ($(CONFIG_USB_SISUSBVGA_CON),y)
300 diff --git a/drivers/video/console/bitblit.c b/drivers/video/console/bitblit.c
301 index af88651..4cd893d 100644
302 --- a/drivers/video/console/bitblit.c
303 +++ b/drivers/video/console/bitblit.c
304 @@ -18,6 +18,7 @@
305 #include <linux/console.h>
306 #include <asm/types.h>
307 #include "fbcon.h"
308 +#include "fbcondecor.h"
309
310 /*
311 * Accelerated handlers.
312 @@ -55,6 +56,13 @@ static void bit_bmove(struct vc_data *vc, struct fb_info *info, int sy,
313 area.height = height * vc->vc_font.height;
314 area.width = width * vc->vc_font.width;
315
316 + if (fbcon_decor_active(info, vc)) {
317 + area.sx += vc->vc_decor.tx;
318 + area.sy += vc->vc_decor.ty;
319 + area.dx += vc->vc_decor.tx;
320 + area.dy += vc->vc_decor.ty;
321 + }
322 +
323 info->fbops->fb_copyarea(info, &area);
324 }
325
326 @@ -380,11 +388,15 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode,
327 cursor.image.depth = 1;
328 cursor.rop = ROP_XOR;
329
330 - if (info->fbops->fb_cursor)
331 - err = info->fbops->fb_cursor(info, &cursor);
332 + if (fbcon_decor_active(info, vc)) {
333 + fbcon_decor_cursor(info, &cursor);
334 + } else {
335 + if (info->fbops->fb_cursor)
336 + err = info->fbops->fb_cursor(info, &cursor);
337
338 - if (err)
339 - soft_cursor(info, &cursor);
340 + if (err)
341 + soft_cursor(info, &cursor);
342 + }
343
344 ops->cursor_reset = 0;
345 }
346 diff --git a/drivers/video/console/cfbcondecor.c b/drivers/video/console/cfbcondecor.c
347 new file mode 100644
348 index 0000000..18a5452
349 --- /dev/null
350 +++ b/drivers/video/console/cfbcondecor.c
351 @@ -0,0 +1,472 @@
352 +/*
353 + * linux/drivers/video/cfbcon_decor.c -- Framebuffer decor render functions
354 + *
355 + * Copyright (C) 2004 Michal Januszewski <spock@gentoo.org>
356 + *
357 + * Code based upon "Bootdecor" (C) 2001-2003
358 + * Volker Poplawski <volker@poplawski.de>,
359 + * Stefan Reinauer <stepan@suse.de>,
360 + * Steffen Winterfeldt <snwint@suse.de>,
361 + * Michael Schroeder <mls@suse.de>,
362 + * Ken Wimer <wimer@suse.de>.
363 + *
364 + * This file is subject to the terms and conditions of the GNU General Public
365 + * License. See the file COPYING in the main directory of this archive for
366 + * more details.
367 + */
368 +#include <linux/module.h>
369 +#include <linux/types.h>
370 +#include <linux/fb.h>
371 +#include <linux/selection.h>
372 +#include <linux/slab.h>
373 +#include <linux/vt_kern.h>
374 +#include <asm/irq.h>
375 +#include <asm/system.h>
376 +
377 +#include "fbcon.h"
378 +#include "fbcondecor.h"
379 +
380 +#define parse_pixel(shift,bpp,type) \
381 + do { \
382 + if (d & (0x80 >> (shift))) \
383 + dd2[(shift)] = fgx; \
384 + else \
385 + dd2[(shift)] = transparent ? *(type *)decor_src : bgx; \
386 + decor_src += (bpp); \
387 + } while (0) \
388 +
389 +extern int get_color(struct vc_data *vc, struct fb_info *info,
390 + u16 c, int is_fg);
391 +
392 +void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc)
393 +{
394 + int i, j, k;
395 + int minlen = min(min(info->var.red.length, info->var.green.length),
396 + info->var.blue.length);
397 + u32 col;
398 +
399 + for (j = i = 0; i < 16; i++) {
400 + k = color_table[i];
401 +
402 + col = ((vc->vc_palette[j++] >> (8-minlen))
403 + << info->var.red.offset);
404 + col |= ((vc->vc_palette[j++] >> (8-minlen))
405 + << info->var.green.offset);
406 + col |= ((vc->vc_palette[j++] >> (8-minlen))
407 + << info->var.blue.offset);
408 + ((u32 *)info->pseudo_palette)[k] = col;
409 + }
410 +}
411 +
412 +void fbcon_decor_renderc(struct fb_info *info, int ypos, int xpos, int height,
413 + int width, u8* src, u32 fgx, u32 bgx, u8 transparent)
414 +{
415 + unsigned int x, y;
416 + u32 dd;
417 + int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
418 + unsigned int d = ypos * info->fix.line_length + xpos * bytespp;
419 + unsigned int ds = (ypos * info->var.xres + xpos) * bytespp;
420 + u16 dd2[4];
421 +
422 + u8* decor_src = (u8 *)(info->bgdecor.data + ds);
423 + u8* dst = (u8 *)(info->screen_base + d);
424 +
425 + if ((ypos + height) > info->var.yres || (xpos + width) > info->var.xres)
426 + return;
427 +
428 + for (y = 0; y < height; y++) {
429 + switch (info->var.bits_per_pixel) {
430 +
431 + case 32:
432 + for (x = 0; x < width; x++) {
433 +
434 + if ((x & 7) == 0)
435 + d = *src++;
436 + if (d & 0x80)
437 + dd = fgx;
438 + else
439 + dd = transparent ?
440 + *(u32 *)decor_src : bgx;
441 +
442 + d <<= 1;
443 + decor_src += 4;
444 + fb_writel(dd, dst);
445 + dst += 4;
446 + }
447 + break;
448 + case 24:
449 + for (x = 0; x < width; x++) {
450 +
451 + if ((x & 7) == 0)
452 + d = *src++;
453 + if (d & 0x80)
454 + dd = fgx;
455 + else
456 + dd = transparent ?
457 + (*(u32 *)decor_src & 0xffffff) : bgx;
458 +
459 + d <<= 1;
460 + decor_src += 3;
461 +#ifdef __LITTLE_ENDIAN
462 + fb_writew(dd & 0xffff, dst);
463 + dst += 2;
464 + fb_writeb((dd >> 16), dst);
465 +#else
466 + fb_writew(dd >> 8, dst);
467 + dst += 2;
468 + fb_writeb(dd & 0xff, dst);
469 +#endif
470 + dst++;
471 + }
472 + break;
473 + case 16:
474 + for (x = 0; x < width; x += 2) {
475 + if ((x & 7) == 0)
476 + d = *src++;
477 +
478 + parse_pixel(0, 2, u16);
479 + parse_pixel(1, 2, u16);
480 +#ifdef __LITTLE_ENDIAN
481 + dd = dd2[0] | (dd2[1] << 16);
482 +#else
483 + dd = dd2[1] | (dd2[0] << 16);
484 +#endif
485 + d <<= 2;
486 + fb_writel(dd, dst);
487 + dst += 4;
488 + }
489 + break;
490 +
491 + case 8:
492 + for (x = 0; x < width; x += 4) {
493 + if ((x & 7) == 0)
494 + d = *src++;
495 +
496 + parse_pixel(0, 1, u8);
497 + parse_pixel(1, 1, u8);
498 + parse_pixel(2, 1, u8);
499 + parse_pixel(3, 1, u8);
500 +
501 +#ifdef __LITTLE_ENDIAN
502 + dd = dd2[0] | (dd2[1] << 8) | (dd2[2] << 16) | (dd2[3] << 24);
503 +#else
504 + dd = dd2[3] | (dd2[2] << 8) | (dd2[1] << 16) | (dd2[0] << 24);
505 +#endif
506 + d <<= 4;
507 + fb_writel(dd, dst);
508 + dst += 4;
509 + }
510 + }
511 +
512 + dst += info->fix.line_length - width * bytespp;
513 + decor_src += (info->var.xres - width) * bytespp;
514 + }
515 +}
516 +
517 +#define cc2cx(a) \
518 + ((info->fix.visual == FB_VISUAL_TRUECOLOR || \
519 + info->fix.visual == FB_VISUAL_DIRECTCOLOR) ? \
520 + ((u32*)info->pseudo_palette)[a] : a)
521 +
522 +void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info,
523 + const unsigned short *s, int count, int yy, int xx)
524 +{
525 + unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
526 + struct fbcon_ops *ops = info->fbcon_par;
527 + int fg_color, bg_color, transparent;
528 + u8 *src;
529 + u32 bgx, fgx;
530 + u16 c = scr_readw(s);
531 +
532 + fg_color = get_color(vc, info, c, 1);
533 + bg_color = get_color(vc, info, c, 0);
534 +
535 + /* Don't paint the background image if console is blanked */
536 + transparent = ops->blank_state ? 0 :
537 + (vc->vc_decor.bg_color == bg_color);
538 +
539 + xx = xx * vc->vc_font.width + vc->vc_decor.tx;
540 + yy = yy * vc->vc_font.height + vc->vc_decor.ty;
541 +
542 + fgx = cc2cx(fg_color);
543 + bgx = cc2cx(bg_color);
544 +
545 + while (count--) {
546 + c = scr_readw(s++);
547 + src = vc->vc_font.data + (c & charmask) * vc->vc_font.height *
548 + ((vc->vc_font.width + 7) >> 3);
549 +
550 + fbcon_decor_renderc(info, yy, xx, vc->vc_font.height,
551 + vc->vc_font.width, src, fgx, bgx, transparent);
552 + xx += vc->vc_font.width;
553 + }
554 +}
555 +
556 +void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor)
557 +{
558 + int i;
559 + unsigned int dsize, s_pitch;
560 + struct fbcon_ops *ops = info->fbcon_par;
561 + struct vc_data* vc;
562 + u8 *src;
563 +
564 + /* we really don't need any cursors while the console is blanked */
565 + if (info->state != FBINFO_STATE_RUNNING || ops->blank_state)
566 + return;
567 +
568 + vc = vc_cons[ops->currcon].d;
569 +
570 + src = kmalloc(64 + sizeof(struct fb_image), GFP_ATOMIC);
571 + if (!src)
572 + return;
573 +
574 + s_pitch = (cursor->image.width + 7) >> 3;
575 + dsize = s_pitch * cursor->image.height;
576 + if (cursor->enable) {
577 + switch (cursor->rop) {
578 + case ROP_XOR:
579 + for (i = 0; i < dsize; i++)
580 + src[i] = cursor->image.data[i] ^ cursor->mask[i];
581 + break;
582 + case ROP_COPY:
583 + default:
584 + for (i = 0; i < dsize; i++)
585 + src[i] = cursor->image.data[i] & cursor->mask[i];
586 + break;
587 + }
588 + } else
589 + memcpy(src, cursor->image.data, dsize);
590 +
591 + fbcon_decor_renderc(info,
592 + cursor->image.dy + vc->vc_decor.ty,
593 + cursor->image.dx + vc->vc_decor.tx,
594 + cursor->image.height,
595 + cursor->image.width,
596 + (u8*)src,
597 + cc2cx(cursor->image.fg_color),
598 + cc2cx(cursor->image.bg_color),
599 + cursor->image.bg_color == vc->vc_decor.bg_color);
600 +
601 + kfree(src);
602 +}
603 +
604 +static void decorset(u8 *dst, int height, int width, int dstbytes,
605 + u32 bgx, int bpp)
606 +{
607 + int i;
608 +
609 + if (bpp == 8)
610 + bgx |= bgx << 8;
611 + if (bpp == 16 || bpp == 8)
612 + bgx |= bgx << 16;
613 +
614 + while (height-- > 0) {
615 + u8 *p = dst;
616 +
617 + switch (bpp) {
618 +
619 + case 32:
620 + for (i=0; i < width; i++) {
621 + fb_writel(bgx, p); p += 4;
622 + }
623 + break;
624 + case 24:
625 + for (i=0; i < width; i++) {
626 +#ifdef __LITTLE_ENDIAN
627 + fb_writew((bgx & 0xffff),(u16*)p); p += 2;
628 + fb_writeb((bgx >> 16),p++);
629 +#else
630 + fb_writew((bgx >> 8),(u16*)p); p += 2;
631 + fb_writeb((bgx & 0xff),p++);
632 +#endif
633 + }
634 + case 16:
635 + for (i=0; i < width/4; i++) {
636 + fb_writel(bgx,p); p += 4;
637 + fb_writel(bgx,p); p += 4;
638 + }
639 + if (width & 2) {
640 + fb_writel(bgx,p); p += 4;
641 + }
642 + if (width & 1)
643 + fb_writew(bgx,(u16*)p);
644 + break;
645 + case 8:
646 + for (i=0; i < width/4; i++) {
647 + fb_writel(bgx,p); p += 4;
648 + }
649 +
650 + if (width & 2) {
651 + fb_writew(bgx,p); p += 2;
652 + }
653 + if (width & 1)
654 + fb_writeb(bgx,(u8*)p);
655 + break;
656 +
657 + }
658 + dst += dstbytes;
659 + }
660 +}
661 +
662 +void fbcon_decor_copy(u8 *dst, u8 *src, int height, int width, int linebytes,
663 + int srclinebytes, int bpp)
664 +{
665 + int i;
666 +
667 + while (height-- > 0) {
668 + u32 *p = (u32 *)dst;
669 + u32 *q = (u32 *)src;
670 +
671 + switch (bpp) {
672 +
673 + case 32:
674 + for (i=0; i < width; i++)
675 + fb_writel(*q++, p++);
676 + break;
677 + case 24:
678 + for (i=0; i < (width*3/4); i++)
679 + fb_writel(*q++, p++);
680 + if ((width*3) % 4) {
681 + if (width & 2) {
682 + fb_writeb(*(u8*)q, (u8*)p);
683 + } else if (width & 1) {
684 + fb_writew(*(u16*)q, (u16*)p);
685 + fb_writeb(*(u8*)((u16*)q+1),(u8*)((u16*)p+2));
686 + }
687 + }
688 + break;
689 + case 16:
690 + for (i=0; i < width/4; i++) {
691 + fb_writel(*q++, p++);
692 + fb_writel(*q++, p++);
693 + }
694 + if (width & 2)
695 + fb_writel(*q++, p++);
696 + if (width & 1)
697 + fb_writew(*(u16*)q, (u16*)p);
698 + break;
699 + case 8:
700 + for (i=0; i < width/4; i++)
701 + fb_writel(*q++, p++);
702 +
703 + if (width & 2) {
704 + fb_writew(*(u16*)q, (u16*)p);
705 + q = (u32*) ((u16*)q + 1);
706 + p = (u32*) ((u16*)p + 1);
707 + }
708 + if (width & 1)
709 + fb_writeb(*(u8*)q, (u8*)p);
710 + break;
711 + }
712 +
713 + dst += linebytes;
714 + src += srclinebytes;
715 + }
716 +}
717 +
718 +static void decorfill(struct fb_info *info, int sy, int sx, int height,
719 + int width)
720 +{
721 + int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
722 + int d = sy * info->fix.line_length + sx * bytespp;
723 + int ds = (sy * info->var.xres + sx) * bytespp;
724 +
725 + fbcon_decor_copy((u8 *)(info->screen_base + d), (u8 *)(info->bgdecor.data + ds),
726 + height, width, info->fix.line_length, info->var.xres * bytespp,
727 + info->var.bits_per_pixel);
728 +}
729 +
730 +void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx,
731 + int height, int width)
732 +{
733 + int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
734 + struct fbcon_ops *ops = info->fbcon_par;
735 + u8 *dst;
736 + int transparent, bg_color = attr_bgcol_ec(bgshift, vc, info);
737 +
738 + transparent = (vc->vc_decor.bg_color == bg_color);
739 + sy = sy * vc->vc_font.height + vc->vc_decor.ty;
740 + sx = sx * vc->vc_font.width + vc->vc_decor.tx;
741 + height *= vc->vc_font.height;
742 + width *= vc->vc_font.width;
743 +
744 + /* Don't paint the background image if console is blanked */
745 + if (transparent && !ops->blank_state) {
746 + decorfill(info, sy, sx, height, width);
747 + } else {
748 + dst = (u8 *)(info->screen_base + sy * info->fix.line_length +
749 + sx * ((info->var.bits_per_pixel + 7) >> 3));
750 + decorset(dst, height, width, info->fix.line_length, cc2cx(bg_color),
751 + info->var.bits_per_pixel);
752 + }
753 +}
754 +
755 +void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info,
756 + int bottom_only)
757 +{
758 + unsigned int tw = vc->vc_cols*vc->vc_font.width;
759 + unsigned int th = vc->vc_rows*vc->vc_font.height;
760 +
761 + if (!bottom_only) {
762 + /* top margin */
763 + decorfill(info, 0, 0, vc->vc_decor.ty, info->var.xres);
764 + /* left margin */
765 + decorfill(info, vc->vc_decor.ty, 0, th, vc->vc_decor.tx);
766 + /* right margin */
767 + decorfill(info, vc->vc_decor.ty, vc->vc_decor.tx + tw, th,
768 + info->var.xres - vc->vc_decor.tx - tw);
769 + }
770 + decorfill(info, vc->vc_decor.ty + th, 0,
771 + info->var.yres - vc->vc_decor.ty - th, info->var.xres);
772 +}
773 +
774 +void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y,
775 + int sx, int dx, int width)
776 +{
777 + u16 *d = (u16 *) (vc->vc_origin + vc->vc_size_row * y + dx * 2);
778 + u16 *s = d + (dx - sx);
779 + u16 *start = d;
780 + u16 *ls = d;
781 + u16 *le = d + width;
782 + u16 c;
783 + int x = dx;
784 + u16 attr = 1;
785 +
786 + do {
787 + c = scr_readw(d);
788 + if (attr != (c & 0xff00)) {
789 + attr = c & 0xff00;
790 + if (d > start) {
791 + fbcon_decor_putcs(vc, info, start, d - start, y, x);
792 + x += d - start;
793 + start = d;
794 + }
795 + }
796 + if (s >= ls && s < le && c == scr_readw(s)) {
797 + if (d > start) {
798 + fbcon_decor_putcs(vc, info, start, d - start, y, x);
799 + x += d - start + 1;
800 + start = d + 1;
801 + } else {
802 + x++;
803 + start++;
804 + }
805 + }
806 + s++;
807 + d++;
808 + } while (d < le);
809 + if (d > start)
810 + fbcon_decor_putcs(vc, info, start, d - start, y, x);
811 +}
812 +
813 +void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank)
814 +{
815 + if (blank) {
816 + decorset((u8 *)info->screen_base, info->var.yres, info->var.xres,
817 + info->fix.line_length, 0, info->var.bits_per_pixel);
818 + } else {
819 + update_screen(vc);
820 + fbcon_decor_clear_margins(vc, info, 0);
821 + }
822 +}
823 +
824 diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
825 index b0a3fa0..7121e94 100644
826 --- a/drivers/video/console/fbcon.c
827 +++ b/drivers/video/console/fbcon.c
828 @@ -80,6 +80,7 @@
829 #include <asm/system.h>
830
831 #include "fbcon.h"
832 +#include "fbcondecor.h"
833
834 #ifdef FBCONDEBUG
835 # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
836 @@ -95,7 +96,7 @@ enum {
837
838 static struct display fb_display[MAX_NR_CONSOLES];
839
840 -static signed char con2fb_map[MAX_NR_CONSOLES];
841 +signed char con2fb_map[MAX_NR_CONSOLES];
842 static signed char con2fb_map_boot[MAX_NR_CONSOLES];
843
844 static int logo_lines;
845 @@ -286,7 +287,7 @@ static inline int fbcon_is_inactive(struct vc_data *vc, struct fb_info *info)
846 vc->vc_mode != KD_TEXT || ops->graphics);
847 }
848
849 -static inline int get_color(struct vc_data *vc, struct fb_info *info,
850 +inline int get_color(struct vc_data *vc, struct fb_info *info,
851 u16 c, int is_fg)
852 {
853 int depth = fb_get_color_depth(&info->var, &info->fix);
854 @@ -391,6 +392,7 @@ static void fb_flashcursor(struct work_struct *work)
855 CM_ERASE : CM_DRAW;
856 ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1),
857 get_color(vc, info, c, 0));
858 +
859 release_console_sem();
860 }
861
862 @@ -527,6 +529,9 @@ static int search_for_mapped_con(void)
863 static int fbcon_takeover(int show_logo)
864 {
865 int err, i;
866 +#ifdef CONFIG_FB_CON_DECOR
867 + struct fb_info *info;
868 +#endif
869
870 if (!num_registered_fb)
871 return -ENODEV;
872 @@ -547,6 +552,12 @@ static int fbcon_takeover(int show_logo)
873 info_idx = -1;
874 } else {
875 fbcon_has_console_bind = 1;
876 +#ifdef CONFIG_FB_CON_DECOR
877 + info = registered_fb[info_idx];
878 + unlock_fb_info(info);
879 + fbcon_decor_init();
880 + lock_fb_info(info);
881 +#endif
882 }
883
884 return err;
885 @@ -1001,6 +1012,12 @@ static const char *fbcon_startup(void)
886 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
887 cols /= vc->vc_font.width;
888 rows /= vc->vc_font.height;
889 +
890 + if (fbcon_decor_active(info, vc)) {
891 + cols = vc->vc_decor.twidth / vc->vc_font.width;
892 + rows = vc->vc_decor.theight / vc->vc_font.height;
893 + }
894 +
895 vc_resize(vc, cols, rows);
896
897 DPRINTK("mode: %s\n", info->fix.id);
898 @@ -1030,7 +1047,7 @@ static void fbcon_init(struct vc_data *vc, int init)
899 cap = info->flags;
900
901 if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
902 - (info->fix.type == FB_TYPE_TEXT))
903 + (info->fix.type == FB_TYPE_TEXT) || fbcon_decor_active(info, vc))
904 logo = 0;
905
906 if (var_to_display(p, &info->var, info))
907 @@ -1239,6 +1256,11 @@ static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
908 if (sy < vc->vc_top && vc->vc_top == logo_lines)
909 vc->vc_top = 0;
910
911 + if (fbcon_decor_active(info, vc)) {
912 + fbcon_decor_clear(vc, info, sy, sx, height, width);
913 + return;
914 + }
915 +
916 /* Split blits that cross physical y_wrap boundary */
917
918 y_break = p->vrows - p->yscroll;
919 @@ -1258,10 +1280,15 @@ static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
920 struct display *p = &fb_display[vc->vc_num];
921 struct fbcon_ops *ops = info->fbcon_par;
922
923 - if (!fbcon_is_inactive(vc, info))
924 - ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
925 - get_color(vc, info, scr_readw(s), 1),
926 - get_color(vc, info, scr_readw(s), 0));
927 + if (!fbcon_is_inactive(vc, info)) {
928 +
929 + if (fbcon_decor_active(info, vc))
930 + fbcon_decor_putcs(vc, info, s, count, ypos, xpos);
931 + else
932 + ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
933 + get_color(vc, info, scr_readw(s), 1),
934 + get_color(vc, info, scr_readw(s), 0));
935 + }
936 }
937
938 static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
939 @@ -1277,8 +1304,13 @@ static void fbcon_clear_margins(struct vc_data *vc, int bottom_only)
940 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
941 struct fbcon_ops *ops = info->fbcon_par;
942
943 - if (!fbcon_is_inactive(vc, info))
944 - ops->clear_margins(vc, info, bottom_only);
945 + if (!fbcon_is_inactive(vc, info)) {
946 + if (fbcon_decor_active(info, vc)) {
947 + fbcon_decor_clear_margins(vc, info, bottom_only);
948 + } else {
949 + ops->clear_margins(vc, info, bottom_only);
950 + }
951 + }
952 }
953
954 static void fbcon_cursor(struct vc_data *vc, int mode)
955 @@ -1798,7 +1830,7 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
956 count = vc->vc_rows;
957 if (softback_top)
958 fbcon_softback_note(vc, t, count);
959 - if (logo_shown >= 0)
960 + if (logo_shown >= 0 || fbcon_decor_active(info, vc))
961 goto redraw_up;
962 switch (p->scrollmode) {
963 case SCROLL_MOVE:
964 @@ -1891,6 +1923,8 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
965 count = vc->vc_rows;
966 if (logo_shown >= 0)
967 goto redraw_down;
968 + if (fbcon_decor_active(info, vc))
969 + goto redraw_down;
970 switch (p->scrollmode) {
971 case SCROLL_MOVE:
972 fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
973 @@ -2039,6 +2073,13 @@ static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int s
974 }
975 return;
976 }
977 +
978 + if (fbcon_decor_active(info, vc) && sy == dy && height == 1) {
979 + /* must use slower redraw bmove to keep background pic intact */
980 + fbcon_decor_bmove_redraw(vc, info, sy, sx, dx, width);
981 + return;
982 + }
983 +
984 ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
985 height, width);
986 }
987 @@ -2109,8 +2150,8 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width,
988 var.yres = virt_h * virt_fh;
989 x_diff = info->var.xres - var.xres;
990 y_diff = info->var.yres - var.yres;
991 - if (x_diff < 0 || x_diff > virt_fw ||
992 - y_diff < 0 || y_diff > virt_fh) {
993 + if ((x_diff < 0 || x_diff > virt_fw ||
994 + y_diff < 0 || y_diff > virt_fh) && !vc->vc_decor.state) {
995 const struct fb_videomode *mode;
996
997 DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
998 @@ -2146,6 +2187,21 @@ static int fbcon_switch(struct vc_data *vc)
999
1000 info = registered_fb[con2fb_map[vc->vc_num]];
1001 ops = info->fbcon_par;
1002 + prev_console = ops->currcon;
1003 + if (prev_console != -1)
1004 + old_info = registered_fb[con2fb_map[prev_console]];
1005 +
1006 +#ifdef CONFIG_FB_CON_DECOR
1007 + if (!fbcon_decor_active_vc(vc) && info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
1008 + struct vc_data *vc_curr = vc_cons[prev_console].d;
1009 + if (vc_curr && fbcon_decor_active_vc(vc_curr)) {
1010 + /* Clear the screen to avoid displaying funky colors during
1011 + * palette updates. */
1012 + memset((u8*)info->screen_base + info->fix.line_length * info->var.yoffset,
1013 + 0, info->var.yres * info->fix.line_length);
1014 + }
1015 + }
1016 +#endif
1017
1018 if (softback_top) {
1019 if (softback_lines)
1020 @@ -2164,9 +2220,6 @@ static int fbcon_switch(struct vc_data *vc)
1021 logo_shown = FBCON_LOGO_CANSHOW;
1022 }
1023
1024 - prev_console = ops->currcon;
1025 - if (prev_console != -1)
1026 - old_info = registered_fb[con2fb_map[prev_console]];
1027 /*
1028 * FIXME: If we have multiple fbdev's loaded, we need to
1029 * update all info->currcon. Perhaps, we can place this
1030 @@ -2210,6 +2263,18 @@ static int fbcon_switch(struct vc_data *vc)
1031 fbcon_del_cursor_timer(old_info);
1032 }
1033
1034 + if (fbcon_decor_active_vc(vc)) {
1035 + struct vc_data *vc_curr = vc_cons[prev_console].d;
1036 +
1037 + if (!vc_curr->vc_decor.theme ||
1038 + strcmp(vc->vc_decor.theme, vc_curr->vc_decor.theme) ||
1039 + (fbcon_decor_active_nores(info, vc_curr) &&
1040 + !fbcon_decor_active(info, vc_curr))) {
1041 + if (fbcon_decor_call_helper("modechange", vc->vc_num))
1042 + fbcon_decor_disable(vc, 0);
1043 + }
1044 + }
1045 +
1046 if (fbcon_is_inactive(vc, info) ||
1047 ops->blank_state != FB_BLANK_UNBLANK)
1048 fbcon_del_cursor_timer(info);
1049 @@ -2318,15 +2383,20 @@ static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)
1050 }
1051 }
1052
1053 - if (!fbcon_is_inactive(vc, info)) {
1054 + if (!fbcon_is_inactive(vc, info)) {
1055 if (ops->blank_state != blank) {
1056 ops->blank_state = blank;
1057 fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
1058 ops->cursor_flash = (!blank);
1059
1060 - if (!(info->flags & FBINFO_MISC_USEREVENT))
1061 - if (fb_blank(info, blank))
1062 - fbcon_generic_blank(vc, info, blank);
1063 + if (!(info->flags & FBINFO_MISC_USEREVENT)) {
1064 + if (fb_blank(info, blank)) {
1065 + if (fbcon_decor_active(info, vc))
1066 + fbcon_decor_blank(vc, info, blank);
1067 + else
1068 + fbcon_generic_blank(vc, info, blank);
1069 + }
1070 + }
1071 }
1072
1073 if (!blank)
1074 @@ -2477,13 +2547,22 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
1075 }
1076
1077 if (resize) {
1078 + /* reset wrap/pan */
1079 int cols, rows;
1080
1081 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
1082 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1083 +
1084 + if (fbcon_decor_active(info, vc)) {
1085 + info->var.xoffset = info->var.yoffset = p->yscroll = 0;
1086 + cols = vc->vc_decor.twidth;
1087 + rows = vc->vc_decor.theight;
1088 + }
1089 cols /= w;
1090 rows /= h;
1091 +
1092 vc_resize(vc, cols, rows);
1093 +
1094 if (CON_IS_VISIBLE(vc) && softback_buf)
1095 fbcon_update_softback(vc);
1096 } else if (CON_IS_VISIBLE(vc)
1097 @@ -2612,7 +2691,11 @@ static int fbcon_set_palette(struct vc_data *vc, unsigned char *table)
1098 int i, j, k, depth;
1099 u8 val;
1100
1101 - if (fbcon_is_inactive(vc, info))
1102 + if (fbcon_is_inactive(vc, info)
1103 +#ifdef CONFIG_FB_CON_DECOR
1104 + || vc->vc_num != fg_console
1105 +#endif
1106 + )
1107 return -EINVAL;
1108
1109 if (!CON_IS_VISIBLE(vc))
1110 @@ -2638,7 +2721,49 @@ static int fbcon_set_palette(struct vc_data *vc, unsigned char *table)
1111 } else
1112 fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap);
1113
1114 - return fb_set_cmap(&palette_cmap, info);
1115 + if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
1116 + info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
1117 +
1118 + u16 *red, *green, *blue;
1119 + int minlen = min(min(info->var.red.length, info->var.green.length),
1120 + info->var.blue.length);
1121 + int h;
1122 +
1123 + struct fb_cmap cmap = {
1124 + .start = 0,
1125 + .len = (1 << minlen),
1126 + .red = NULL,
1127 + .green = NULL,
1128 + .blue = NULL,
1129 + .transp = NULL
1130 + };
1131 +
1132 + red = kmalloc(256 * sizeof(u16) * 3, GFP_KERNEL);
1133 +
1134 + if (!red)
1135 + goto out;
1136 +
1137 + green = red + 256;
1138 + blue = green + 256;
1139 + cmap.red = red;
1140 + cmap.green = green;
1141 + cmap.blue = blue;
1142 +
1143 + for (i = 0; i < cmap.len; i++) {
1144 + red[i] = green[i] = blue[i] = (0xffff * i)/(cmap.len-1);
1145 + }
1146 +
1147 + h = fb_set_cmap(&cmap, info);
1148 + fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
1149 + kfree(red);
1150 +
1151 + return h;
1152 +
1153 + } else if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
1154 + info->var.bits_per_pixel == 8 && info->bgdecor.cmap.red != NULL)
1155 + fb_set_cmap(&info->bgdecor.cmap, info);
1156 +
1157 +out: return fb_set_cmap(&palette_cmap, info);
1158 }
1159
1160 static u16 *fbcon_screen_pos(struct vc_data *vc, int offset)
1161 @@ -2846,7 +2971,7 @@ static void fbcon_modechanged(struct fb_info *info)
1162 struct fbcon_ops *ops = info->fbcon_par;
1163 struct vc_data *vc;
1164 struct display *p;
1165 - int rows, cols;
1166 + int rows, cols, res;
1167
1168 if (!ops || ops->currcon < 0)
1169 return;
1170 @@ -2864,7 +2989,18 @@ static void fbcon_modechanged(struct fb_info *info)
1171 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1172 cols /= vc->vc_font.width;
1173 rows /= vc->vc_font.height;
1174 - vc_resize(vc, cols, rows);
1175 +
1176 + if (!fbcon_decor_active_nores(info, vc)) {
1177 + vc_resize(vc, cols, rows);
1178 + } else {
1179 + /* HACK: Do this properly at some point.. */
1180 + unlock_fb_info(info);
1181 + res = fbcon_decor_call_helper("modechange", vc->vc_num);
1182 + lock_fb_info(info);
1183 + if (res)
1184 + fbcon_decor_disable(vc, 0);
1185 + }
1186 +
1187 updatescrollmode(p, info, vc);
1188 scrollback_max = 0;
1189 scrollback_current = 0;
1190 @@ -3516,6 +3652,7 @@ static void fbcon_exit(void)
1191 }
1192 }
1193
1194 + fbcon_decor_exit();
1195 fbcon_has_exited = 1;
1196 }
1197
1198 diff --git a/drivers/video/console/fbcondecor.c b/drivers/video/console/fbcondecor.c
1199 new file mode 100644
1200 index 0000000..a0b4ae3
1201 --- /dev/null
1202 +++ b/drivers/video/console/fbcondecor.c
1203 @@ -0,0 +1,561 @@
1204 +/*
1205 + * linux/drivers/video/console/fbcondecor.c -- Framebuffer console decorations
1206 + *
1207 + * Copyright (C) 2004-2009 Michal Januszewski <spock@gentoo.org>
1208 + *
1209 + * Code based upon "Bootsplash" (C) 2001-2003
1210 + * Volker Poplawski <volker@poplawski.de>,
1211 + * Stefan Reinauer <stepan@suse.de>,
1212 + * Steffen Winterfeldt <snwint@suse.de>,
1213 + * Michael Schroeder <mls@suse.de>,
1214 + * Ken Wimer <wimer@suse.de>.
1215 + *
1216 + * Compat ioctl support by Thorsten Klein <TK@Thorsten-Klein.de>.
1217 + *
1218 + * This file is subject to the terms and conditions of the GNU General Public
1219 + * License. See the file COPYING in the main directory of this archive for
1220 + * more details.
1221 + *
1222 + */
1223 +#include <linux/module.h>
1224 +#include <linux/kernel.h>
1225 +#include <linux/string.h>
1226 +#include <linux/types.h>
1227 +#include <linux/fb.h>
1228 +#include <linux/vt_kern.h>
1229 +#include <linux/vmalloc.h>
1230 +#include <linux/unistd.h>
1231 +#include <linux/syscalls.h>
1232 +#include <linux/init.h>
1233 +#include <linux/proc_fs.h>
1234 +#include <linux/workqueue.h>
1235 +#include <linux/kmod.h>
1236 +#include <linux/miscdevice.h>
1237 +#include <linux/device.h>
1238 +#include <linux/fs.h>
1239 +#include <linux/compat.h>
1240 +
1241 +#include <asm/uaccess.h>
1242 +#include <asm/irq.h>
1243 +#include <asm/system.h>
1244 +
1245 +#include "fbcon.h"
1246 +#include "fbcondecor.h"
1247 +
1248 +extern signed char con2fb_map[];
1249 +static int fbcon_decor_enable(struct vc_data *vc);
1250 +char fbcon_decor_path[KMOD_PATH_LEN] = "/sbin/fbcondecor_helper";
1251 +static int initialized = 0;
1252 +
1253 +int fbcon_decor_call_helper(char* cmd, unsigned short vc)
1254 +{
1255 + char *envp[] = {
1256 + "HOME=/",
1257 + "PATH=/sbin:/bin",
1258 + NULL
1259 + };
1260 +
1261 + char tfb[5];
1262 + char tcons[5];
1263 + unsigned char fb = (int) con2fb_map[vc];
1264 +
1265 + char *argv[] = {
1266 + fbcon_decor_path,
1267 + "2",
1268 + cmd,
1269 + tcons,
1270 + tfb,
1271 + vc_cons[vc].d->vc_decor.theme,
1272 + NULL
1273 + };
1274 +
1275 + snprintf(tfb,5,"%d",fb);
1276 + snprintf(tcons,5,"%d",vc);
1277 +
1278 + return call_usermodehelper(fbcon_decor_path, argv, envp, 1);
1279 +}
1280 +
1281 +/* Disables fbcondecor on a virtual console; called with console sem held. */
1282 +int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw)
1283 +{
1284 + struct fb_info* info;
1285 +
1286 + if (!vc->vc_decor.state)
1287 + return -EINVAL;
1288 +
1289 + info = registered_fb[(int) con2fb_map[vc->vc_num]];
1290 +
1291 + if (info == NULL)
1292 + return -EINVAL;
1293 +
1294 + vc->vc_decor.state = 0;
1295 + vc_resize(vc, info->var.xres / vc->vc_font.width,
1296 + info->var.yres / vc->vc_font.height);
1297 +
1298 + if (fg_console == vc->vc_num && redraw) {
1299 + redraw_screen(vc, 0);
1300 + update_region(vc, vc->vc_origin +
1301 + vc->vc_size_row * vc->vc_top,
1302 + vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1303 + }
1304 +
1305 + printk(KERN_INFO "fbcondecor: switched decor state to 'off' on console %d\n",
1306 + vc->vc_num);
1307 +
1308 + return 0;
1309 +}
1310 +
1311 +/* Enables fbcondecor on a virtual console; called with console sem held. */
1312 +static int fbcon_decor_enable(struct vc_data *vc)
1313 +{
1314 + struct fb_info* info;
1315 +
1316 + info = registered_fb[(int) con2fb_map[vc->vc_num]];
1317 +
1318 + if (vc->vc_decor.twidth == 0 || vc->vc_decor.theight == 0 ||
1319 + info == NULL || vc->vc_decor.state || (!info->bgdecor.data &&
1320 + vc->vc_num == fg_console))
1321 + return -EINVAL;
1322 +
1323 + vc->vc_decor.state = 1;
1324 + vc_resize(vc, vc->vc_decor.twidth / vc->vc_font.width,
1325 + vc->vc_decor.theight / vc->vc_font.height);
1326 +
1327 + if (fg_console == vc->vc_num) {
1328 + redraw_screen(vc, 0);
1329 + update_region(vc, vc->vc_origin +
1330 + vc->vc_size_row * vc->vc_top,
1331 + vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1332 + fbcon_decor_clear_margins(vc, info, 0);
1333 + }
1334 +
1335 + printk(KERN_INFO "fbcondecor: switched decor state to 'on' on console %d\n",
1336 + vc->vc_num);
1337 +
1338 + return 0;
1339 +}
1340 +
1341 +static inline int fbcon_decor_ioctl_dosetstate(struct vc_data *vc, unsigned int state, unsigned char origin)
1342 +{
1343 + int ret;
1344 +
1345 + if (origin == FBCON_DECOR_IO_ORIG_USER)
1346 + acquire_console_sem();
1347 + if (!state)
1348 + ret = fbcon_decor_disable(vc, 1);
1349 + else
1350 + ret = fbcon_decor_enable(vc);
1351 + if (origin == FBCON_DECOR_IO_ORIG_USER)
1352 + release_console_sem();
1353 +
1354 + return ret;
1355 +}
1356 +
1357 +static inline void fbcon_decor_ioctl_dogetstate(struct vc_data *vc, unsigned int *state)
1358 +{
1359 + *state = vc->vc_decor.state;
1360 +}
1361 +
1362 +static int fbcon_decor_ioctl_dosetcfg(struct vc_data *vc, struct vc_decor *cfg, unsigned char origin)
1363 +{
1364 + struct fb_info *info;
1365 + int len;
1366 + char *tmp;
1367 +
1368 + info = registered_fb[(int) con2fb_map[vc->vc_num]];
1369 +
1370 + if (info == NULL || !cfg->twidth || !cfg->theight ||
1371 + cfg->tx + cfg->twidth > info->var.xres ||
1372 + cfg->ty + cfg->theight > info->var.yres)
1373 + return -EINVAL;
1374 +
1375 + len = strlen_user(cfg->theme);
1376 + if (!len || len > FBCON_DECOR_THEME_LEN)
1377 + return -EINVAL;
1378 + tmp = kmalloc(len, GFP_KERNEL);
1379 + if (!tmp)
1380 + return -ENOMEM;
1381 + if (copy_from_user(tmp, (void __user *)cfg->theme, len))
1382 + return -EFAULT;
1383 + cfg->theme = tmp;
1384 + cfg->state = 0;
1385 +
1386 + /* If this ioctl is a response to a request from kernel, the console sem
1387 + * is already held; we also don't need to disable decor because either the
1388 + * new config and background picture will be successfully loaded, and the
1389 + * decor will stay on, or in case of a failure it'll be turned off in fbcon. */
1390 + if (origin == FBCON_DECOR_IO_ORIG_USER) {
1391 + acquire_console_sem();
1392 + if (vc->vc_decor.state)
1393 + fbcon_decor_disable(vc, 1);
1394 + }
1395 +
1396 + if (vc->vc_decor.theme)
1397 + kfree(vc->vc_decor.theme);
1398 +
1399 + vc->vc_decor = *cfg;
1400 +
1401 + if (origin == FBCON_DECOR_IO_ORIG_USER)
1402 + release_console_sem();
1403 +
1404 + printk(KERN_INFO "fbcondecor: console %d using theme '%s'\n",
1405 + vc->vc_num, vc->vc_decor.theme);
1406 + return 0;
1407 +}
1408 +
1409 +static int fbcon_decor_ioctl_dogetcfg(struct vc_data *vc, struct vc_decor *decor)
1410 +{
1411 + char __user *tmp;
1412 +
1413 + tmp = decor->theme;
1414 + *decor = vc->vc_decor;
1415 + decor->theme = tmp;
1416 +
1417 + if (vc->vc_decor.theme) {
1418 + if (copy_to_user(tmp, vc->vc_decor.theme, strlen(vc->vc_decor.theme) + 1))
1419 + return -EFAULT;
1420 + } else
1421 + if (put_user(0, tmp))
1422 + return -EFAULT;
1423 +
1424 + return 0;
1425 +}
1426 +
1427 +static int fbcon_decor_ioctl_dosetpic(struct vc_data *vc, struct fb_image *img, unsigned char origin)
1428 +{
1429 + struct fb_info *info;
1430 + int len;
1431 + u8 *tmp;
1432 +
1433 + if (vc->vc_num != fg_console)
1434 + return -EINVAL;
1435 +
1436 + info = registered_fb[(int) con2fb_map[vc->vc_num]];
1437 +
1438 + if (info == NULL)
1439 + return -EINVAL;
1440 +
1441 + if (img->width != info->var.xres || img->height != info->var.yres) {
1442 + printk(KERN_ERR "fbcondecor: picture dimensions mismatch\n");
1443 + printk(KERN_ERR "%dx%d vs %dx%d\n", img->width, img->height, info->var.xres, info->var.yres);
1444 + return -EINVAL;
1445 + }
1446 +
1447 + if (img->depth != info->var.bits_per_pixel) {
1448 + printk(KERN_ERR "fbcondecor: picture depth mismatch\n");
1449 + return -EINVAL;
1450 + }
1451 +
1452 + if (img->depth == 8) {
1453 + if (!img->cmap.len || !img->cmap.red || !img->cmap.green ||
1454 + !img->cmap.blue)
1455 + return -EINVAL;
1456 +
1457 + tmp = vmalloc(img->cmap.len * 3 * 2);
1458 + if (!tmp)
1459 + return -ENOMEM;
1460 +
1461 + if (copy_from_user(tmp,
1462 + (void __user*)img->cmap.red, (img->cmap.len << 1)) ||
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 +
1481 + /*
1482 + * Allocate an additional byte so that we never go outside of the
1483 + * buffer boundaries in the rendering functions in a 24 bpp mode.
1484 + */
1485 + tmp = vmalloc(len + 1);
1486 +
1487 + if (!tmp)
1488 + goto out;
1489 +
1490 + if (copy_from_user(tmp, (void __user*)img->data, len))
1491 + goto out;
1492 +
1493 + img->data = tmp;
1494 +
1495 + /* If this ioctl is a response to a request from kernel, the console sem
1496 + * is already held. */
1497 + if (origin == FBCON_DECOR_IO_ORIG_USER)
1498 + acquire_console_sem();
1499 +
1500 + if (info->bgdecor.data)
1501 + vfree((u8*)info->bgdecor.data);
1502 + if (info->bgdecor.cmap.red)
1503 + vfree(info->bgdecor.cmap.red);
1504 +
1505 + info->bgdecor = *img;
1506 +
1507 + if (fbcon_decor_active_vc(vc) && fg_console == vc->vc_num) {
1508 + redraw_screen(vc, 0);
1509 + update_region(vc, vc->vc_origin +
1510 + vc->vc_size_row * vc->vc_top,
1511 + vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1512 + fbcon_decor_clear_margins(vc, info, 0);
1513 + }
1514 +
1515 + if (origin == FBCON_DECOR_IO_ORIG_USER)
1516 + release_console_sem();
1517 +
1518 + return 0;
1519 +
1520 +out: if (img->cmap.red)
1521 + vfree(img->cmap.red);
1522 +
1523 + if (tmp)
1524 + vfree(tmp);
1525 + return -ENOMEM;
1526 +}
1527 +
1528 +static int fbcon_decor_ioctl(struct inode * inode, struct file *filp, u_int cmd,
1529 + u_long arg)
1530 +{
1531 + struct fbcon_decor_iowrapper __user *wrapper = (void __user*) arg;
1532 + struct vc_data *vc = NULL;
1533 + unsigned short vc_num = 0;
1534 + unsigned char origin = 0;
1535 + void __user *data = NULL;
1536 +
1537 + if (!access_ok(VERIFY_READ, wrapper,
1538 + sizeof(struct fbcon_decor_iowrapper)))
1539 + return -EFAULT;
1540 +
1541 + __get_user(vc_num, &wrapper->vc);
1542 + __get_user(origin, &wrapper->origin);
1543 + __get_user(data, &wrapper->data);
1544 +
1545 + if (!vc_cons_allocated(vc_num))
1546 + return -EINVAL;
1547 +
1548 + vc = vc_cons[vc_num].d;
1549 +
1550 + switch (cmd) {
1551 + case FBIOCONDECOR_SETPIC:
1552 + {
1553 + struct fb_image img;
1554 + if (copy_from_user(&img, (struct fb_image __user *)data, sizeof(struct fb_image)))
1555 + return -EFAULT;
1556 +
1557 + return fbcon_decor_ioctl_dosetpic(vc, &img, origin);
1558 + }
1559 + case FBIOCONDECOR_SETCFG:
1560 + {
1561 + struct vc_decor cfg;
1562 + if (copy_from_user(&cfg, (struct vc_decor __user *)data, sizeof(struct vc_decor)))
1563 + return -EFAULT;
1564 +
1565 + return fbcon_decor_ioctl_dosetcfg(vc, &cfg, origin);
1566 + }
1567 + case FBIOCONDECOR_GETCFG:
1568 + {
1569 + int rval;
1570 + struct vc_decor cfg;
1571 +
1572 + if (copy_from_user(&cfg, (struct vc_decor __user *)data, sizeof(struct vc_decor)))
1573 + return -EFAULT;
1574 +
1575 + rval = fbcon_decor_ioctl_dogetcfg(vc, &cfg);
1576 +
1577 + if (copy_to_user(data, &cfg, sizeof(struct vc_decor)))
1578 + return -EFAULT;
1579 + return rval;
1580 + }
1581 + case FBIOCONDECOR_SETSTATE:
1582 + {
1583 + unsigned int state = 0;
1584 + if (get_user(state, (unsigned int __user *)data))
1585 + return -EFAULT;
1586 + return fbcon_decor_ioctl_dosetstate(vc, state, origin);
1587 + }
1588 + case FBIOCONDECOR_GETSTATE:
1589 + {
1590 + unsigned int state = 0;
1591 + fbcon_decor_ioctl_dogetstate(vc, &state);
1592 + return put_user(state, (unsigned int __user *)data);
1593 + }
1594 +
1595 + default:
1596 + return -ENOIOCTLCMD;
1597 + }
1598 +}
1599 +
1600 +#ifdef CONFIG_COMPAT
1601 +
1602 +static long fbcon_decor_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) {
1603 +
1604 + struct fbcon_decor_iowrapper32 __user *wrapper = (void __user *)arg;
1605 + struct vc_data *vc = NULL;
1606 + unsigned short vc_num = 0;
1607 + unsigned char origin = 0;
1608 + compat_uptr_t data_compat = 0;
1609 + void __user *data = NULL;
1610 +
1611 + if (!access_ok(VERIFY_READ, wrapper,
1612 + sizeof(struct fbcon_decor_iowrapper32)))
1613 + return -EFAULT;
1614 +
1615 + __get_user(vc_num, &wrapper->vc);
1616 + __get_user(origin, &wrapper->origin);
1617 + __get_user(data_compat, &wrapper->data);
1618 + data = compat_ptr(data_compat);
1619 +
1620 + if (!vc_cons_allocated(vc_num))
1621 + return -EINVAL;
1622 +
1623 + vc = vc_cons[vc_num].d;
1624 +
1625 + switch (cmd) {
1626 + case FBIOCONDECOR_SETPIC32:
1627 + {
1628 + struct fb_image32 img_compat;
1629 + struct fb_image img;
1630 +
1631 + if (copy_from_user(&img_compat, (struct fb_image32 __user *)data, sizeof(struct fb_image32)))
1632 + return -EFAULT;
1633 +
1634 + fb_image_from_compat(img, img_compat);
1635 +
1636 + return fbcon_decor_ioctl_dosetpic(vc, &img, origin);
1637 + }
1638 +
1639 + case FBIOCONDECOR_SETCFG32:
1640 + {
1641 + struct vc_decor32 cfg_compat;
1642 + struct vc_decor cfg;
1643 +
1644 + if (copy_from_user(&cfg_compat, (struct vc_decor32 __user *)data, sizeof(struct vc_decor32)))
1645 + return -EFAULT;
1646 +
1647 + vc_decor_from_compat(cfg, cfg_compat);
1648 +
1649 + return fbcon_decor_ioctl_dosetcfg(vc, &cfg, origin);
1650 + }
1651 +
1652 + case FBIOCONDECOR_GETCFG32:
1653 + {
1654 + int rval;
1655 + struct vc_decor32 cfg_compat;
1656 + struct vc_decor cfg;
1657 +
1658 + if (copy_from_user(&cfg_compat, (struct vc_decor32 __user *)data, sizeof(struct vc_decor32)))
1659 + return -EFAULT;
1660 + cfg.theme = compat_ptr(cfg_compat.theme);
1661 +
1662 + rval = fbcon_decor_ioctl_dogetcfg(vc, &cfg);
1663 +
1664 + vc_decor_to_compat(cfg_compat, cfg);
1665 +
1666 + if (copy_to_user((struct vc_decor32 __user *)data, &cfg_compat, sizeof(struct vc_decor32)))
1667 + return -EFAULT;
1668 + return rval;
1669 + }
1670 +
1671 + case FBIOCONDECOR_SETSTATE32:
1672 + {
1673 + compat_uint_t state_compat = 0;
1674 + unsigned int state = 0;
1675 +
1676 + if (get_user(state_compat, (compat_uint_t __user *)data))
1677 + return -EFAULT;
1678 +
1679 + state = (unsigned int)state_compat;
1680 +
1681 + return fbcon_decor_ioctl_dosetstate(vc, state, origin);
1682 + }
1683 +
1684 + case FBIOCONDECOR_GETSTATE32:
1685 + {
1686 + compat_uint_t state_compat = 0;
1687 + unsigned int state = 0;
1688 +
1689 + fbcon_decor_ioctl_dogetstate(vc, &state);
1690 + state_compat = (compat_uint_t)state;
1691 +
1692 + return put_user(state_compat, (compat_uint_t __user *)data);
1693 + }
1694 +
1695 + default:
1696 + return -ENOIOCTLCMD;
1697 + }
1698 +}
1699 +#else
1700 + #define fbcon_decor_compat_ioctl NULL
1701 +#endif
1702 +
1703 +static struct file_operations fbcon_decor_ops = {
1704 + .owner = THIS_MODULE,
1705 + .ioctl = fbcon_decor_ioctl,
1706 + .compat_ioctl = fbcon_decor_compat_ioctl
1707 +};
1708 +
1709 +static struct miscdevice fbcon_decor_dev = {
1710 + .minor = MISC_DYNAMIC_MINOR,
1711 + .name = "fbcondecor",
1712 + .fops = &fbcon_decor_ops
1713 +};
1714 +
1715 +void fbcon_decor_reset(void)
1716 +{
1717 + struct fb_info *info;
1718 + struct vc_data *vc;
1719 + int i;
1720 +
1721 + vc = vc_cons[0].d;
1722 + info = registered_fb[0];
1723 +
1724 + for (i = 0; i < num_registered_fb; i++) {
1725 + registered_fb[i]->bgdecor.data = NULL;
1726 + registered_fb[i]->bgdecor.cmap.red = NULL;
1727 + }
1728 +
1729 + for (i = 0; i < MAX_NR_CONSOLES && vc_cons[i].d; i++) {
1730 + vc_cons[i].d->vc_decor.state = vc_cons[i].d->vc_decor.twidth =
1731 + vc_cons[i].d->vc_decor.theight = 0;
1732 + vc_cons[i].d->vc_decor.theme = NULL;
1733 + }
1734 +
1735 + return;
1736 +}
1737 +
1738 +int fbcon_decor_init(void)
1739 +{
1740 + int i;
1741 +
1742 + fbcon_decor_reset();
1743 +
1744 + if (initialized)
1745 + return 0;
1746 +
1747 + i = misc_register(&fbcon_decor_dev);
1748 + if (i) {
1749 + printk(KERN_ERR "fbcondecor: failed to register device\n");
1750 + return i;
1751 + }
1752 +
1753 + fbcon_decor_call_helper("init", 0);
1754 + initialized = 1;
1755 + return 0;
1756 +}
1757 +
1758 +int fbcon_decor_exit(void)
1759 +{
1760 + fbcon_decor_reset();
1761 + return 0;
1762 +}
1763 +
1764 +EXPORT_SYMBOL(fbcon_decor_path);
1765 diff --git a/drivers/video/console/fbcondecor.h b/drivers/video/console/fbcondecor.h
1766 new file mode 100644
1767 index 0000000..1d852dd
1768 --- /dev/null
1769 +++ b/drivers/video/console/fbcondecor.h
1770 @@ -0,0 +1,78 @@
1771 +/*
1772 + * linux/drivers/video/console/fbcondecor.h -- Framebuffer Console Decoration headers
1773 + *
1774 + * Copyright (C) 2004 Michal Januszewski <spock@gentoo.org>
1775 + *
1776 + */
1777 +
1778 +#ifndef __FBCON_DECOR_H
1779 +#define __FBCON_DECOR_H
1780 +
1781 +#ifndef _LINUX_FB_H
1782 +#include <linux/fb.h>
1783 +#endif
1784 +
1785 +/* This is needed for vc_cons in fbcmap.c */
1786 +#include <linux/vt_kern.h>
1787 +
1788 +struct fb_cursor;
1789 +struct fb_info;
1790 +struct vc_data;
1791 +
1792 +#ifdef CONFIG_FB_CON_DECOR
1793 +/* fbcondecor.c */
1794 +int fbcon_decor_init(void);
1795 +int fbcon_decor_exit(void);
1796 +int fbcon_decor_call_helper(char* cmd, unsigned short cons);
1797 +int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw);
1798 +
1799 +/* cfbcondecor.c */
1800 +void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx);
1801 +void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor);
1802 +void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width);
1803 +void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only);
1804 +void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank);
1805 +void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width);
1806 +void fbcon_decor_copy(u8 *dst, u8 *src, int height, int width, int linebytes, int srclinesbytes, int bpp);
1807 +void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc);
1808 +
1809 +/* vt.c */
1810 +void acquire_console_sem(void);
1811 +void release_console_sem(void);
1812 +void do_unblank_screen(int entering_gfx);
1813 +
1814 +/* struct vc_data *y */
1815 +#define fbcon_decor_active_vc(y) (y->vc_decor.state && y->vc_decor.theme)
1816 +
1817 +/* struct fb_info *x, struct vc_data *y */
1818 +#define fbcon_decor_active_nores(x,y) (x->bgdecor.data && fbcon_decor_active_vc(y))
1819 +
1820 +/* struct fb_info *x, struct vc_data *y */
1821 +#define fbcon_decor_active(x,y) (fbcon_decor_active_nores(x,y) && \
1822 + x->bgdecor.width == x->var.xres && \
1823 + x->bgdecor.height == x->var.yres && \
1824 + x->bgdecor.depth == x->var.bits_per_pixel)
1825 +
1826 +
1827 +#else /* CONFIG_FB_CON_DECOR */
1828 +
1829 +static inline void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx) {}
1830 +static inline void fbcon_decor_putc(struct vc_data *vc, struct fb_info *info, int c, int ypos, int xpos) {}
1831 +static inline void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor) {}
1832 +static inline void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) {}
1833 +static inline void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only) {}
1834 +static inline void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank) {}
1835 +static inline void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width) {}
1836 +static inline void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc) {}
1837 +static inline int fbcon_decor_call_helper(char* cmd, unsigned short cons) { return 0; }
1838 +static inline int fbcon_decor_init(void) { return 0; }
1839 +static inline int fbcon_decor_exit(void) { return 0; }
1840 +static inline int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw) { return 0; }
1841 +
1842 +#define fbcon_decor_active_vc(y) (0)
1843 +#define fbcon_decor_active_nores(x,y) (0)
1844 +#define fbcon_decor_active(x,y) (0)
1845 +
1846 +#endif /* CONFIG_FB_CON_DECOR */
1847 +
1848 +#endif /* __FBCON_DECOR_H */
1849 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
1850 index f53b9f1..467f921 100644
1851 --- a/drivers/video/fbcmap.c
1852 +++ b/drivers/video/fbcmap.c
1853 @@ -17,6 +17,8 @@
1854 #include <linux/slab.h>
1855 #include <linux/uaccess.h>
1856
1857 +#include "console/fbcondecor.h"
1858 +
1859 static u16 red2[] __read_mostly = {
1860 0x0000, 0xaaaa
1861 };
1862 @@ -234,14 +236,17 @@ int fb_set_cmap(struct fb_cmap *cmap, struct fb_info *info)
1863 if (transp)
1864 htransp = *transp++;
1865 if (info->fbops->fb_setcolreg(start++,
1866 - hred, hgreen, hblue,
1867 + hred, hgreen, hblue,
1868 htransp, info))
1869 break;
1870 }
1871 }
1872 - if (rc == 0)
1873 + if (rc == 0) {
1874 fb_copy_cmap(cmap, &info->cmap);
1875 -
1876 + if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
1877 + info->fix.visual == FB_VISUAL_DIRECTCOLOR)
1878 + fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
1879 + }
1880 return rc;
1881 }
1882
1883 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
1884 index 731fce6..f0ecef4 100644
1885 --- a/drivers/video/fbmem.c
1886 +++ b/drivers/video/fbmem.c
1887 @@ -1184,15 +1184,6 @@ struct fb_fix_screeninfo32 {
1888 u16 reserved[3];
1889 };
1890
1891 -struct fb_cmap32 {
1892 - u32 start;
1893 - u32 len;
1894 - compat_caddr_t red;
1895 - compat_caddr_t green;
1896 - compat_caddr_t blue;
1897 - compat_caddr_t transp;
1898 -};
1899 -
1900 static int fb_getput_cmap(struct fb_info *info, unsigned int cmd,
1901 unsigned long arg)
1902 {
1903 diff --git a/include/linux/console_decor.h b/include/linux/console_decor.h
1904 new file mode 100644
1905 index 0000000..04b8d80
1906 --- /dev/null
1907 +++ b/include/linux/console_decor.h
1908 @@ -0,0 +1,46 @@
1909 +#ifndef _LINUX_CONSOLE_DECOR_H_
1910 +#define _LINUX_CONSOLE_DECOR_H_ 1
1911 +
1912 +/* A structure used by the framebuffer console decorations (drivers/video/console/fbcondecor.c) */
1913 +struct vc_decor {
1914 + __u8 bg_color; /* The color that is to be treated as transparent */
1915 + __u8 state; /* Current decor state: 0 = off, 1 = on */
1916 + __u16 tx, ty; /* Top left corner coordinates of the text field */
1917 + __u16 twidth, theight; /* Width and height of the text field */
1918 + char* theme;
1919 +};
1920 +
1921 +#ifdef __KERNEL__
1922 +#ifdef CONFIG_COMPAT
1923 +#include <linux/compat.h>
1924 +
1925 +struct vc_decor32 {
1926 + __u8 bg_color; /* The color that is to be treated as transparent */
1927 + __u8 state; /* Current decor state: 0 = off, 1 = on */
1928 + __u16 tx, ty; /* Top left corner coordinates of the text field */
1929 + __u16 twidth, theight; /* Width and height of the text field */
1930 + compat_uptr_t theme;
1931 +};
1932 +
1933 +#define vc_decor_from_compat(to, from) \
1934 + (to).bg_color = (from).bg_color; \
1935 + (to).state = (from).state; \
1936 + (to).tx = (from).tx; \
1937 + (to).ty = (from).ty; \
1938 + (to).twidth = (from).twidth; \
1939 + (to).theight = (from).theight; \
1940 + (to).theme = compat_ptr((from).theme)
1941 +
1942 +#define vc_decor_to_compat(to, from) \
1943 + (to).bg_color = (from).bg_color; \
1944 + (to).state = (from).state; \
1945 + (to).tx = (from).tx; \
1946 + (to).ty = (from).ty; \
1947 + (to).twidth = (from).twidth; \
1948 + (to).theight = (from).theight; \
1949 + (to).theme = ptr_to_compat((from).theme)
1950 +
1951 +#endif /* CONFIG_COMPAT */
1952 +#endif /* __KERNEL__ */
1953 +
1954 +#endif
1955 diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h
1956 index 38fe59d..8e4058b 100644
1957 --- a/include/linux/console_struct.h
1958 +++ b/include/linux/console_struct.h
1959 @@ -19,6 +19,7 @@
1960 struct vt_struct;
1961
1962 #define NPAR 16
1963 +#include <linux/console_decor.h>
1964
1965 struct vc_data {
1966 unsigned short vc_num; /* Console number */
1967 @@ -105,6 +106,8 @@ struct vc_data {
1968 struct vc_data **vc_display_fg; /* [!] Ptr to var holding fg console for this display */
1969 unsigned long vc_uni_pagedir;
1970 unsigned long *vc_uni_pagedir_loc; /* [!] Location of uni_pagedir variable for this console */
1971 +
1972 + struct vc_decor vc_decor;
1973 /* additional information is in vt_kern.h */
1974 };
1975
1976 diff --git a/include/linux/fb.h b/include/linux/fb.h
1977 index 8e5a9df..7883651 100644
1978 --- a/include/linux/fb.h
1979 +++ b/include/linux/fb.h
1980 @@ -8,6 +8,25 @@
1981
1982 #define FB_MAX 32 /* sufficient for now */
1983
1984 +struct fbcon_decor_iowrapper
1985 +{
1986 + unsigned short vc; /* Virtual console */
1987 + unsigned char origin; /* Point of origin of the request */
1988 + void *data;
1989 +};
1990 +
1991 +#ifdef __KERNEL__
1992 +#ifdef CONFIG_COMPAT
1993 +#include <linux/compat.h>
1994 +struct fbcon_decor_iowrapper32
1995 +{
1996 + unsigned short vc; /* Virtual console */
1997 + unsigned char origin; /* Point of origin of the request */
1998 + compat_uptr_t data;
1999 +};
2000 +#endif /* CONFIG_COMPAT */
2001 +#endif /* __KERNEL__ */
2002 +
2003 /* ioctls
2004 0x46 is 'F' */
2005 #define FBIOGET_VSCREENINFO 0x4600
2006 @@ -36,6 +55,24 @@
2007 #define FBIOPUT_MODEINFO 0x4617
2008 #define FBIOGET_DISPINFO 0x4618
2009 #define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
2010 +#define FBIOCONDECOR_SETCFG _IOWR('F', 0x19, struct fbcon_decor_iowrapper)
2011 +#define FBIOCONDECOR_GETCFG _IOR('F', 0x1A, struct fbcon_decor_iowrapper)
2012 +#define FBIOCONDECOR_SETSTATE _IOWR('F', 0x1B, struct fbcon_decor_iowrapper)
2013 +#define FBIOCONDECOR_GETSTATE _IOR('F', 0x1C, struct fbcon_decor_iowrapper)
2014 +#define FBIOCONDECOR_SETPIC _IOWR('F', 0x1D, struct fbcon_decor_iowrapper)
2015 +#ifdef __KERNEL__
2016 +#ifdef CONFIG_COMPAT
2017 +#define FBIOCONDECOR_SETCFG32 _IOWR('F', 0x19, struct fbcon_decor_iowrapper32)
2018 +#define FBIOCONDECOR_GETCFG32 _IOR('F', 0x1A, struct fbcon_decor_iowrapper32)
2019 +#define FBIOCONDECOR_SETSTATE32 _IOWR('F', 0x1B, struct fbcon_decor_iowrapper32)
2020 +#define FBIOCONDECOR_GETSTATE32 _IOR('F', 0x1C, struct fbcon_decor_iowrapper32)
2021 +#define FBIOCONDECOR_SETPIC32 _IOWR('F', 0x1D, struct fbcon_decor_iowrapper32)
2022 +#endif /* CONFIG_COMPAT */
2023 +#endif /* __KERNEL__ */
2024 +
2025 +#define FBCON_DECOR_THEME_LEN 128 /* Maximum lenght of a theme name */
2026 +#define FBCON_DECOR_IO_ORIG_KERNEL 0 /* Kernel ioctl origin */
2027 +#define FBCON_DECOR_IO_ORIG_USER 1 /* User ioctl origin */
2028
2029 #define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */
2030 #define FB_TYPE_PLANES 1 /* Non interleaved planes */
2031 @@ -280,6 +317,28 @@ struct fb_cmap {
2032 __u16 *transp; /* transparency, can be NULL */
2033 };
2034
2035 +#ifdef __KERNEL__
2036 +#ifdef CONFIG_COMPAT
2037 +struct fb_cmap32 {
2038 + __u32 start;
2039 + __u32 len; /* Number of entries */
2040 + compat_uptr_t red; /* Red values */
2041 + compat_uptr_t green;
2042 + compat_uptr_t blue;
2043 + compat_uptr_t transp; /* transparency, can be NULL */
2044 +};
2045 +
2046 +#define fb_cmap_from_compat(to, from) \
2047 + (to).start = (from).start; \
2048 + (to).len = (from).len; \
2049 + (to).red = compat_ptr((from).red); \
2050 + (to).green = compat_ptr((from).green); \
2051 + (to).blue = compat_ptr((from).blue); \
2052 + (to).transp = compat_ptr((from).transp)
2053 +
2054 +#endif /* CONFIG_COMPAT */
2055 +#endif /* __KERNEL__ */
2056 +
2057 struct fb_con2fbmap {
2058 __u32 console;
2059 __u32 framebuffer;
2060 @@ -361,6 +420,34 @@ struct fb_image {
2061 struct fb_cmap cmap; /* color map info */
2062 };
2063
2064 +#ifdef __KERNEL__
2065 +#ifdef CONFIG_COMPAT
2066 +struct fb_image32 {
2067 + __u32 dx; /* Where to place image */
2068 + __u32 dy;
2069 + __u32 width; /* Size of image */
2070 + __u32 height;
2071 + __u32 fg_color; /* Only used when a mono bitmap */
2072 + __u32 bg_color;
2073 + __u8 depth; /* Depth of the image */
2074 + const compat_uptr_t data; /* Pointer to image data */
2075 + struct fb_cmap32 cmap; /* color map info */
2076 +};
2077 +
2078 +#define fb_image_from_compat(to, from) \
2079 + (to).dx = (from).dx; \
2080 + (to).dy = (from).dy; \
2081 + (to).width = (from).width; \
2082 + (to).height = (from).height; \
2083 + (to).fg_color = (from).fg_color; \
2084 + (to).bg_color = (from).bg_color; \
2085 + (to).depth = (from).depth; \
2086 + (to).data = compat_ptr((from).data); \
2087 + fb_cmap_from_compat((to).cmap, (from).cmap)
2088 +
2089 +#endif /* CONFIG_COMPAT */
2090 +#endif /* __KERNEL__ */
2091 +
2092 /*
2093 * hardware cursor control
2094 */
2095 @@ -856,6 +943,9 @@ struct fb_info {
2096 #define FBINFO_STATE_SUSPENDED 1
2097 u32 state; /* Hardware state i.e suspend */
2098 void *fbcon_par; /* fbcon use-only private area */
2099 +
2100 + struct fb_image bgdecor;
2101 +
2102 /* From here on everything is device dependent */
2103 void *par;
2104 /* we need the PCI or similiar aperture base/size not
2105 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
2106 index d24f761..a47ce49 100644
2107 --- a/kernel/sysctl.c
2108 +++ b/kernel/sysctl.c
2109 @@ -130,6 +130,10 @@ static int min_percpu_pagelist_fract = 8;
2110
2111 static int ngroups_max = NGROUPS_MAX;
2112
2113 +#ifdef CONFIG_FB_CON_DECOR
2114 +extern char fbcon_decor_path[];
2115 +#endif
2116 +
2117 #ifdef CONFIG_SPARC
2118 #include <asm/system.h>
2119 #endif
2120 @@ -245,6 +249,16 @@ static struct ctl_table root_table[] = {
2121 .mode = 0555,
2122 .child = dev_table,
2123 },
2124 +#ifdef CONFIG_FB_CON_DECOR
2125 + {
2126 + .procname = "fbcondecor",
2127 + .data = &fbcon_decor_path,
2128 + .maxlen = KMOD_PATH_LEN,
2129 + .mode = 0644,
2130 + .proc_handler = &proc_dostring,
2131 + },
2132 +#endif
2133 +
2134 /*
2135 * NOTE: do not add new entries to this table unless you have read
2136 * Documentation/sysctl/ctl_unnumbered.txt