/[linux-patches]/genpatches-2.6/tags/2.6.38-5/4200_fbcondecor-0.9.6.patch
Gentoo

Contents of /genpatches-2.6/tags/2.6.38-5/4200_fbcondecor-0.9.6.patch

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.20