Magellan Linux

Contents of /trunk/kernel26-alx/patches-2.6.33-r4/0150-2.6.33-fbcondecor-0.9.6.patch

Parent Directory Parent Directory | Revision Log Revision Log


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