]> git.pld-linux.org Git - packages/kernel.git/blob - kernel-fbcondecor.patch
Up to 5.15.26 (fixes SECURITY issue https://dirtypipe.cm4all.com/ - fixed in .25)
[packages/kernel.git] / kernel-fbcondecor.patch
1 diff -Naurp -x .git /tmp/linux/Documentation/fb/00-INDEX ./Documentation/fb/00-INDEX
2 --- /tmp/linux/Documentation/fb/00-INDEX        2008-03-25 07:24:16.000000000 +0100
3 +++ ./Documentation/fb/00-INDEX 2008-03-25 23:04:10.000000000 +0100
4 @@ -17,6 +17,8 @@ deferred_io.txt
5         - an introduction to deferred IO.
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  imacfb.txt
13 diff -Naurp -x .git /tmp/linux/Documentation/fb/fbcondecor.txt ./Documentation/fb/fbcondecor.txt
14 --- /tmp/linux/Documentation/fb/fbcondecor.txt  1970-01-01 01:00:00.000000000 +0100
15 +++ ./Documentation/fb/fbcondecor.txt   2008-03-25 23:04:10.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 -Naurp -x .git /tmp/linux/drivers/Makefile ./drivers/Makefile
225 --- /tmp/linux/drivers/Makefile 2008-03-25 07:24:16.000000000 +0100
226 +++ ./drivers/Makefile  2008-03-25 23:04:10.000000000 +0100
227 @@ -9,6 +9,9 @@ obj-$(CONFIG_HAVE_GPIO_LIB)     += gpio/
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                          += char/
234  obj-y                          += video/
235  obj-$(CONFIG_ACPI)             += acpi/
236  # PnP must come after ACPI since it will eventually need to check if acpi
237 @@ -18,10 +21,6 @@ obj-$(CONFIG_ARM_AMBA)               += amba/
238  
239  obj-$(CONFIG_XEN)              += xen/
240  
241 -# char/ comes before serial/ etc so that the VT console is the boot-time
242 -# default.
243 -obj-y                          += char/
244 -
245  obj-$(CONFIG_CONNECTOR)                += connector/
246  
247  # i810fb and intelfb depend on char/agp/
248 diff -Naurp -x .git /tmp/linux/drivers/video/console/bitblit.c ./drivers/video/console/bitblit.c
249 --- /tmp/linux/drivers/video/console/bitblit.c  2008-03-25 07:24:16.000000000 +0100
250 +++ ./drivers/video/console/bitblit.c   2008-03-25 23:04:10.000000000 +0100
251 @@ -17,6 +17,7 @@
252  #include <linux/console.h>
253  #include <asm/types.h>
254  #include "fbcon.h"
255 +#include "fbcondecor.h"
256  
257  /*
258   * Accelerated handlers.
259 @@ -54,6 +55,13 @@ static void bit_bmove(struct vc_data *vc
260         area.height = height * vc->vc_font.height;
261         area.width = width * vc->vc_font.width;
262  
263 +       if (fbcon_decor_active(info, vc)) {
264 +               area.sx += vc->vc_decor.tx;
265 +               area.sy += vc->vc_decor.ty;
266 +               area.dx += vc->vc_decor.tx;
267 +               area.dy += vc->vc_decor.ty;
268 +       }
269 +
270         info->fbops->fb_copyarea(info, &area);
271  }
272  
273 @@ -379,11 +387,15 @@ static void bit_cursor(struct vc_data *v
274         cursor.image.depth = 1;
275         cursor.rop = ROP_XOR;
276  
277 -       if (info->fbops->fb_cursor)
278 -               err = info->fbops->fb_cursor(info, &cursor);
279 +       if (fbcon_decor_active(info, vc)) {
280 +               fbcon_decor_cursor(info, &cursor);
281 +       } else {
282 +               if (info->fbops->fb_cursor)
283 +                       err = info->fbops->fb_cursor(info, &cursor);
284  
285 -       if (err)
286 -               soft_cursor(info, &cursor);
287 +               if (err)
288 +                       soft_cursor(info, &cursor);
289 +       }
290  
291         ops->cursor_reset = 0;
292  }
293 diff -Naurp -x .git /tmp/linux/drivers/video/console/cfbcondecor.c ./drivers/video/console/cfbcondecor.c
294 --- /tmp/linux/drivers/video/console/cfbcondecor.c      1970-01-01 01:00:00.000000000 +0100
295 +++ ./drivers/video/console/cfbcondecor.c       2008-03-25 23:11:30.000000000 +0100
296 @@ -0,0 +1,471 @@
297 +/*
298 + *  linux/drivers/video/cfbcon_decor.c -- Framebuffer decor render functions
299 + *
300 + *  Copyright (C) 2004 Michal Januszewski <spock@gentoo.org>
301 + *
302 + *  Code based upon "Bootdecor" (C) 2001-2003
303 + *       Volker Poplawski <volker@poplawski.de>,
304 + *       Stefan Reinauer <stepan@suse.de>,
305 + *       Steffen Winterfeldt <snwint@suse.de>,
306 + *       Michael Schroeder <mls@suse.de>,
307 + *       Ken Wimer <wimer@suse.de>.
308 + *
309 + *  This file is subject to the terms and conditions of the GNU General Public
310 + *  License.  See the file COPYING in the main directory of this archive for
311 + *  more details.
312 + */
313 +#include <linux/module.h>
314 +#include <linux/types.h>
315 +#include <linux/fb.h>
316 +#include <linux/selection.h>
317 +#include <linux/vt_kern.h>
318 +#include <asm/irq.h>
319 +#include <asm/system.h>
320 +
321 +#include "fbcon.h"
322 +#include "fbcondecor.h"
323 +
324 +#define parse_pixel(shift,bpp,type)                                            \
325 +       do {                                                                    \
326 +               if (d & (0x80 >> (shift)))                                      \
327 +                       dd2[(shift)] = fgx;                                     \
328 +               else                                                            \
329 +                       dd2[(shift)] = transparent ? *(type *)decor_src : bgx;  \
330 +               decor_src += (bpp);                                             \
331 +       } while (0)                                                             \
332 +
333 +extern int get_color(struct vc_data *vc, struct fb_info *info,
334 +                    u16 c, int is_fg);
335 +
336 +void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc)
337 +{
338 +       int i, j, k;
339 +       int minlen = min(min(info->var.red.length, info->var.green.length),
340 +                            info->var.blue.length);
341 +       u32 col;
342 +
343 +       for (j = i = 0; i < 16; i++) {
344 +               k = color_table[i];
345 +
346 +               col = ((vc->vc_palette[j++]  >> (8-minlen))
347 +                       << info->var.red.offset);
348 +               col |= ((vc->vc_palette[j++] >> (8-minlen))
349 +                       << info->var.green.offset);
350 +               col |= ((vc->vc_palette[j++] >> (8-minlen))
351 +                       << info->var.blue.offset);
352 +                       ((u32 *)info->pseudo_palette)[k] = col;
353 +       }
354 +}
355 +
356 +void fbcon_decor_renderc(struct fb_info *info, int ypos, int xpos, int height,
357 +                     int width, u8* src, u32 fgx, u32 bgx, u8 transparent)
358 +{
359 +       unsigned int x, y;
360 +       u32 dd;
361 +       int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
362 +       unsigned int d = ypos * info->fix.line_length + xpos * bytespp;
363 +       unsigned int ds = (ypos * info->var.xres + xpos) * bytespp;
364 +       u16 dd2[4];
365 +
366 +       u8* decor_src = (u8 *)(info->bgdecor.data + ds);
367 +       u8* dst = (u8 *)(info->screen_base + d);
368 +
369 +       if ((ypos + height) > info->var.yres || (xpos + width) > info->var.xres)
370 +               return;
371 +
372 +       for (y = 0; y < height; y++) {
373 +               switch (info->var.bits_per_pixel) {
374 +
375 +               case 32:
376 +                       for (x = 0; x < width; x++) {
377 +
378 +                               if ((x & 7) == 0)
379 +                                       d = *src++;
380 +                               if (d & 0x80)
381 +                                       dd = fgx;
382 +                               else
383 +                                       dd = transparent ?
384 +                                            *(u32 *)decor_src : bgx;
385 +
386 +                               d <<= 1;
387 +                               decor_src += 4;
388 +                               fb_writel(dd, dst);
389 +                               dst += 4;
390 +                       }
391 +                       break;
392 +               case 24:
393 +                       for (x = 0; x < width; x++) {
394 +
395 +                               if ((x & 7) == 0)
396 +                                       d = *src++;
397 +                               if (d & 0x80)
398 +                                       dd = fgx;
399 +                               else
400 +                                       dd = transparent ?
401 +                                            (*(u32 *)decor_src & 0xffffff) : bgx;
402 +
403 +                               d <<= 1;
404 +                               decor_src += 3;
405 +#ifdef __LITTLE_ENDIAN
406 +                               fb_writew(dd & 0xffff, dst);
407 +                               dst += 2;
408 +                               fb_writeb((dd >> 16), dst);
409 +#else
410 +                               fb_writew(dd >> 8, dst);
411 +                               dst += 2;
412 +                               fb_writeb(dd & 0xff, dst);
413 +#endif
414 +                               dst++;
415 +                       }
416 +                       break;
417 +               case 16:
418 +                       for (x = 0; x < width; x += 2) {
419 +                               if ((x & 7) == 0)
420 +                                       d = *src++;
421 +
422 +                               parse_pixel(0, 2, u16);
423 +                               parse_pixel(1, 2, u16);
424 +#ifdef __LITTLE_ENDIAN
425 +                               dd = dd2[0] | (dd2[1] << 16);
426 +#else
427 +                               dd = dd2[1] | (dd2[0] << 16);
428 +#endif
429 +                               d <<= 2;
430 +                               fb_writel(dd, dst);
431 +                               dst += 4;
432 +                       }
433 +                       break;
434 +
435 +               case 8:
436 +                       for (x = 0; x < width; x += 4) {
437 +                               if ((x & 7) == 0)
438 +                                       d = *src++;
439 +
440 +                               parse_pixel(0, 1, u8);
441 +                               parse_pixel(1, 1, u8);
442 +                               parse_pixel(2, 1, u8);
443 +                               parse_pixel(3, 1, u8);
444 +
445 +#ifdef __LITTLE_ENDIAN
446 +                               dd = dd2[0] | (dd2[1] << 8) | (dd2[2] << 16) | (dd2[3] << 24);
447 +#else
448 +                               dd = dd2[3] | (dd2[2] << 8) | (dd2[1] << 16) | (dd2[0] << 24);
449 +#endif
450 +                               d <<= 4;
451 +                               fb_writel(dd, dst);
452 +                               dst += 4;
453 +                       }
454 +               }
455 +
456 +               dst += info->fix.line_length - width * bytespp;
457 +               decor_src += (info->var.xres - width) * bytespp;
458 +       }
459 +}
460 +
461 +#define cc2cx(a)                                               \
462 +       ((info->fix.visual == FB_VISUAL_TRUECOLOR ||            \
463 +         info->fix.visual == FB_VISUAL_DIRECTCOLOR) ?          \
464 +        ((u32*)info->pseudo_palette)[a] : a)
465 +
466 +void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info,
467 +                  const unsigned short *s, int count, int yy, int xx)
468 +{
469 +       unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
470 +       struct fbcon_ops *ops = info->fbcon_par;
471 +       int fg_color, bg_color, transparent;
472 +       u8 *src;
473 +       u32 bgx, fgx;
474 +       u16 c = scr_readw(s);
475 +
476 +       fg_color = get_color(vc, info, c, 1);
477 +        bg_color = get_color(vc, info, c, 0);
478 +
479 +       /* Don't paint the background image if console is blanked */
480 +       transparent = ops->blank_state ? 0 :
481 +               (vc->vc_decor.bg_color == bg_color);
482 +
483 +       xx = xx * vc->vc_font.width + vc->vc_decor.tx;
484 +       yy = yy * vc->vc_font.height + vc->vc_decor.ty;
485 +
486 +       fgx = cc2cx(fg_color);
487 +       bgx = cc2cx(bg_color);
488 +
489 +       while (count--) {
490 +               c = scr_readw(s++);
491 +               src = vc->vc_font.data + (c & charmask) * vc->vc_font.height *
492 +                     ((vc->vc_font.width + 7) >> 3);
493 +
494 +               fbcon_decor_renderc(info, yy, xx, vc->vc_font.height,
495 +                              vc->vc_font.width, src, fgx, bgx, transparent);
496 +               xx += vc->vc_font.width;
497 +       }
498 +}
499 +
500 +void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor)
501 +{
502 +       int i;
503 +       unsigned int dsize, s_pitch;
504 +       struct fbcon_ops *ops = info->fbcon_par;
505 +       struct vc_data* vc;
506 +       u8 *src;
507 +
508 +       /* we really don't need any cursors while the console is blanked */
509 +       if (info->state != FBINFO_STATE_RUNNING || ops->blank_state)
510 +               return;
511 +
512 +       vc = vc_cons[ops->currcon].d;
513 +
514 +       src = kmalloc(64 + sizeof(struct fb_image), GFP_ATOMIC);
515 +       if (!src)
516 +               return;
517 +
518 +       s_pitch = (cursor->image.width + 7) >> 3;
519 +       dsize = s_pitch * cursor->image.height;
520 +       if (cursor->enable) {
521 +               switch (cursor->rop) {
522 +               case ROP_XOR:
523 +                       for (i = 0; i < dsize; i++)
524 +                               src[i] = cursor->image.data[i] ^ cursor->mask[i];
525 +                        break;
526 +               case ROP_COPY:
527 +               default:
528 +                       for (i = 0; i < dsize; i++)
529 +                               src[i] = cursor->image.data[i] & cursor->mask[i];
530 +                       break;
531 +               }
532 +       } else
533 +               memcpy(src, cursor->image.data, dsize);
534 +
535 +       fbcon_decor_renderc(info,
536 +                       cursor->image.dy + vc->vc_decor.ty,
537 +                       cursor->image.dx + vc->vc_decor.tx,
538 +                       cursor->image.height,
539 +                       cursor->image.width,
540 +                       (u8*)src,
541 +                       cc2cx(cursor->image.fg_color),
542 +                       cc2cx(cursor->image.bg_color),
543 +                       cursor->image.bg_color == vc->vc_decor.bg_color);
544 +
545 +       kfree(src);
546 +}
547 +
548 +static void decorset(u8 *dst, int height, int width, int dstbytes,
549 +                       u32 bgx, int bpp)
550 +{
551 +       int i;
552 +
553 +       if (bpp == 8)
554 +               bgx |= bgx << 8;
555 +       if (bpp == 16 || bpp == 8)
556 +               bgx |= bgx << 16;
557 +
558 +       while (height-- > 0) {
559 +               u8 *p = dst;
560 +
561 +               switch (bpp) {
562 +
563 +               case 32:
564 +                       for (i=0; i < width; i++) {
565 +                               fb_writel(bgx, p); p += 4;
566 +                       }
567 +                       break;
568 +               case 24:
569 +                       for (i=0; i < width; i++) {
570 +#ifdef __LITTLE_ENDIAN
571 +                               fb_writew((bgx & 0xffff),(u16*)p); p += 2;
572 +                               fb_writeb((bgx >> 16),p++);
573 +#else
574 +                               fb_writew((bgx >> 8),(u16*)p); p += 2;
575 +                               fb_writeb((bgx & 0xff),p++);
576 +#endif
577 +                       }
578 +               case 16:
579 +                       for (i=0; i < width/4; i++) {
580 +                               fb_writel(bgx,p); p += 4;
581 +                               fb_writel(bgx,p); p += 4;
582 +                       }
583 +                       if (width & 2) {
584 +                               fb_writel(bgx,p); p += 4;
585 +                       }
586 +                       if (width & 1)
587 +                               fb_writew(bgx,(u16*)p);
588 +                       break;
589 +               case 8:
590 +                       for (i=0; i < width/4; i++) {
591 +                               fb_writel(bgx,p); p += 4;
592 +                       }
593 +
594 +                       if (width & 2) {
595 +                               fb_writew(bgx,p); p += 2;
596 +                       }
597 +                       if (width & 1)
598 +                               fb_writeb(bgx,(u8*)p);
599 +                       break;
600 +
601 +               }
602 +               dst += dstbytes;
603 +       }
604 +}
605 +
606 +void fbcon_decor_copy(u8 *dst, u8 *src, int height, int width, int linebytes,
607 +                  int srclinebytes, int bpp)
608 +{
609 +       int i;
610 +
611 +       while (height-- > 0) {
612 +               u32 *p = (u32 *)dst;
613 +               u32 *q = (u32 *)src;
614 +
615 +               switch (bpp) {
616 +
617 +               case 32:
618 +                       for (i=0; i < width; i++)
619 +                               fb_writel(*q++, p++);
620 +                       break;
621 +               case 24:
622 +                       for (i=0; i < (width*3/4); i++)
623 +                               fb_writel(*q++, p++);
624 +                       if ((width*3) % 4) {
625 +                               if (width & 2) {
626 +                                       fb_writeb(*(u8*)q, (u8*)p);
627 +                               } else if (width & 1) {
628 +                                       fb_writew(*(u16*)q, (u16*)p);
629 +                                       fb_writeb(*(u8*)((u16*)q+1),(u8*)((u16*)p+2));
630 +                               }
631 +                       }
632 +                       break;
633 +               case 16:
634 +                       for (i=0; i < width/4; i++) {
635 +                               fb_writel(*q++, p++);
636 +                               fb_writel(*q++, p++);
637 +                       }
638 +                       if (width & 2)
639 +                               fb_writel(*q++, p++);
640 +                       if (width & 1)
641 +                               fb_writew(*(u16*)q, (u16*)p);
642 +                       break;
643 +               case 8:
644 +                       for (i=0; i < width/4; i++)
645 +                               fb_writel(*q++, p++);
646 +
647 +                       if (width & 2) {
648 +                               fb_writew(*(u16*)q, (u16*)p);
649 +                               q = (u32*) ((u16*)q + 1);
650 +                               p = (u32*) ((u16*)p + 1);
651 +                       }
652 +                       if (width & 1)
653 +                               fb_writeb(*(u8*)q, (u8*)p);
654 +                       break;
655 +               }
656 +
657 +               dst += linebytes;
658 +               src += srclinebytes;
659 +       }
660 +}
661 +
662 +static void decorfill(struct fb_info *info, int sy, int sx, int height,
663 +                      int width)
664 +{
665 +       int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
666 +       int d  = sy * info->fix.line_length + sx * bytespp;
667 +       int ds = (sy * info->var.xres + sx) * bytespp;
668 +
669 +       fbcon_decor_copy((u8 *)(info->screen_base + d), (u8 *)(info->bgdecor.data + ds),
670 +                   height, width, info->fix.line_length, info->var.xres * bytespp,
671 +                   info->var.bits_per_pixel);
672 +}
673 +
674 +void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx,
675 +                   int height, int width)
676 +{
677 +       int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
678 +       struct fbcon_ops *ops = info->fbcon_par;
679 +       u8 *dst;
680 +       int transparent, bg_color = attr_bgcol_ec(bgshift, vc, info);
681 +
682 +       transparent = (vc->vc_decor.bg_color == bg_color);
683 +       sy = sy * vc->vc_font.height + vc->vc_decor.ty;
684 +       sx = sx * vc->vc_font.width + vc->vc_decor.tx;
685 +       height *= vc->vc_font.height;
686 +       width *= vc->vc_font.width;
687 +
688 +       /* Don't paint the background image if console is blanked */
689 +       if (transparent && !ops->blank_state) {
690 +               decorfill(info, sy, sx, height, width);
691 +       } else {
692 +               dst = (u8 *)(info->screen_base + sy * info->fix.line_length +
693 +                            sx * ((info->var.bits_per_pixel + 7) >> 3));
694 +               decorset(dst, height, width, info->fix.line_length, cc2cx(bg_color),
695 +                         info->var.bits_per_pixel);
696 +       }
697 +}
698 +
699 +void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info,
700 +                           int bottom_only)
701 +{
702 +       unsigned int tw = vc->vc_cols*vc->vc_font.width;
703 +       unsigned int th = vc->vc_rows*vc->vc_font.height;
704 +
705 +       if (!bottom_only) {
706 +               /* top margin */
707 +               decorfill(info, 0, 0, vc->vc_decor.ty, info->var.xres);
708 +               /* left margin */
709 +               decorfill(info, vc->vc_decor.ty, 0, th, vc->vc_decor.tx);
710 +               /* right margin */
711 +               decorfill(info, vc->vc_decor.ty, vc->vc_decor.tx + tw, th, 
712 +                          info->var.xres - vc->vc_decor.tx - tw);
713 +       }
714 +       decorfill(info, vc->vc_decor.ty + th, 0, 
715 +                  info->var.yres - vc->vc_decor.ty - th, info->var.xres);
716 +}
717 +
718 +void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, 
719 +                          int sx, int dx, int width)
720 +{
721 +       u16 *d = (u16 *) (vc->vc_origin + vc->vc_size_row * y + dx * 2);
722 +       u16 *s = d + (dx - sx);
723 +       u16 *start = d;
724 +       u16 *ls = d;
725 +       u16 *le = d + width;
726 +       u16 c;
727 +       int x = dx;
728 +       u16 attr = 1;
729 +
730 +       do {
731 +               c = scr_readw(d);
732 +               if (attr != (c & 0xff00)) {
733 +                       attr = c & 0xff00;
734 +                       if (d > start) {
735 +                               fbcon_decor_putcs(vc, info, start, d - start, y, x);
736 +                               x += d - start;
737 +                               start = d;
738 +                       }
739 +               }
740 +               if (s >= ls && s < le && c == scr_readw(s)) {
741 +                       if (d > start) {
742 +                               fbcon_decor_putcs(vc, info, start, d - start, y, x);
743 +                               x += d - start + 1;
744 +                               start = d + 1;
745 +                       } else {
746 +                               x++;
747 +                               start++;
748 +                       }
749 +               }
750 +               s++;
751 +               d++;
752 +       } while (d < le);
753 +       if (d > start)
754 +               fbcon_decor_putcs(vc, info, start, d - start, y, x);
755 +}
756 +
757 +void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank)
758 +{
759 +       if (blank) {
760 +               decorset((u8 *)info->screen_base, info->var.yres, info->var.xres,
761 +                         info->fix.line_length, 0, info->var.bits_per_pixel);
762 +       } else {
763 +               update_screen(vc);
764 +               fbcon_decor_clear_margins(vc, info, 0);
765 +       }
766 +}
767 +
768 diff -Naurp -x .git /tmp/linux/drivers/video/console/fbcon.c ./drivers/video/console/fbcon.c
769 --- /tmp/linux/drivers/video/console/fbcon.c    2008-03-25 07:24:16.000000000 +0100
770 +++ ./drivers/video/console/fbcon.c     2008-03-25 23:04:10.000000000 +0100
771 @@ -90,6 +90,7 @@
772  #endif
773  
774  #include "fbcon.h"
775 +#include "fbcondecor.h"
776  
777  #ifdef FBCONDEBUG
778  #  define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
779 @@ -105,7 +106,7 @@ enum {
780  
781  static struct display fb_display[MAX_NR_CONSOLES];
782  
783 -static signed char con2fb_map[MAX_NR_CONSOLES];
784 +signed char con2fb_map[MAX_NR_CONSOLES];
785  static signed char con2fb_map_boot[MAX_NR_CONSOLES];
786  #ifndef MODULE
787  static int logo_height;
788 @@ -315,7 +316,7 @@ static inline int fbcon_is_inactive(stru
789                 vc->vc_mode != KD_TEXT || ops->graphics);
790  }
791  
792 -static inline int get_color(struct vc_data *vc, struct fb_info *info,
793 +inline int get_color(struct vc_data *vc, struct fb_info *info,
794               u16 c, int is_fg)
795  {
796         int depth = fb_get_color_depth(&info->var, &info->fix);
797 @@ -420,6 +421,7 @@ static void fb_flashcursor(struct work_s
798                 CM_ERASE : CM_DRAW;
799         ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1),
800                     get_color(vc, info, c, 0));
801 +       
802         release_console_sem();
803  }
804  
805 @@ -590,6 +592,8 @@ static int fbcon_takeover(int show_logo)
806                 info_idx = -1;
807         }
808  
809 +       fbcon_decor_init();
810 +
811         return err;
812  }
813  
814 @@ -1031,6 +1035,12 @@ static const char *fbcon_startup(void)
815         rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
816         cols /= vc->vc_font.width;
817         rows /= vc->vc_font.height;
818 +
819 +       if (fbcon_decor_active(info, vc)) {
820 +               cols = vc->vc_decor.twidth / vc->vc_font.width;
821 +               rows = vc->vc_decor.theight / vc->vc_font.height;
822 +       }
823 +
824         vc_resize(vc, cols, rows);
825  
826         DPRINTK("mode:   %s\n", info->fix.id);
827 @@ -1114,7 +1124,7 @@ static void fbcon_init(struct vc_data *v
828         cap = info->flags;
829  
830         if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
831 -           (info->fix.type == FB_TYPE_TEXT))
832 +           (info->fix.type == FB_TYPE_TEXT) || fbcon_decor_active(info, vc))
833                 logo = 0;
834  
835         if (var_to_display(p, &info->var, info))
836 @@ -1313,6 +1323,11 @@ static void fbcon_clear(struct vc_data *
837         if (!height || !width)
838                 return;
839  
840 +       if (fbcon_decor_active(info, vc)) {
841 +               fbcon_decor_clear(vc, info, sy, sx, height, width);
842 +               return;
843 +       }
844 +       
845         /* Split blits that cross physical y_wrap boundary */
846  
847         y_break = p->vrows - p->yscroll;
848 @@ -1332,10 +1347,15 @@ static void fbcon_putcs(struct vc_data *
849         struct display *p = &fb_display[vc->vc_num];
850         struct fbcon_ops *ops = info->fbcon_par;
851  
852 -       if (!fbcon_is_inactive(vc, info))
853 -               ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
854 -                          get_color(vc, info, scr_readw(s), 1),
855 -                          get_color(vc, info, scr_readw(s), 0));
856 +       if (!fbcon_is_inactive(vc, info)) {
857 +               
858 +               if (fbcon_decor_active(info, vc))
859 +                       fbcon_decor_putcs(vc, info, s, count, ypos, xpos);
860 +               else
861 +                       ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
862 +                                  get_color(vc, info, scr_readw(s), 1),
863 +                                  get_color(vc, info, scr_readw(s), 0));
864 +       }
865  }
866  
867  static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
868 @@ -1351,8 +1371,13 @@ static void fbcon_clear_margins(struct v
869         struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
870         struct fbcon_ops *ops = info->fbcon_par;
871  
872 -       if (!fbcon_is_inactive(vc, info))
873 -               ops->clear_margins(vc, info, bottom_only);
874 +       if (!fbcon_is_inactive(vc, info)) {
875 +               if (fbcon_decor_active(info, vc)) {
876 +                       fbcon_decor_clear_margins(vc, info, bottom_only);
877 +               } else {
878 +                       ops->clear_margins(vc, info, bottom_only);
879 +               }
880 +       }
881  }
882  
883  static void fbcon_cursor(struct vc_data *vc, int mode)
884 @@ -1872,7 +1897,7 @@ static int fbcon_scroll(struct vc_data *
885                         count = vc->vc_rows;
886                 if (softback_top)
887                         fbcon_softback_note(vc, t, count);
888 -               if (logo_shown >= 0)
889 +               if (logo_shown >= 0 || fbcon_decor_active(info, vc))
890                         goto redraw_up;
891                 switch (p->scrollmode) {
892                 case SCROLL_MOVE:
893 @@ -1965,6 +1990,8 @@ static int fbcon_scroll(struct vc_data *
894                         count = vc->vc_rows;
895                 if (logo_shown >= 0)
896                         goto redraw_down;
897 +               if (fbcon_decor_active(info, vc))
898 +                       goto redraw_down;
899                 switch (p->scrollmode) {
900                 case SCROLL_MOVE:
901                         fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
902 @@ -2113,6 +2140,13 @@ static void fbcon_bmove_rec(struct vc_da
903                 }
904                 return;
905         }
906 +
907 +       if (fbcon_decor_active(info, vc) && sy == dy && height == 1) {
908 +               /* must use slower redraw bmove to keep background pic intact */
909 +               fbcon_decor_bmove_redraw(vc, info, sy, sx, dx, width);
910 +               return;
911 +       }
912 +       
913         ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
914                    height, width);
915  }
916 @@ -2183,8 +2217,8 @@ static int fbcon_resize(struct vc_data *
917         var.yres = virt_h * virt_fh;
918         x_diff = info->var.xres - var.xres;
919         y_diff = info->var.yres - var.yres;
920 -       if (x_diff < 0 || x_diff > virt_fw ||
921 -           y_diff < 0 || y_diff > virt_fh) {
922 +       if ((x_diff < 0 || x_diff > virt_fw ||
923 +               y_diff < 0 || y_diff > virt_fh) && !vc->vc_decor.state) {
924                 const struct fb_videomode *mode;
925  
926                 DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
927 @@ -2220,6 +2254,19 @@ static int fbcon_switch(struct vc_data *
928  
929         info = registered_fb[con2fb_map[vc->vc_num]];
930         ops = info->fbcon_par;
931 +       prev_console = ops->currcon;
932 +       if (prev_console != -1)
933 +               old_info = registered_fb[con2fb_map[prev_console]];
934 +
935 +       if (!fbcon_decor_active_vc(vc) && info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
936 +               struct vc_data *vc_curr = vc_cons[prev_console].d;
937 +               if (vc_curr && fbcon_decor_active_vc(vc_curr)) {
938 +                       /* Clear the screen to avoid displaying funky colors during
939 +                        * palette updates. */
940 +                       memset((u8*)info->screen_base + info->fix.line_length * info->var.yoffset,
941 +                              0, info->var.yres * info->fix.line_length);
942 +               }
943 +       }
944  
945         if (softback_top) {
946                 if (softback_lines)
947 @@ -2238,9 +2285,6 @@ static int fbcon_switch(struct vc_data *
948                 logo_shown = FBCON_LOGO_CANSHOW;
949         }
950  
951 -       prev_console = ops->currcon;
952 -       if (prev_console != -1)
953 -               old_info = registered_fb[con2fb_map[prev_console]];
954         /*
955          * FIXME: If we have multiple fbdev's loaded, we need to
956          * update all info->currcon.  Perhaps, we can place this
957 @@ -2280,6 +2324,18 @@ static int fbcon_switch(struct vc_data *
958                         fbcon_del_cursor_timer(old_info);
959         }
960  
961 +       if (fbcon_decor_active_vc(vc)) {
962 +               struct vc_data *vc_curr = vc_cons[prev_console].d;
963 +
964 +               if (!vc_curr->vc_decor.theme ||
965 +                       strcmp(vc->vc_decor.theme, vc_curr->vc_decor.theme) ||
966 +                       (fbcon_decor_active_nores(info, vc_curr) &&
967 +                        !fbcon_decor_active(info, vc_curr))) {
968 +                       if (fbcon_decor_call_helper("modechange", vc->vc_num))
969 +                               fbcon_decor_disable(vc, 0);
970 +               }
971 +       }
972 +
973         if (fbcon_is_inactive(vc, info) ||
974             ops->blank_state != FB_BLANK_UNBLANK)
975                 fbcon_del_cursor_timer(info);
976 @@ -2394,8 +2450,12 @@ static int fbcon_blank(struct vc_data *v
977                         fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
978                         ops->cursor_flash = (!blank);
979  
980 -                       if (fb_blank(info, blank))
981 -                               fbcon_generic_blank(vc, info, blank);
982 +                       if (fb_blank(info, blank)) {
983 +                               if (fbcon_decor_active(info, vc))
984 +                                       fbcon_decor_blank(vc, info, blank);
985 +                               else 
986 +                                       fbcon_generic_blank(vc, info, blank);
987 +                       }
988                 }
989  
990                 if (!blank)
991 @@ -2546,13 +2606,22 @@ static int fbcon_do_set_font(struct vc_d
992         }
993  
994         if (resize) {
995 +               /* reset wrap/pan */
996                 int cols, rows;
997  
998                 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
999                 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1000 +
1001 +               info->var.xoffset = info->var.yoffset = p->yscroll = 0;
1002 +               if (fbcon_decor_active(info, vc)) {
1003 +                       cols = vc->vc_decor.twidth;
1004 +                       rows = vc->vc_decor.theight;
1005 +               }
1006                 cols /= w;
1007                 rows /= h;
1008 +
1009                 vc_resize(vc, cols, rows);
1010 +
1011                 if (CON_IS_VISIBLE(vc) && softback_buf)
1012                         fbcon_update_softback(vc);
1013         } else if (CON_IS_VISIBLE(vc)
1014 @@ -2681,7 +2750,7 @@ static int fbcon_set_palette(struct vc_d
1015         int i, j, k, depth;
1016         u8 val;
1017  
1018 -       if (fbcon_is_inactive(vc, info))
1019 +       if (fbcon_is_inactive(vc, info) || vc->vc_num != fg_console)
1020                 return -EINVAL;
1021  
1022         if (!CON_IS_VISIBLE(vc))
1023 @@ -2707,7 +2776,49 @@ static int fbcon_set_palette(struct vc_d
1024         } else
1025                 fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap);
1026  
1027 -       return fb_set_cmap(&palette_cmap, info);
1028 +       if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
1029 +           info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
1030 +
1031 +               u16 *red, *green, *blue;
1032 +               int minlen = min(min(info->var.red.length, info->var.green.length), 
1033 +                                    info->var.blue.length);
1034 +               int h;
1035 +
1036 +               struct fb_cmap cmap = {
1037 +                       .start = 0,
1038 +                       .len = (1 << minlen),
1039 +                       .red = NULL,
1040 +                       .green = NULL,
1041 +                       .blue = NULL,
1042 +                       .transp = NULL
1043 +               };
1044 +
1045 +               red = kmalloc(256 * sizeof(u16) * 3, GFP_KERNEL);
1046 +       
1047 +               if (!red)
1048 +                       goto out;               
1049 +       
1050 +               green = red + 256;
1051 +               blue = green + 256;
1052 +               cmap.red = red;
1053 +               cmap.green = green;
1054 +               cmap.blue = blue;
1055 +               
1056 +               for (i = 0; i < cmap.len; i++) {
1057 +                       red[i] = green[i] = blue[i] = (0xffff * i)/(cmap.len-1);
1058 +               }
1059 +
1060 +               h = fb_set_cmap(&cmap, info);
1061 +               fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
1062 +               kfree(red);
1063 +               
1064 +               return h;
1065 +               
1066 +       } else if (fbcon_decor_active(info, vc_cons[fg_console].d) && 
1067 +                  info->var.bits_per_pixel == 8 && info->bgdecor.cmap.red != NULL) 
1068 +               fb_set_cmap(&info->bgdecor.cmap, info);
1069 +               
1070 +out:   return fb_set_cmap(&palette_cmap, info);
1071  }
1072  
1073  static u16 *fbcon_screen_pos(struct vc_data *vc, int offset)
1074 @@ -2933,7 +3044,14 @@ static void fbcon_modechanged(struct fb_
1075                 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1076                 cols /= vc->vc_font.width;
1077                 rows /= vc->vc_font.height;
1078 -               vc_resize(vc, cols, rows);
1079 +                               
1080 +               if (!fbcon_decor_active_nores(info, vc)) {
1081 +                       vc_resize(vc, cols, rows);
1082 +               } else {
1083 +                       if (fbcon_decor_call_helper("modechange", vc->vc_num))
1084 +                               fbcon_decor_disable(vc, 0);
1085 +               }
1086 +
1087                 updatescrollmode(p, info, vc);
1088                 scrollback_max = 0;
1089                 scrollback_current = 0;
1090 @@ -3561,6 +3679,7 @@ static void fbcon_exit(void)
1091                 }
1092         }
1093  
1094 +       fbcon_decor_exit();
1095         fbcon_has_exited = 1;
1096  }
1097  
1098 diff -Naurp -x .git /tmp/linux/drivers/video/console/fbcondecor.c ./drivers/video/console/fbcondecor.c
1099 --- /tmp/linux/drivers/video/console/fbcondecor.c       1970-01-01 01:00:00.000000000 +0100
1100 +++ ./drivers/video/console/fbcondecor.c        2008-03-25 23:04:10.000000000 +0100
1101 @@ -0,0 +1,420 @@
1102 +/* 
1103 + *  linux/drivers/video/console/fbcondecor.c -- Framebuffer console decorations
1104 + *
1105 + *  Copyright (C) 2004 Michal Januszewski <spock@gentoo.org>
1106 + *
1107 + *  Code based upon "Bootsplash" (C) 2001-2003 
1108 + *       Volker Poplawski <volker@poplawski.de>,
1109 + *       Stefan Reinauer <stepan@suse.de>,
1110 + *       Steffen Winterfeldt <snwint@suse.de>,
1111 + *       Michael Schroeder <mls@suse.de>,
1112 + *       Ken Wimer <wimer@suse.de>.
1113 + * 
1114 + *  This file is subject to the terms and conditions of the GNU General Public
1115 + *  License.  See the file COPYING in the main directory of this archive for
1116 + *  more details.
1117 + * 
1118 + */
1119 +#include <linux/module.h>
1120 +#include <linux/kernel.h>
1121 +#include <linux/string.h>
1122 +#include <linux/types.h>
1123 +#include <linux/fb.h>
1124 +#include <linux/vt_kern.h>
1125 +#include <linux/vmalloc.h>
1126 +#include <linux/unistd.h>
1127 +#include <linux/syscalls.h>
1128 +#include <linux/init.h>
1129 +#include <linux/proc_fs.h>
1130 +#include <linux/workqueue.h>
1131 +#include <linux/kmod.h>
1132 +#include <linux/miscdevice.h>
1133 +#include <linux/device.h>
1134 +#include <linux/fs.h>
1135 +
1136 +#include <asm/uaccess.h>
1137 +#include <asm/irq.h>
1138 +#include <asm/system.h>
1139 +
1140 +#include "fbcon.h"
1141 +#include "fbcondecor.h"
1142 +
1143 +extern signed char con2fb_map[];
1144 +static int fbcon_decor_enable(struct vc_data *vc);
1145 +char fbcon_decor_path[KMOD_PATH_LEN] = "/sbin/fbcondecor_helper";
1146 +static int initialized = 0;
1147 +
1148 +int fbcon_decor_call_helper(char* cmd, unsigned short vc)
1149 +{
1150 +       char *envp[] = {
1151 +               "HOME=/",
1152 +               "PATH=/sbin:/bin",
1153 +               NULL
1154 +       };
1155 +
1156 +       char tfb[5];
1157 +       char tcons[5];
1158 +       unsigned char fb = (int) con2fb_map[vc];
1159 +
1160 +       char *argv[] = {
1161 +               fbcon_decor_path,
1162 +               "2",
1163 +               cmd,
1164 +               tcons,
1165 +               tfb,
1166 +               vc_cons[vc].d->vc_decor.theme,
1167 +               NULL
1168 +       };
1169 +
1170 +       snprintf(tfb,5,"%d",fb);
1171 +       snprintf(tcons,5,"%d",vc);
1172 +
1173 +       return call_usermodehelper(fbcon_decor_path, argv, envp, 1);
1174 +}
1175 +
1176 +/* Disables fbcondecor on a virtual console; called with console sem held. */
1177 +int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw)
1178 +{
1179 +       struct fb_info* info;
1180 +
1181 +       if (!vc->vc_decor.state)
1182 +               return -EINVAL;
1183 +
1184 +       info = registered_fb[(int) con2fb_map[vc->vc_num]];
1185 +
1186 +       if (info == NULL)
1187 +               return -EINVAL;
1188 +
1189 +       vc->vc_decor.state = 0; 
1190 +       vc_resize(vc, info->var.xres / vc->vc_font.width, 
1191 +                 info->var.yres / vc->vc_font.height);
1192 +
1193 +       if (fg_console == vc->vc_num && redraw) {
1194 +               redraw_screen(vc, 0);
1195 +               update_region(vc, vc->vc_origin + 
1196 +                             vc->vc_size_row * vc->vc_top, 
1197 +                             vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1198 +       }
1199 +
1200 +       printk(KERN_INFO "fbcondecor: switched decor state to 'off' on console %d\n", 
1201 +                        vc->vc_num);
1202 +
1203 +       return 0;
1204 +}
1205 +
1206 +/* Enables fbcondecor on a virtual console; called with console sem held. */
1207 +static int fbcon_decor_enable(struct vc_data *vc)
1208 +{
1209 +       struct fb_info* info;
1210 +
1211 +       info = registered_fb[(int) con2fb_map[vc->vc_num]];
1212 +               
1213 +       if (vc->vc_decor.twidth == 0 || vc->vc_decor.theight == 0 || 
1214 +           info == NULL || vc->vc_decor.state || (!info->bgdecor.data &&
1215 +           vc->vc_num == fg_console))
1216 +               return -EINVAL;
1217 +       
1218 +       vc->vc_decor.state = 1;
1219 +       vc_resize(vc, vc->vc_decor.twidth / vc->vc_font.width, 
1220 +                 vc->vc_decor.theight / vc->vc_font.height);
1221 +
1222 +       if (fg_console == vc->vc_num) {
1223 +               redraw_screen(vc, 0);
1224 +               update_region(vc, vc->vc_origin + 
1225 +                             vc->vc_size_row * vc->vc_top, 
1226 +                             vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1227 +               fbcon_decor_clear_margins(vc, info, 0);
1228 +       }
1229 +
1230 +       printk(KERN_INFO "fbcondecor: switched decor state to 'on' on console %d\n", 
1231 +                        vc->vc_num);
1232 +
1233 +       return 0;
1234 +}
1235 +
1236 +static inline int fbcon_decor_ioctl_dosetstate(struct vc_data *vc, unsigned int __user* state, unsigned char origin)
1237 +{
1238 +       int tmp, ret;
1239 +
1240 +       if (get_user(tmp, state))
1241 +               return -EFAULT;
1242 +
1243 +       if (origin == FBCON_DECOR_IO_ORIG_USER)
1244 +               acquire_console_sem();
1245 +       if (!tmp)
1246 +               ret = fbcon_decor_disable(vc, 1);
1247 +       else
1248 +               ret = fbcon_decor_enable(vc);
1249 +       if (origin == FBCON_DECOR_IO_ORIG_USER)
1250 +               release_console_sem();
1251 +
1252 +       return ret;
1253 +}
1254 +
1255 +static inline int fbcon_decor_ioctl_dogetstate(struct vc_data *vc, unsigned int __user *state)
1256 +{
1257 +       return put_user(vc->vc_decor.state, (unsigned int __user*) state);
1258 +}
1259 +
1260 +static int fbcon_decor_ioctl_dosetcfg(struct vc_data *vc, struct vc_decor __user *arg, unsigned char origin)
1261 +{
1262 +       struct vc_decor cfg;
1263 +       struct fb_info *info;
1264 +       int len;
1265 +       char *tmp;
1266 +       
1267 +       info = registered_fb[(int) con2fb_map[vc->vc_num]];
1268 +
1269 +       if (copy_from_user(&cfg, arg, sizeof(struct vc_decor)))
1270 +               return -EFAULT;
1271 +       if (info == NULL || !cfg.twidth || !cfg.theight || 
1272 +           cfg.tx + cfg.twidth  > info->var.xres ||
1273 +           cfg.ty + cfg.theight > info->var.yres)
1274 +               return -EINVAL;
1275 +
1276 +       len = strlen_user(cfg.theme);
1277 +       if (!len || len > FBCON_DECOR_THEME_LEN)
1278 +               return -EINVAL;
1279 +       tmp = kmalloc(len, GFP_KERNEL);
1280 +       if (!tmp)
1281 +               return -ENOMEM;
1282 +       if (copy_from_user(tmp, (void __user *)cfg.theme, len))
1283 +               return -EFAULT;
1284 +       cfg.theme = tmp;
1285 +       cfg.state = 0;
1286 +
1287 +       /* If this ioctl is a response to a request from kernel, the console sem
1288 +        * is already held; we also don't need to disable decor because either the
1289 +        * new config and background picture will be successfully loaded, and the 
1290 +        * decor will stay on, or in case of a failure it'll be turned off in fbcon. */
1291 +       if (origin == FBCON_DECOR_IO_ORIG_USER) {
1292 +               acquire_console_sem();
1293 +               if (vc->vc_decor.state)
1294 +                       fbcon_decor_disable(vc, 1);
1295 +       }
1296 +
1297 +       if (vc->vc_decor.theme)
1298 +               kfree(vc->vc_decor.theme);
1299 +
1300 +       vc->vc_decor = cfg;
1301 +
1302 +       if (origin == FBCON_DECOR_IO_ORIG_USER)
1303 +               release_console_sem();
1304 +
1305 +       printk(KERN_INFO "fbcondecor: console %d using theme '%s'\n", 
1306 +                        vc->vc_num, vc->vc_decor.theme);
1307 +       return 0;       
1308 +}
1309 +
1310 +static int fbcon_decor_ioctl_dogetcfg(struct vc_data *vc, struct vc_decor __user *arg)
1311 +{
1312 +       struct vc_decor decor;
1313 +       char __user *tmp;
1314 +
1315 +       if (get_user(tmp, &arg->theme))
1316 +               return -EFAULT;
1317 +       
1318 +       decor = vc->vc_decor;
1319 +       decor.theme = tmp;
1320 +
1321 +       if (vc->vc_decor.theme) {
1322 +               if (copy_to_user(tmp, vc->vc_decor.theme, strlen(vc->vc_decor.theme) + 1))
1323 +                       return -EFAULT;
1324 +       } else
1325 +               if (put_user(0, tmp))
1326 +                       return -EFAULT;
1327 +
1328 +       if (copy_to_user(arg, &decor, sizeof(struct vc_decor)))
1329 +               return -EFAULT;
1330 +
1331 +       return 0;
1332 +}
1333 +
1334 +static int fbcon_decor_ioctl_dosetpic(struct vc_data *vc, struct fb_image __user *arg, unsigned char origin)
1335 +{
1336 +       struct fb_image img;
1337 +       struct fb_info *info;
1338 +       int len;
1339 +       u8 *tmp;
1340 +       
1341 +       if (vc->vc_num != fg_console) 
1342 +               return -EINVAL;
1343 +
1344 +       info = registered_fb[(int) con2fb_map[vc->vc_num]];
1345 +       
1346 +       if (info == NULL)
1347 +               return -EINVAL;
1348 +       
1349 +       if (copy_from_user(&img, arg, sizeof(struct fb_image)))
1350 +               return -EFAULT;
1351 +       
1352 +       if (img.width != info->var.xres || img.height != info->var.yres) {
1353 +               printk(KERN_ERR "fbcondecor: picture dimensions mismatch\n");
1354 +               return -EINVAL;
1355 +       }
1356 +
1357 +       if (img.depth != info->var.bits_per_pixel) {
1358 +               printk(KERN_ERR "fbcondecor: picture depth mismatch\n");
1359 +               return -EINVAL;
1360 +       }
1361 +               
1362 +       if (img.depth == 8) {
1363 +               if (!img.cmap.len || !img.cmap.red || !img.cmap.green || 
1364 +                   !img.cmap.blue)
1365 +                       return -EINVAL;
1366 +               
1367 +               tmp = vmalloc(img.cmap.len * 3 * 2);
1368 +               if (!tmp)
1369 +                       return -ENOMEM;
1370 +
1371 +               if (copy_from_user(tmp, (void __user*)img.cmap.red, img.cmap.len * 2) ||
1372 +                   copy_from_user(tmp + (img.cmap.len << 1),
1373 +                                  (void __user*)img.cmap.green, (img.cmap.len << 1)) ||
1374 +                   copy_from_user(tmp + (img.cmap.len << 2),
1375 +                                  (void __user*)img.cmap.blue, (img.cmap.len << 1))) {
1376 +                       vfree(tmp);
1377 +                       return -EFAULT;
1378 +               }
1379 +                       
1380 +               img.cmap.transp = NULL;
1381 +               img.cmap.red = (u16*)tmp;
1382 +               img.cmap.green = img.cmap.red + img.cmap.len;
1383 +               img.cmap.blue = img.cmap.green + img.cmap.len;
1384 +       } else {
1385 +               img.cmap.red = NULL;
1386 +       }
1387 +               
1388 +       len = ((img.depth + 7) >> 3) * img.width * img.height;
1389 +       tmp = vmalloc(len);
1390 +
1391 +       if (!tmp)
1392 +               goto out;
1393 +
1394 +       if (copy_from_user(tmp, (void __user*)img.data, len))
1395 +               goto out;
1396 +               
1397 +       img.data = tmp;
1398 +
1399 +       /* If this ioctl is a response to a request from kernel, the console sem
1400 +        * is already held. */
1401 +       if (origin == FBCON_DECOR_IO_ORIG_USER)
1402 +               acquire_console_sem();
1403 +       
1404 +       if (info->bgdecor.data)
1405 +               vfree((u8*)info->bgdecor.data);
1406 +       if (info->bgdecor.cmap.red)
1407 +               vfree(info->bgdecor.cmap.red);
1408 +       
1409 +       info->bgdecor = img;
1410 +
1411 +       if (origin == FBCON_DECOR_IO_ORIG_USER)
1412 +               release_console_sem();
1413 +
1414 +       return 0;
1415 +
1416 +out:   if (img.cmap.red)
1417 +               vfree(img.cmap.red);
1418 +       if (tmp)
1419 +               vfree(tmp);
1420 +       return -ENOMEM;
1421 +}
1422 +
1423 +static int fbcon_decor_ioctl(struct inode * inode, struct file *filp, u_int cmd,
1424 +                       u_long arg)
1425 +{
1426 +       struct fbcon_decor_iowrapper __user *wrapper = (void __user*) arg;
1427 +       struct vc_data *vc = NULL;
1428 +       unsigned short vc_num = 0;
1429 +       unsigned char origin = 0;
1430 +       void __user *data = NULL;
1431 +
1432 +       if (!access_ok(VERIFY_READ, wrapper,
1433 +                       sizeof(struct fbcon_decor_iowrapper)))
1434 +               return -EFAULT;
1435 +
1436 +       __get_user(vc_num, &wrapper->vc);
1437 +       __get_user(origin, &wrapper->origin);
1438 +       __get_user(data, &wrapper->data);
1439 +
1440 +       if (!vc_cons_allocated(vc_num))
1441 +               return -EINVAL;
1442 +
1443 +       vc = vc_cons[vc_num].d;
1444 +
1445 +       switch (cmd) {
1446 +       case FBIOCONDECOR_SETPIC:
1447 +               return fbcon_decor_ioctl_dosetpic(vc, (struct fb_image __user*)data, origin);
1448 +       case FBIOCONDECOR_SETCFG:
1449 +               return fbcon_decor_ioctl_dosetcfg(vc, (struct vc_decor*)data, origin);
1450 +       case FBIOCONDECOR_GETCFG:
1451 +               return fbcon_decor_ioctl_dogetcfg(vc, (struct vc_decor*)data);
1452 +       case FBIOCONDECOR_SETSTATE:
1453 +               return fbcon_decor_ioctl_dosetstate(vc, (unsigned int *)data, origin);
1454 +       case FBIOCONDECOR_GETSTATE:
1455 +               return fbcon_decor_ioctl_dogetstate(vc, (unsigned int *)data);
1456 +       default:
1457 +               return -ENOIOCTLCMD;
1458 +       }
1459 +}
1460 +
1461 +static struct file_operations fbcon_decor_ops = {
1462 +       .owner = THIS_MODULE,
1463 +       .ioctl = fbcon_decor_ioctl
1464 +};
1465 +
1466 +static struct miscdevice fbcon_decor_dev = {
1467 +       .minor = MISC_DYNAMIC_MINOR,
1468 +       .name = "fbcondecor",
1469 +       .fops = &fbcon_decor_ops
1470 +};
1471 +
1472 +void fbcon_decor_reset(void)
1473 +{
1474 +       struct fb_info *info;
1475 +       struct vc_data *vc;
1476 +       int i;
1477 +
1478 +       vc = vc_cons[0].d;
1479 +       info = registered_fb[0];
1480 +
1481 +       for (i = 0; i < num_registered_fb; i++) {
1482 +               registered_fb[i]->bgdecor.data = NULL;
1483 +               registered_fb[i]->bgdecor.cmap.red = NULL;
1484 +       }
1485 +
1486 +       for (i = 0; i < MAX_NR_CONSOLES && vc_cons[i].d; i++) {
1487 +               vc_cons[i].d->vc_decor.state = vc_cons[i].d->vc_decor.twidth = 
1488 +                                               vc_cons[i].d->vc_decor.theight = 0;
1489 +               vc_cons[i].d->vc_decor.theme = NULL;
1490 +       }
1491 +
1492 +       return;
1493 +}
1494 +
1495 +int fbcon_decor_init(void)
1496 +{
1497 +       int i;
1498 +
1499 +       fbcon_decor_reset();
1500 +
1501 +       if (initialized)
1502 +               return 0;
1503 +
1504 +       i = misc_register(&fbcon_decor_dev);
1505 +       if (i) {
1506 +               printk(KERN_ERR "fbcondecor: failed to register device\n");
1507 +               return i;
1508 +       }
1509 +
1510 +       fbcon_decor_call_helper("init", 0);
1511 +       initialized = 1;
1512 +       return 0;
1513 +}
1514 +
1515 +int fbcon_decor_exit(void)
1516 +{
1517 +       fbcon_decor_reset();
1518 +       return 0;
1519 +}
1520 +
1521 +EXPORT_SYMBOL(fbcon_decor_path);
1522 diff -Naurp -x .git /tmp/linux/drivers/video/console/fbcondecor.h ./drivers/video/console/fbcondecor.h
1523 --- /tmp/linux/drivers/video/console/fbcondecor.h       1970-01-01 01:00:00.000000000 +0100
1524 +++ ./drivers/video/console/fbcondecor.h        2008-03-25 23:04:10.000000000 +0100
1525 @@ -0,0 +1,78 @@
1526 +/* 
1527 + *  linux/drivers/video/console/fbcondecor.h -- Framebuffer Console Decoration headers
1528 + *
1529 + *  Copyright (C) 2004 Michal Januszewski <spock@gentoo.org>
1530 + *
1531 + */
1532 +
1533 +#ifndef __FBCON_DECOR_H
1534 +#define __FBCON_DECOR_H
1535 +
1536 +#ifndef _LINUX_FB_H
1537 +#include <linux/fb.h>
1538 +#endif
1539 +
1540 +/* This is needed for vc_cons in fbcmap.c */
1541 +#include <linux/vt_kern.h>
1542 +
1543 +struct fb_cursor;
1544 +struct fb_info;
1545 +struct vc_data;
1546 +
1547 +#ifdef CONFIG_FB_CON_DECOR
1548 +/* fbcondecor.c */
1549 +int fbcon_decor_init(void);
1550 +int fbcon_decor_exit(void);
1551 +int fbcon_decor_call_helper(char* cmd, unsigned short cons);
1552 +int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw);
1553 +
1554 +/* cfbcondecor.c */
1555 +void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx);
1556 +void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor);
1557 +void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width);
1558 +void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only);
1559 +void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank);
1560 +void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width);
1561 +void fbcon_decor_copy(u8 *dst, u8 *src, int height, int width, int linebytes, int srclinesbytes, int bpp);
1562 +void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc);
1563 +
1564 +/* vt.c */
1565 +void acquire_console_sem(void);
1566 +void release_console_sem(void);
1567 +void do_unblank_screen(int entering_gfx);
1568 +
1569 +/* struct vc_data *y */
1570 +#define fbcon_decor_active_vc(y) (y->vc_decor.state && y->vc_decor.theme) 
1571 +
1572 +/* struct fb_info *x, struct vc_data *y */
1573 +#define fbcon_decor_active_nores(x,y) (x->bgdecor.data && fbcon_decor_active_vc(y))
1574 +
1575 +/* struct fb_info *x, struct vc_data *y */
1576 +#define fbcon_decor_active(x,y) (fbcon_decor_active_nores(x,y) &&              \
1577 +                             x->bgdecor.width == x->var.xres &&        \
1578 +                             x->bgdecor.height == x->var.yres &&       \
1579 +                             x->bgdecor.depth == x->var.bits_per_pixel)
1580 +
1581 +
1582 +#else /* CONFIG_FB_CON_DECOR */
1583 +
1584 +static inline void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx) {}
1585 +static inline void fbcon_decor_putc(struct vc_data *vc, struct fb_info *info, int c, int ypos, int xpos) {}
1586 +static inline void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor) {}
1587 +static inline void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) {}
1588 +static inline void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only) {}
1589 +static inline void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank) {}
1590 +static inline void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width) {}
1591 +static inline void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc) {}
1592 +static inline int fbcon_decor_call_helper(char* cmd, unsigned short cons) { return 0; }
1593 +static inline int fbcon_decor_init(void) { return 0; }
1594 +static inline int fbcon_decor_exit(void) { return 0; }
1595 +static inline int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw) { return 0; }
1596 +
1597 +#define fbcon_decor_active_vc(y) (0)
1598 +#define fbcon_decor_active_nores(x,y) (0)
1599 +#define fbcon_decor_active(x,y) (0)
1600 +
1601 +#endif /* CONFIG_FB_CON_DECOR */
1602 +
1603 +#endif /* __FBCON_DECOR_H */
1604 diff -Naurp -x .git /tmp/linux/drivers/video/console/Kconfig ./drivers/video/console/Kconfig
1605 --- /tmp/linux/drivers/video/console/Kconfig    2008-03-25 07:24:16.000000000 +0100
1606 +++ ./drivers/video/console/Kconfig     2008-03-25 23:04:10.000000000 +0100
1607 @@ -144,6 +144,19 @@ config FRAMEBUFFER_CONSOLE_ROTATION
1608           such that other users of the framebuffer will remain normally
1609           oriented.
1610  
1611 +config FB_CON_DECOR
1612 +       bool "Support for the Framebuffer Console Decorations"
1613 +       depends on FRAMEBUFFER_CONSOLE=y && !FB_TILEBLITTING
1614 +       default n
1615 +       ---help---
1616 +         This option enables support for framebuffer console decorations which
1617 +         makes it possible to display images in the background of the system
1618 +         consoles.  Note that userspace utilities are necessary in order to take 
1619 +         advantage of these features. Refer to Documentation/fb/fbcondecor.txt 
1620 +         for more information.
1621 +
1622 +         If unsure, say N.
1623 +
1624  config STI_CONSOLE
1625          bool "STI text console"
1626          depends on PARISC
1627 diff -Naurp -x .git /tmp/linux/drivers/video/console/Makefile ./drivers/video/console/Makefile
1628 --- /tmp/linux/drivers/video/console/Makefile   2008-03-25 07:24:16.000000000 +0100
1629 +++ ./drivers/video/console/Makefile    2008-03-25 23:04:10.000000000 +0100
1630 @@ -35,6 +35,7 @@ obj-$(CONFIG_FRAMEBUFFER_CONSOLE)     +=
1631                                           fbcon_ccw.o
1632  endif
1633  
1634 +obj-$(CONFIG_FB_CON_DECOR)               += fbcondecor.o cfbcondecor.o
1635  obj-$(CONFIG_FB_STI)              += sticore.o font.o
1636  
1637  ifeq ($(CONFIG_USB_SISUSBVGA_CON),y)
1638 diff -Naurp -x .git /tmp/linux/drivers/video/fbcmap.c ./drivers/video/fbcmap.c
1639 --- /tmp/linux/drivers/video/fbcmap.c   2008-03-25 07:24:16.000000000 +0100
1640 +++ ./drivers/video/fbcmap.c    2008-03-25 23:04:10.000000000 +0100
1641 @@ -17,6 +17,8 @@
1642  #include <linux/slab.h>
1643  #include <linux/uaccess.h>
1644  
1645 +#include "console/fbcondecor.h"
1646 +
1647  static u16 red2[] __read_mostly = {
1648      0x0000, 0xaaaa
1649  };
1650 @@ -234,14 +236,17 @@ int fb_set_cmap(struct fb_cmap *cmap, st
1651                         if (transp)
1652                                 htransp = *transp++;
1653                         if (info->fbops->fb_setcolreg(start++,
1654 -                                                     hred, hgreen, hblue,
1655 +                                                     hred, hgreen, hblue, 
1656                                                       htransp, info))
1657                                 break;
1658                 }
1659         }
1660 -       if (rc == 0)
1661 +       if (rc == 0) {
1662                 fb_copy_cmap(cmap, &info->cmap);
1663 -
1664 +               if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
1665 +                   info->fix.visual == FB_VISUAL_DIRECTCOLOR)
1666 +                       fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
1667 +       }
1668         return rc;
1669  }
1670  
1671 @@ -249,7 +254,7 @@ int fb_set_user_cmap(struct fb_cmap_user
1672  {
1673         int rc, size = cmap->len * sizeof(u16);
1674         struct fb_cmap umap;
1675 -
1676 +       
1677         if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
1678                                 !info->fbops->fb_setcmap))
1679                 return -EINVAL;
1680 diff -Naurp -x .git /tmp/linux/drivers/video/Kconfig ./drivers/video/Kconfig
1681 --- /tmp/linux/drivers/video/Kconfig    2008-03-25 07:24:16.000000000 +0100
1682 +++ ./drivers/video/Kconfig     2008-03-25 23:04:10.000000000 +0100
1683 @@ -1134,7 +1134,6 @@ config FB_MATROX
1684         select FB_CFB_FILLRECT
1685         select FB_CFB_COPYAREA
1686         select FB_CFB_IMAGEBLIT
1687 -       select FB_TILEBLITTING
1688         select FB_MACMODES if PPC_PMAC
1689         ---help---
1690           Say Y here if you have a Matrox Millennium, Matrox Millennium II,
1691 diff -Naurp -x .git /tmp/linux/include/linux/console_decor.h ./include/linux/console_decor.h
1692 --- /tmp/linux/include/linux/console_decor.h    1970-01-01 01:00:00.000000000 +0100
1693 +++ ./include/linux/console_decor.h     2008-03-25 23:04:10.000000000 +0100
1694 @@ -0,0 +1,13 @@
1695 +#ifndef _LINUX_CONSOLE_DECOR_H_
1696 +#define _LINUX_CONSOLE_DECOR_H_ 1
1697 +
1698 +/* A structure used by the framebuffer console decorations (drivers/video/console/fbcondecor.c) */
1699 +struct vc_decor {
1700 +       __u8 bg_color;                          /* The color that is to be treated as transparent */
1701 +       __u8 state;                             /* Current decor state: 0 = off, 1 = on */
1702 +       __u16 tx, ty;                           /* Top left corner coordinates of the text field */
1703 +       __u16 twidth, theight;                  /* Width and height of the text field */
1704 +       char* theme;
1705 +};
1706 +
1707 +#endif
1708 diff -Naurp -x .git /tmp/linux/include/linux/console_struct.h ./include/linux/console_struct.h
1709 --- /tmp/linux/include/linux/console_struct.h   2008-03-25 07:24:16.000000000 +0100
1710 +++ ./include/linux/console_struct.h    2008-03-25 23:04:10.000000000 +0100
1711 @@ -19,6 +19,7 @@
1712  struct vt_struct;
1713  
1714  #define NPAR 16
1715 +#include <linux/console_decor.h>
1716  
1717  struct vc_data {
1718         unsigned short  vc_num;                 /* Console number */
1719 @@ -106,6 +107,8 @@ struct vc_data {
1720         struct vc_data **vc_display_fg;         /* [!] Ptr to var holding fg console for this display */
1721         unsigned long   vc_uni_pagedir;
1722         unsigned long   *vc_uni_pagedir_loc;  /* [!] Location of uni_pagedir variable for this console */
1723 +
1724 +       struct vc_decor vc_decor;
1725         /* additional information is in vt_kern.h */
1726  };
1727  
1728 diff -Naurp -x .git /tmp/linux/include/linux/fb.h ./include/linux/fb.h
1729 --- /tmp/linux/include/linux/fb.h       2008-03-25 07:24:16.000000000 +0100
1730 +++ ./include/linux/fb.h        2008-03-25 23:04:10.000000000 +0100
1731 @@ -11,6 +11,13 @@ struct dentry;
1732  #define FB_MAJOR               29
1733  #define FB_MAX                 32      /* sufficient for now */
1734  
1735 +struct fbcon_decor_iowrapper
1736 +{
1737 +       unsigned short vc;              /* Virtual console */
1738 +       unsigned char origin;           /* Point of origin of the request */
1739 +       void *data;
1740 +};
1741 +
1742  /* ioctls
1743     0x46 is 'F'                                                         */
1744  #define FBIOGET_VSCREENINFO    0x4600
1745 @@ -38,7 +45,15 @@ struct dentry;
1746  #define FBIOGET_HWCINFO         0x4616
1747  #define FBIOPUT_MODEINFO        0x4617
1748  #define FBIOGET_DISPINFO        0x4618
1749 -
1750 +#define FBIOCONDECOR_SETCFG    _IOWR('F', 0x19, struct fbcon_decor_iowrapper)
1751 +#define FBIOCONDECOR_GETCFG    _IOR('F', 0x1A, struct fbcon_decor_iowrapper)
1752 +#define FBIOCONDECOR_SETSTATE  _IOWR('F', 0x1B, struct fbcon_decor_iowrapper)
1753 +#define FBIOCONDECOR_GETSTATE  _IOR('F', 0x1C, struct fbcon_decor_iowrapper)
1754 +#define FBIOCONDECOR_SETPIC    _IOWR('F', 0x1D, struct fbcon_decor_iowrapper)
1755 +
1756 +#define FBCON_DECOR_THEME_LEN          128     /* Maximum lenght of a theme name */
1757 +#define FBCON_DECOR_IO_ORIG_KERNEL     0       /* Kernel ioctl origin */
1758 +#define FBCON_DECOR_IO_ORIG_USER       1       /* User ioctl origin */
1759  
1760  #define FB_TYPE_PACKED_PIXELS          0       /* Packed Pixels        */
1761  #define FB_TYPE_PLANES                 1       /* Non interleaved planes */
1762 @@ -833,6 +848,9 @@ struct fb_info {
1763  #define FBINFO_STATE_SUSPENDED 1
1764         u32 state;                      /* Hardware state i.e suspend */
1765         void *fbcon_par;                /* fbcon use-only private area */
1766 +
1767 +       struct fb_image bgdecor;
1768 +
1769         /* From here on everything is device dependent */
1770         void *par;      
1771  };
1772 diff -Naurp -x .git /tmp/linux/include/linux/fb.h.rej ./include/linux/fb.h.rej
1773 --- /tmp/linux/include/linux/fb.h.rej   1970-01-01 01:00:00.000000000 +0100
1774 +++ ./include/linux/fb.h.rej    2006-08-21 02:51:22.000000000 +0200
1775 @@ -0,0 +1,32 @@
1776 +***************
1777 +*** 1,7 ****
1778 +  #ifndef _LINUX_FB_H
1779 +  #define _LINUX_FB_H
1780 +  
1781 +- #include <linux/backlight.h>
1782 +  #include <asm/types.h>
1783 +  
1784 +  /* Definitions of frame buffers                                              */
1785 +--- 1,6 ----
1786 +  #ifndef _LINUX_FB_H
1787 +  #define _LINUX_FB_H
1788 +  
1789 +  #include <asm/types.h>
1790 +  
1791 +  /* Definitions of frame buffers                                              */
1792 +***************
1793 +*** 381,386 ****
1794 +  #include <linux/workqueue.h>
1795 +  #include <linux/notifier.h>
1796 +  #include <linux/list.h>
1797 +  #include <asm/io.h>
1798 +  
1799 +  struct vm_area_struct;
1800 +--- 380,386 ----
1801 +  #include <linux/workqueue.h>
1802 +  #include <linux/notifier.h>
1803 +  #include <linux/list.h>
1804 ++ #include <linux/backlight.h>
1805 +  #include <asm/io.h>
1806 +  
1807 +  struct vm_area_struct;
1808 diff -Naurp -x .git /tmp/linux/kernel/sysctl.c ./kernel/sysctl.c
1809 --- /tmp/linux/kernel/sysctl.c  2008-03-25 07:24:16.000000000 +0100
1810 +++ ./kernel/sysctl.c   2008-03-25 23:04:10.000000000 +0100
1811 @@ -107,6 +107,9 @@ static int ngroups_max = NGROUPS_MAX;
1812  #ifdef CONFIG_KMOD
1813  extern char modprobe_path[];
1814  #endif
1815 +#ifdef CONFIG_FB_CON_DECOR
1816 +extern char fbcon_decor_path[];
1817 +#endif
1818  #ifdef CONFIG_CHR_DEV_SG
1819  extern int sg_big_buff;
1820  #endif
1821 @@ -820,6 +823,18 @@ static struct ctl_table kern_table[] = {
1822                 .proc_handler   = &proc_dostring,
1823                 .strategy       = &sysctl_string,
1824         },
1825 +#ifdef CONFIG_FB_CON_DECOR
1826 +       {
1827 +               .ctl_name       = CTL_UNNUMBERED,
1828 +               .procname       = "fbcondecor",
1829 +               .data           = &fbcon_decor_path,
1830 +               .maxlen         = KMOD_PATH_LEN,
1831 +               .mode           = 0644,
1832 +               .proc_handler   = &proc_dostring,
1833 +               .strategy       = &sysctl_string,
1834 +       },
1835 +#endif
1836 +
1837  /*
1838   * NOTE: do not add new entries to this table unless you have read
1839   * Documentation/sysctl/ctl_unnumbered.txt
This page took 0.346236 seconds and 3 git commands to generate.