linux: bump kernel versions
[openadk.git] / target / linux / patches / 3.16.49 / fblogo.patch
blob5b907024270bde2c7d7a5daa8354ad01aabcf34b
1 diff -Nur linux-3.18.9.orig/Documentation/fb/00-INDEX linux-3.18.9/Documentation/fb/00-INDEX
2 --- linux-3.18.9.orig/Documentation/fb/00-INDEX 2015-03-06 16:53:42.000000000 -0600
3 +++ linux-3.18.9/Documentation/fb/00-INDEX 2015-03-15 14:34:13.068143682 -0500
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.18.9.orig/Documentation/fb/fbcondecor.txt linux-3.18.9/Documentation/fb/fbcondecor.txt
14 --- linux-3.18.9.orig/Documentation/fb/fbcondecor.txt 1969-12-31 18:00:00.000000000 -0600
15 +++ linux-3.18.9/Documentation/fb/fbcondecor.txt 2015-03-15 14:34:13.068143682 -0500
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.
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.18.9.orig/drivers/Makefile linux-3.18.9/drivers/Makefile
225 --- linux-3.18.9.orig/drivers/Makefile 2015-03-06 16:53:42.000000000 -0600
226 +++ linux-3.18.9/drivers/Makefile 2015-03-15 14:34:13.068143682 -0500
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 @@ -45,11 +49,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.18.9.orig/drivers/video/console/bitblit.c linux-3.18.9/drivers/video/console/bitblit.c
251 --- linux-3.18.9.orig/drivers/video/console/bitblit.c 2015-03-06 16:53:42.000000000 -0600
252 +++ linux-3.18.9/drivers/video/console/bitblit.c 2015-03-15 14:34:13.068143682 -0500
253 @@ -18,6 +18,7 @@
254 #include <linux/console.h>
255 #include <asm/types.h>
256 #include "fbcon.h"
257 +#include "fbcondecor.h"
260 * Accelerated handlers.
261 @@ -55,6 +56,13 @@
262 area.height = height * vc->vc_font.height;
263 area.width = width * vc->vc_font.width;
265 + if (fbcon_decor_active(info, vc)) {
266 + area.sx += vc->vc_decor.tx;
267 + area.sy += vc->vc_decor.ty;
268 + area.dx += vc->vc_decor.tx;
269 + area.dy += vc->vc_decor.ty;
272 info->fbops->fb_copyarea(info, &area);
275 @@ -379,11 +387,15 @@
276 cursor.image.depth = 1;
277 cursor.rop = ROP_XOR;
279 - if (info->fbops->fb_cursor)
280 - err = info->fbops->fb_cursor(info, &cursor);
281 + if (fbcon_decor_active(info, vc)) {
282 + fbcon_decor_cursor(info, &cursor);
283 + } else {
284 + if (info->fbops->fb_cursor)
285 + err = info->fbops->fb_cursor(info, &cursor);
287 - if (err)
288 - soft_cursor(info, &cursor);
289 + if (err)
290 + soft_cursor(info, &cursor);
293 ops->cursor_reset = 0;
295 diff -Nur linux-3.18.9.orig/drivers/video/console/cfbcondecor.c linux-3.18.9/drivers/video/console/cfbcondecor.c
296 --- linux-3.18.9.orig/drivers/video/console/cfbcondecor.c 1969-12-31 18:00:00.000000000 -0600
297 +++ linux-3.18.9/drivers/video/console/cfbcondecor.c 2015-03-15 14:34:13.072143681 -0500
298 @@ -0,0 +1,471 @@
300 + * linux/drivers/video/cfbcon_decor.c -- Framebuffer decor render functions
302 + * Copyright (C) 2004 Michal Januszewski <michalj+fbcondecor@gmail.com>
304 + * Code based upon "Bootdecor" (C) 2001-2003
305 + * Volker Poplawski <volker@poplawski.de>,
306 + * Stefan Reinauer <stepan@suse.de>,
307 + * Steffen Winterfeldt <snwint@suse.de>,
308 + * Michael Schroeder <mls@suse.de>,
309 + * Ken Wimer <wimer@suse.de>.
311 + * This file is subject to the terms and conditions of the GNU General Public
312 + * License. See the file COPYING in the main directory of this archive for
313 + * more details.
314 + */
315 +#include <linux/module.h>
316 +#include <linux/types.h>
317 +#include <linux/fb.h>
318 +#include <linux/selection.h>
319 +#include <linux/slab.h>
320 +#include <linux/vt_kern.h>
321 +#include <asm/irq.h>
323 +#include "fbcon.h"
324 +#include "fbcondecor.h"
326 +#define parse_pixel(shift,bpp,type) \
327 + do { \
328 + if (d & (0x80 >> (shift))) \
329 + dd2[(shift)] = fgx; \
330 + else \
331 + dd2[(shift)] = transparent ? *(type *)decor_src : bgx; \
332 + decor_src += (bpp); \
333 + } while (0) \
335 +extern int get_color(struct vc_data *vc, struct fb_info *info,
336 + u16 c, int is_fg);
338 +void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc)
340 + int i, j, k;
341 + int minlen = min(min(info->var.red.length, info->var.green.length),
342 + info->var.blue.length);
343 + u32 col;
345 + for (j = i = 0; i < 16; i++) {
346 + k = color_table[i];
348 + col = ((vc->vc_palette[j++] >> (8-minlen))
349 + << info->var.red.offset);
350 + col |= ((vc->vc_palette[j++] >> (8-minlen))
351 + << info->var.green.offset);
352 + col |= ((vc->vc_palette[j++] >> (8-minlen))
353 + << info->var.blue.offset);
354 + ((u32 *)info->pseudo_palette)[k] = col;
358 +void fbcon_decor_renderc(struct fb_info *info, int ypos, int xpos, int height,
359 + int width, u8* src, u32 fgx, u32 bgx, u8 transparent)
361 + unsigned int x, y;
362 + u32 dd;
363 + int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
364 + unsigned int d = ypos * info->fix.line_length + xpos * bytespp;
365 + unsigned int ds = (ypos * info->var.xres + xpos) * bytespp;
366 + u16 dd2[4];
368 + u8* decor_src = (u8 *)(info->bgdecor.data + ds);
369 + u8* dst = (u8 *)(info->screen_base + d);
371 + if ((ypos + height) > info->var.yres || (xpos + width) > info->var.xres)
372 + return;
374 + for (y = 0; y < height; y++) {
375 + switch (info->var.bits_per_pixel) {
377 + case 32:
378 + for (x = 0; x < width; x++) {
380 + if ((x & 7) == 0)
381 + d = *src++;
382 + if (d & 0x80)
383 + dd = fgx;
384 + else
385 + dd = transparent ?
386 + *(u32 *)decor_src : bgx;
388 + d <<= 1;
389 + decor_src += 4;
390 + fb_writel(dd, dst);
391 + dst += 4;
393 + break;
394 + case 24:
395 + for (x = 0; x < width; x++) {
397 + if ((x & 7) == 0)
398 + d = *src++;
399 + if (d & 0x80)
400 + dd = fgx;
401 + else
402 + dd = transparent ?
403 + (*(u32 *)decor_src & 0xffffff) : bgx;
405 + d <<= 1;
406 + decor_src += 3;
407 +#ifdef __LITTLE_ENDIAN
408 + fb_writew(dd & 0xffff, dst);
409 + dst += 2;
410 + fb_writeb((dd >> 16), dst);
411 +#else
412 + fb_writew(dd >> 8, dst);
413 + dst += 2;
414 + fb_writeb(dd & 0xff, dst);
415 +#endif
416 + dst++;
418 + break;
419 + case 16:
420 + for (x = 0; x < width; x += 2) {
421 + if ((x & 7) == 0)
422 + d = *src++;
424 + parse_pixel(0, 2, u16);
425 + parse_pixel(1, 2, u16);
426 +#ifdef __LITTLE_ENDIAN
427 + dd = dd2[0] | (dd2[1] << 16);
428 +#else
429 + dd = dd2[1] | (dd2[0] << 16);
430 +#endif
431 + d <<= 2;
432 + fb_writel(dd, dst);
433 + dst += 4;
435 + break;
437 + case 8:
438 + for (x = 0; x < width; x += 4) {
439 + if ((x & 7) == 0)
440 + d = *src++;
442 + parse_pixel(0, 1, u8);
443 + parse_pixel(1, 1, u8);
444 + parse_pixel(2, 1, u8);
445 + parse_pixel(3, 1, u8);
447 +#ifdef __LITTLE_ENDIAN
448 + dd = dd2[0] | (dd2[1] << 8) | (dd2[2] << 16) | (dd2[3] << 24);
449 +#else
450 + dd = dd2[3] | (dd2[2] << 8) | (dd2[1] << 16) | (dd2[0] << 24);
451 +#endif
452 + d <<= 4;
453 + fb_writel(dd, dst);
454 + dst += 4;
458 + dst += info->fix.line_length - width * bytespp;
459 + decor_src += (info->var.xres - width) * bytespp;
463 +#define cc2cx(a) \
464 + ((info->fix.visual == FB_VISUAL_TRUECOLOR || \
465 + info->fix.visual == FB_VISUAL_DIRECTCOLOR) ? \
466 + ((u32*)info->pseudo_palette)[a] : a)
468 +void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info,
469 + const unsigned short *s, int count, int yy, int xx)
471 + unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
472 + struct fbcon_ops *ops = info->fbcon_par;
473 + int fg_color, bg_color, transparent;
474 + u8 *src;
475 + u32 bgx, fgx;
476 + u16 c = scr_readw(s);
478 + fg_color = get_color(vc, info, c, 1);
479 + bg_color = get_color(vc, info, c, 0);
481 + /* Don't paint the background image if console is blanked */
482 + transparent = ops->blank_state ? 0 :
483 + (vc->vc_decor.bg_color == bg_color);
485 + xx = xx * vc->vc_font.width + vc->vc_decor.tx;
486 + yy = yy * vc->vc_font.height + vc->vc_decor.ty;
488 + fgx = cc2cx(fg_color);
489 + bgx = cc2cx(bg_color);
491 + while (count--) {
492 + c = scr_readw(s++);
493 + src = vc->vc_font.data + (c & charmask) * vc->vc_font.height *
494 + ((vc->vc_font.width + 7) >> 3);
496 + fbcon_decor_renderc(info, yy, xx, vc->vc_font.height,
497 + vc->vc_font.width, src, fgx, bgx, transparent);
498 + xx += vc->vc_font.width;
502 +void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor)
504 + int i;
505 + unsigned int dsize, s_pitch;
506 + struct fbcon_ops *ops = info->fbcon_par;
507 + struct vc_data* vc;
508 + u8 *src;
510 + /* we really don't need any cursors while the console is blanked */
511 + if (info->state != FBINFO_STATE_RUNNING || ops->blank_state)
512 + return;
514 + vc = vc_cons[ops->currcon].d;
516 + src = kmalloc(64 + sizeof(struct fb_image), GFP_ATOMIC);
517 + if (!src)
518 + return;
520 + s_pitch = (cursor->image.width + 7) >> 3;
521 + dsize = s_pitch * cursor->image.height;
522 + if (cursor->enable) {
523 + switch (cursor->rop) {
524 + case ROP_XOR:
525 + for (i = 0; i < dsize; i++)
526 + src[i] = cursor->image.data[i] ^ cursor->mask[i];
527 + break;
528 + case ROP_COPY:
529 + default:
530 + for (i = 0; i < dsize; i++)
531 + src[i] = cursor->image.data[i] & cursor->mask[i];
532 + break;
534 + } else
535 + memcpy(src, cursor->image.data, dsize);
537 + fbcon_decor_renderc(info,
538 + cursor->image.dy + vc->vc_decor.ty,
539 + cursor->image.dx + vc->vc_decor.tx,
540 + cursor->image.height,
541 + cursor->image.width,
542 + (u8*)src,
543 + cc2cx(cursor->image.fg_color),
544 + cc2cx(cursor->image.bg_color),
545 + cursor->image.bg_color == vc->vc_decor.bg_color);
547 + kfree(src);
550 +static void decorset(u8 *dst, int height, int width, int dstbytes,
551 + u32 bgx, int bpp)
553 + int i;
555 + if (bpp == 8)
556 + bgx |= bgx << 8;
557 + if (bpp == 16 || bpp == 8)
558 + bgx |= bgx << 16;
560 + while (height-- > 0) {
561 + u8 *p = dst;
563 + switch (bpp) {
565 + case 32:
566 + for (i=0; i < width; i++) {
567 + fb_writel(bgx, p); p += 4;
569 + break;
570 + case 24:
571 + for (i=0; i < width; i++) {
572 +#ifdef __LITTLE_ENDIAN
573 + fb_writew((bgx & 0xffff),(u16*)p); p += 2;
574 + fb_writeb((bgx >> 16),p++);
575 +#else
576 + fb_writew((bgx >> 8),(u16*)p); p += 2;
577 + fb_writeb((bgx & 0xff),p++);
578 +#endif
580 + case 16:
581 + for (i=0; i < width/4; i++) {
582 + fb_writel(bgx,p); p += 4;
583 + fb_writel(bgx,p); p += 4;
585 + if (width & 2) {
586 + fb_writel(bgx,p); p += 4;
588 + if (width & 1)
589 + fb_writew(bgx,(u16*)p);
590 + break;
591 + case 8:
592 + for (i=0; i < width/4; i++) {
593 + fb_writel(bgx,p); p += 4;
596 + if (width & 2) {
597 + fb_writew(bgx,p); p += 2;
599 + if (width & 1)
600 + fb_writeb(bgx,(u8*)p);
601 + break;
604 + dst += dstbytes;
608 +void fbcon_decor_copy(u8 *dst, u8 *src, int height, int width, int linebytes,
609 + int srclinebytes, int bpp)
611 + int i;
613 + while (height-- > 0) {
614 + u32 *p = (u32 *)dst;
615 + u32 *q = (u32 *)src;
617 + switch (bpp) {
619 + case 32:
620 + for (i=0; i < width; i++)
621 + fb_writel(*q++, p++);
622 + break;
623 + case 24:
624 + for (i=0; i < (width*3/4); i++)
625 + fb_writel(*q++, p++);
626 + if ((width*3) % 4) {
627 + if (width & 2) {
628 + fb_writeb(*(u8*)q, (u8*)p);
629 + } else if (width & 1) {
630 + fb_writew(*(u16*)q, (u16*)p);
631 + fb_writeb(*(u8*)((u16*)q+1),(u8*)((u16*)p+2));
634 + break;
635 + case 16:
636 + for (i=0; i < width/4; i++) {
637 + fb_writel(*q++, p++);
638 + fb_writel(*q++, p++);
640 + if (width & 2)
641 + fb_writel(*q++, p++);
642 + if (width & 1)
643 + fb_writew(*(u16*)q, (u16*)p);
644 + break;
645 + case 8:
646 + for (i=0; i < width/4; i++)
647 + fb_writel(*q++, p++);
649 + if (width & 2) {
650 + fb_writew(*(u16*)q, (u16*)p);
651 + q = (u32*) ((u16*)q + 1);
652 + p = (u32*) ((u16*)p + 1);
654 + if (width & 1)
655 + fb_writeb(*(u8*)q, (u8*)p);
656 + break;
659 + dst += linebytes;
660 + src += srclinebytes;
664 +static void decorfill(struct fb_info *info, int sy, int sx, int height,
665 + int width)
667 + int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
668 + int d = sy * info->fix.line_length + sx * bytespp;
669 + int ds = (sy * info->var.xres + sx) * bytespp;
671 + fbcon_decor_copy((u8 *)(info->screen_base + d), (u8 *)(info->bgdecor.data + ds),
672 + height, width, info->fix.line_length, info->var.xres * bytespp,
673 + info->var.bits_per_pixel);
676 +void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx,
677 + int height, int width)
679 + int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
680 + struct fbcon_ops *ops = info->fbcon_par;
681 + u8 *dst;
682 + int transparent, bg_color = attr_bgcol_ec(bgshift, vc, info);
684 + transparent = (vc->vc_decor.bg_color == bg_color);
685 + sy = sy * vc->vc_font.height + vc->vc_decor.ty;
686 + sx = sx * vc->vc_font.width + vc->vc_decor.tx;
687 + height *= vc->vc_font.height;
688 + width *= vc->vc_font.width;
690 + /* Don't paint the background image if console is blanked */
691 + if (transparent && !ops->blank_state) {
692 + decorfill(info, sy, sx, height, width);
693 + } else {
694 + dst = (u8 *)(info->screen_base + sy * info->fix.line_length +
695 + sx * ((info->var.bits_per_pixel + 7) >> 3));
696 + decorset(dst, height, width, info->fix.line_length, cc2cx(bg_color),
697 + info->var.bits_per_pixel);
701 +void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info,
702 + int bottom_only)
704 + unsigned int tw = vc->vc_cols*vc->vc_font.width;
705 + unsigned int th = vc->vc_rows*vc->vc_font.height;
707 + if (!bottom_only) {
708 + /* top margin */
709 + decorfill(info, 0, 0, vc->vc_decor.ty, info->var.xres);
710 + /* left margin */
711 + decorfill(info, vc->vc_decor.ty, 0, th, vc->vc_decor.tx);
712 + /* right margin */
713 + decorfill(info, vc->vc_decor.ty, vc->vc_decor.tx + tw, th,
714 + info->var.xres - vc->vc_decor.tx - tw);
716 + decorfill(info, vc->vc_decor.ty + th, 0,
717 + info->var.yres - vc->vc_decor.ty - th, info->var.xres);
720 +void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y,
721 + int sx, int dx, int width)
723 + u16 *d = (u16 *) (vc->vc_origin + vc->vc_size_row * y + dx * 2);
724 + u16 *s = d + (dx - sx);
725 + u16 *start = d;
726 + u16 *ls = d;
727 + u16 *le = d + width;
728 + u16 c;
729 + int x = dx;
730 + u16 attr = 1;
732 + do {
733 + c = scr_readw(d);
734 + if (attr != (c & 0xff00)) {
735 + attr = c & 0xff00;
736 + if (d > start) {
737 + fbcon_decor_putcs(vc, info, start, d - start, y, x);
738 + x += d - start;
739 + start = d;
742 + if (s >= ls && s < le && c == scr_readw(s)) {
743 + if (d > start) {
744 + fbcon_decor_putcs(vc, info, start, d - start, y, x);
745 + x += d - start + 1;
746 + start = d + 1;
747 + } else {
748 + x++;
749 + start++;
752 + s++;
753 + d++;
754 + } while (d < le);
755 + if (d > start)
756 + fbcon_decor_putcs(vc, info, start, d - start, y, x);
759 +void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank)
761 + if (blank) {
762 + decorset((u8 *)info->screen_base, info->var.yres, info->var.xres,
763 + info->fix.line_length, 0, info->var.bits_per_pixel);
764 + } else {
765 + update_screen(vc);
766 + fbcon_decor_clear_margins(vc, info, 0);
770 diff -Nur linux-3.18.9.orig/drivers/video/console/fbcon.c linux-3.18.9/drivers/video/console/fbcon.c
771 --- linux-3.18.9.orig/drivers/video/console/fbcon.c 2015-03-06 16:53:42.000000000 -0600
772 +++ linux-3.18.9/drivers/video/console/fbcon.c 2015-03-15 14:34:13.072143681 -0500
773 @@ -79,6 +79,7 @@
774 #include <asm/irq.h>
776 #include "fbcon.h"
777 +#include "fbcondecor.h"
779 #ifdef FBCONDEBUG
780 # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
781 @@ -94,7 +95,7 @@
783 static struct display fb_display[MAX_NR_CONSOLES];
785 -static signed char con2fb_map[MAX_NR_CONSOLES];
786 +signed char con2fb_map[MAX_NR_CONSOLES];
787 static signed char con2fb_map_boot[MAX_NR_CONSOLES];
789 static int logo_lines;
790 @@ -286,7 +287,7 @@
791 !vt_force_oops_output(vc);
794 -static int get_color(struct vc_data *vc, struct fb_info *info,
795 +int get_color(struct vc_data *vc, struct fb_info *info,
796 u16 c, int is_fg)
798 int depth = fb_get_color_depth(&info->var, &info->fix);
799 @@ -550,6 +551,9 @@
800 info_idx = -1;
801 } else {
802 fbcon_has_console_bind = 1;
803 +#ifdef CONFIG_FB_CON_DECOR
804 + fbcon_decor_init();
805 +#endif
808 return err;
809 @@ -1007,6 +1011,12 @@
810 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
811 cols /= vc->vc_font.width;
812 rows /= vc->vc_font.height;
814 + if (fbcon_decor_active(info, vc)) {
815 + cols = vc->vc_decor.twidth / vc->vc_font.width;
816 + rows = vc->vc_decor.theight / vc->vc_font.height;
819 vc_resize(vc, cols, rows);
821 DPRINTK("mode: %s\n", info->fix.id);
822 @@ -1036,7 +1046,7 @@
823 cap = info->flags;
825 if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
826 - (info->fix.type == FB_TYPE_TEXT))
827 + (info->fix.type == FB_TYPE_TEXT) || fbcon_decor_active(info, vc))
828 logo = 0;
830 if (var_to_display(p, &info->var, info))
831 @@ -1260,6 +1270,11 @@
832 fbcon_clear_margins(vc, 0);
835 + if (fbcon_decor_active(info, vc)) {
836 + fbcon_decor_clear(vc, info, sy, sx, height, width);
837 + return;
840 /* Split blits that cross physical y_wrap boundary */
842 y_break = p->vrows - p->yscroll;
843 @@ -1279,10 +1294,15 @@
844 struct display *p = &fb_display[vc->vc_num];
845 struct fbcon_ops *ops = info->fbcon_par;
847 - if (!fbcon_is_inactive(vc, info))
848 - ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
849 - get_color(vc, info, scr_readw(s), 1),
850 - get_color(vc, info, scr_readw(s), 0));
851 + if (!fbcon_is_inactive(vc, info)) {
853 + if (fbcon_decor_active(info, vc))
854 + fbcon_decor_putcs(vc, info, s, count, ypos, xpos);
855 + else
856 + ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
857 + get_color(vc, info, scr_readw(s), 1),
858 + get_color(vc, info, scr_readw(s), 0));
862 static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
863 @@ -1298,8 +1318,13 @@
864 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
865 struct fbcon_ops *ops = info->fbcon_par;
867 - if (!fbcon_is_inactive(vc, info))
868 - ops->clear_margins(vc, info, bottom_only);
869 + if (!fbcon_is_inactive(vc, info)) {
870 + if (fbcon_decor_active(info, vc)) {
871 + fbcon_decor_clear_margins(vc, info, bottom_only);
872 + } else {
873 + ops->clear_margins(vc, info, bottom_only);
878 static void fbcon_cursor(struct vc_data *vc, int mode)
879 @@ -1819,7 +1844,7 @@
880 count = vc->vc_rows;
881 if (softback_top)
882 fbcon_softback_note(vc, t, count);
883 - if (logo_shown >= 0)
884 + if (logo_shown >= 0 || fbcon_decor_active(info, vc))
885 goto redraw_up;
886 switch (p->scrollmode) {
887 case SCROLL_MOVE:
888 @@ -1912,6 +1937,8 @@
889 count = vc->vc_rows;
890 if (logo_shown >= 0)
891 goto redraw_down;
892 + if (fbcon_decor_active(info, vc))
893 + goto redraw_down;
894 switch (p->scrollmode) {
895 case SCROLL_MOVE:
896 fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
897 @@ -2060,6 +2087,13 @@
899 return;
902 + if (fbcon_decor_active(info, vc) && sy == dy && height == 1) {
903 + /* must use slower redraw bmove to keep background pic intact */
904 + fbcon_decor_bmove_redraw(vc, info, sy, sx, dx, width);
905 + return;
908 ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
909 height, width);
911 @@ -2130,8 +2164,8 @@
912 var.yres = virt_h * virt_fh;
913 x_diff = info->var.xres - var.xres;
914 y_diff = info->var.yres - var.yres;
915 - if (x_diff < 0 || x_diff > virt_fw ||
916 - y_diff < 0 || y_diff > virt_fh) {
917 + if ((x_diff < 0 || x_diff > virt_fw ||
918 + y_diff < 0 || y_diff > virt_fh) && !vc->vc_decor.state) {
919 const struct fb_videomode *mode;
921 DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
922 @@ -2167,6 +2201,21 @@
924 info = registered_fb[con2fb_map[vc->vc_num]];
925 ops = info->fbcon_par;
926 + prev_console = ops->currcon;
927 + if (prev_console != -1)
928 + old_info = registered_fb[con2fb_map[prev_console]];
930 +#ifdef CONFIG_FB_CON_DECOR
931 + if (!fbcon_decor_active_vc(vc) && info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
932 + struct vc_data *vc_curr = vc_cons[prev_console].d;
933 + if (vc_curr && fbcon_decor_active_vc(vc_curr)) {
934 + /* Clear the screen to avoid displaying funky colors during
935 + * palette updates. */
936 + memset((u8*)info->screen_base + info->fix.line_length * info->var.yoffset,
937 + 0, info->var.yres * info->fix.line_length);
940 +#endif
942 if (softback_top) {
943 if (softback_lines)
944 @@ -2185,9 +2234,6 @@
945 logo_shown = FBCON_LOGO_CANSHOW;
948 - prev_console = ops->currcon;
949 - if (prev_console != -1)
950 - old_info = registered_fb[con2fb_map[prev_console]];
952 * FIXME: If we have multiple fbdev's loaded, we need to
953 * update all info->currcon. Perhaps, we can place this
954 @@ -2231,6 +2277,18 @@
955 fbcon_del_cursor_timer(old_info);
958 + if (fbcon_decor_active_vc(vc)) {
959 + struct vc_data *vc_curr = vc_cons[prev_console].d;
961 + if (!vc_curr->vc_decor.theme ||
962 + strcmp(vc->vc_decor.theme, vc_curr->vc_decor.theme) ||
963 + (fbcon_decor_active_nores(info, vc_curr) &&
964 + !fbcon_decor_active(info, vc_curr))) {
965 + fbcon_decor_disable(vc, 0);
966 + fbcon_decor_call_helper("modechange", vc->vc_num);
970 if (fbcon_is_inactive(vc, info) ||
971 ops->blank_state != FB_BLANK_UNBLANK)
972 fbcon_del_cursor_timer(info);
973 @@ -2339,15 +2397,20 @@
977 - if (!fbcon_is_inactive(vc, info)) {
978 + if (!fbcon_is_inactive(vc, info)) {
979 if (ops->blank_state != blank) {
980 ops->blank_state = blank;
981 fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
982 ops->cursor_flash = (!blank);
984 - if (!(info->flags & FBINFO_MISC_USEREVENT))
985 - if (fb_blank(info, blank))
986 - fbcon_generic_blank(vc, info, blank);
987 + if (!(info->flags & FBINFO_MISC_USEREVENT)) {
988 + if (fb_blank(info, blank)) {
989 + if (fbcon_decor_active(info, vc))
990 + fbcon_decor_blank(vc, info, blank);
991 + else
992 + fbcon_generic_blank(vc, info, blank);
997 if (!blank)
998 @@ -2522,13 +2585,22 @@
1001 if (resize) {
1002 + /* reset wrap/pan */
1003 int cols, rows;
1005 cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
1006 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1008 + if (fbcon_decor_active(info, vc)) {
1009 + info->var.xoffset = info->var.yoffset = p->yscroll = 0;
1010 + cols = vc->vc_decor.twidth;
1011 + rows = vc->vc_decor.theight;
1013 cols /= w;
1014 rows /= h;
1016 vc_resize(vc, cols, rows);
1018 if (CON_IS_VISIBLE(vc) && softback_buf)
1019 fbcon_update_softback(vc);
1020 } else if (CON_IS_VISIBLE(vc)
1021 @@ -2657,7 +2729,11 @@
1022 int i, j, k, depth;
1023 u8 val;
1025 - if (fbcon_is_inactive(vc, info))
1026 + if (fbcon_is_inactive(vc, info)
1027 +#ifdef CONFIG_FB_CON_DECOR
1028 + || vc->vc_num != fg_console
1029 +#endif
1031 return -EINVAL;
1033 if (!CON_IS_VISIBLE(vc))
1034 @@ -2683,14 +2759,56 @@
1035 } else
1036 fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap);
1038 - return fb_set_cmap(&palette_cmap, info);
1039 + if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
1040 + info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
1042 + u16 *red, *green, *blue;
1043 + int minlen = min(min(info->var.red.length, info->var.green.length),
1044 + info->var.blue.length);
1045 + int h;
1047 + struct fb_cmap cmap = {
1048 + .start = 0,
1049 + .len = (1 << minlen),
1050 + .red = NULL,
1051 + .green = NULL,
1052 + .blue = NULL,
1053 + .transp = NULL
1054 + };
1056 + red = kmalloc(256 * sizeof(u16) * 3, GFP_KERNEL);
1058 + if (!red)
1059 + goto out;
1061 + green = red + 256;
1062 + blue = green + 256;
1063 + cmap.red = red;
1064 + cmap.green = green;
1065 + cmap.blue = blue;
1067 + for (i = 0; i < cmap.len; i++) {
1068 + red[i] = green[i] = blue[i] = (0xffff * i)/(cmap.len-1);
1071 + h = fb_set_cmap(&cmap, info);
1072 + fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
1073 + kfree(red);
1075 + return h;
1077 + } else if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
1078 + info->var.bits_per_pixel == 8 && info->bgdecor.cmap.red != NULL)
1079 + fb_set_cmap(&info->bgdecor.cmap, info);
1081 +out: return fb_set_cmap(&palette_cmap, info);
1084 static u16 *fbcon_screen_pos(struct vc_data *vc, int offset)
1086 unsigned long p;
1087 int line;
1090 if (vc->vc_num != fg_console || !softback_lines)
1091 return (u16 *) (vc->vc_origin + offset);
1092 line = offset / vc->vc_size_row;
1093 @@ -2909,7 +3027,14 @@
1094 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1095 cols /= vc->vc_font.width;
1096 rows /= vc->vc_font.height;
1097 - vc_resize(vc, cols, rows);
1099 + if (!fbcon_decor_active_nores(info, vc)) {
1100 + vc_resize(vc, cols, rows);
1101 + } else {
1102 + fbcon_decor_disable(vc, 0);
1103 + fbcon_decor_call_helper("modechange", vc->vc_num);
1106 updatescrollmode(p, info, vc);
1107 scrollback_max = 0;
1108 scrollback_current = 0;
1109 @@ -2954,7 +3079,9 @@
1110 rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1111 cols /= vc->vc_font.width;
1112 rows /= vc->vc_font.height;
1113 - vc_resize(vc, cols, rows);
1114 + if (!fbcon_decor_active_nores(info, vc)) {
1115 + vc_resize(vc, cols, rows);
1119 if (fg != -1)
1120 @@ -3596,6 +3723,7 @@
1124 + fbcon_decor_exit();
1125 fbcon_has_exited = 1;
1128 diff -Nur linux-3.18.9.orig/drivers/video/console/fbcondecor.c linux-3.18.9/drivers/video/console/fbcondecor.c
1129 --- linux-3.18.9.orig/drivers/video/console/fbcondecor.c 1969-12-31 18:00:00.000000000 -0600
1130 +++ linux-3.18.9/drivers/video/console/fbcondecor.c 2015-03-15 14:34:13.076143680 -0500
1131 @@ -0,0 +1,555 @@
1133 + * linux/drivers/video/console/fbcondecor.c -- Framebuffer console decorations
1135 + * Copyright (C) 2004-2009 Michal Januszewski <michalj+fbcondecor@gmail.com>
1137 + * Code based upon "Bootsplash" (C) 2001-2003
1138 + * Volker Poplawski <volker@poplawski.de>,
1139 + * Stefan Reinauer <stepan@suse.de>,
1140 + * Steffen Winterfeldt <snwint@suse.de>,
1141 + * Michael Schroeder <mls@suse.de>,
1142 + * Ken Wimer <wimer@suse.de>.
1144 + * Compat ioctl support by Thorsten Klein <TK@Thorsten-Klein.de>.
1146 + * This file is subject to the terms and conditions of the GNU General Public
1147 + * License. See the file COPYING in the main directory of this archive for
1148 + * more details.
1150 + */
1151 +#include <linux/module.h>
1152 +#include <linux/kernel.h>
1153 +#include <linux/string.h>
1154 +#include <linux/types.h>
1155 +#include <linux/fb.h>
1156 +#include <linux/vt_kern.h>
1157 +#include <linux/vmalloc.h>
1158 +#include <linux/unistd.h>
1159 +#include <linux/syscalls.h>
1160 +#include <linux/init.h>
1161 +#include <linux/proc_fs.h>
1162 +#include <linux/workqueue.h>
1163 +#include <linux/kmod.h>
1164 +#include <linux/miscdevice.h>
1165 +#include <linux/device.h>
1166 +#include <linux/fs.h>
1167 +#include <linux/compat.h>
1168 +#include <linux/console.h>
1170 +#include <asm/uaccess.h>
1171 +#include <asm/irq.h>
1173 +#include "fbcon.h"
1174 +#include "fbcondecor.h"
1176 +extern signed char con2fb_map[];
1177 +static int fbcon_decor_enable(struct vc_data *vc);
1178 +char fbcon_decor_path[KMOD_PATH_LEN] = "/sbin/fbcondecor_helper";
1179 +static int initialized = 0;
1181 +int fbcon_decor_call_helper(char* cmd, unsigned short vc)
1183 + char *envp[] = {
1184 + "HOME=/",
1185 + "PATH=/sbin:/bin",
1186 + NULL
1187 + };
1189 + char tfb[5];
1190 + char tcons[5];
1191 + unsigned char fb = (int) con2fb_map[vc];
1193 + char *argv[] = {
1194 + fbcon_decor_path,
1195 + "2",
1196 + cmd,
1197 + tcons,
1198 + tfb,
1199 + vc_cons[vc].d->vc_decor.theme,
1200 + NULL
1201 + };
1203 + snprintf(tfb,5,"%d",fb);
1204 + snprintf(tcons,5,"%d",vc);
1206 + return call_usermodehelper(fbcon_decor_path, argv, envp, UMH_WAIT_EXEC);
1209 +/* Disables fbcondecor on a virtual console; called with console sem held. */
1210 +int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw)
1212 + struct fb_info* info;
1214 + if (!vc->vc_decor.state)
1215 + return -EINVAL;
1217 + info = registered_fb[(int) con2fb_map[vc->vc_num]];
1219 + if (info == NULL)
1220 + return -EINVAL;
1222 + vc->vc_decor.state = 0;
1223 + vc_resize(vc, info->var.xres / vc->vc_font.width,
1224 + info->var.yres / vc->vc_font.height);
1226 + if (fg_console == vc->vc_num && redraw) {
1227 + redraw_screen(vc, 0);
1228 + update_region(vc, vc->vc_origin +
1229 + vc->vc_size_row * vc->vc_top,
1230 + vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1233 + printk(KERN_INFO "fbcondecor: switched decor state to 'off' on console %d\n",
1234 + vc->vc_num);
1236 + return 0;
1239 +/* Enables fbcondecor on a virtual console; called with console sem held. */
1240 +static int fbcon_decor_enable(struct vc_data *vc)
1242 + struct fb_info* info;
1244 + info = registered_fb[(int) con2fb_map[vc->vc_num]];
1246 + if (vc->vc_decor.twidth == 0 || vc->vc_decor.theight == 0 ||
1247 + info == NULL || vc->vc_decor.state || (!info->bgdecor.data &&
1248 + vc->vc_num == fg_console))
1249 + return -EINVAL;
1251 + vc->vc_decor.state = 1;
1252 + vc_resize(vc, vc->vc_decor.twidth / vc->vc_font.width,
1253 + vc->vc_decor.theight / vc->vc_font.height);
1255 + if (fg_console == vc->vc_num) {
1256 + redraw_screen(vc, 0);
1257 + update_region(vc, vc->vc_origin +
1258 + vc->vc_size_row * vc->vc_top,
1259 + vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1260 + fbcon_decor_clear_margins(vc, info, 0);
1263 + printk(KERN_INFO "fbcondecor: switched decor state to 'on' on console %d\n",
1264 + vc->vc_num);
1266 + return 0;
1269 +static inline int fbcon_decor_ioctl_dosetstate(struct vc_data *vc, unsigned int state, unsigned char origin)
1271 + int ret;
1273 +// if (origin == FBCON_DECOR_IO_ORIG_USER)
1274 + console_lock();
1275 + if (!state)
1276 + ret = fbcon_decor_disable(vc, 1);
1277 + else
1278 + ret = fbcon_decor_enable(vc);
1279 +// if (origin == FBCON_DECOR_IO_ORIG_USER)
1280 + console_unlock();
1282 + return ret;
1285 +static inline void fbcon_decor_ioctl_dogetstate(struct vc_data *vc, unsigned int *state)
1287 + *state = vc->vc_decor.state;
1290 +static int fbcon_decor_ioctl_dosetcfg(struct vc_data *vc, struct vc_decor *cfg, unsigned char origin)
1292 + struct fb_info *info;
1293 + int len;
1294 + char *tmp;
1296 + info = registered_fb[(int) con2fb_map[vc->vc_num]];
1298 + if (info == NULL || !cfg->twidth || !cfg->theight ||
1299 + cfg->tx + cfg->twidth > info->var.xres ||
1300 + cfg->ty + cfg->theight > info->var.yres)
1301 + return -EINVAL;
1303 + len = strlen_user(cfg->theme);
1304 + if (!len || len > FBCON_DECOR_THEME_LEN)
1305 + return -EINVAL;
1306 + tmp = kmalloc(len, GFP_KERNEL);
1307 + if (!tmp)
1308 + return -ENOMEM;
1309 + if (copy_from_user(tmp, (void __user *)cfg->theme, len))
1310 + return -EFAULT;
1311 + cfg->theme = tmp;
1312 + cfg->state = 0;
1314 + /* If this ioctl is a response to a request from kernel, the console sem
1315 + * is already held; we also don't need to disable decor because either the
1316 + * new config and background picture will be successfully loaded, and the
1317 + * decor will stay on, or in case of a failure it'll be turned off in fbcon. */
1318 +// if (origin == FBCON_DECOR_IO_ORIG_USER) {
1319 + console_lock();
1320 + if (vc->vc_decor.state)
1321 + fbcon_decor_disable(vc, 1);
1322 +// }
1324 + if (vc->vc_decor.theme)
1325 + kfree(vc->vc_decor.theme);
1327 + vc->vc_decor = *cfg;
1329 +// if (origin == FBCON_DECOR_IO_ORIG_USER)
1330 + console_unlock();
1332 + printk(KERN_INFO "fbcondecor: console %d using theme '%s'\n",
1333 + vc->vc_num, vc->vc_decor.theme);
1334 + return 0;
1337 +static int fbcon_decor_ioctl_dogetcfg(struct vc_data *vc, struct vc_decor *decor)
1339 + char __user *tmp;
1341 + tmp = decor->theme;
1342 + *decor = vc->vc_decor;
1343 + decor->theme = tmp;
1345 + if (vc->vc_decor.theme) {
1346 + if (copy_to_user(tmp, vc->vc_decor.theme, strlen(vc->vc_decor.theme) + 1))
1347 + return -EFAULT;
1348 + } else
1349 + if (put_user(0, tmp))
1350 + return -EFAULT;
1352 + return 0;
1355 +static int fbcon_decor_ioctl_dosetpic(struct vc_data *vc, struct fb_image *img, unsigned char origin)
1357 + struct fb_info *info;
1358 + int len;
1359 + u8 *tmp;
1361 + if (vc->vc_num != fg_console)
1362 + return -EINVAL;
1364 + info = registered_fb[(int) con2fb_map[vc->vc_num]];
1366 + if (info == NULL)
1367 + return -EINVAL;
1369 + if (img->width != info->var.xres || img->height != info->var.yres) {
1370 + printk(KERN_ERR "fbcondecor: picture dimensions mismatch\n");
1371 + printk(KERN_ERR "%dx%d vs %dx%d\n", img->width, img->height, info->var.xres, info->var.yres);
1372 + return -EINVAL;
1375 + if (img->depth != info->var.bits_per_pixel) {
1376 + printk(KERN_ERR "fbcondecor: picture depth mismatch\n");
1377 + return -EINVAL;
1380 + if (img->depth == 8) {
1381 + if (!img->cmap.len || !img->cmap.red || !img->cmap.green ||
1382 + !img->cmap.blue)
1383 + return -EINVAL;
1385 + tmp = vmalloc(img->cmap.len * 3 * 2);
1386 + if (!tmp)
1387 + return -ENOMEM;
1389 + if (copy_from_user(tmp,
1390 + (void __user*)img->cmap.red, (img->cmap.len << 1)) ||
1391 + copy_from_user(tmp + (img->cmap.len << 1),
1392 + (void __user*)img->cmap.green, (img->cmap.len << 1)) ||
1393 + copy_from_user(tmp + (img->cmap.len << 2),
1394 + (void __user*)img->cmap.blue, (img->cmap.len << 1))) {
1395 + vfree(tmp);
1396 + return -EFAULT;
1399 + img->cmap.transp = NULL;
1400 + img->cmap.red = (u16*)tmp;
1401 + img->cmap.green = img->cmap.red + img->cmap.len;
1402 + img->cmap.blue = img->cmap.green + img->cmap.len;
1403 + } else {
1404 + img->cmap.red = NULL;
1407 + len = ((img->depth + 7) >> 3) * img->width * img->height;
1409 + /*
1410 + * Allocate an additional byte so that we never go outside of the
1411 + * buffer boundaries in the rendering functions in a 24 bpp mode.
1412 + */
1413 + tmp = vmalloc(len + 1);
1415 + if (!tmp)
1416 + goto out;
1418 + if (copy_from_user(tmp, (void __user*)img->data, len))
1419 + goto out;
1421 + img->data = tmp;
1423 + /* If this ioctl is a response to a request from kernel, the console sem
1424 + * is already held. */
1425 +// if (origin == FBCON_DECOR_IO_ORIG_USER)
1426 + console_lock();
1428 + if (info->bgdecor.data)
1429 + vfree((u8*)info->bgdecor.data);
1430 + if (info->bgdecor.cmap.red)
1431 + vfree(info->bgdecor.cmap.red);
1433 + info->bgdecor = *img;
1435 + if (fbcon_decor_active_vc(vc) && fg_console == vc->vc_num) {
1436 + redraw_screen(vc, 0);
1437 + update_region(vc, vc->vc_origin +
1438 + vc->vc_size_row * vc->vc_top,
1439 + vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1440 + fbcon_decor_clear_margins(vc, info, 0);
1443 +// if (origin == FBCON_DECOR_IO_ORIG_USER)
1444 + console_unlock();
1446 + return 0;
1448 +out: if (img->cmap.red)
1449 + vfree(img->cmap.red);
1451 + if (tmp)
1452 + vfree(tmp);
1453 + return -ENOMEM;
1456 +static long fbcon_decor_ioctl(struct file *filp, u_int cmd, u_long arg)
1458 + struct fbcon_decor_iowrapper __user *wrapper = (void __user*) arg;
1459 + struct vc_data *vc = NULL;
1460 + unsigned short vc_num = 0;
1461 + unsigned char origin = 0;
1462 + void __user *data = NULL;
1464 + if (!access_ok(VERIFY_READ, wrapper,
1465 + sizeof(struct fbcon_decor_iowrapper)))
1466 + return -EFAULT;
1468 + __get_user(vc_num, &wrapper->vc);
1469 + __get_user(origin, &wrapper->origin);
1470 + __get_user(data, &wrapper->data);
1472 + if (!vc_cons_allocated(vc_num))
1473 + return -EINVAL;
1475 + vc = vc_cons[vc_num].d;
1477 + switch (cmd) {
1478 + case FBIOCONDECOR_SETPIC:
1480 + struct fb_image img;
1481 + if (copy_from_user(&img, (struct fb_image __user *)data, sizeof(struct fb_image)))
1482 + return -EFAULT;
1484 + return fbcon_decor_ioctl_dosetpic(vc, &img, origin);
1486 + case FBIOCONDECOR_SETCFG:
1488 + struct vc_decor cfg;
1489 + if (copy_from_user(&cfg, (struct vc_decor __user *)data, sizeof(struct vc_decor)))
1490 + return -EFAULT;
1492 + return fbcon_decor_ioctl_dosetcfg(vc, &cfg, origin);
1494 + case FBIOCONDECOR_GETCFG:
1496 + int rval;
1497 + struct vc_decor cfg;
1499 + if (copy_from_user(&cfg, (struct vc_decor __user *)data, sizeof(struct vc_decor)))
1500 + return -EFAULT;
1502 + rval = fbcon_decor_ioctl_dogetcfg(vc, &cfg);
1504 + if (copy_to_user(data, &cfg, sizeof(struct vc_decor)))
1505 + return -EFAULT;
1506 + return rval;
1508 + case FBIOCONDECOR_SETSTATE:
1510 + unsigned int state = 0;
1511 + if (get_user(state, (unsigned int __user *)data))
1512 + return -EFAULT;
1513 + return fbcon_decor_ioctl_dosetstate(vc, state, origin);
1515 + case FBIOCONDECOR_GETSTATE:
1517 + unsigned int state = 0;
1518 + fbcon_decor_ioctl_dogetstate(vc, &state);
1519 + return put_user(state, (unsigned int __user *)data);
1522 + default:
1523 + return -ENOIOCTLCMD;
1527 +#ifdef CONFIG_COMPAT
1529 +static long fbcon_decor_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) {
1531 + struct fbcon_decor_iowrapper32 __user *wrapper = (void __user *)arg;
1532 + struct vc_data *vc = NULL;
1533 + unsigned short vc_num = 0;
1534 + unsigned char origin = 0;
1535 + compat_uptr_t data_compat = 0;
1536 + void __user *data = NULL;
1538 + if (!access_ok(VERIFY_READ, wrapper,
1539 + sizeof(struct fbcon_decor_iowrapper32)))
1540 + return -EFAULT;
1542 + __get_user(vc_num, &wrapper->vc);
1543 + __get_user(origin, &wrapper->origin);
1544 + __get_user(data_compat, &wrapper->data);
1545 + data = compat_ptr(data_compat);
1547 + if (!vc_cons_allocated(vc_num))
1548 + return -EINVAL;
1550 + vc = vc_cons[vc_num].d;
1552 + switch (cmd) {
1553 + case FBIOCONDECOR_SETPIC32:
1555 + struct fb_image32 img_compat;
1556 + struct fb_image img;
1558 + if (copy_from_user(&img_compat, (struct fb_image32 __user *)data, sizeof(struct fb_image32)))
1559 + return -EFAULT;
1561 + fb_image_from_compat(img, img_compat);
1563 + return fbcon_decor_ioctl_dosetpic(vc, &img, origin);
1566 + case FBIOCONDECOR_SETCFG32:
1568 + struct vc_decor32 cfg_compat;
1569 + struct vc_decor cfg;
1571 + if (copy_from_user(&cfg_compat, (struct vc_decor32 __user *)data, sizeof(struct vc_decor32)))
1572 + return -EFAULT;
1574 + vc_decor_from_compat(cfg, cfg_compat);
1576 + return fbcon_decor_ioctl_dosetcfg(vc, &cfg, origin);
1579 + case FBIOCONDECOR_GETCFG32:
1581 + int rval;
1582 + struct vc_decor32 cfg_compat;
1583 + struct vc_decor cfg;
1585 + if (copy_from_user(&cfg_compat, (struct vc_decor32 __user *)data, sizeof(struct vc_decor32)))
1586 + return -EFAULT;
1587 + cfg.theme = compat_ptr(cfg_compat.theme);
1589 + rval = fbcon_decor_ioctl_dogetcfg(vc, &cfg);
1591 + vc_decor_to_compat(cfg_compat, cfg);
1593 + if (copy_to_user((struct vc_decor32 __user *)data, &cfg_compat, sizeof(struct vc_decor32)))
1594 + return -EFAULT;
1595 + return rval;
1598 + case FBIOCONDECOR_SETSTATE32:
1600 + compat_uint_t state_compat = 0;
1601 + unsigned int state = 0;
1603 + if (get_user(state_compat, (compat_uint_t __user *)data))
1604 + return -EFAULT;
1606 + state = (unsigned int)state_compat;
1608 + return fbcon_decor_ioctl_dosetstate(vc, state, origin);
1611 + case FBIOCONDECOR_GETSTATE32:
1613 + compat_uint_t state_compat = 0;
1614 + unsigned int state = 0;
1616 + fbcon_decor_ioctl_dogetstate(vc, &state);
1617 + state_compat = (compat_uint_t)state;
1619 + return put_user(state_compat, (compat_uint_t __user *)data);
1622 + default:
1623 + return -ENOIOCTLCMD;
1626 +#else
1627 + #define fbcon_decor_compat_ioctl NULL
1628 +#endif
1630 +static struct file_operations fbcon_decor_ops = {
1631 + .owner = THIS_MODULE,
1632 + .unlocked_ioctl = fbcon_decor_ioctl,
1633 + .compat_ioctl = fbcon_decor_compat_ioctl
1636 +static struct miscdevice fbcon_decor_dev = {
1637 + .minor = MISC_DYNAMIC_MINOR,
1638 + .name = "fbcondecor",
1639 + .fops = &fbcon_decor_ops
1642 +void fbcon_decor_reset()
1644 + int i;
1646 + for (i = 0; i < num_registered_fb; i++) {
1647 + registered_fb[i]->bgdecor.data = NULL;
1648 + registered_fb[i]->bgdecor.cmap.red = NULL;
1651 + for (i = 0; i < MAX_NR_CONSOLES && vc_cons[i].d; i++) {
1652 + vc_cons[i].d->vc_decor.state = vc_cons[i].d->vc_decor.twidth =
1653 + vc_cons[i].d->vc_decor.theight = 0;
1654 + vc_cons[i].d->vc_decor.theme = NULL;
1657 + return;
1660 +int fbcon_decor_init()
1662 + int i;
1664 + fbcon_decor_reset();
1666 + if (initialized)
1667 + return 0;
1669 + i = misc_register(&fbcon_decor_dev);
1670 + if (i) {
1671 + printk(KERN_ERR "fbcondecor: failed to register device\n");
1672 + return i;
1675 + fbcon_decor_call_helper("init", 0);
1676 + initialized = 1;
1677 + return 0;
1680 +int fbcon_decor_exit(void)
1682 + fbcon_decor_reset();
1683 + return 0;
1686 +EXPORT_SYMBOL(fbcon_decor_path);
1687 diff -Nur linux-3.18.9.orig/drivers/video/console/fbcondecor.h linux-3.18.9/drivers/video/console/fbcondecor.h
1688 --- linux-3.18.9.orig/drivers/video/console/fbcondecor.h 1969-12-31 18:00:00.000000000 -0600
1689 +++ linux-3.18.9/drivers/video/console/fbcondecor.h 2015-03-15 14:34:13.076143680 -0500
1690 @@ -0,0 +1,79 @@
1691 +/*
1692 + * linux/drivers/video/console/fbcondecor.h -- Framebuffer Console Decoration headers
1694 + * Copyright (C) 2004 Michal Januszewski <michalj+fbcondecor@gmail.com>
1696 + */
1698 +#ifndef __FBCON_DECOR_H
1699 +#define __FBCON_DECOR_H
1701 +#ifndef _LINUX_FB_H
1702 +#include <linux/fb.h>
1703 +#endif
1705 +/* This is needed for vc_cons in fbcmap.c */
1706 +#include <linux/vt_kern.h>
1708 +struct fb_cursor;
1709 +struct fb_info;
1710 +struct vc_data;
1712 +#ifdef CONFIG_FB_CON_DECOR
1713 +/* fbcondecor.c */
1714 +int fbcon_decor_init(void);
1715 +void fbcon_decor_reset(void);
1716 +int fbcon_decor_exit(void);
1717 +int fbcon_decor_call_helper(char* cmd, unsigned short cons);
1718 +int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw);
1720 +/* cfbcondecor.c */
1721 +void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx);
1722 +void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor);
1723 +void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width);
1724 +void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only);
1725 +void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank);
1726 +void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width);
1727 +void fbcon_decor_copy(u8 *dst, u8 *src, int height, int width, int linebytes, int srclinesbytes, int bpp);
1728 +void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc);
1730 +/* vt.c */
1731 +void acquire_console_sem(void);
1732 +void release_console_sem(void);
1733 +void do_unblank_screen(int entering_gfx);
1735 +/* struct vc_data *y */
1736 +#define fbcon_decor_active_vc(y) (y->vc_decor.state && y->vc_decor.theme)
1738 +/* struct fb_info *x, struct vc_data *y */
1739 +#define fbcon_decor_active_nores(x,y) (x->bgdecor.data && fbcon_decor_active_vc(y))
1741 +/* struct fb_info *x, struct vc_data *y */
1742 +#define fbcon_decor_active(x,y) (fbcon_decor_active_nores(x,y) && \
1743 + x->bgdecor.width == x->var.xres && \
1744 + x->bgdecor.height == x->var.yres && \
1745 + x->bgdecor.depth == x->var.bits_per_pixel)
1748 +#else /* CONFIG_FB_CON_DECOR */
1750 +static inline void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx) {}
1751 +static inline void fbcon_decor_putc(struct vc_data *vc, struct fb_info *info, int c, int ypos, int xpos) {}
1752 +static inline void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor) {}
1753 +static inline void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) {}
1754 +static inline void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only) {}
1755 +static inline void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank) {}
1756 +static inline void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width) {}
1757 +static inline void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc) {}
1758 +static inline int fbcon_decor_call_helper(char* cmd, unsigned short cons) { return 0; }
1759 +static inline int fbcon_decor_init(void) { return 0; }
1760 +static inline int fbcon_decor_exit(void) { return 0; }
1761 +static inline int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw) { return 0; }
1763 +#define fbcon_decor_active_vc(y) (0)
1764 +#define fbcon_decor_active_nores(x,y) (0)
1765 +#define fbcon_decor_active(x,y) (0)
1767 +#endif /* CONFIG_FB_CON_DECOR */
1769 +#endif /* __FBCON_DECOR_H */
1770 diff -Nur linux-3.18.9.orig/drivers/video/console/Kconfig linux-3.18.9/drivers/video/console/Kconfig
1771 --- linux-3.18.9.orig/drivers/video/console/Kconfig 2015-03-06 16:53:42.000000000 -0600
1772 +++ linux-3.18.9/drivers/video/console/Kconfig 2015-03-15 14:34:13.068143682 -0500
1773 @@ -126,6 +126,19 @@
1774 such that other users of the framebuffer will remain normally
1775 oriented.
1777 +config FB_CON_DECOR
1778 + bool "Support for the Framebuffer Console Decorations"
1779 + depends on FRAMEBUFFER_CONSOLE=y && !FB_TILEBLITTING
1780 + default n
1781 + ---help---
1782 + This option enables support for framebuffer console decorations which
1783 + makes it possible to display images in the background of the system
1784 + consoles. Note that userspace utilities are necessary in order to take
1785 + advantage of these features. Refer to Documentation/fb/fbcondecor.txt
1786 + for more information.
1788 + If unsure, say N.
1790 config STI_CONSOLE
1791 bool "STI text console"
1792 depends on PARISC
1793 diff -Nur linux-3.18.9.orig/drivers/video/console/Makefile linux-3.18.9/drivers/video/console/Makefile
1794 --- linux-3.18.9.orig/drivers/video/console/Makefile 2015-03-06 16:53:42.000000000 -0600
1795 +++ linux-3.18.9/drivers/video/console/Makefile 2015-03-15 14:34:13.068143682 -0500
1796 @@ -16,4 +16,5 @@
1797 fbcon_ccw.o
1798 endif
1800 +obj-$(CONFIG_FB_CON_DECOR) += fbcondecor.o cfbcondecor.o
1801 obj-$(CONFIG_FB_STI) += sticore.o
1802 diff -Nur linux-3.18.9.orig/drivers/video/fbdev/core/fbcmap.c linux-3.18.9/drivers/video/fbdev/core/fbcmap.c
1803 --- linux-3.18.9.orig/drivers/video/fbdev/core/fbcmap.c 2015-03-06 16:53:42.000000000 -0600
1804 +++ linux-3.18.9/drivers/video/fbdev/core/fbcmap.c 2015-03-15 14:34:13.076143680 -0500
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
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.18.9.orig/include/linux/console_decor.h linux-3.18.9/include/linux/console_decor.h
1826 --- linux-3.18.9.orig/include/linux/console_decor.h 1969-12-31 18:00:00.000000000 -0600
1827 +++ linux-3.18.9/include/linux/console_decor.h 2015-03-15 14:34:13.076143680 -0500
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.18.9.orig/include/linux/console_struct.h linux-3.18.9/include/linux/console_struct.h
1876 --- linux-3.18.9.orig/include/linux/console_struct.h 2015-03-06 16:53:42.000000000 -0600
1877 +++ linux-3.18.9/include/linux/console_struct.h 2015-03-15 14:34:13.076143680 -0500
1878 @@ -20,6 +20,7 @@
1879 struct uni_pagedir;
1881 #define NPAR 16
1882 +#include <linux/console_decor.h>
1884 struct vc_data {
1885 struct tty_port port; /* Upper level data */
1886 @@ -108,6 +109,8 @@
1887 struct uni_pagedir *vc_uni_pagedir;
1888 struct uni_pagedir **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 */
1895 diff -Nur linux-3.18.9.orig/include/linux/fb.h linux-3.18.9/include/linux/fb.h
1896 --- linux-3.18.9.orig/include/linux/fb.h 2015-03-06 16:53:42.000000000 -0600
1897 +++ linux-3.18.9/include/linux/fb.h 2015-03-15 14:34:13.080143679 -0500
1898 @@ -220,6 +220,34 @@
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__ */
1931 * Frame buffer operations
1933 @@ -490,6 +518,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.18.9.orig/include/uapi/linux/fb.h linux-3.18.9/include/uapi/linux/fb.h
1944 --- linux-3.18.9.orig/include/uapi/linux/fb.h 2015-03-06 16:53:42.000000000 -0600
1945 +++ linux-3.18.9/include/uapi/linux/fb.h 2015-03-15 14:34:13.080143679 -0500
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 */
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.18.9.orig/kernel/sysctl.c linux-3.18.9/kernel/sysctl.c
2029 --- linux-3.18.9.orig/kernel/sysctl.c 2015-03-06 16:53:42.000000000 -0600
2030 +++ linux-3.18.9/kernel/sysctl.c 2015-03-15 14:34:13.080143679 -0500
2031 @@ -145,6 +145,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 @@ -257,6 +261,15 @@
2043 .mode = 0555,
2044 .child = dev_table,
2046 +#ifdef CONFIG_FB_CON_DECOR
2048 + .procname = "fbcondecor",
2049 + .data = &fbcon_decor_path,
2050 + .maxlen = KMOD_PATH_LEN,
2051 + .mode = 0644,
2052 + .proc_handler = &proc_dostring,
2053 + },
2054 +#endif