default to 3.19, only 3.14 for kodi and solidrun (gpu drivers)
[openadk.git] / target / linux / patches / 3.19 / patch-fblogo
blobf1fad64c1728292531c7cd60df95ec584d56fdef
1 diff -Nur linux-3.15.1.orig/Documentation/fb/00-INDEX linux-3.15.1/Documentation/fb/00-INDEX
2 --- linux-3.15.1.orig/Documentation/fb/00-INDEX 2014-06-16 22:44:27.000000000 +0200
3 +++ linux-3.15.1/Documentation/fb/00-INDEX      2014-06-28 11:21:19.000000000 +0200
4 @@ -23,6 +23,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 -Nur linux-3.15.1.orig/Documentation/fb/fbcondecor.txt linux-3.15.1/Documentation/fb/fbcondecor.txt
14 --- linux-3.15.1.orig/Documentation/fb/fbcondecor.txt   1970-01-01 01:00:00.000000000 +0100
15 +++ linux-3.15.1/Documentation/fb/fbcondecor.txt        2014-06-28 11:21:19.000000000 +0200
16 @@ -0,0 +1,207 @@
17 +What is it?
18 +-----------
20 +The framebuffer decorations are a kernel feature which allows displaying a 
21 +background picture on selected consoles.
23 +What do I need to get it to work?
24 +---------------------------------
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.
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.
36 +[1] The splashutils package can be downloaded from:
37 +    http://github.com/alanhaggai/fbsplash
39 +The userspace helper
40 +--------------------
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.
49 +It's possible to set path to the fbcondecor helper by writing it to
50 +/proc/sys/kernel/fbcondecor.
52 +*****************************************************************************
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.
57 +The fbcondecor protocol
58 +-----------------------
60 +The fbcondecor protocol defines a communication interface between the kernel and
61 +the userspace fbcondecor helper.
63 +The kernel side is responsible for:
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.
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.
75 +The fbcondecor protocol specifies how communication is done in both ways:
76 +kernel->userspace and userspace->helper.
77 +  
78 +Kernel -> Userspace
79 +-------------------
81 +The kernel communicates with the userspace helper by calling it and specifying
82 +the task to be done in a series of arguments.
84 +The arguments follow the pattern:
85 +<fbcondecor protocol version> <command> <parameters>
87 +All commands defined in fbcondecor protocol v2 have the following parameters:
88 + virtual console
89 + framebuffer number
90 + theme
92 +Fbcondecor protocol v1 specified an additional 'fbcondecor mode' after the
93 +framebuffer number. Fbcondecor protocol v1 is deprecated and should not be used.
95 +Fbcondecor protocol v2 specifies the following commands:
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.
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.
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.
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.
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.
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.
135 +Userspace -> Kernel
136 +-------------------
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).
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.
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.
152 +The framebuffer console decoration provides the following ioctls (all defined in 
153 +linux/fb.h):
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.
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.
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.
173 +FBIOCONDECOR_GETCFG
174 +description: gets the fbcondecor config for a virtual console
175 +argument: struct fbcon_decor_iowrapper*; data: struct vc_decor*
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.
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
187 +Info on used structures:
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.
195 +Definition of struct fbcon_decor_iowrapper can be found in linux/fb.h.
196 +The fields in this struct have the following meaning:
198 +vc: 
199 +Virtual console number.
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.
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.
211 +*****************************************************************************
213 +Credit
214 +------
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>.
221 +Fbcondecor, fbcondecor protocol design, current implementation & docs by:
222 +  Michal Januszewski <michalj+fbcondecor@gmail.com>
224 diff -Nur linux-3.15.1.orig/drivers/Makefile linux-3.15.1/drivers/Makefile
225 --- linux-3.15.1.orig/drivers/Makefile  2014-06-16 22:44:27.000000000 +0200
226 +++ linux-3.15.1/drivers/Makefile       2014-06-28 11:21:19.000000000 +0200
227 @@ -17,6 +17,10 @@
228  obj-$(CONFIG_PCI)              += pci/
229  obj-$(CONFIG_PARISC)           += parisc/
230  obj-$(CONFIG_RAPIDIO)          += rapidio/
231 +# tty/ comes before char/ 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/
238 @@ -42,11 +46,6 @@
239  # reset controllers early, since gpu drivers might rely on them to initialize
240  obj-$(CONFIG_RESET_CONTROLLER) += reset/
242 -# tty/ comes before char/ so that the VT console is the boot-time
243 -# default.
244 -obj-y                          += tty/
245 -obj-y                          += char/
247  # gpu/ comes after char for AGP vs DRM startup
248  obj-y                          += gpu/
250 diff -Nur linux-3.15.1.orig/drivers/video/console/Kconfig linux-3.15.1/drivers/video/console/Kconfig
251 --- linux-3.15.1.orig/drivers/video/console/Kconfig     2014-06-16 22:44:27.000000000 +0200
252 +++ linux-3.15.1/drivers/video/console/Kconfig  2014-06-28 11:21:19.000000000 +0200
253 @@ -126,6 +126,19 @@
254           such that other users of the framebuffer will remain normally
255           oriented.
257 +config FB_CON_DECOR
258 +       bool "Support for the Framebuffer Console Decorations"
259 +       depends on FRAMEBUFFER_CONSOLE=y && !FB_TILEBLITTING
260 +       default n
261 +       ---help---
262 +         This option enables support for framebuffer console decorations which
263 +         makes it possible to display images in the background of the system
264 +         consoles.  Note that userspace utilities are necessary in order to take 
265 +         advantage of these features. Refer to Documentation/fb/fbcondecor.txt 
266 +         for more information.
268 +         If unsure, say N.
270  config STI_CONSOLE
271          bool "STI text console"
272          depends on PARISC
273 diff -Nur linux-3.15.1.orig/drivers/video/console/Makefile linux-3.15.1/drivers/video/console/Makefile
274 --- linux-3.15.1.orig/drivers/video/console/Makefile    2014-06-16 22:44:27.000000000 +0200
275 +++ linux-3.15.1/drivers/video/console/Makefile 2014-06-28 11:21:19.000000000 +0200
276 @@ -16,4 +16,5 @@
277                                           fbcon_ccw.o
278  endif
280 +obj-$(CONFIG_FB_CON_DECOR)               += fbcondecor.o cfbcondecor.o
281  obj-$(CONFIG_FB_STI)              += sticore.o
282 diff -Nur linux-3.15.1.orig/drivers/video/console/bitblit.c linux-3.15.1/drivers/video/console/bitblit.c
283 --- linux-3.15.1.orig/drivers/video/console/bitblit.c   2014-06-16 22:44:27.000000000 +0200
284 +++ linux-3.15.1/drivers/video/console/bitblit.c        2014-06-28 11:21:19.000000000 +0200
285 @@ -18,6 +18,7 @@
286  #include <linux/console.h>
287  #include <asm/types.h>
288  #include "fbcon.h"
289 +#include "fbcondecor.h"
291  /*
292   * Accelerated handlers.
293 @@ -55,6 +56,13 @@
294         area.height = height * vc->vc_font.height;
295         area.width = width * vc->vc_font.width;
297 +       if (fbcon_decor_active(info, vc)) {
298 +               area.sx += vc->vc_decor.tx;
299 +               area.sy += vc->vc_decor.ty;
300 +               area.dx += vc->vc_decor.tx;
301 +               area.dy += vc->vc_decor.ty;
302 +       }
304         info->fbops->fb_copyarea(info, &area);
307 @@ -380,11 +388,15 @@
308         cursor.image.depth = 1;
309         cursor.rop = ROP_XOR;
311 -       if (info->fbops->fb_cursor)
312 -               err = info->fbops->fb_cursor(info, &cursor);
313 +       if (fbcon_decor_active(info, vc)) {
314 +               fbcon_decor_cursor(info, &cursor);
315 +       } else {
316 +               if (info->fbops->fb_cursor)
317 +                       err = info->fbops->fb_cursor(info, &cursor);
319 -       if (err)
320 -               soft_cursor(info, &cursor);
321 +               if (err)
322 +                       soft_cursor(info, &cursor);
323 +       }
325         ops->cursor_reset = 0;
327 diff -Nur linux-3.15.1.orig/drivers/video/console/cfbcondecor.c linux-3.15.1/drivers/video/console/cfbcondecor.c
328 --- linux-3.15.1.orig/drivers/video/console/cfbcondecor.c       1970-01-01 01:00:00.000000000 +0100
329 +++ linux-3.15.1/drivers/video/console/cfbcondecor.c    2014-06-28 11:21:19.000000000 +0200
330 @@ -0,0 +1,471 @@
332 + *  linux/drivers/video/cfbcon_decor.c -- Framebuffer decor render functions
333 + *
334 + *  Copyright (C) 2004 Michal Januszewski <michalj+fbcondecor@gmail.com>
335 + *
336 + *  Code based upon "Bootdecor" (C) 2001-2003
337 + *       Volker Poplawski <volker@poplawski.de>,
338 + *       Stefan Reinauer <stepan@suse.de>,
339 + *       Steffen Winterfeldt <snwint@suse.de>,
340 + *       Michael Schroeder <mls@suse.de>,
341 + *       Ken Wimer <wimer@suse.de>.
342 + *
343 + *  This file is subject to the terms and conditions of the GNU General Public
344 + *  License.  See the file COPYING in the main directory of this archive for
345 + *  more details.
346 + */
347 +#include <linux/module.h>
348 +#include <linux/types.h>
349 +#include <linux/fb.h>
350 +#include <linux/selection.h>
351 +#include <linux/slab.h>
352 +#include <linux/vt_kern.h>
353 +#include <asm/irq.h>
355 +#include "fbcon.h"
356 +#include "fbcondecor.h"
358 +#define parse_pixel(shift,bpp,type)                                            \
359 +       do {                                                                    \
360 +               if (d & (0x80 >> (shift)))                                      \
361 +                       dd2[(shift)] = fgx;                                     \
362 +               else                                                            \
363 +                       dd2[(shift)] = transparent ? *(type *)decor_src : bgx;  \
364 +               decor_src += (bpp);                                             \
365 +       } while (0)                                                             \
367 +extern int get_color(struct vc_data *vc, struct fb_info *info,
368 +                    u16 c, int is_fg);
370 +void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc)
372 +       int i, j, k;
373 +       int minlen = min(min(info->var.red.length, info->var.green.length),
374 +                            info->var.blue.length);
375 +       u32 col;
377 +       for (j = i = 0; i < 16; i++) {
378 +               k = color_table[i];
380 +               col = ((vc->vc_palette[j++]  >> (8-minlen))
381 +                       << info->var.red.offset);
382 +               col |= ((vc->vc_palette[j++] >> (8-minlen))
383 +                       << info->var.green.offset);
384 +               col |= ((vc->vc_palette[j++] >> (8-minlen))
385 +                       << info->var.blue.offset);
386 +                       ((u32 *)info->pseudo_palette)[k] = col;
387 +       }
390 +void fbcon_decor_renderc(struct fb_info *info, int ypos, int xpos, int height,
391 +                     int width, u8* src, u32 fgx, u32 bgx, u8 transparent)
393 +       unsigned int x, y;
394 +       u32 dd;
395 +       int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
396 +       unsigned int d = ypos * info->fix.line_length + xpos * bytespp;
397 +       unsigned int ds = (ypos * info->var.xres + xpos) * bytespp;
398 +       u16 dd2[4];
400 +       u8* decor_src = (u8 *)(info->bgdecor.data + ds);
401 +       u8* dst = (u8 *)(info->screen_base + d);
403 +       if ((ypos + height) > info->var.yres || (xpos + width) > info->var.xres)
404 +               return;
406 +       for (y = 0; y < height; y++) {
407 +               switch (info->var.bits_per_pixel) {
409 +               case 32:
410 +                       for (x = 0; x < width; x++) {
412 +                               if ((x & 7) == 0)
413 +                                       d = *src++;
414 +                               if (d & 0x80)
415 +                                       dd = fgx;
416 +                               else
417 +                                       dd = transparent ?
418 +                                            *(u32 *)decor_src : bgx;
420 +                               d <<= 1;
421 +                               decor_src += 4;
422 +                               fb_writel(dd, dst);
423 +                               dst += 4;
424 +                       }
425 +                       break;
426 +               case 24:
427 +                       for (x = 0; x < width; x++) {
429 +                               if ((x & 7) == 0)
430 +                                       d = *src++;
431 +                               if (d & 0x80)
432 +                                       dd = fgx;
433 +                               else
434 +                                       dd = transparent ?
435 +                                            (*(u32 *)decor_src & 0xffffff) : bgx;
437 +                               d <<= 1;
438 +                               decor_src += 3;
439 +#ifdef __LITTLE_ENDIAN
440 +                               fb_writew(dd & 0xffff, dst);
441 +                               dst += 2;
442 +                               fb_writeb((dd >> 16), dst);
443 +#else
444 +                               fb_writew(dd >> 8, dst);
445 +                               dst += 2;
446 +                               fb_writeb(dd & 0xff, dst);
447 +#endif
448 +                               dst++;
449 +                       }
450 +                       break;
451 +               case 16:
452 +                       for (x = 0; x < width; x += 2) {
453 +                               if ((x & 7) == 0)
454 +                                       d = *src++;
456 +                               parse_pixel(0, 2, u16);
457 +                               parse_pixel(1, 2, u16);
458 +#ifdef __LITTLE_ENDIAN
459 +                               dd = dd2[0] | (dd2[1] << 16);
460 +#else
461 +                               dd = dd2[1] | (dd2[0] << 16);
462 +#endif
463 +                               d <<= 2;
464 +                               fb_writel(dd, dst);
465 +                               dst += 4;
466 +                       }
467 +                       break;
469 +               case 8:
470 +                       for (x = 0; x < width; x += 4) {
471 +                               if ((x & 7) == 0)
472 +                                       d = *src++;
474 +                               parse_pixel(0, 1, u8);
475 +                               parse_pixel(1, 1, u8);
476 +                               parse_pixel(2, 1, u8);
477 +                               parse_pixel(3, 1, u8);
479 +#ifdef __LITTLE_ENDIAN
480 +                               dd = dd2[0] | (dd2[1] << 8) | (dd2[2] << 16) | (dd2[3] << 24);
481 +#else
482 +                               dd = dd2[3] | (dd2[2] << 8) | (dd2[1] << 16) | (dd2[0] << 24);
483 +#endif
484 +                               d <<= 4;
485 +                               fb_writel(dd, dst);
486 +                               dst += 4;
487 +                       }
488 +               }
490 +               dst += info->fix.line_length - width * bytespp;
491 +               decor_src += (info->var.xres - width) * bytespp;
492 +       }
495 +#define cc2cx(a)                                               \
496 +       ((info->fix.visual == FB_VISUAL_TRUECOLOR ||            \
497 +         info->fix.visual == FB_VISUAL_DIRECTCOLOR) ?          \
498 +        ((u32*)info->pseudo_palette)[a] : a)
500 +void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info,
501 +                  const unsigned short *s, int count, int yy, int xx)
503 +       unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
504 +       struct fbcon_ops *ops = info->fbcon_par;
505 +       int fg_color, bg_color, transparent;
506 +       u8 *src;
507 +       u32 bgx, fgx;
508 +       u16 c = scr_readw(s);
510 +       fg_color = get_color(vc, info, c, 1);
511 +        bg_color = get_color(vc, info, c, 0);
513 +       /* Don't paint the background image if console is blanked */
514 +       transparent = ops->blank_state ? 0 :
515 +               (vc->vc_decor.bg_color == bg_color);
517 +       xx = xx * vc->vc_font.width + vc->vc_decor.tx;
518 +       yy = yy * vc->vc_font.height + vc->vc_decor.ty;
520 +       fgx = cc2cx(fg_color);
521 +       bgx = cc2cx(bg_color);
523 +       while (count--) {
524 +               c = scr_readw(s++);
525 +               src = vc->vc_font.data + (c & charmask) * vc->vc_font.height *
526 +                     ((vc->vc_font.width + 7) >> 3);
528 +               fbcon_decor_renderc(info, yy, xx, vc->vc_font.height,
529 +                              vc->vc_font.width, src, fgx, bgx, transparent);
530 +               xx += vc->vc_font.width;
531 +       }
534 +void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor)
536 +       int i;
537 +       unsigned int dsize, s_pitch;
538 +       struct fbcon_ops *ops = info->fbcon_par;
539 +       struct vc_data* vc;
540 +       u8 *src;
542 +       /* we really don't need any cursors while the console is blanked */
543 +       if (info->state != FBINFO_STATE_RUNNING || ops->blank_state)
544 +               return;
546 +       vc = vc_cons[ops->currcon].d;
548 +       src = kmalloc(64 + sizeof(struct fb_image), GFP_ATOMIC);
549 +       if (!src)
550 +               return;
552 +       s_pitch = (cursor->image.width + 7) >> 3;
553 +       dsize = s_pitch * cursor->image.height;
554 +       if (cursor->enable) {
555 +               switch (cursor->rop) {
556 +               case ROP_XOR:
557 +                       for (i = 0; i < dsize; i++)
558 +                               src[i] = cursor->image.data[i] ^ cursor->mask[i];
559 +                        break;
560 +               case ROP_COPY:
561 +               default:
562 +                       for (i = 0; i < dsize; i++)
563 +                               src[i] = cursor->image.data[i] & cursor->mask[i];
564 +                       break;
565 +               }
566 +       } else
567 +               memcpy(src, cursor->image.data, dsize);
569 +       fbcon_decor_renderc(info,
570 +                       cursor->image.dy + vc->vc_decor.ty,
571 +                       cursor->image.dx + vc->vc_decor.tx,
572 +                       cursor->image.height,
573 +                       cursor->image.width,
574 +                       (u8*)src,
575 +                       cc2cx(cursor->image.fg_color),
576 +                       cc2cx(cursor->image.bg_color),
577 +                       cursor->image.bg_color == vc->vc_decor.bg_color);
579 +       kfree(src);
582 +static void decorset(u8 *dst, int height, int width, int dstbytes,
583 +                       u32 bgx, int bpp)
585 +       int i;
587 +       if (bpp == 8)
588 +               bgx |= bgx << 8;
589 +       if (bpp == 16 || bpp == 8)
590 +               bgx |= bgx << 16;
592 +       while (height-- > 0) {
593 +               u8 *p = dst;
595 +               switch (bpp) {
597 +               case 32:
598 +                       for (i=0; i < width; i++) {
599 +                               fb_writel(bgx, p); p += 4;
600 +                       }
601 +                       break;
602 +               case 24:
603 +                       for (i=0; i < width; i++) {
604 +#ifdef __LITTLE_ENDIAN
605 +                               fb_writew((bgx & 0xffff),(u16*)p); p += 2;
606 +                               fb_writeb((bgx >> 16),p++);
607 +#else
608 +                               fb_writew((bgx >> 8),(u16*)p); p += 2;
609 +                               fb_writeb((bgx & 0xff),p++);
610 +#endif
611 +                       }
612 +               case 16:
613 +                       for (i=0; i < width/4; i++) {
614 +                               fb_writel(bgx,p); p += 4;
615 +                               fb_writel(bgx,p); p += 4;
616 +                       }
617 +                       if (width & 2) {
618 +                               fb_writel(bgx,p); p += 4;
619 +                       }
620 +                       if (width & 1)
621 +                               fb_writew(bgx,(u16*)p);
622 +                       break;
623 +               case 8:
624 +                       for (i=0; i < width/4; i++) {
625 +                               fb_writel(bgx,p); p += 4;
626 +                       }
628 +                       if (width & 2) {
629 +                               fb_writew(bgx,p); p += 2;
630 +                       }
631 +                       if (width & 1)
632 +                               fb_writeb(bgx,(u8*)p);
633 +                       break;
635 +               }
636 +               dst += dstbytes;
637 +       }
640 +void fbcon_decor_copy(u8 *dst, u8 *src, int height, int width, int linebytes,
641 +                  int srclinebytes, int bpp)
643 +       int i;
645 +       while (height-- > 0) {
646 +               u32 *p = (u32 *)dst;
647 +               u32 *q = (u32 *)src;
649 +               switch (bpp) {
651 +               case 32:
652 +                       for (i=0; i < width; i++)
653 +                               fb_writel(*q++, p++);
654 +                       break;
655 +               case 24:
656 +                       for (i=0; i < (width*3/4); i++)
657 +                               fb_writel(*q++, p++);
658 +                       if ((width*3) % 4) {
659 +                               if (width & 2) {
660 +                                       fb_writeb(*(u8*)q, (u8*)p);
661 +                               } else if (width & 1) {
662 +                                       fb_writew(*(u16*)q, (u16*)p);
663 +                                       fb_writeb(*(u8*)((u16*)q+1),(u8*)((u16*)p+2));
664 +                               }
665 +                       }
666 +                       break;
667 +               case 16:
668 +                       for (i=0; i < width/4; i++) {
669 +                               fb_writel(*q++, p++);
670 +                               fb_writel(*q++, p++);
671 +                       }
672 +                       if (width & 2)
673 +                               fb_writel(*q++, p++);
674 +                       if (width & 1)
675 +                               fb_writew(*(u16*)q, (u16*)p);
676 +                       break;
677 +               case 8:
678 +                       for (i=0; i < width/4; i++)
679 +                               fb_writel(*q++, p++);
681 +                       if (width & 2) {
682 +                               fb_writew(*(u16*)q, (u16*)p);
683 +                               q = (u32*) ((u16*)q + 1);
684 +                               p = (u32*) ((u16*)p + 1);
685 +                       }
686 +                       if (width & 1)
687 +                               fb_writeb(*(u8*)q, (u8*)p);
688 +                       break;
689 +               }
691 +               dst += linebytes;
692 +               src += srclinebytes;
693 +       }
696 +static void decorfill(struct fb_info *info, int sy, int sx, int height,
697 +                      int width)
699 +       int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
700 +       int d  = sy * info->fix.line_length + sx * bytespp;
701 +       int ds = (sy * info->var.xres + sx) * bytespp;
703 +       fbcon_decor_copy((u8 *)(info->screen_base + d), (u8 *)(info->bgdecor.data + ds),
704 +                   height, width, info->fix.line_length, info->var.xres * bytespp,
705 +                   info->var.bits_per_pixel);
708 +void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx,
709 +                   int height, int width)
711 +       int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
712 +       struct fbcon_ops *ops = info->fbcon_par;
713 +       u8 *dst;
714 +       int transparent, bg_color = attr_bgcol_ec(bgshift, vc, info);
716 +       transparent = (vc->vc_decor.bg_color == bg_color);
717 +       sy = sy * vc->vc_font.height + vc->vc_decor.ty;
718 +       sx = sx * vc->vc_font.width + vc->vc_decor.tx;
719 +       height *= vc->vc_font.height;
720 +       width *= vc->vc_font.width;
722 +       /* Don't paint the background image if console is blanked */
723 +       if (transparent && !ops->blank_state) {
724 +               decorfill(info, sy, sx, height, width);
725 +       } else {
726 +               dst = (u8 *)(info->screen_base + sy * info->fix.line_length +
727 +                            sx * ((info->var.bits_per_pixel + 7) >> 3));
728 +               decorset(dst, height, width, info->fix.line_length, cc2cx(bg_color),
729 +                         info->var.bits_per_pixel);
730 +       }
733 +void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info,
734 +                           int bottom_only)
736 +       unsigned int tw = vc->vc_cols*vc->vc_font.width;
737 +       unsigned int th = vc->vc_rows*vc->vc_font.height;
739 +       if (!bottom_only) {
740 +               /* top margin */
741 +               decorfill(info, 0, 0, vc->vc_decor.ty, info->var.xres);
742 +               /* left margin */
743 +               decorfill(info, vc->vc_decor.ty, 0, th, vc->vc_decor.tx);
744 +               /* right margin */
745 +               decorfill(info, vc->vc_decor.ty, vc->vc_decor.tx + tw, th, 
746 +                          info->var.xres - vc->vc_decor.tx - tw);
747 +       }
748 +       decorfill(info, vc->vc_decor.ty + th, 0, 
749 +                  info->var.yres - vc->vc_decor.ty - th, info->var.xres);
752 +void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, 
753 +                          int sx, int dx, int width)
755 +       u16 *d = (u16 *) (vc->vc_origin + vc->vc_size_row * y + dx * 2);
756 +       u16 *s = d + (dx - sx);
757 +       u16 *start = d;
758 +       u16 *ls = d;
759 +       u16 *le = d + width;
760 +       u16 c;
761 +       int x = dx;
762 +       u16 attr = 1;
764 +       do {
765 +               c = scr_readw(d);
766 +               if (attr != (c & 0xff00)) {
767 +                       attr = c & 0xff00;
768 +                       if (d > start) {
769 +                               fbcon_decor_putcs(vc, info, start, d - start, y, x);
770 +                               x += d - start;
771 +                               start = d;
772 +                       }
773 +               }
774 +               if (s >= ls && s < le && c == scr_readw(s)) {
775 +                       if (d > start) {
776 +                               fbcon_decor_putcs(vc, info, start, d - start, y, x);
777 +                               x += d - start + 1;
778 +                               start = d + 1;
779 +                       } else {
780 +                               x++;
781 +                               start++;
782 +                       }
783 +               }
784 +               s++;
785 +               d++;
786 +       } while (d < le);
787 +       if (d > start)
788 +               fbcon_decor_putcs(vc, info, start, d - start, y, x);
791 +void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank)
793 +       if (blank) {
794 +               decorset((u8 *)info->screen_base, info->var.yres, info->var.xres,
795 +                         info->fix.line_length, 0, info->var.bits_per_pixel);
796 +       } else {
797 +               update_screen(vc);
798 +               fbcon_decor_clear_margins(vc, info, 0);
799 +       }
802 diff -Nur linux-3.15.1.orig/drivers/video/console/fbcon.c linux-3.15.1/drivers/video/console/fbcon.c
803 --- linux-3.15.1.orig/drivers/video/console/fbcon.c     2014-06-16 22:44:27.000000000 +0200
804 +++ linux-3.15.1/drivers/video/console/fbcon.c  2014-06-28 11:21:19.000000000 +0200
805 @@ -79,6 +79,7 @@
806  #include <asm/irq.h>
808  #include "fbcon.h"
809 +#include "fbcondecor.h"
811  #ifdef FBCONDEBUG
812  #  define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
813 @@ -94,7 +95,7 @@
815  static struct display fb_display[MAX_NR_CONSOLES];
817 -static signed char con2fb_map[MAX_NR_CONSOLES];
818 +signed char con2fb_map[MAX_NR_CONSOLES];
819  static signed char con2fb_map_boot[MAX_NR_CONSOLES];
821  static int logo_lines;
822 @@ -286,7 +287,7 @@
823                 !vt_force_oops_output(vc);
826 -static int get_color(struct vc_data *vc, struct fb_info *info,
827 +int get_color(struct vc_data *vc, struct fb_info *info,
828               u16 c, int is_fg)
830         int depth = fb_get_color_depth(&info->var, &info->fix);
831 @@ -551,6 +552,9 @@
832                 info_idx = -1;
833         } else {
834                 fbcon_has_console_bind = 1;
835 +#ifdef CONFIG_FB_CON_DECOR
836 +               fbcon_decor_init();
837 +#endif
838         }
840         return err;
841 @@ -1007,6 +1011,12 @@
842         rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
843         cols /= vc->vc_font.width;
844         rows /= vc->vc_font.height;
846 +       if (fbcon_decor_active(info, vc)) {
847 +               cols = vc->vc_decor.twidth / vc->vc_font.width;
848 +               rows = vc->vc_decor.theight / vc->vc_font.height;
849 +       }
851         vc_resize(vc, cols, rows);
853         DPRINTK("mode:   %s\n", info->fix.id);
854 @@ -1036,7 +1046,7 @@
855         cap = info->flags;
857         if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
858 -           (info->fix.type == FB_TYPE_TEXT))
859 +           (info->fix.type == FB_TYPE_TEXT) || fbcon_decor_active(info, vc))
860                 logo = 0;
862         if (var_to_display(p, &info->var, info))
863 @@ -1260,6 +1270,11 @@
864                 fbcon_clear_margins(vc, 0);
865         }
867 +       if (fbcon_decor_active(info, vc)) {
868 +               fbcon_decor_clear(vc, info, sy, sx, height, width);
869 +               return;
870 +       }
872         /* Split blits that cross physical y_wrap boundary */
874         y_break = p->vrows - p->yscroll;
875 @@ -1279,10 +1294,15 @@
876         struct display *p = &fb_display[vc->vc_num];
877         struct fbcon_ops *ops = info->fbcon_par;
879 -       if (!fbcon_is_inactive(vc, info))
880 -               ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
881 -                          get_color(vc, info, scr_readw(s), 1),
882 -                          get_color(vc, info, scr_readw(s), 0));
883 +       if (!fbcon_is_inactive(vc, info)) {
885 +               if (fbcon_decor_active(info, vc))
886 +                       fbcon_decor_putcs(vc, info, s, count, ypos, xpos);
887 +               else
888 +                       ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
889 +                                  get_color(vc, info, scr_readw(s), 1),
890 +                                  get_color(vc, info, scr_readw(s), 0));
891 +       }
894  static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
895 @@ -1298,8 +1318,13 @@
896         struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
897         struct fbcon_ops *ops = info->fbcon_par;
899 -       if (!fbcon_is_inactive(vc, info))
900 -               ops->clear_margins(vc, info, bottom_only);
901 +       if (!fbcon_is_inactive(vc, info)) {
902 +               if (fbcon_decor_active(info, vc)) {
903 +                       fbcon_decor_clear_margins(vc, info, bottom_only);
904 +               } else {
905 +                       ops->clear_margins(vc, info, bottom_only);
906 +               }
907 +       }
910  static void fbcon_cursor(struct vc_data *vc, int mode)
911 @@ -1819,7 +1844,7 @@
912                         count = vc->vc_rows;
913                 if (softback_top)
914                         fbcon_softback_note(vc, t, count);
915 -               if (logo_shown >= 0)
916 +               if (logo_shown >= 0 || fbcon_decor_active(info, vc))
917                         goto redraw_up;
918                 switch (p->scrollmode) {
919                 case SCROLL_MOVE:
920 @@ -1912,6 +1937,8 @@
921                         count = vc->vc_rows;
922                 if (logo_shown >= 0)
923                         goto redraw_down;
924 +               if (fbcon_decor_active(info, vc))
925 +                       goto redraw_down;
926                 switch (p->scrollmode) {
927                 case SCROLL_MOVE:
928                         fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
929 @@ -2060,6 +2087,13 @@
930                 }
931                 return;
932         }
934 +       if (fbcon_decor_active(info, vc) && sy == dy && height == 1) {
935 +               /* must use slower redraw bmove to keep background pic intact */
936 +               fbcon_decor_bmove_redraw(vc, info, sy, sx, dx, width);
937 +               return;
938 +       }
940         ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
941                    height, width);
943 @@ -2130,8 +2164,8 @@
944         var.yres = virt_h * virt_fh;
945         x_diff = info->var.xres - var.xres;
946         y_diff = info->var.yres - var.yres;
947 -       if (x_diff < 0 || x_diff > virt_fw ||
948 -           y_diff < 0 || y_diff > virt_fh) {
949 +       if ((x_diff < 0 || x_diff > virt_fw ||
950 +               y_diff < 0 || y_diff > virt_fh) && !vc->vc_decor.state) {
951                 const struct fb_videomode *mode;
953                 DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
954 @@ -2167,6 +2201,21 @@
956         info = registered_fb[con2fb_map[vc->vc_num]];
957         ops = info->fbcon_par;
958 +       prev_console = ops->currcon;
959 +       if (prev_console != -1)
960 +               old_info = registered_fb[con2fb_map[prev_console]];
962 +#ifdef CONFIG_FB_CON_DECOR
963 +       if (!fbcon_decor_active_vc(vc) && info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
964 +               struct vc_data *vc_curr = vc_cons[prev_console].d;
965 +               if (vc_curr && fbcon_decor_active_vc(vc_curr)) {
966 +                       /* Clear the screen to avoid displaying funky colors during
967 +                        * palette updates. */
968 +                       memset((u8*)info->screen_base + info->fix.line_length * info->var.yoffset,
969 +                              0, info->var.yres * info->fix.line_length);
970 +               }
971 +       }
972 +#endif
974         if (softback_top) {
975                 if (softback_lines)
976 @@ -2185,9 +2234,6 @@
977                 logo_shown = FBCON_LOGO_CANSHOW;
978         }
980 -       prev_console = ops->currcon;
981 -       if (prev_console != -1)
982 -               old_info = registered_fb[con2fb_map[prev_console]];
983         /*
984          * FIXME: If we have multiple fbdev's loaded, we need to
985          * update all info->currcon.  Perhaps, we can place this
986 @@ -2231,6 +2277,18 @@
987                         fbcon_del_cursor_timer(old_info);
988         }
990 +       if (fbcon_decor_active_vc(vc)) {
991 +               struct vc_data *vc_curr = vc_cons[prev_console].d;
993 +               if (!vc_curr->vc_decor.theme ||
994 +                       strcmp(vc->vc_decor.theme, vc_curr->vc_decor.theme) ||
995 +                       (fbcon_decor_active_nores(info, vc_curr) &&
996 +                        !fbcon_decor_active(info, vc_curr))) {
997 +                       fbcon_decor_disable(vc, 0);
998 +                       fbcon_decor_call_helper("modechange", vc->vc_num);
999 +               }
1000 +       }
1002         if (fbcon_is_inactive(vc, info) ||
1003             ops->blank_state != FB_BLANK_UNBLANK)
1004                 fbcon_del_cursor_timer(info);
1005 @@ -2339,15 +2397,20 @@
1006                 }
1007         }
1009 -       if (!fbcon_is_inactive(vc, info)) {
1010 +       if (!fbcon_is_inactive(vc, info)) {
1011                 if (ops->blank_state != blank) {
1012                         ops->blank_state = blank;
1013                         fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
1014                         ops->cursor_flash = (!blank);
1016 -                       if (!(info->flags & FBINFO_MISC_USEREVENT))
1017 -                               if (fb_blank(info, blank))
1018 -                                       fbcon_generic_blank(vc, info, blank);
1019 +                       if (!(info->flags & FBINFO_MISC_USEREVENT)) {
1020 +                               if (fb_blank(info, blank)) {
1021 +                                       if (fbcon_decor_active(info, vc))
1022 +                                               fbcon_decor_blank(vc, info, blank);
1023 +                                       else
1024 +                                               fbcon_generic_blank(vc, info, blank);
1025 +                               }
1026 +                       }
1027                 }
1029                 if (!blank)
1030 @@ -2522,13 +2585,22 @@
1031         }
1033         if (resize) {
1034 +               /* reset wrap/pan */
1035                 int cols, rows;
1037                 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
1038                 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1040 +               if (fbcon_decor_active(info, vc)) {
1041 +                       info->var.xoffset = info->var.yoffset = p->yscroll = 0;
1042 +                       cols = vc->vc_decor.twidth;
1043 +                       rows = vc->vc_decor.theight;
1044 +               }
1045                 cols /= w;
1046                 rows /= h;
1048                 vc_resize(vc, cols, rows);
1050                 if (CON_IS_VISIBLE(vc) && softback_buf)
1051                         fbcon_update_softback(vc);
1052         } else if (CON_IS_VISIBLE(vc)
1053 @@ -2657,7 +2729,11 @@
1054         int i, j, k, depth;
1055         u8 val;
1057 -       if (fbcon_is_inactive(vc, info))
1058 +       if (fbcon_is_inactive(vc, info)
1059 +#ifdef CONFIG_FB_CON_DECOR
1060 +                       || vc->vc_num != fg_console
1061 +#endif
1062 +               )
1063                 return -EINVAL;
1065         if (!CON_IS_VISIBLE(vc))
1066 @@ -2683,14 +2759,56 @@
1067         } else
1068                 fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap);
1070 -       return fb_set_cmap(&palette_cmap, info);
1071 +       if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
1072 +           info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
1074 +               u16 *red, *green, *blue;
1075 +               int minlen = min(min(info->var.red.length, info->var.green.length),
1076 +                                    info->var.blue.length);
1077 +               int h;
1079 +               struct fb_cmap cmap = {
1080 +                       .start = 0,
1081 +                       .len = (1 << minlen),
1082 +                       .red = NULL,
1083 +                       .green = NULL,
1084 +                       .blue = NULL,
1085 +                       .transp = NULL
1086 +               };
1088 +               red = kmalloc(256 * sizeof(u16) * 3, GFP_KERNEL);
1090 +               if (!red)
1091 +                       goto out;
1093 +               green = red + 256;
1094 +               blue = green + 256;
1095 +               cmap.red = red;
1096 +               cmap.green = green;
1097 +               cmap.blue = blue;
1099 +               for (i = 0; i < cmap.len; i++) {
1100 +                       red[i] = green[i] = blue[i] = (0xffff * i)/(cmap.len-1);
1101 +               }
1103 +               h = fb_set_cmap(&cmap, info);
1104 +               fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
1105 +               kfree(red);
1107 +               return h;
1109 +       } else if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
1110 +                  info->var.bits_per_pixel == 8 && info->bgdecor.cmap.red != NULL)
1111 +               fb_set_cmap(&info->bgdecor.cmap, info);
1113 +out:   return fb_set_cmap(&palette_cmap, info);
1116  static u16 *fbcon_screen_pos(struct vc_data *vc, int offset)
1118         unsigned long p;
1119         int line;
1120 -       
1122         if (vc->vc_num != fg_console || !softback_lines)
1123                 return (u16 *) (vc->vc_origin + offset);
1124         line = offset / vc->vc_size_row;
1125 @@ -2909,7 +3027,14 @@
1126                 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1127                 cols /= vc->vc_font.width;
1128                 rows /= vc->vc_font.height;
1129 -               vc_resize(vc, cols, rows);
1131 +               if (!fbcon_decor_active_nores(info, vc)) {
1132 +                       vc_resize(vc, cols, rows);
1133 +               } else {
1134 +                       fbcon_decor_disable(vc, 0);
1135 +                       fbcon_decor_call_helper("modechange", vc->vc_num);
1136 +               }
1138                 updatescrollmode(p, info, vc);
1139                 scrollback_max = 0;
1140                 scrollback_current = 0;
1141 @@ -2954,7 +3079,9 @@
1142                 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1143                 cols /= vc->vc_font.width;
1144                 rows /= vc->vc_font.height;
1145 -               vc_resize(vc, cols, rows);
1146 +               if (!fbcon_decor_active_nores(info, vc)) {
1147 +                       vc_resize(vc, cols, rows);
1148 +               }
1149         }
1151         if (fg != -1)
1152 @@ -3596,6 +3723,7 @@
1153                 }
1154         }
1156 +       fbcon_decor_exit();
1157         fbcon_has_exited = 1;
1160 diff -Nur linux-3.15.1.orig/drivers/video/console/fbcondecor.c linux-3.15.1/drivers/video/console/fbcondecor.c
1161 --- linux-3.15.1.orig/drivers/video/console/fbcondecor.c        1970-01-01 01:00:00.000000000 +0100
1162 +++ linux-3.15.1/drivers/video/console/fbcondecor.c     2014-06-28 11:21:19.000000000 +0200
1163 @@ -0,0 +1,555 @@
1165 + *  linux/drivers/video/console/fbcondecor.c -- Framebuffer console decorations
1166 + *
1167 + *  Copyright (C) 2004-2009 Michal Januszewski <michalj+fbcondecor@gmail.com>
1168 + *
1169 + *  Code based upon "Bootsplash" (C) 2001-2003
1170 + *       Volker Poplawski <volker@poplawski.de>,
1171 + *       Stefan Reinauer <stepan@suse.de>,
1172 + *       Steffen Winterfeldt <snwint@suse.de>,
1173 + *       Michael Schroeder <mls@suse.de>,
1174 + *       Ken Wimer <wimer@suse.de>.
1175 + *
1176 + *  Compat ioctl support by Thorsten Klein <TK@Thorsten-Klein.de>.
1177 + *
1178 + *  This file is subject to the terms and conditions of the GNU General Public
1179 + *  License.  See the file COPYING in the main directory of this archive for
1180 + *  more details.
1181 + *
1182 + */
1183 +#include <linux/module.h>
1184 +#include <linux/kernel.h>
1185 +#include <linux/string.h>
1186 +#include <linux/types.h>
1187 +#include <linux/fb.h>
1188 +#include <linux/vt_kern.h>
1189 +#include <linux/vmalloc.h>
1190 +#include <linux/unistd.h>
1191 +#include <linux/syscalls.h>
1192 +#include <linux/init.h>
1193 +#include <linux/proc_fs.h>
1194 +#include <linux/workqueue.h>
1195 +#include <linux/kmod.h>
1196 +#include <linux/miscdevice.h>
1197 +#include <linux/device.h>
1198 +#include <linux/fs.h>
1199 +#include <linux/compat.h>
1200 +#include <linux/console.h>
1202 +#include <asm/uaccess.h>
1203 +#include <asm/irq.h>
1205 +#include "fbcon.h"
1206 +#include "fbcondecor.h"
1208 +extern signed char con2fb_map[];
1209 +static int fbcon_decor_enable(struct vc_data *vc);
1210 +char fbcon_decor_path[KMOD_PATH_LEN] = "/sbin/fbcondecor_helper";
1211 +static int initialized = 0;
1213 +int fbcon_decor_call_helper(char* cmd, unsigned short vc)
1215 +       char *envp[] = {
1216 +               "HOME=/",
1217 +               "PATH=/sbin:/bin",
1218 +               NULL
1219 +       };
1221 +       char tfb[5];
1222 +       char tcons[5];
1223 +       unsigned char fb = (int) con2fb_map[vc];
1225 +       char *argv[] = {
1226 +               fbcon_decor_path,
1227 +               "2",
1228 +               cmd,
1229 +               tcons,
1230 +               tfb,
1231 +               vc_cons[vc].d->vc_decor.theme,
1232 +               NULL
1233 +       };
1235 +       snprintf(tfb,5,"%d",fb);
1236 +       snprintf(tcons,5,"%d",vc);
1238 +       return call_usermodehelper(fbcon_decor_path, argv, envp, UMH_WAIT_EXEC);
1241 +/* Disables fbcondecor on a virtual console; called with console sem held. */
1242 +int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw)
1244 +       struct fb_info* info;
1246 +       if (!vc->vc_decor.state)
1247 +               return -EINVAL;
1249 +       info = registered_fb[(int) con2fb_map[vc->vc_num]];
1251 +       if (info == NULL)
1252 +               return -EINVAL;
1254 +       vc->vc_decor.state = 0;
1255 +       vc_resize(vc, info->var.xres / vc->vc_font.width,
1256 +                 info->var.yres / vc->vc_font.height);
1258 +       if (fg_console == vc->vc_num && redraw) {
1259 +               redraw_screen(vc, 0);
1260 +               update_region(vc, vc->vc_origin +
1261 +                             vc->vc_size_row * vc->vc_top,
1262 +                             vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1263 +       }
1265 +       printk(KERN_INFO "fbcondecor: switched decor state to 'off' on console %d\n",
1266 +                        vc->vc_num);
1268 +       return 0;
1271 +/* Enables fbcondecor on a virtual console; called with console sem held. */
1272 +static int fbcon_decor_enable(struct vc_data *vc)
1274 +       struct fb_info* info;
1276 +       info = registered_fb[(int) con2fb_map[vc->vc_num]];
1278 +       if (vc->vc_decor.twidth == 0 || vc->vc_decor.theight == 0 ||
1279 +           info == NULL || vc->vc_decor.state || (!info->bgdecor.data &&
1280 +           vc->vc_num == fg_console))
1281 +               return -EINVAL;
1283 +       vc->vc_decor.state = 1;
1284 +       vc_resize(vc, vc->vc_decor.twidth / vc->vc_font.width,
1285 +                 vc->vc_decor.theight / vc->vc_font.height);
1287 +       if (fg_console == vc->vc_num) {
1288 +               redraw_screen(vc, 0);
1289 +               update_region(vc, vc->vc_origin +
1290 +                             vc->vc_size_row * vc->vc_top,
1291 +                             vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1292 +               fbcon_decor_clear_margins(vc, info, 0);
1293 +       }
1295 +       printk(KERN_INFO "fbcondecor: switched decor state to 'on' on console %d\n",
1296 +                        vc->vc_num);
1298 +       return 0;
1301 +static inline int fbcon_decor_ioctl_dosetstate(struct vc_data *vc, unsigned int state, unsigned char origin)
1303 +       int ret;
1305 +//     if (origin == FBCON_DECOR_IO_ORIG_USER)
1306 +               console_lock();
1307 +       if (!state)
1308 +               ret = fbcon_decor_disable(vc, 1);
1309 +       else
1310 +               ret = fbcon_decor_enable(vc);
1311 +//     if (origin == FBCON_DECOR_IO_ORIG_USER)
1312 +               console_unlock();
1314 +       return ret;
1317 +static inline void fbcon_decor_ioctl_dogetstate(struct vc_data *vc, unsigned int *state)
1319 +       *state = vc->vc_decor.state;
1322 +static int fbcon_decor_ioctl_dosetcfg(struct vc_data *vc, struct vc_decor *cfg, unsigned char origin)
1324 +       struct fb_info *info;
1325 +       int len;
1326 +       char *tmp;
1328 +       info = registered_fb[(int) con2fb_map[vc->vc_num]];
1330 +       if (info == NULL || !cfg->twidth || !cfg->theight ||
1331 +           cfg->tx + cfg->twidth  > info->var.xres ||
1332 +           cfg->ty + cfg->theight > info->var.yres)
1333 +               return -EINVAL;
1335 +       len = strlen_user(cfg->theme);
1336 +       if (!len || len > FBCON_DECOR_THEME_LEN)
1337 +               return -EINVAL;
1338 +       tmp = kmalloc(len, GFP_KERNEL);
1339 +       if (!tmp)
1340 +               return -ENOMEM;
1341 +       if (copy_from_user(tmp, (void __user *)cfg->theme, len))
1342 +               return -EFAULT;
1343 +       cfg->theme = tmp;
1344 +       cfg->state = 0;
1346 +       /* If this ioctl is a response to a request from kernel, the console sem
1347 +        * is already held; we also don't need to disable decor because either the
1348 +        * new config and background picture will be successfully loaded, and the
1349 +        * decor will stay on, or in case of a failure it'll be turned off in fbcon. */
1350 +//     if (origin == FBCON_DECOR_IO_ORIG_USER) {
1351 +               console_lock();
1352 +               if (vc->vc_decor.state)
1353 +                       fbcon_decor_disable(vc, 1);
1354 +//     }
1356 +       if (vc->vc_decor.theme)
1357 +               kfree(vc->vc_decor.theme);
1359 +       vc->vc_decor = *cfg;
1361 +//     if (origin == FBCON_DECOR_IO_ORIG_USER)
1362 +               console_unlock();
1364 +       printk(KERN_INFO "fbcondecor: console %d using theme '%s'\n",
1365 +                        vc->vc_num, vc->vc_decor.theme);
1366 +       return 0;
1369 +static int fbcon_decor_ioctl_dogetcfg(struct vc_data *vc, struct vc_decor *decor)
1371 +       char __user *tmp;
1373 +       tmp = decor->theme;
1374 +       *decor = vc->vc_decor;
1375 +       decor->theme = tmp;
1377 +       if (vc->vc_decor.theme) {
1378 +               if (copy_to_user(tmp, vc->vc_decor.theme, strlen(vc->vc_decor.theme) + 1))
1379 +                       return -EFAULT;
1380 +       } else
1381 +               if (put_user(0, tmp))
1382 +                       return -EFAULT;
1384 +       return 0;
1387 +static int fbcon_decor_ioctl_dosetpic(struct vc_data *vc, struct fb_image *img, unsigned char origin)
1389 +       struct fb_info *info;
1390 +       int len;
1391 +       u8 *tmp;
1393 +       if (vc->vc_num != fg_console)
1394 +               return -EINVAL;
1396 +       info = registered_fb[(int) con2fb_map[vc->vc_num]];
1398 +       if (info == NULL)
1399 +               return -EINVAL;
1401 +       if (img->width != info->var.xres || img->height != info->var.yres) {
1402 +               printk(KERN_ERR "fbcondecor: picture dimensions mismatch\n");
1403 +               printk(KERN_ERR "%dx%d vs %dx%d\n", img->width, img->height, info->var.xres, info->var.yres);
1404 +               return -EINVAL;
1405 +       }
1407 +       if (img->depth != info->var.bits_per_pixel) {
1408 +               printk(KERN_ERR "fbcondecor: picture depth mismatch\n");
1409 +               return -EINVAL;
1410 +       }
1412 +       if (img->depth == 8) {
1413 +               if (!img->cmap.len || !img->cmap.red || !img->cmap.green ||
1414 +                   !img->cmap.blue)
1415 +                       return -EINVAL;
1417 +               tmp = vmalloc(img->cmap.len * 3 * 2);
1418 +               if (!tmp)
1419 +                       return -ENOMEM;
1421 +               if (copy_from_user(tmp,
1422 +                                  (void __user*)img->cmap.red, (img->cmap.len << 1)) ||
1423 +                   copy_from_user(tmp + (img->cmap.len << 1),
1424 +                                  (void __user*)img->cmap.green, (img->cmap.len << 1)) ||
1425 +                   copy_from_user(tmp + (img->cmap.len << 2),
1426 +                                  (void __user*)img->cmap.blue, (img->cmap.len << 1))) {
1427 +                       vfree(tmp);
1428 +                       return -EFAULT;
1429 +               }
1431 +               img->cmap.transp = NULL;
1432 +               img->cmap.red = (u16*)tmp;
1433 +               img->cmap.green = img->cmap.red + img->cmap.len;
1434 +               img->cmap.blue = img->cmap.green + img->cmap.len;
1435 +       } else {
1436 +               img->cmap.red = NULL;
1437 +       }
1439 +       len = ((img->depth + 7) >> 3) * img->width * img->height;
1441 +       /*
1442 +        * Allocate an additional byte so that we never go outside of the
1443 +        * buffer boundaries in the rendering functions in a 24 bpp mode.
1444 +        */
1445 +       tmp = vmalloc(len + 1);
1447 +       if (!tmp)
1448 +               goto out;
1450 +       if (copy_from_user(tmp, (void __user*)img->data, len))
1451 +               goto out;
1453 +       img->data = tmp;
1455 +       /* If this ioctl is a response to a request from kernel, the console sem
1456 +        * is already held. */
1457 +//     if (origin == FBCON_DECOR_IO_ORIG_USER)
1458 +               console_lock();
1460 +       if (info->bgdecor.data)
1461 +               vfree((u8*)info->bgdecor.data);
1462 +       if (info->bgdecor.cmap.red)
1463 +               vfree(info->bgdecor.cmap.red);
1465 +       info->bgdecor = *img;
1467 +       if (fbcon_decor_active_vc(vc) && fg_console == vc->vc_num) {
1468 +               redraw_screen(vc, 0);
1469 +               update_region(vc, vc->vc_origin +
1470 +                             vc->vc_size_row * vc->vc_top,
1471 +                             vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1472 +               fbcon_decor_clear_margins(vc, info, 0);
1473 +       }
1475 +//     if (origin == FBCON_DECOR_IO_ORIG_USER)
1476 +               console_unlock();
1478 +       return 0;
1480 +out:   if (img->cmap.red)
1481 +               vfree(img->cmap.red);
1483 +       if (tmp)
1484 +               vfree(tmp);
1485 +       return -ENOMEM;
1488 +static long fbcon_decor_ioctl(struct file *filp, u_int cmd, u_long arg)
1490 +       struct fbcon_decor_iowrapper __user *wrapper = (void __user*) arg;
1491 +       struct vc_data *vc = NULL;
1492 +       unsigned short vc_num = 0;
1493 +       unsigned char origin = 0;
1494 +       void __user *data = NULL;
1496 +       if (!access_ok(VERIFY_READ, wrapper,
1497 +                       sizeof(struct fbcon_decor_iowrapper)))
1498 +               return -EFAULT;
1500 +       __get_user(vc_num, &wrapper->vc);
1501 +       __get_user(origin, &wrapper->origin);
1502 +       __get_user(data, &wrapper->data);
1504 +       if (!vc_cons_allocated(vc_num))
1505 +               return -EINVAL;
1507 +       vc = vc_cons[vc_num].d;
1509 +       switch (cmd) {
1510 +       case FBIOCONDECOR_SETPIC:
1511 +       {
1512 +               struct fb_image img;
1513 +               if (copy_from_user(&img, (struct fb_image __user *)data, sizeof(struct fb_image)))
1514 +                       return -EFAULT;
1516 +               return fbcon_decor_ioctl_dosetpic(vc, &img, origin);
1517 +       }
1518 +       case FBIOCONDECOR_SETCFG:
1519 +       {
1520 +               struct vc_decor cfg;
1521 +               if (copy_from_user(&cfg, (struct vc_decor __user *)data, sizeof(struct vc_decor)))
1522 +                       return -EFAULT;
1524 +               return fbcon_decor_ioctl_dosetcfg(vc, &cfg, origin);
1525 +       }
1526 +       case FBIOCONDECOR_GETCFG:
1527 +       {
1528 +               int rval;
1529 +               struct vc_decor cfg;
1531 +               if (copy_from_user(&cfg, (struct vc_decor __user *)data, sizeof(struct vc_decor)))
1532 +                       return -EFAULT;
1534 +               rval = fbcon_decor_ioctl_dogetcfg(vc, &cfg);
1536 +               if (copy_to_user(data, &cfg, sizeof(struct vc_decor)))
1537 +                       return -EFAULT;
1538 +               return rval;
1539 +       }
1540 +       case FBIOCONDECOR_SETSTATE:
1541 +       {
1542 +               unsigned int state = 0;
1543 +               if (get_user(state, (unsigned int __user *)data))
1544 +                       return -EFAULT;
1545 +               return fbcon_decor_ioctl_dosetstate(vc, state, origin);
1546 +       }
1547 +       case FBIOCONDECOR_GETSTATE:
1548 +       {
1549 +               unsigned int state = 0;
1550 +               fbcon_decor_ioctl_dogetstate(vc, &state);
1551 +               return put_user(state, (unsigned int __user *)data);
1552 +       }
1554 +       default:
1555 +               return -ENOIOCTLCMD;
1556 +       }
1559 +#ifdef CONFIG_COMPAT
1561 +static long fbcon_decor_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) {
1563 +       struct fbcon_decor_iowrapper32 __user *wrapper = (void __user *)arg;
1564 +       struct vc_data *vc = NULL;
1565 +       unsigned short vc_num = 0;
1566 +       unsigned char origin = 0;
1567 +       compat_uptr_t data_compat = 0;
1568 +       void __user *data = NULL;
1570 +       if (!access_ok(VERIFY_READ, wrapper,
1571 +                       sizeof(struct fbcon_decor_iowrapper32)))
1572 +               return -EFAULT;
1574 +       __get_user(vc_num, &wrapper->vc);
1575 +       __get_user(origin, &wrapper->origin);
1576 +       __get_user(data_compat, &wrapper->data);
1577 +       data = compat_ptr(data_compat);
1579 +       if (!vc_cons_allocated(vc_num))
1580 +               return -EINVAL;
1582 +       vc = vc_cons[vc_num].d;
1584 +       switch (cmd) {
1585 +       case FBIOCONDECOR_SETPIC32:
1586 +       {
1587 +               struct fb_image32 img_compat;
1588 +               struct fb_image img;
1590 +               if (copy_from_user(&img_compat, (struct fb_image32 __user *)data, sizeof(struct fb_image32)))
1591 +                       return -EFAULT;
1593 +               fb_image_from_compat(img, img_compat);
1595 +               return fbcon_decor_ioctl_dosetpic(vc, &img, origin);
1596 +       }
1598 +       case FBIOCONDECOR_SETCFG32:
1599 +       {
1600 +               struct vc_decor32 cfg_compat;
1601 +               struct vc_decor cfg;
1603 +               if (copy_from_user(&cfg_compat, (struct vc_decor32 __user *)data, sizeof(struct vc_decor32)))
1604 +                       return -EFAULT;
1606 +               vc_decor_from_compat(cfg, cfg_compat);
1608 +               return fbcon_decor_ioctl_dosetcfg(vc, &cfg, origin);
1609 +       }
1611 +       case FBIOCONDECOR_GETCFG32:
1612 +       {
1613 +               int rval;
1614 +               struct vc_decor32 cfg_compat;
1615 +               struct vc_decor cfg;
1617 +               if (copy_from_user(&cfg_compat, (struct vc_decor32 __user *)data, sizeof(struct vc_decor32)))
1618 +                       return -EFAULT;
1619 +               cfg.theme = compat_ptr(cfg_compat.theme);
1621 +               rval = fbcon_decor_ioctl_dogetcfg(vc, &cfg);
1623 +               vc_decor_to_compat(cfg_compat, cfg);
1625 +               if (copy_to_user((struct vc_decor32 __user *)data, &cfg_compat, sizeof(struct vc_decor32)))
1626 +                       return -EFAULT;
1627 +               return rval;
1628 +       }
1630 +       case FBIOCONDECOR_SETSTATE32:
1631 +       {
1632 +               compat_uint_t state_compat = 0;
1633 +               unsigned int state = 0;
1635 +               if (get_user(state_compat, (compat_uint_t __user *)data))
1636 +                       return -EFAULT;
1638 +               state = (unsigned int)state_compat;
1640 +               return fbcon_decor_ioctl_dosetstate(vc, state, origin);
1641 +       }
1643 +       case FBIOCONDECOR_GETSTATE32:
1644 +       {
1645 +               compat_uint_t state_compat = 0;
1646 +               unsigned int state = 0;
1648 +               fbcon_decor_ioctl_dogetstate(vc, &state);
1649 +               state_compat = (compat_uint_t)state;
1651 +               return put_user(state_compat, (compat_uint_t __user *)data);
1652 +       }
1654 +       default:
1655 +               return -ENOIOCTLCMD;
1656 +       }
1658 +#else
1659 +  #define fbcon_decor_compat_ioctl NULL
1660 +#endif
1662 +static struct file_operations fbcon_decor_ops = {
1663 +       .owner = THIS_MODULE,
1664 +       .unlocked_ioctl = fbcon_decor_ioctl,
1665 +       .compat_ioctl = fbcon_decor_compat_ioctl
1668 +static struct miscdevice fbcon_decor_dev = {
1669 +       .minor = MISC_DYNAMIC_MINOR,
1670 +       .name = "fbcondecor",
1671 +       .fops = &fbcon_decor_ops
1674 +void fbcon_decor_reset()
1676 +       int i;
1678 +       for (i = 0; i < num_registered_fb; i++) {
1679 +               registered_fb[i]->bgdecor.data = NULL;
1680 +               registered_fb[i]->bgdecor.cmap.red = NULL;
1681 +       }
1683 +       for (i = 0; i < MAX_NR_CONSOLES && vc_cons[i].d; i++) {
1684 +               vc_cons[i].d->vc_decor.state = vc_cons[i].d->vc_decor.twidth =
1685 +                                               vc_cons[i].d->vc_decor.theight = 0;
1686 +               vc_cons[i].d->vc_decor.theme = NULL;
1687 +       }
1689 +       return;
1692 +int fbcon_decor_init()
1694 +       int i;
1696 +       fbcon_decor_reset();
1698 +       if (initialized)
1699 +               return 0;
1701 +       i = misc_register(&fbcon_decor_dev);
1702 +       if (i) {
1703 +               printk(KERN_ERR "fbcondecor: failed to register device\n");
1704 +               return i;
1705 +       }
1707 +       fbcon_decor_call_helper("init", 0);
1708 +       initialized = 1;
1709 +       return 0;
1712 +int fbcon_decor_exit(void)
1714 +       fbcon_decor_reset();
1715 +       return 0;
1718 +EXPORT_SYMBOL(fbcon_decor_path);
1719 diff -Nur linux-3.15.1.orig/drivers/video/console/fbcondecor.h linux-3.15.1/drivers/video/console/fbcondecor.h
1720 --- linux-3.15.1.orig/drivers/video/console/fbcondecor.h        1970-01-01 01:00:00.000000000 +0100
1721 +++ linux-3.15.1/drivers/video/console/fbcondecor.h     2014-06-28 11:21:19.000000000 +0200
1722 @@ -0,0 +1,79 @@
1723 +/* 
1724 + *  linux/drivers/video/console/fbcondecor.h -- Framebuffer Console Decoration headers
1725 + *
1726 + *  Copyright (C) 2004 Michal Januszewski <michalj+fbcondecor@gmail.com>
1727 + *
1728 + */
1730 +#ifndef __FBCON_DECOR_H
1731 +#define __FBCON_DECOR_H
1733 +#ifndef _LINUX_FB_H
1734 +#include <linux/fb.h>
1735 +#endif
1737 +/* This is needed for vc_cons in fbcmap.c */
1738 +#include <linux/vt_kern.h>
1740 +struct fb_cursor;
1741 +struct fb_info;
1742 +struct vc_data;
1744 +#ifdef CONFIG_FB_CON_DECOR
1745 +/* fbcondecor.c */
1746 +int fbcon_decor_init(void);
1747 +void fbcon_decor_reset(void);
1748 +int fbcon_decor_exit(void);
1749 +int fbcon_decor_call_helper(char* cmd, unsigned short cons);
1750 +int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw);
1752 +/* cfbcondecor.c */
1753 +void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx);
1754 +void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor);
1755 +void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width);
1756 +void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only);
1757 +void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank);
1758 +void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width);
1759 +void fbcon_decor_copy(u8 *dst, u8 *src, int height, int width, int linebytes, int srclinesbytes, int bpp);
1760 +void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc);
1762 +/* vt.c */
1763 +void acquire_console_sem(void);
1764 +void release_console_sem(void);
1765 +void do_unblank_screen(int entering_gfx);
1767 +/* struct vc_data *y */
1768 +#define fbcon_decor_active_vc(y) (y->vc_decor.state && y->vc_decor.theme) 
1770 +/* struct fb_info *x, struct vc_data *y */
1771 +#define fbcon_decor_active_nores(x,y) (x->bgdecor.data && fbcon_decor_active_vc(y))
1773 +/* struct fb_info *x, struct vc_data *y */
1774 +#define fbcon_decor_active(x,y) (fbcon_decor_active_nores(x,y) &&              \
1775 +                             x->bgdecor.width == x->var.xres &&        \
1776 +                             x->bgdecor.height == x->var.yres &&       \
1777 +                             x->bgdecor.depth == x->var.bits_per_pixel)
1780 +#else /* CONFIG_FB_CON_DECOR */
1782 +static inline void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx) {}
1783 +static inline void fbcon_decor_putc(struct vc_data *vc, struct fb_info *info, int c, int ypos, int xpos) {}
1784 +static inline void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor) {}
1785 +static inline void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) {}
1786 +static inline void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only) {}
1787 +static inline void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank) {}
1788 +static inline void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width) {}
1789 +static inline void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc) {}
1790 +static inline int fbcon_decor_call_helper(char* cmd, unsigned short cons) { return 0; }
1791 +static inline int fbcon_decor_init(void) { return 0; }
1792 +static inline int fbcon_decor_exit(void) { return 0; }
1793 +static inline int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw) { return 0; }
1795 +#define fbcon_decor_active_vc(y) (0)
1796 +#define fbcon_decor_active_nores(x,y) (0)
1797 +#define fbcon_decor_active(x,y) (0)
1799 +#endif /* CONFIG_FB_CON_DECOR */
1801 +#endif /* __FBCON_DECOR_H */
1802 diff -Nur linux-3.15.1.orig/drivers/video/fbdev/core/fbcmap.c linux-3.15.1/drivers/video/fbdev/core/fbcmap.c
1803 --- linux-3.15.1.orig/drivers/video/fbdev/core/fbcmap.c 2014-06-16 22:44:27.000000000 +0200
1804 +++ linux-3.15.1/drivers/video/fbdev/core/fbcmap.c      2014-06-28 11:21:49.000000000 +0200
1805 @@ -17,6 +17,8 @@
1806  #include <linux/slab.h>
1807  #include <linux/uaccess.h>
1809 +#include "../../console/fbcondecor.h"
1811  static u16 red2[] __read_mostly = {
1812      0x0000, 0xaaaa
1813  };
1814 @@ -257,6 +259,10 @@
1815         if (rc == 0)
1816                 fb_copy_cmap(cmap, &info->cmap);
1818 +               if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
1819 +                   info->fix.visual == FB_VISUAL_DIRECTCOLOR)
1820 +                       fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
1822         return rc;
1825 diff -Nur linux-3.15.1.orig/include/linux/console_decor.h linux-3.15.1/include/linux/console_decor.h
1826 --- linux-3.15.1.orig/include/linux/console_decor.h     1970-01-01 01:00:00.000000000 +0100
1827 +++ linux-3.15.1/include/linux/console_decor.h  2014-06-28 11:21:19.000000000 +0200
1828 @@ -0,0 +1,46 @@
1829 +#ifndef _LINUX_CONSOLE_DECOR_H_
1830 +#define _LINUX_CONSOLE_DECOR_H_ 1
1832 +/* A structure used by the framebuffer console decorations (drivers/video/console/fbcondecor.c) */
1833 +struct vc_decor {
1834 +       __u8 bg_color;                          /* The color that is to be treated as transparent */
1835 +       __u8 state;                             /* Current decor state: 0 = off, 1 = on */
1836 +       __u16 tx, ty;                           /* Top left corner coordinates of the text field */
1837 +       __u16 twidth, theight;                  /* Width and height of the text field */
1838 +       char* theme;
1841 +#ifdef __KERNEL__
1842 +#ifdef CONFIG_COMPAT
1843 +#include <linux/compat.h>
1845 +struct vc_decor32 {
1846 +       __u8 bg_color;                          /* The color that is to be treated as transparent */
1847 +       __u8 state;                             /* Current decor state: 0 = off, 1 = on */
1848 +       __u16 tx, ty;                           /* Top left corner coordinates of the text field */
1849 +       __u16 twidth, theight;                  /* Width and height of the text field */
1850 +       compat_uptr_t theme;
1853 +#define vc_decor_from_compat(to, from) \
1854 +       (to).bg_color = (from).bg_color; \
1855 +       (to).state    = (from).state; \
1856 +       (to).tx       = (from).tx; \
1857 +       (to).ty       = (from).ty; \
1858 +       (to).twidth   = (from).twidth; \
1859 +       (to).theight  = (from).theight; \
1860 +       (to).theme    = compat_ptr((from).theme)
1862 +#define vc_decor_to_compat(to, from) \
1863 +       (to).bg_color = (from).bg_color; \
1864 +       (to).state    = (from).state; \
1865 +       (to).tx       = (from).tx; \
1866 +       (to).ty       = (from).ty; \
1867 +       (to).twidth   = (from).twidth; \
1868 +       (to).theight  = (from).theight; \
1869 +       (to).theme    = ptr_to_compat((from).theme)
1871 +#endif /* CONFIG_COMPAT */
1872 +#endif /* __KERNEL__ */
1874 +#endif
1875 diff -Nur linux-3.15.1.orig/include/linux/console_struct.h linux-3.15.1/include/linux/console_struct.h
1876 --- linux-3.15.1.orig/include/linux/console_struct.h    2014-06-16 22:44:27.000000000 +0200
1877 +++ linux-3.15.1/include/linux/console_struct.h 2014-06-28 11:21:19.000000000 +0200
1878 @@ -19,6 +19,7 @@
1879  struct vt_struct;
1881  #define NPAR 16
1882 +#include <linux/console_decor.h>
1884  struct vc_data {
1885         struct tty_port port;                   /* Upper level data */
1886 @@ -107,6 +108,8 @@
1887         unsigned long   vc_uni_pagedir;
1888         unsigned long   *vc_uni_pagedir_loc;  /* [!] Location of uni_pagedir variable for this console */
1889         bool vc_panic_force_write; /* when oops/panic this VC can accept forced output/blanking */
1891 +       struct vc_decor vc_decor;
1892         /* additional information is in vt_kern.h */
1893  };
1895 diff -Nur linux-3.15.1.orig/include/linux/fb.h linux-3.15.1/include/linux/fb.h
1896 --- linux-3.15.1.orig/include/linux/fb.h        2014-06-16 22:44:27.000000000 +0200
1897 +++ linux-3.15.1/include/linux/fb.h     2014-06-28 11:21:19.000000000 +0200
1898 @@ -219,6 +219,34 @@
1899  };
1900  #endif
1902 +#ifdef __KERNEL__
1903 +#ifdef CONFIG_COMPAT
1904 +struct fb_image32 {
1905 +       __u32 dx;                       /* Where to place image */
1906 +       __u32 dy;
1907 +       __u32 width;                    /* Size of image */
1908 +       __u32 height;
1909 +       __u32 fg_color;                 /* Only used when a mono bitmap */
1910 +       __u32 bg_color;
1911 +       __u8  depth;                    /* Depth of the image */
1912 +       const compat_uptr_t data;       /* Pointer to image data */
1913 +       struct fb_cmap32 cmap;          /* color map info */
1916 +#define fb_image_from_compat(to, from) \
1917 +       (to).dx       = (from).dx; \
1918 +       (to).dy       = (from).dy; \
1919 +       (to).width    = (from).width; \
1920 +       (to).height   = (from).height; \
1921 +       (to).fg_color = (from).fg_color; \
1922 +       (to).bg_color = (from).bg_color; \
1923 +       (to).depth    = (from).depth; \
1924 +       (to).data     = compat_ptr((from).data); \
1925 +       fb_cmap_from_compat((to).cmap, (from).cmap)
1927 +#endif /* CONFIG_COMPAT */
1928 +#endif /* __KERNEL__ */
1930  /*
1931   * Frame buffer operations
1932   *
1933 @@ -489,6 +517,9 @@
1934  #define FBINFO_STATE_SUSPENDED 1
1935         u32 state;                      /* Hardware state i.e suspend */
1936         void *fbcon_par;                /* fbcon use-only private area */
1938 +       struct fb_image bgdecor;
1940         /* From here on everything is device dependent */
1941         void *par;
1942         /* we need the PCI or similar aperture base/size not
1943 diff -Nur linux-3.15.1.orig/include/uapi/linux/fb.h linux-3.15.1/include/uapi/linux/fb.h
1944 --- linux-3.15.1.orig/include/uapi/linux/fb.h   2014-06-16 22:44:27.000000000 +0200
1945 +++ linux-3.15.1/include/uapi/linux/fb.h        2014-06-28 11:21:19.000000000 +0200
1946 @@ -8,6 +8,25 @@
1948  #define FB_MAX                 32      /* sufficient for now */
1950 +struct fbcon_decor_iowrapper
1952 +       unsigned short vc;              /* Virtual console */
1953 +       unsigned char origin;           /* Point of origin of the request */
1954 +       void *data;
1957 +#ifdef __KERNEL__
1958 +#ifdef CONFIG_COMPAT
1959 +#include <linux/compat.h>
1960 +struct fbcon_decor_iowrapper32
1962 +       unsigned short vc;              /* Virtual console */
1963 +       unsigned char origin;           /* Point of origin of the request */
1964 +       compat_uptr_t data;
1966 +#endif /* CONFIG_COMPAT */
1967 +#endif /* __KERNEL__ */
1969  /* ioctls
1970     0x46 is 'F'                                                         */
1971  #define FBIOGET_VSCREENINFO    0x4600
1972 @@ -35,6 +54,25 @@
1973  #define FBIOGET_DISPINFO        0x4618
1974  #define FBIO_WAITFORVSYNC      _IOW('F', 0x20, __u32)
1976 +#define FBIOCONDECOR_SETCFG    _IOWR('F', 0x19, struct fbcon_decor_iowrapper)
1977 +#define FBIOCONDECOR_GETCFG    _IOR('F', 0x1A, struct fbcon_decor_iowrapper)
1978 +#define FBIOCONDECOR_SETSTATE  _IOWR('F', 0x1B, struct fbcon_decor_iowrapper)
1979 +#define FBIOCONDECOR_GETSTATE  _IOR('F', 0x1C, struct fbcon_decor_iowrapper)
1980 +#define FBIOCONDECOR_SETPIC    _IOWR('F', 0x1D, struct fbcon_decor_iowrapper)
1981 +#ifdef __KERNEL__
1982 +#ifdef CONFIG_COMPAT
1983 +#define FBIOCONDECOR_SETCFG32  _IOWR('F', 0x19, struct fbcon_decor_iowrapper32)
1984 +#define FBIOCONDECOR_GETCFG32  _IOR('F', 0x1A, struct fbcon_decor_iowrapper32)
1985 +#define FBIOCONDECOR_SETSTATE32        _IOWR('F', 0x1B, struct fbcon_decor_iowrapper32)
1986 +#define FBIOCONDECOR_GETSTATE32        _IOR('F', 0x1C, struct fbcon_decor_iowrapper32)
1987 +#define FBIOCONDECOR_SETPIC32  _IOWR('F', 0x1D, struct fbcon_decor_iowrapper32)
1988 +#endif /* CONFIG_COMPAT */
1989 +#endif /* __KERNEL__ */
1991 +#define FBCON_DECOR_THEME_LEN          128     /* Maximum lenght of a theme name */
1992 +#define FBCON_DECOR_IO_ORIG_KERNEL     0       /* Kernel ioctl origin */
1993 +#define FBCON_DECOR_IO_ORIG_USER       1       /* User ioctl origin */
1995  #define FB_TYPE_PACKED_PIXELS          0       /* Packed Pixels        */
1996  #define FB_TYPE_PLANES                 1       /* Non interleaved planes */
1997  #define FB_TYPE_INTERLEAVED_PLANES     2       /* Interleaved planes   */
1998 @@ -277,6 +315,29 @@
1999         __u32 reserved[4];              /* Reserved for future compatibility */
2000  };
2002 +#ifdef __KERNEL__
2003 +#ifdef CONFIG_COMPAT
2004 +struct fb_cmap32 {
2005 +       __u32 start;
2006 +       __u32 len;                      /* Number of entries */
2007 +       compat_uptr_t red;              /* Red values   */
2008 +       compat_uptr_t green;
2009 +       compat_uptr_t blue;
2010 +       compat_uptr_t transp;           /* transparency, can be NULL */
2013 +#define fb_cmap_from_compat(to, from) \
2014 +       (to).start  = (from).start; \
2015 +       (to).len    = (from).len; \
2016 +       (to).red    = compat_ptr((from).red); \
2017 +       (to).green  = compat_ptr((from).green); \
2018 +       (to).blue   = compat_ptr((from).blue); \
2019 +       (to).transp = compat_ptr((from).transp)
2021 +#endif /* CONFIG_COMPAT */
2022 +#endif /* __KERNEL__ */
2025  struct fb_cmap {
2026         __u32 start;                    /* First entry  */
2027         __u32 len;                      /* Number of entries */
2028 diff -Nur linux-3.15.1.orig/kernel/sysctl.c linux-3.15.1/kernel/sysctl.c
2029 --- linux-3.15.1.orig/kernel/sysctl.c   2014-06-16 22:44:27.000000000 +0200
2030 +++ linux-3.15.1/kernel/sysctl.c        2014-06-28 11:21:19.000000000 +0200
2031 @@ -146,6 +146,10 @@
2032  static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
2033  #endif
2035 +#ifdef CONFIG_FB_CON_DECOR
2036 +extern char fbcon_decor_path[];
2037 +#endif
2039  #ifdef CONFIG_INOTIFY_USER
2040  #include <linux/inotify.h>
2041  #endif
2042 @@ -255,6 +259,15 @@
2043                 .mode           = 0555,
2044                 .child          = dev_table,
2045         },
2046 +#ifdef CONFIG_FB_CON_DECOR
2047 +       {
2048 +               .procname       = "fbcondecor",
2049 +               .data           = &fbcon_decor_path,
2050 +               .maxlen         = KMOD_PATH_LEN,
2051 +               .mode           = 0644,
2052 +               .proc_handler   = &proc_dostring,
2053 +       },
2054 +#endif
2055         { }
2056  };