/[linux-patches]/genpatches-2.6/tags/2.6.32-15/4200_fbcondecor-0.9.6.patch
Gentoo

Contents of /genpatches-2.6/tags/2.6.32-15/4200_fbcondecor-0.9.6.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1735 - (show annotations) (download)
Wed Aug 4 11:25:09 2010 UTC (3 years, 11 months ago) by mpagano
File size: 62445 byte(s)
2.6.32-15 release
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 bc4205d..794ce71 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 # PnP must come after ACPI since it will eventually need to check if acpi
241 @@ -21,10 +24,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 3b54b39..23ce357 100644
254 --- a/drivers/video/Kconfig
255 +++ b/drivers/video/Kconfig
256 @@ -1160,7 +1160,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 2f50a80..aa73fb7 100644
266 --- a/drivers/video/console/Kconfig
267 +++ b/drivers/video/console/Kconfig
268 @@ -128,6 +128,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 ac46cc3..e300ea0 100644
290 --- a/drivers/video/console/Makefile
291 +++ b/drivers/video/console/Makefile
292 @@ -35,6 +35,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 69864b1..77c1feb 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/fbcondecor.c b/drivers/video/console/fbcondecor.c
824 new file mode 100644
825 index 0000000..a0b4ae3
826 --- /dev/null
827 +++ b/drivers/video/console/fbcondecor.c
828 @@ -0,0 +1,561 @@
829 +/*
830 + * linux/drivers/video/console/fbcondecor.c -- Framebuffer console decorations
831 + *
832 + * Copyright (C) 2004-2009 Michal Januszewski <spock@gentoo.org>
833 + *
834 + * Code based upon "Bootsplash" (C) 2001-2003
835 + * Volker Poplawski <volker@poplawski.de>,
836 + * Stefan Reinauer <stepan@suse.de>,
837 + * Steffen Winterfeldt <snwint@suse.de>,
838 + * Michael Schroeder <mls@suse.de>,
839 + * Ken Wimer <wimer@suse.de>.
840 + *
841 + * Compat ioctl support by Thorsten Klein <TK@Thorsten-Klein.de>.
842 + *
843 + * This file is subject to the terms and conditions of the GNU General Public
844 + * License. See the file COPYING in the main directory of this archive for
845 + * more details.
846 + *
847 + */
848 +#include <linux/module.h>
849 +#include <linux/kernel.h>
850 +#include <linux/string.h>
851 +#include <linux/types.h>
852 +#include <linux/fb.h>
853 +#include <linux/vt_kern.h>
854 +#include <linux/vmalloc.h>
855 +#include <linux/unistd.h>
856 +#include <linux/syscalls.h>
857 +#include <linux/init.h>
858 +#include <linux/proc_fs.h>
859 +#include <linux/workqueue.h>
860 +#include <linux/kmod.h>
861 +#include <linux/miscdevice.h>
862 +#include <linux/device.h>
863 +#include <linux/fs.h>
864 +#include <linux/compat.h>
865 +
866 +#include <asm/uaccess.h>
867 +#include <asm/irq.h>
868 +#include <asm/system.h>
869 +
870 +#include "fbcon.h"
871 +#include "fbcondecor.h"
872 +
873 +extern signed char con2fb_map[];
874 +static int fbcon_decor_enable(struct vc_data *vc);
875 +char fbcon_decor_path[KMOD_PATH_LEN] = "/sbin/fbcondecor_helper";
876 +static int initialized = 0;
877 +
878 +int fbcon_decor_call_helper(char* cmd, unsigned short vc)
879 +{
880 + char *envp[] = {
881 + "HOME=/",
882 + "PATH=/sbin:/bin",
883 + NULL
884 + };
885 +
886 + char tfb[5];
887 + char tcons[5];
888 + unsigned char fb = (int) con2fb_map[vc];
889 +
890 + char *argv[] = {
891 + fbcon_decor_path,
892 + "2",
893 + cmd,
894 + tcons,
895 + tfb,
896 + vc_cons[vc].d->vc_decor.theme,
897 + NULL
898 + };
899 +
900 + snprintf(tfb,5,"%d",fb);
901 + snprintf(tcons,5,"%d",vc);
902 +
903 + return call_usermodehelper(fbcon_decor_path, argv, envp, 1);
904 +}
905 +
906 +/* Disables fbcondecor on a virtual console; called with console sem held. */
907 +int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw)
908 +{
909 + struct fb_info* info;
910 +
911 + if (!vc->vc_decor.state)
912 + return -EINVAL;
913 +
914 + info = registered_fb[(int) con2fb_map[vc->vc_num]];
915 +
916 + if (info == NULL)
917 + return -EINVAL;
918 +
919 + vc->vc_decor.state = 0;
920 + vc_resize(vc, info->var.xres / vc->vc_font.width,
921 + info->var.yres / vc->vc_font.height);
922 +
923 + if (fg_console == vc->vc_num && redraw) {
924 + redraw_screen(vc, 0);
925 + update_region(vc, vc->vc_origin +
926 + vc->vc_size_row * vc->vc_top,
927 + vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
928 + }
929 +
930 + printk(KERN_INFO "fbcondecor: switched decor state to 'off' on console %d\n",
931 + vc->vc_num);
932 +
933 + return 0;
934 +}
935 +
936 +/* Enables fbcondecor on a virtual console; called with console sem held. */
937 +static int fbcon_decor_enable(struct vc_data *vc)
938 +{
939 + struct fb_info* info;
940 +
941 + info = registered_fb[(int) con2fb_map[vc->vc_num]];
942 +
943 + if (vc->vc_decor.twidth == 0 || vc->vc_decor.theight == 0 ||
944 + info == NULL || vc->vc_decor.state || (!info->bgdecor.data &&
945 + vc->vc_num == fg_console))
946 + return -EINVAL;
947 +
948 + vc->vc_decor.state = 1;
949 + vc_resize(vc, vc->vc_decor.twidth / vc->vc_font.width,
950 + vc->vc_decor.theight / vc->vc_font.height);
951 +
952 + if (fg_console == vc->vc_num) {
953 + redraw_screen(vc, 0);
954 + update_region(vc, vc->vc_origin +
955 + vc->vc_size_row * vc->vc_top,
956 + vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
957 + fbcon_decor_clear_margins(vc, info, 0);
958 + }
959 +
960 + printk(KERN_INFO "fbcondecor: switched decor state to 'on' on console %d\n",
961 + vc->vc_num);
962 +
963 + return 0;
964 +}
965 +
966 +static inline int fbcon_decor_ioctl_dosetstate(struct vc_data *vc, unsigned int state, unsigned char origin)
967 +{
968 + int ret;
969 +
970 + if (origin == FBCON_DECOR_IO_ORIG_USER)
971 + acquire_console_sem();
972 + if (!state)
973 + ret = fbcon_decor_disable(vc, 1);
974 + else
975 + ret = fbcon_decor_enable(vc);
976 + if (origin == FBCON_DECOR_IO_ORIG_USER)
977 + release_console_sem();
978 +
979 + return ret;
980 +}
981 +
982 +static inline void fbcon_decor_ioctl_dogetstate(struct vc_data *vc, unsigned int *state)
983 +{
984 + *state = vc->vc_decor.state;
985 +}
986 +
987 +static int fbcon_decor_ioctl_dosetcfg(struct vc_data *vc, struct vc_decor *cfg, unsigned char origin)
988 +{
989 + struct fb_info *info;
990 + int len;
991 + char *tmp;
992 +
993 + info = registered_fb[(int) con2fb_map[vc->vc_num]];
994 +
995 + if (info == NULL || !cfg->twidth || !cfg->theight ||
996 + cfg->tx + cfg->twidth > info->var.xres ||
997 + cfg->ty + cfg->theight > info->var.yres)
998 + return -EINVAL;
999 +
1000 + len = strlen_user(cfg->theme);
1001 + if (!len || len > FBCON_DECOR_THEME_LEN)
1002 + return -EINVAL;
1003 + tmp = kmalloc(len, GFP_KERNEL);
1004 + if (!tmp)
1005 + return -ENOMEM;
1006 + if (copy_from_user(tmp, (void __user *)cfg->theme, len))
1007 + return -EFAULT;
1008 + cfg->theme = tmp;
1009 + cfg->state = 0;
1010 +
1011 + /* If this ioctl is a response to a request from kernel, the console sem
1012 + * is already held; we also don't need to disable decor because either the
1013 + * new config and background picture will be successfully loaded, and the
1014 + * decor will stay on, or in case of a failure it'll be turned off in fbcon. */
1015 + if (origin == FBCON_DECOR_IO_ORIG_USER) {
1016 + acquire_console_sem();
1017 + if (vc->vc_decor.state)
1018 + fbcon_decor_disable(vc, 1);
1019 + }
1020 +
1021 + if (vc->vc_decor.theme)
1022 + kfree(vc->vc_decor.theme);
1023 +
1024 + vc->vc_decor = *cfg;
1025 +
1026 + if (origin == FBCON_DECOR_IO_ORIG_USER)
1027 + release_console_sem();
1028 +
1029 + printk(KERN_INFO "fbcondecor: console %d using theme '%s'\n",
1030 + vc->vc_num, vc->vc_decor.theme);
1031 + return 0;
1032 +}
1033 +
1034 +static int fbcon_decor_ioctl_dogetcfg(struct vc_data *vc, struct vc_decor *decor)
1035 +{
1036 + char __user *tmp;
1037 +
1038 + tmp = decor->theme;
1039 + *decor = vc->vc_decor;
1040 + decor->theme = tmp;
1041 +
1042 + if (vc->vc_decor.theme) {
1043 + if (copy_to_user(tmp, vc->vc_decor.theme, strlen(vc->vc_decor.theme) + 1))
1044 + return -EFAULT;
1045 + } else
1046 + if (put_user(0, tmp))
1047 + return -EFAULT;
1048 +
1049 + return 0;
1050 +}
1051 +
1052 +static int fbcon_decor_ioctl_dosetpic(struct vc_data *vc, struct fb_image *img, unsigned char origin)
1053 +{
1054 + struct fb_info *info;
1055 + int len;
1056 + u8 *tmp;
1057 +
1058 + if (vc->vc_num != fg_console)
1059 + return -EINVAL;
1060 +
1061 + info = registered_fb[(int) con2fb_map[vc->vc_num]];
1062 +
1063 + if (info == NULL)
1064 + return -EINVAL;
1065 +
1066 + if (img->width != info->var.xres || img->height != info->var.yres) {
1067 + printk(KERN_ERR "fbcondecor: picture dimensions mismatch\n");
1068 + printk(KERN_ERR "%dx%d vs %dx%d\n", img->width, img->height, info->var.xres, info->var.yres);
1069 + return -EINVAL;
1070 + }
1071 +
1072 + if (img->depth != info->var.bits_per_pixel) {
1073 + printk(KERN_ERR "fbcondecor: picture depth mismatch\n");
1074 + return -EINVAL;
1075 + }
1076 +
1077 + if (img->depth == 8) {
1078 + if (!img->cmap.len || !img->cmap.red || !img->cmap.green ||
1079 + !img->cmap.blue)
1080 + return -EINVAL;
1081 +
1082 + tmp = vmalloc(img->cmap.len * 3 * 2);
1083 + if (!tmp)
1084 + return -ENOMEM;
1085 +
1086 + if (copy_from_user(tmp,
1087 + (void __user*)img->cmap.red, (img->cmap.len << 1)) ||
1088 + copy_from_user(tmp + (img->cmap.len << 1),
1089 + (void __user*)img->cmap.green, (img->cmap.len << 1)) ||
1090 + copy_from_user(tmp + (img->cmap.len << 2),
1091 + (void __user*)img->cmap.blue, (img->cmap.len << 1))) {
1092 + vfree(tmp);
1093 + return -EFAULT;
1094 + }
1095 +
1096 + img->cmap.transp = NULL;
1097 + img->cmap.red = (u16*)tmp;
1098 + img->cmap.green = img->cmap.red + img->cmap.len;
1099 + img->cmap.blue = img->cmap.green + img->cmap.len;
1100 + } else {
1101 + img->cmap.red = NULL;
1102 + }
1103 +
1104 + len = ((img->depth + 7) >> 3) * img->width * img->height;
1105 +
1106 + /*
1107 + * Allocate an additional byte so that we never go outside of the
1108 + * buffer boundaries in the rendering functions in a 24 bpp mode.
1109 + */
1110 + tmp = vmalloc(len + 1);
1111 +
1112 + if (!tmp)
1113 + goto out;
1114 +
1115 + if (copy_from_user(tmp, (void __user*)img->data, len))
1116 + goto out;
1117 +
1118 + img->data = tmp;
1119 +
1120 + /* If this ioctl is a response to a request from kernel, the console sem
1121 + * is already held. */
1122 + if (origin == FBCON_DECOR_IO_ORIG_USER)
1123 + acquire_console_sem();
1124 +
1125 + if (info->bgdecor.data)
1126 + vfree((u8*)info->bgdecor.data);
1127 + if (info->bgdecor.cmap.red)
1128 + vfree(info->bgdecor.cmap.red);
1129 +
1130 + info->bgdecor = *img;
1131 +
1132 + if (fbcon_decor_active_vc(vc) && fg_console == vc->vc_num) {
1133 + redraw_screen(vc, 0);
1134 + update_region(vc, vc->vc_origin +
1135 + vc->vc_size_row * vc->vc_top,
1136 + vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1137 + fbcon_decor_clear_margins(vc, info, 0);
1138 + }
1139 +
1140 + if (origin == FBCON_DECOR_IO_ORIG_USER)
1141 + release_console_sem();
1142 +
1143 + return 0;
1144 +
1145 +out: if (img->cmap.red)
1146 + vfree(img->cmap.red);
1147 +
1148 + if (tmp)
1149 + vfree(tmp);
1150 + return -ENOMEM;
1151 +}
1152 +
1153 +static int fbcon_decor_ioctl(struct inode * inode, struct file *filp, u_int cmd,
1154 + u_long arg)
1155 +{
1156 + struct fbcon_decor_iowrapper __user *wrapper = (void __user*) arg;
1157 + struct vc_data *vc = NULL;
1158 + unsigned short vc_num = 0;
1159 + unsigned char origin = 0;
1160 + void __user *data = NULL;
1161 +
1162 + if (!access_ok(VERIFY_READ, wrapper,
1163 + sizeof(struct fbcon_decor_iowrapper)))
1164 + return -EFAULT;
1165 +
1166 + __get_user(vc_num, &wrapper->vc);
1167 + __get_user(origin, &wrapper->origin);
1168 + __get_user(data, &wrapper->data);
1169 +
1170 + if (!vc_cons_allocated(vc_num))
1171 + return -EINVAL;
1172 +
1173 + vc = vc_cons[vc_num].d;
1174 +
1175 + switch (cmd) {
1176 + case FBIOCONDECOR_SETPIC:
1177 + {
1178 + struct fb_image img;
1179 + if (copy_from_user(&img, (struct fb_image __user *)data, sizeof(struct fb_image)))
1180 + return -EFAULT;
1181 +
1182 + return fbcon_decor_ioctl_dosetpic(vc, &img, origin);
1183 + }
1184 + case FBIOCONDECOR_SETCFG:
1185 + {
1186 + struct vc_decor cfg;
1187 + if (copy_from_user(&cfg, (struct vc_decor __user *)data, sizeof(struct vc_decor)))
1188 + return -EFAULT;
1189 +
1190 + return fbcon_decor_ioctl_dosetcfg(vc, &cfg, origin);
1191 + }
1192 + case FBIOCONDECOR_GETCFG:
1193 + {
1194 + int rval;
1195 + struct vc_decor cfg;
1196 +
1197 + if (copy_from_user(&cfg, (struct vc_decor __user *)data, sizeof(struct vc_decor)))
1198 + return -EFAULT;
1199 +
1200 + rval = fbcon_decor_ioctl_dogetcfg(vc, &cfg);
1201 +
1202 + if (copy_to_user(data, &cfg, sizeof(struct vc_decor)))
1203 + return -EFAULT;
1204 + return rval;
1205 + }
1206 + case FBIOCONDECOR_SETSTATE:
1207 + {
1208 + unsigned int state = 0;
1209 + if (get_user(state, (unsigned int __user *)data))
1210 + return -EFAULT;
1211 + return fbcon_decor_ioctl_dosetstate(vc, state, origin);
1212 + }
1213 + case FBIOCONDECOR_GETSTATE:
1214 + {
1215 + unsigned int state = 0;
1216 + fbcon_decor_ioctl_dogetstate(vc, &state);
1217 + return put_user(state, (unsigned int __user *)data);
1218 + }
1219 +
1220 + default:
1221 + return -ENOIOCTLCMD;
1222 + }
1223 +}
1224 +
1225 +#ifdef CONFIG_COMPAT
1226 +
1227 +static long fbcon_decor_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) {
1228 +
1229 + struct fbcon_decor_iowrapper32 __user *wrapper = (void __user *)arg;
1230 + struct vc_data *vc = NULL;
1231 + unsigned short vc_num = 0;
1232 + unsigned char origin = 0;
1233 + compat_uptr_t data_compat = 0;
1234 + void __user *data = NULL;
1235 +
1236 + if (!access_ok(VERIFY_READ, wrapper,
1237 + sizeof(struct fbcon_decor_iowrapper32)))
1238 + return -EFAULT;
1239 +
1240 + __get_user(vc_num, &wrapper->vc);
1241 + __get_user(origin, &wrapper->origin);
1242 + __get_user(data_compat, &wrapper->data);
1243 + data = compat_ptr(data_compat);
1244 +
1245 + if (!vc_cons_allocated(vc_num))
1246 + return -EINVAL;
1247 +
1248 + vc = vc_cons[vc_num].d;
1249 +
1250 + switch (cmd) {
1251 + case FBIOCONDECOR_SETPIC32:
1252 + {
1253 + struct fb_image32 img_compat;
1254 + struct fb_image img;
1255 +
1256 + if (copy_from_user(&img_compat, (struct fb_image32 __user *)data, sizeof(struct fb_image32)))
1257 + return -EFAULT;
1258 +
1259 + fb_image_from_compat(img, img_compat);
1260 +
1261 + return fbcon_decor_ioctl_dosetpic(vc, &img, origin);
1262 + }
1263 +
1264 + case FBIOCONDECOR_SETCFG32:
1265 + {
1266 + struct vc_decor32 cfg_compat;
1267 + struct vc_decor cfg;
1268 +
1269 + if (copy_from_user(&cfg_compat, (struct vc_decor32 __user *)data, sizeof(struct vc_decor32)))
1270 + return -EFAULT;
1271 +
1272 + vc_decor_from_compat(cfg, cfg_compat);
1273 +
1274 + return fbcon_decor_ioctl_dosetcfg(vc, &cfg, origin);
1275 + }
1276 +
1277 + case FBIOCONDECOR_GETCFG32:
1278 + {
1279 + int rval;
1280 + struct vc_decor32 cfg_compat;
1281 + struct vc_decor cfg;
1282 +
1283 + if (copy_from_user(&cfg_compat, (struct vc_decor32 __user *)data, sizeof(struct vc_decor32)))
1284 + return -EFAULT;
1285 + cfg.theme = compat_ptr(cfg_compat.theme);
1286 +
1287 + rval = fbcon_decor_ioctl_dogetcfg(vc, &cfg);
1288 +
1289 + vc_decor_to_compat(cfg_compat, cfg);
1290 +
1291 + if (copy_to_user((struct vc_decor32 __user *)data, &cfg_compat, sizeof(struct vc_decor32)))
1292 + return -EFAULT;
1293 + return rval;
1294 + }
1295 +
1296 + case FBIOCONDECOR_SETSTATE32:
1297 + {
1298 + compat_uint_t state_compat = 0;
1299 + unsigned int state = 0;
1300 +
1301 + if (get_user(state_compat, (compat_uint_t __user *)data))
1302 + return -EFAULT;
1303 +
1304 + state = (unsigned int)state_compat;
1305 +
1306 + return fbcon_decor_ioctl_dosetstate(vc, state, origin);
1307 + }
1308 +
1309 + case FBIOCONDECOR_GETSTATE32:
1310 + {
1311 + compat_uint_t state_compat = 0;
1312 + unsigned int state = 0;
1313 +
1314 + fbcon_decor_ioctl_dogetstate(vc, &state);
1315 + state_compat = (compat_uint_t)state;
1316 +
1317 + return put_user(state_compat, (compat_uint_t __user *)data);
1318 + }
1319 +
1320 + default:
1321 + return -ENOIOCTLCMD;
1322 + }
1323 +}
1324 +#else
1325 + #define fbcon_decor_compat_ioctl NULL
1326 +#endif
1327 +
1328 +static struct file_operations fbcon_decor_ops = {
1329 + .owner = THIS_MODULE,
1330 + .ioctl = fbcon_decor_ioctl,
1331 + .compat_ioctl = fbcon_decor_compat_ioctl
1332 +};
1333 +
1334 +static struct miscdevice fbcon_decor_dev = {
1335 + .minor = MISC_DYNAMIC_MINOR,
1336 + .name = "fbcondecor",
1337 + .fops = &fbcon_decor_ops
1338 +};
1339 +
1340 +void fbcon_decor_reset(void)
1341 +{
1342 + struct fb_info *info;
1343 + struct vc_data *vc;
1344 + int i;
1345 +
1346 + vc = vc_cons[0].d;
1347 + info = registered_fb[0];
1348 +
1349 + for (i = 0; i < num_registered_fb; i++) {
1350 + registered_fb[i]->bgdecor.data = NULL;
1351 + registered_fb[i]->bgdecor.cmap.red = NULL;
1352 + }
1353 +
1354 + for (i = 0; i < MAX_NR_CONSOLES && vc_cons[i].d; i++) {
1355 + vc_cons[i].d->vc_decor.state = vc_cons[i].d->vc_decor.twidth =
1356 + vc_cons[i].d->vc_decor.theight = 0;
1357 + vc_cons[i].d->vc_decor.theme = NULL;
1358 + }
1359 +
1360 + return;
1361 +}
1362 +
1363 +int fbcon_decor_init(void)
1364 +{
1365 + int i;
1366 +
1367 + fbcon_decor_reset();
1368 +
1369 + if (initialized)
1370 + return 0;
1371 +
1372 + i = misc_register(&fbcon_decor_dev);
1373 + if (i) {
1374 + printk(KERN_ERR "fbcondecor: failed to register device\n");
1375 + return i;
1376 + }
1377 +
1378 + fbcon_decor_call_helper("init", 0);
1379 + initialized = 1;
1380 + return 0;
1381 +}
1382 +
1383 +int fbcon_decor_exit(void)
1384 +{
1385 + fbcon_decor_reset();
1386 + return 0;
1387 +}
1388 +
1389 +EXPORT_SYMBOL(fbcon_decor_path);
1390 diff --git a/drivers/video/console/fbcondecor.h b/drivers/video/console/fbcondecor.h
1391 new file mode 100644
1392 index 0000000..1d852dd
1393 --- /dev/null
1394 +++ b/drivers/video/console/fbcondecor.h
1395 @@ -0,0 +1,78 @@
1396 +/*
1397 + * linux/drivers/video/console/fbcondecor.h -- Framebuffer Console Decoration headers
1398 + *
1399 + * Copyright (C) 2004 Michal Januszewski <spock@gentoo.org>
1400 + *
1401 + */
1402 +
1403 +#ifndef __FBCON_DECOR_H
1404 +#define __FBCON_DECOR_H
1405 +
1406 +#ifndef _LINUX_FB_H
1407 +#include <linux/fb.h>
1408 +#endif
1409 +
1410 +/* This is needed for vc_cons in fbcmap.c */
1411 +#include <linux/vt_kern.h>
1412 +
1413 +struct fb_cursor;
1414 +struct fb_info;
1415 +struct vc_data;
1416 +
1417 +#ifdef CONFIG_FB_CON_DECOR
1418 +/* fbcondecor.c */
1419 +int fbcon_decor_init(void);
1420 +int fbcon_decor_exit(void);
1421 +int fbcon_decor_call_helper(char* cmd, unsigned short cons);
1422 +int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw);
1423 +
1424 +/* cfbcondecor.c */
1425 +void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx);
1426 +void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor);
1427 +void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width);
1428 +void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only);
1429 +void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank);
1430 +void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width);
1431 +void fbcon_decor_copy(u8 *dst, u8 *src, int height, int width, int linebytes, int srclinesbytes, int bpp);
1432 +void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc);
1433 +
1434 +/* vt.c */
1435 +void acquire_console_sem(void);
1436 +void release_console_sem(void);
1437 +void do_unblank_screen(int entering_gfx);
1438 +
1439 +/* struct vc_data *y */
1440 +#define fbcon_decor_active_vc(y) (y->vc_decor.state && y->vc_decor.theme)
1441 +
1442 +/* struct fb_info *x, struct vc_data *y */
1443 +#define fbcon_decor_active_nores(x,y) (x->bgdecor.data && fbcon_decor_active_vc(y))
1444 +
1445 +/* struct fb_info *x, struct vc_data *y */
1446 +#define fbcon_decor_active(x,y) (fbcon_decor_active_nores(x,y) && \
1447 + x->bgdecor.width == x->var.xres && \
1448 + x->bgdecor.height == x->var.yres && \
1449 + x->bgdecor.depth == x->var.bits_per_pixel)
1450 +
1451 +
1452 +#else /* CONFIG_FB_CON_DECOR */
1453 +
1454 +static inline void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx) {}
1455 +static inline void fbcon_decor_putc(struct vc_data *vc, struct fb_info *info, int c, int ypos, int xpos) {}
1456 +static inline void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor) {}
1457 +static inline void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) {}
1458 +static inline void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only) {}
1459 +static inline void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank) {}
1460 +static inline void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width) {}
1461 +static inline void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc) {}
1462 +static inline int fbcon_decor_call_helper(char* cmd, unsigned short cons) { return 0; }
1463 +static inline int fbcon_decor_init(void) { return 0; }
1464 +static inline int fbcon_decor_exit(void) { return 0; }
1465 +static inline int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw) { return 0; }
1466 +
1467 +#define fbcon_decor_active_vc(y) (0)
1468 +#define fbcon_decor_active_nores(x,y) (0)
1469 +#define fbcon_decor_active(x,y) (0)
1470 +
1471 +#endif /* CONFIG_FB_CON_DECOR */
1472 +
1473 +#endif /* __FBCON_DECOR_H */
1474 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
1475 index f53b9f1..467f921 100644
1476 --- a/drivers/video/fbcmap.c
1477 +++ b/drivers/video/fbcmap.c
1478 @@ -17,6 +17,8 @@
1479 #include <linux/slab.h>
1480 #include <linux/uaccess.h>
1481
1482 +#include "console/fbcondecor.h"
1483 +
1484 static u16 red2[] __read_mostly = {
1485 0x0000, 0xaaaa
1486 };
1487 @@ -234,14 +236,17 @@ int fb_set_cmap(struct fb_cmap *cmap, struct fb_info *info)
1488 if (transp)
1489 htransp = *transp++;
1490 if (info->fbops->fb_setcolreg(start++,
1491 - hred, hgreen, hblue,
1492 + hred, hgreen, hblue,
1493 htransp, info))
1494 break;
1495 }
1496 }
1497 - if (rc == 0)
1498 + if (rc == 0) {
1499 fb_copy_cmap(cmap, &info->cmap);
1500 -
1501 + if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
1502 + info->fix.visual == FB_VISUAL_DIRECTCOLOR)
1503 + fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
1504 + }
1505 return rc;
1506 }
1507
1508 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
1509 index a85c818..1f1c24b 100644
1510 --- a/drivers/video/fbmem.c
1511 +++ b/drivers/video/fbmem.c
1512 @@ -1173,15 +1173,6 @@ struct fb_fix_screeninfo32 {
1513 u16 reserved[3];
1514 };
1515
1516 -struct fb_cmap32 {
1517 - u32 start;
1518 - u32 len;
1519 - compat_caddr_t red;
1520 - compat_caddr_t green;
1521 - compat_caddr_t blue;
1522 - compat_caddr_t transp;
1523 -};
1524 -
1525 static int fb_getput_cmap(struct fb_info *info, unsigned int cmd,
1526 unsigned long arg)
1527 {
1528 diff --git a/include/linux/console_decor.h b/include/linux/console_decor.h
1529 new file mode 100644
1530 index 0000000..04b8d80
1531 --- /dev/null
1532 +++ b/include/linux/console_decor.h
1533 @@ -0,0 +1,46 @@
1534 +#ifndef _LINUX_CONSOLE_DECOR_H_
1535 +#define _LINUX_CONSOLE_DECOR_H_ 1
1536 +
1537 +/* A structure used by the framebuffer console decorations (drivers/video/console/fbcondecor.c) */
1538 +struct vc_decor {
1539 + __u8 bg_color; /* The color that is to be treated as transparent */
1540 + __u8 state; /* Current decor state: 0 = off, 1 = on */
1541 + __u16 tx, ty; /* Top left corner coordinates of the text field */
1542 + __u16 twidth, theight; /* Width and height of the text field */
1543 + char* theme;
1544 +};
1545 +
1546 +#ifdef __KERNEL__
1547 +#ifdef CONFIG_COMPAT
1548 +#include <linux/compat.h>
1549 +
1550 +struct vc_decor32 {
1551 + __u8 bg_color; /* The color that is to be treated as transparent */
1552 + __u8 state; /* Current decor state: 0 = off, 1 = on */
1553 + __u16 tx, ty; /* Top left corner coordinates of the text field */
1554 + __u16 twidth, theight; /* Width and height of the text field */
1555 + compat_uptr_t theme;
1556 +};
1557 +
1558 +#define vc_decor_from_compat(to, from) \
1559 + (to).bg_color = (from).bg_color; \
1560 + (to).state = (from).state; \
1561 + (to).tx = (from).tx; \
1562 + (to).ty = (from).ty; \
1563 + (to).twidth = (from).twidth; \
1564 + (to).theight = (from).theight; \
1565 + (to).theme = compat_ptr((from).theme)
1566 +
1567 +#define vc_decor_to_compat(to, from) \
1568 + (to).bg_color = (from).bg_color; \
1569 + (to).state = (from).state; \
1570 + (to).tx = (from).tx; \
1571 + (to).ty = (from).ty; \
1572 + (to).twidth = (from).twidth; \
1573 + (to).theight = (from).theight; \
1574 + (to).theme = ptr_to_compat((from).theme)
1575 +
1576 +#endif /* CONFIG_COMPAT */
1577 +#endif /* __KERNEL__ */
1578 +
1579 +#endif
1580 diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h
1581 index 38fe59d..8e4058b 100644
1582 --- a/include/linux/console_struct.h
1583 +++ b/include/linux/console_struct.h
1584 @@ -19,6 +19,7 @@
1585 struct vt_struct;
1586
1587 #define NPAR 16
1588 +#include <linux/console_decor.h>
1589
1590 struct vc_data {
1591 unsigned short vc_num; /* Console number */
1592 @@ -105,6 +106,8 @@ struct vc_data {
1593 struct vc_data **vc_display_fg; /* [!] Ptr to var holding fg console for this display */
1594 unsigned long vc_uni_pagedir;
1595 unsigned long *vc_uni_pagedir_loc; /* [!] Location of uni_pagedir variable for this console */
1596 +
1597 + struct vc_decor vc_decor;
1598 /* additional information is in vt_kern.h */
1599 };
1600
1601 diff --git a/include/linux/fb.h b/include/linux/fb.h
1602 index f847df9..7ac118e 100644
1603 --- a/include/linux/fb.h
1604 +++ b/include/linux/fb.h
1605 @@ -3,13 +3,31 @@
1606
1607 #include <linux/types.h>
1608 #include <linux/i2c.h>
1609 -
1610 struct dentry;
1611
1612 /* Definitions of frame buffers */
1613
1614 #define FB_MAX 32 /* sufficient for now */
1615
1616 +struct fbcon_decor_iowrapper
1617 +{
1618 + unsigned short vc; /* Virtual console */
1619 + unsigned char origin; /* Point of origin of the request */
1620 + void *data;
1621 +};
1622 +
1623 +#ifdef __KERNEL__
1624 +#ifdef CONFIG_COMPAT
1625 +#include <linux/compat.h>
1626 +struct fbcon_decor_iowrapper32
1627 +{
1628 + unsigned short vc; /* Virtual console */
1629 + unsigned char origin; /* Point of origin of the request */
1630 + compat_uptr_t data;
1631 +};
1632 +#endif /* CONFIG_COMPAT */
1633 +#endif /* __KERNEL__ */
1634 +
1635 /* ioctls
1636 0x46 is 'F' */
1637 #define FBIOGET_VSCREENINFO 0x4600
1638 @@ -37,7 +55,24 @@ struct dentry;
1639 #define FBIOGET_HWCINFO 0x4616
1640 #define FBIOPUT_MODEINFO 0x4617
1641 #define FBIOGET_DISPINFO 0x4618
1642 +#define FBIOCONDECOR_SETCFG _IOWR('F', 0x19, struct fbcon_decor_iowrapper)
1643 +#define FBIOCONDECOR_GETCFG _IOR('F', 0x1A, struct fbcon_decor_iowrapper)
1644 +#define FBIOCONDECOR_SETSTATE _IOWR('F', 0x1B, struct fbcon_decor_iowrapper)
1645 +#define FBIOCONDECOR_GETSTATE _IOR('F', 0x1C, struct fbcon_decor_iowrapper)
1646 +#define FBIOCONDECOR_SETPIC _IOWR('F', 0x1D, struct fbcon_decor_iowrapper)
1647 +#ifdef __KERNEL__
1648 +#ifdef CONFIG_COMPAT
1649 +#define FBIOCONDECOR_SETCFG32 _IOWR('F', 0x19, struct fbcon_decor_iowrapper32)
1650 +#define FBIOCONDECOR_GETCFG32 _IOR('F', 0x1A, struct fbcon_decor_iowrapper32)
1651 +#define FBIOCONDECOR_SETSTATE32 _IOWR('F', 0x1B, struct fbcon_decor_iowrapper32)
1652 +#define FBIOCONDECOR_GETSTATE32 _IOR('F', 0x1C, struct fbcon_decor_iowrapper32)
1653 +#define FBIOCONDECOR_SETPIC32 _IOWR('F', 0x1D, struct fbcon_decor_iowrapper32)
1654 +#endif /* CONFIG_COMPAT */
1655 +#endif /* __KERNEL__ */
1656
1657 +#define FBCON_DECOR_THEME_LEN 128 /* Maximum lenght of a theme name */
1658 +#define FBCON_DECOR_IO_ORIG_KERNEL 0 /* Kernel ioctl origin */
1659 +#define FBCON_DECOR_IO_ORIG_USER 1 /* User ioctl origin */
1660
1661 #define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */
1662 #define FB_TYPE_PLANES 1 /* Non interleaved planes */
1663 @@ -281,6 +316,28 @@ struct fb_cmap {
1664 __u16 *transp; /* transparency, can be NULL */
1665 };
1666
1667 +#ifdef __KERNEL__
1668 +#ifdef CONFIG_COMPAT
1669 +struct fb_cmap32 {
1670 + __u32 start;
1671 + __u32 len; /* Number of entries */
1672 + compat_uptr_t red; /* Red values */
1673 + compat_uptr_t green;
1674 + compat_uptr_t blue;
1675 + compat_uptr_t transp; /* transparency, can be NULL */
1676 +};
1677 +
1678 +#define fb_cmap_from_compat(to, from) \
1679 + (to).start = (from).start; \
1680 + (to).len = (from).len; \
1681 + (to).red = compat_ptr((from).red); \
1682 + (to).green = compat_ptr((from).green); \
1683 + (to).blue = compat_ptr((from).blue); \
1684 + (to).transp = compat_ptr((from).transp)
1685 +
1686 +#endif /* CONFIG_COMPAT */
1687 +#endif /* __KERNEL__ */
1688 +
1689 struct fb_con2fbmap {
1690 __u32 console;
1691 __u32 framebuffer;
1692 @@ -362,6 +419,34 @@ struct fb_image {
1693 struct fb_cmap cmap; /* color map info */
1694 };
1695
1696 +#ifdef __KERNEL__
1697 +#ifdef CONFIG_COMPAT
1698 +struct fb_image32 {
1699 + __u32 dx; /* Where to place image */
1700 + __u32 dy;
1701 + __u32 width; /* Size of image */
1702 + __u32 height;
1703 + __u32 fg_color; /* Only used when a mono bitmap */
1704 + __u32 bg_color;
1705 + __u8 depth; /* Depth of the image */
1706 + const compat_uptr_t data; /* Pointer to image data */
1707 + struct fb_cmap32 cmap; /* color map info */
1708 +};
1709 +
1710 +#define fb_image_from_compat(to, from) \
1711 + (to).dx = (from).dx; \
1712 + (to).dy = (from).dy; \
1713 + (to).width = (from).width; \
1714 + (to).height = (from).height; \
1715 + (to).fg_color = (from).fg_color; \
1716 + (to).bg_color = (from).bg_color; \
1717 + (to).depth = (from).depth; \
1718 + (to).data = compat_ptr((from).data); \
1719 + fb_cmap_from_compat((to).cmap, (from).cmap)
1720 +
1721 +#endif /* CONFIG_COMPAT */
1722 +#endif /* __KERNEL__ */
1723 +
1724 /*
1725 * hardware cursor control
1726 */
1727 @@ -859,6 +944,9 @@ struct fb_info {
1728 #define FBINFO_STATE_SUSPENDED 1
1729 u32 state; /* Hardware state i.e suspend */
1730 void *fbcon_par; /* fbcon use-only private area */
1731 +
1732 + struct fb_image bgdecor;
1733 +
1734 /* From here on everything is device dependent */
1735 void *par;
1736 /* we need the PCI or similiar aperture base/size not
1737 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
1738 index 98e0232..24f4e31 100644
1739 --- a/kernel/sysctl.c
1740 +++ b/kernel/sysctl.c
1741 @@ -118,6 +118,9 @@ static int ngroups_max = NGROUPS_MAX;
1742 extern char modprobe_path[];
1743 extern int modules_disabled;
1744 #endif
1745 +#ifdef CONFIG_FB_CON_DECOR
1746 +extern char fbcon_decor_path[];
1747 +#endif
1748 #ifdef CONFIG_CHR_DEV_SG
1749 extern int sg_big_buff;
1750 #endif
1751 @@ -230,6 +233,18 @@ static struct ctl_table root_table[] = {
1752 .mode = 0555,
1753 .child = dev_table,
1754 },
1755 +#ifdef CONFIG_FB_CON_DECOR
1756 + {
1757 + .ctl_name = CTL_UNNUMBERED,
1758 + .procname = "fbcondecor",
1759 + .data = &fbcon_decor_path,
1760 + .maxlen = KMOD_PATH_LEN,
1761 + .mode = 0644,
1762 + .proc_handler = &proc_dostring,
1763 + .strategy = &sysctl_string,
1764 + },
1765 +#endif
1766 +
1767 /*
1768 * NOTE: do not add new entries to this table unless you have read
1769 * Documentation/sysctl/ctl_unnumbered.txt
1770 --- a/drivers/video/console/fbcon.c 2009-10-07 20:24:23.000000000 -0400
1771 +++ b/drivers/video/console/fbcon.c 2009-10-07 20:23:26.000000000 -0400
1772 @@ -80,6 +80,7 @@
1773 #include <asm/system.h>
1774
1775 #include "fbcon.h"
1776 +#include "fbcondecor.h"
1777
1778 #ifdef FBCONDEBUG
1779 # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
1780 @@ -95,7 +96,7 @@ enum {
1781
1782 static struct display fb_display[MAX_NR_CONSOLES];
1783
1784 -static signed char con2fb_map[MAX_NR_CONSOLES];
1785 +signed char con2fb_map[MAX_NR_CONSOLES];
1786 static signed char con2fb_map_boot[MAX_NR_CONSOLES];
1787
1788 static int logo_lines;
1789 @@ -286,7 +287,7 @@ static inline int fbcon_is_inactive(stru
1790 vc->vc_mode != KD_TEXT || ops->graphics);
1791 }
1792
1793 -static inline int get_color(struct vc_data *vc, struct fb_info *info,
1794 +inline int get_color(struct vc_data *vc, struct fb_info *info,
1795 u16 c, int is_fg)
1796 {
1797 int depth = fb_get_color_depth(&info->var, &info->fix);
1798 @@ -391,6 +392,7 @@ static void fb_flashcursor(struct work_s
1799 CM_ERASE : CM_DRAW;
1800 ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1),
1801 get_color(vc, info, c, 0));
1802 +
1803 release_console_sem();
1804 }
1805
1806 @@ -527,6 +529,7 @@ static int search_for_mapped_con(void)
1807 static int fbcon_takeover(int show_logo)
1808 {
1809 int err, i;
1810 + struct fb_info *info;
1811
1812 if (!num_registered_fb)
1813 return -ENODEV;
1814 @@ -540,6 +543,8 @@ static int fbcon_takeover(int show_logo)
1815 err = take_over_console(&fb_con, first_fb_vc, last_fb_vc,
1816 fbcon_is_default);
1817
1818 + info = registered_fb[info_idx];
1819 +
1820 if (err) {
1821 for (i = first_fb_vc; i <= last_fb_vc; i++) {
1822 con2fb_map[i] = -1;
1823 @@ -547,6 +552,9 @@ static int fbcon_takeover(int show_logo)
1824 info_idx = -1;
1825 } else {
1826 fbcon_has_console_bind = 1;
1827 + unlock_fb_info(info);
1828 + fbcon_decor_init();
1829 + lock_fb_info(info);
1830 }
1831
1832 return err;
1833 @@ -988,6 +996,12 @@ static const char *fbcon_startup(void)
1834 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1835 cols /= vc->vc_font.width;
1836 rows /= vc->vc_font.height;
1837 +
1838 + if (fbcon_decor_active(info, vc)) {
1839 + cols = vc->vc_decor.twidth / vc->vc_font.width;
1840 + rows = vc->vc_decor.theight / vc->vc_font.height;
1841 + }
1842 +
1843 vc_resize(vc, cols, rows);
1844
1845 DPRINTK("mode: %s\n", info->fix.id);
1846 @@ -1017,7 +1031,7 @@ static void fbcon_init(struct vc_data *v
1847 cap = info->flags;
1848
1849 if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
1850 - (info->fix.type == FB_TYPE_TEXT))
1851 + (info->fix.type == FB_TYPE_TEXT) || fbcon_decor_active(info, vc))
1852 logo = 0;
1853
1854 if (var_to_display(p, &info->var, info))
1855 @@ -1219,6 +1233,11 @@ static void fbcon_clear(struct vc_data *
1856 if (sy < vc->vc_top && vc->vc_top == logo_lines)
1857 vc->vc_top = 0;
1858
1859 + if (fbcon_decor_active(info, vc)) {
1860 + fbcon_decor_clear(vc, info, sy, sx, height, width);
1861 + return;
1862 + }
1863 +
1864 /* Split blits that cross physical y_wrap boundary */
1865
1866 y_break = p->vrows - p->yscroll;
1867 @@ -1238,10 +1257,15 @@ static void fbcon_putcs(struct vc_data *
1868 struct display *p = &fb_display[vc->vc_num];
1869 struct fbcon_ops *ops = info->fbcon_par;
1870
1871 - if (!fbcon_is_inactive(vc, info))
1872 - ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
1873 - get_color(vc, info, scr_readw(s), 1),
1874 - get_color(vc, info, scr_readw(s), 0));
1875 + if (!fbcon_is_inactive(vc, info)) {
1876 +
1877 + if (fbcon_decor_active(info, vc))
1878 + fbcon_decor_putcs(vc, info, s, count, ypos, xpos);
1879 + else
1880 + ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
1881 + get_color(vc, info, scr_readw(s), 1),
1882 + get_color(vc, info, scr_readw(s), 0));
1883 + }
1884 }
1885
1886 static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
1887 @@ -1257,8 +1281,13 @@ static void fbcon_clear_margins(struct v
1888 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1889 struct fbcon_ops *ops = info->fbcon_par;
1890
1891 - if (!fbcon_is_inactive(vc, info))
1892 - ops->clear_margins(vc, info, bottom_only);
1893 + if (!fbcon_is_inactive(vc, info)) {
1894 + if (fbcon_decor_active(info, vc)) {
1895 + fbcon_decor_clear_margins(vc, info, bottom_only);
1896 + } else {
1897 + ops->clear_margins(vc, info, bottom_only);
1898 + }
1899 + }
1900 }
1901
1902 static void fbcon_cursor(struct vc_data *vc, int mode)
1903 @@ -1778,7 +1807,7 @@ static int fbcon_scroll(struct vc_data *
1904 count = vc->vc_rows;
1905 if (softback_top)
1906 fbcon_softback_note(vc, t, count);
1907 - if (logo_shown >= 0)
1908 + if (logo_shown >= 0 || fbcon_decor_active(info, vc))
1909 goto redraw_up;
1910 switch (p->scrollmode) {
1911 case SCROLL_MOVE:
1912 @@ -1871,6 +1900,8 @@ static int fbcon_scroll(struct vc_data *
1913 count = vc->vc_rows;
1914 if (logo_shown >= 0)
1915 goto redraw_down;
1916 + if (fbcon_decor_active(info, vc))
1917 + goto redraw_down;
1918 switch (p->scrollmode) {
1919 case SCROLL_MOVE:
1920 fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
1921 @@ -2019,6 +2050,13 @@ static void fbcon_bmove_rec(struct vc_da
1922 }
1923 return;
1924 }
1925 +
1926 + if (fbcon_decor_active(info, vc) && sy == dy && height == 1) {
1927 + /* must use slower redraw bmove to keep background pic intact */
1928 + fbcon_decor_bmove_redraw(vc, info, sy, sx, dx, width);
1929 + return;
1930 + }
1931 +
1932 ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
1933 height, width);
1934 }
1935 @@ -2089,8 +2127,8 @@ static int fbcon_resize(struct vc_data *
1936 var.yres = virt_h * virt_fh;
1937 x_diff = info->var.xres - var.xres;
1938 y_diff = info->var.yres - var.yres;
1939 - if (x_diff < 0 || x_diff > virt_fw ||
1940 - y_diff < 0 || y_diff > virt_fh) {
1941 + if ((x_diff < 0 || x_diff > virt_fw ||
1942 + y_diff < 0 || y_diff > virt_fh) && !vc->vc_decor.state) {
1943 const struct fb_videomode *mode;
1944
1945 DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
1946 @@ -2126,6 +2164,19 @@ static int fbcon_switch(struct vc_data *
1947
1948 info = registered_fb[con2fb_map[vc->vc_num]];
1949 ops = info->fbcon_par;
1950 + prev_console = ops->currcon;
1951 + if (prev_console != -1)
1952 + old_info = registered_fb[con2fb_map[prev_console]];
1953 +
1954 + if (!fbcon_decor_active_vc(vc) && info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
1955 + struct vc_data *vc_curr = vc_cons[prev_console].d;
1956 + if (vc_curr && fbcon_decor_active_vc(vc_curr)) {
1957 + /* Clear the screen to avoid displaying funky colors during
1958 + * palette updates. */
1959 + memset((u8*)info->screen_base + info->fix.line_length * info->var.yoffset,
1960 + 0, info->var.yres * info->fix.line_length);
1961 + }
1962 + }
1963
1964 if (softback_top) {
1965 if (softback_lines)
1966 @@ -2144,9 +2195,6 @@ static int fbcon_switch(struct vc_data *
1967 logo_shown = FBCON_LOGO_CANSHOW;
1968 }
1969
1970 - prev_console = ops->currcon;
1971 - if (prev_console != -1)
1972 - old_info = registered_fb[con2fb_map[prev_console]];
1973 /*
1974 * FIXME: If we have multiple fbdev's loaded, we need to
1975 * update all info->currcon. Perhaps, we can place this
1976 @@ -2184,6 +2232,18 @@ static int fbcon_switch(struct vc_data *
1977 fbcon_del_cursor_timer(old_info);
1978 }
1979
1980 + if (fbcon_decor_active_vc(vc)) {
1981 + struct vc_data *vc_curr = vc_cons[prev_console].d;
1982 +
1983 + if (!vc_curr->vc_decor.theme ||
1984 + strcmp(vc->vc_decor.theme, vc_curr->vc_decor.theme) ||
1985 + (fbcon_decor_active_nores(info, vc_curr) &&
1986 + !fbcon_decor_active(info, vc_curr))) {
1987 + if (fbcon_decor_call_helper("modechange", vc->vc_num))
1988 + fbcon_decor_disable(vc, 0);
1989 + }
1990 + }
1991 +
1992 if (fbcon_is_inactive(vc, info) ||
1993 ops->blank_state != FB_BLANK_UNBLANK)
1994 fbcon_del_cursor_timer(info);
1995 @@ -2295,15 +2355,20 @@ static int fbcon_blank(struct vc_data *v
1996 info->fbops->fb_restore_state(info);
1997 }
1998
1999 - if (!fbcon_is_inactive(vc, info)) {
2000 + if (!fbcon_is_inactive(vc, info)) {
2001 if (ops->blank_state != blank) {
2002 ops->blank_state = blank;
2003 fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
2004 ops->cursor_flash = (!blank);
2005
2006 - if (!(info->flags & FBINFO_MISC_USEREVENT))
2007 - if (fb_blank(info, blank))
2008 - fbcon_generic_blank(vc, info, blank);
2009 + if (!(info->flags & FBINFO_MISC_USEREVENT)) {
2010 + if (fb_blank(info, blank)) {
2011 + if (fbcon_decor_active(info, vc))
2012 + fbcon_decor_blank(vc, info, blank);
2013 + else
2014 + fbcon_generic_blank(vc, info, blank);
2015 + }
2016 + }
2017 }
2018
2019 if (!blank)
2020 @@ -2454,13 +2519,22 @@ static int fbcon_do_set_font(struct vc_d
2021 }
2022
2023 if (resize) {
2024 + /* reset wrap/pan */
2025 int cols, rows;
2026
2027 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
2028 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2029 +
2030 + info->var.xoffset = info->var.yoffset = p->yscroll = 0;
2031 + if (fbcon_decor_active(info, vc)) {
2032 + cols = vc->vc_decor.twidth;
2033 + rows = vc->vc_decor.theight;
2034 + }
2035 cols /= w;
2036 rows /= h;
2037 +
2038 vc_resize(vc, cols, rows);
2039 +
2040 if (CON_IS_VISIBLE(vc) && softback_buf)
2041 fbcon_update_softback(vc);
2042 } else if (CON_IS_VISIBLE(vc)
2043 @@ -2589,7 +2663,7 @@ static int fbcon_set_palette(struct vc_d
2044 int i, j, k, depth;
2045 u8 val;
2046
2047 - if (fbcon_is_inactive(vc, info))
2048 + if (fbcon_is_inactive(vc, info) || vc->vc_num != fg_console)
2049 return -EINVAL;
2050
2051 if (!CON_IS_VISIBLE(vc))
2052 @@ -2615,7 +2689,49 @@ static int fbcon_set_palette(struct vc_d
2053 } else
2054 fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap);
2055
2056 - return fb_set_cmap(&palette_cmap, info);
2057 + if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
2058 + info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
2059 +
2060 + u16 *red, *green, *blue;
2061 + int minlen = min(min(info->var.red.length, info->var.green.length),
2062 + info->var.blue.length);
2063 + int h;
2064 +
2065 + struct fb_cmap cmap = {
2066 + .start = 0,
2067 + .len = (1 << minlen),
2068 + .red = NULL,
2069 + .green = NULL,
2070 + .blue = NULL,
2071 + .transp = NULL
2072 + };
2073 +
2074 + red = kmalloc(256 * sizeof(u16) * 3, GFP_KERNEL);
2075 +
2076 + if (!red)
2077 + goto out;
2078 +
2079 + green = red + 256;
2080 + blue = green + 256;
2081 + cmap.red = red;
2082 + cmap.green = green;
2083 + cmap.blue = blue;
2084 +
2085 + for (i = 0; i < cmap.len; i++) {
2086 + red[i] = green[i] = blue[i] = (0xffff * i)/(cmap.len-1);
2087 + }
2088 +
2089 + h = fb_set_cmap(&cmap, info);
2090 + fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
2091 + kfree(red);
2092 +
2093 + return h;
2094 +
2095 + } else if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
2096 + info->var.bits_per_pixel == 8 && info->bgdecor.cmap.red != NULL)
2097 + fb_set_cmap(&info->bgdecor.cmap, info);
2098 +
2099 +out: return fb_set_cmap(&palette_cmap, info);
2100 }
2101
2102 static u16 *fbcon_screen_pos(struct vc_data *vc, int offset)
2103 @@ -2841,7 +2957,18 @@ static void fbcon_modechanged(struct fb_
2104 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2105 cols /= vc->vc_font.width;
2106 rows /= vc->vc_font.height;
2107 - vc_resize(vc, cols, rows);
2108 +
2109 + if (!fbcon_decor_active_nores(info, vc)) {
2110 + vc_resize(vc, cols, rows);
2111 + } else {
2112 + /* HACK: Do this properly at some point.. */
2113 + unlock_fb_info(info);
2114 + int res = fbcon_decor_call_helper("modechange", vc->vc_num);
2115 + lock_fb_info(info);
2116 + if (res)
2117 + fbcon_decor_disable(vc, 0);
2118 + }
2119 +
2120 updatescrollmode(p, info, vc);
2121 scrollback_max = 0;
2122 scrollback_current = 0;
2123 @@ -3475,6 +3602,7 @@ static void fbcon_exit(void)
2124 }
2125 }
2126
2127 + fbcon_decor_exit();
2128 fbcon_has_exited = 1;
2129 }
2130

  ViewVC Help
Powered by ViewVC 1.1.20