Gentoo Archives: gentoo-commits

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