Magellan Linux

Annotation of /trunk/kernel26-mcore/patches-2.6.37-r3/0150-2.6.37-fbcondecor-0.9.6.patch

Parent Directory Parent Directory | Revision Log Revision Log


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