Gentoo Archives: gentoo-commits

From: "Mike Pagano (mpagano)" <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] linux-patches r1876 - genpatches-2.6/trunk/2.6.38
Date: Sun, 27 Feb 2011 15:16:14
Message-Id: 20110227151543.475FA20054@flycatcher.gentoo.org
1 Author: mpagano
2 Date: 2011-02-27 15:15:42 +0000 (Sun, 27 Feb 2011)
3 New Revision: 1876
4
5 Modified:
6 genpatches-2.6/trunk/2.6.38/4200_fbcondecor-0.9.6.patch
7 Log:
8 Updated patch for fbcondecor
9
10 Modified: genpatches-2.6/trunk/2.6.38/4200_fbcondecor-0.9.6.patch
11 ===================================================================
12 --- genpatches-2.6/trunk/2.6.38/4200_fbcondecor-0.9.6.patch 2011-02-26 00:47:01 UTC (rev 1875)
13 +++ genpatches-2.6/trunk/2.6.38/4200_fbcondecor-0.9.6.patch 2011-02-27 15:15:42 UTC (rev 1876)
14 @@ -1,4 +1,4 @@
15 -From c487b396d2c8a819dbe6548490a4d18bb520736a Mon Sep 17 00:00:00 2001
16 +From cfc6b027203601fcbf0578380b7f5922dc6b2798 Mon Sep 17 00:00:00 2001
17 From: Alexey Shvetsov <alexxy@g.o>
18 Date: Sun, 23 Jan 2011 00:09:58 +0300
19 Subject: [PATCH] [PATCH] [fbcondecor-0.9.6] Import fbcondecor
20 @@ -11,7 +11,6 @@
21 Documentation/fb/00-INDEX | 2 +
22 Documentation/fb/fbcondecor.txt | 206 +++++++++++++
23 drivers/Makefile | 4 +-
24 - drivers/Makefile.rej | 16 +
25 drivers/video/console/Kconfig | 13 +
26 drivers/video/console/Makefile | 1 +
27 drivers/video/console/bitblit.c | 20 +-
28 @@ -25,9 +24,8 @@
29 include/linux/console_struct.h | 3 +
30 include/linux/fb.h | 88 ++++++
31 kernel/sysctl.c | 13 +
32 - 17 files changed, 1686 insertions(+), 41 deletions(-)
33 + 16 files changed, 1670 insertions(+), 41 deletions(-)
34 create mode 100644 Documentation/fb/fbcondecor.txt
35 - create mode 100644 drivers/Makefile.rej
36 create mode 100644 drivers/video/console/cfbcondecor.c
37 create mode 100644 drivers/video/console/fbcondecor.c
38 create mode 100644 drivers/video/console/fbcondecor.h
39 @@ -38,13 +36,13 @@
40 --- a/Documentation/fb/00-INDEX
41 +++ b/Documentation/fb/00-INDEX
42 @@ -21,6 +21,8 @@ ep93xx-fb.txt
43 - - info on the driver for EP93xx LCD controller.
44 + - info on the driver for EP93xx LCD controller.
45 fbcon.txt
46 - - intro to and usage guide for the framebuffer console (fbcon).
47 + - intro to and usage guide for the framebuffer console (fbcon).
48 +fbcondecor.txt
49 -+ - info on the Framebuffer Console Decoration
50 ++ - info on the Framebuffer Console Decoration
51 framebuffer.txt
52 - - introduction to frame buffer devices.
53 + - introduction to frame buffer devices.
54 gxfb.txt
55 diff --git a/Documentation/fb/fbcondecor.txt b/Documentation/fb/fbcondecor.txt
56 new file mode 100644
57 @@ -262,46 +260,24 @@
58 index b423bb1..4ce76a6 100644
59 --- a/drivers/Makefile
60 +++ b/drivers/Makefile
61 -@@ -9,6 +9,9 @@ obj-y += gpio/
62 - obj-$(CONFIG_PCI) += pci/
63 - obj-$(CONFIG_PARISC) += parisc/
64 - obj-$(CONFIG_RAPIDIO) += rapidio/
65 +@@ -9,6 +9,9 @@ obj-y += gpio/
66 + obj-$(CONFIG_PCI) += pci/
67 + obj-$(CONFIG_PARISC) += parisc/
68 + obj-$(CONFIG_RAPIDIO) += rapidio/
69 +# char/ comes before serial/ etc so that the VT console is the boot-time
70 +# default.
71 -+obj-y += char/
72 - obj-y += video/
73 - obj-y += idle/
74 - obj-$(CONFIG_ACPI) += acpi/
75 -@@ -27,7 +30,6 @@ obj-$(CONFIG_REGULATOR) += regulator/
76 ++obj-y += char/
77 + obj-y += video/
78 + obj-y += idle/
79 + obj-$(CONFIG_ACPI) += acpi/
80 +@@ -27,7 +30,6 @@ obj-$(CONFIG_REGULATOR) += regulator/
81 # tty/ comes before char/ so that the VT console is the boot-time
82 # default.
83 - obj-y += tty/
84 --obj-y += char/
85 + obj-y += tty/
86 +-obj-y += char/
87
88 # gpu/ comes after char for AGP vs DRM startup
89 - obj-y += gpu/
90 -diff --git a/drivers/Makefile.rej b/drivers/Makefile.rej
91 -new file mode 100644
92 -index 0000000..c3d3251
93 ---- /dev/null
94 -+++ b/drivers/Makefile.rej
95 -@@ -0,0 +1,16 @@
96 -+--- drivers/Makefile
97 -++++ drivers/Makefile
98 -+@@ -27,10 +30,12 @@
99 -+ # regulators early, since some subsystems rely on them to initialize
100 -+ obj-$(CONFIG_REGULATOR) += regulator/
101 -+
102 -++<<<<<<< HEAD
103 -+ # tty/ comes before char/ so that the VT console is the boot-time
104 -+ # default.
105 -++=======
106 -++>>>>>>> [fbcondecor-0.9.6] Import fbcondecor
107 -+ obj-y += tty/
108 -+-obj-y += char/
109 -+
110 -+ # gpu/ comes after char for AGP vs DRM startup
111 -+ obj-y += gpu/
112 + obj-y += gpu/
113 diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
114 index 2209e35..1c49f8e 100644
115 --- a/drivers/video/console/Kconfig
116 @@ -311,17 +287,17 @@
117 oriented.
118
119 +config FB_CON_DECOR
120 -+ bool "Support for the Framebuffer Console Decorations"
121 -+ depends on FRAMEBUFFER_CONSOLE=y && !FB_TILEBLITTING
122 -+ default n
123 -+ ---help---
124 -+ This option enables support for framebuffer console decorations which
125 -+ makes it possible to display images in the background of the system
126 -+ consoles. Note that userspace utilities are necessary in order to take
127 -+ advantage of these features. Refer to Documentation/fb/fbcondecor.txt
128 -+ for more information.
129 ++ bool "Support for the Framebuffer Console Decorations"
130 ++ depends on FRAMEBUFFER_CONSOLE=y && !FB_TILEBLITTING
131 ++ default n
132 ++ ---help---
133 ++ This option enables support for framebuffer console decorations which
134 ++ makes it possible to display images in the background of the system
135 ++ consoles. Note that userspace utilities are necessary in order to take
136 ++ advantage of these features. Refer to Documentation/fb/fbcondecor.txt
137 ++ for more information.
138 +
139 -+ If unsure, say N.
140 ++ If unsure, say N.
141 +
142 config STI_CONSOLE
143 bool "STI text console"
144 @@ -334,7 +310,7 @@
145 fbcon_ccw.o
146 endif
147
148 -+obj-$(CONFIG_FB_CON_DECOR) += fbcondecor.o cfbcondecor.o
149 ++obj-$(CONFIG_FB_CON_DECOR) += fbcondecor.o cfbcondecor.o
150 obj-$(CONFIG_FB_STI) += sticore.o font.o
151
152 ifeq ($(CONFIG_USB_SISUSBVGA_CON),y)
153 @@ -351,38 +327,38 @@
154 /*
155 * Accelerated handlers.
156 @@ -55,6 +56,13 @@ static void bit_bmove(struct vc_data *vc, struct fb_info *info, int sy,
157 - area.height = height * vc->vc_font.height;
158 - area.width = width * vc->vc_font.width;
159 + area.height = height * vc->vc_font.height;
160 + area.width = width * vc->vc_font.width;
161
162 -+ if (fbcon_decor_active(info, vc)) {
163 -+ area.sx += vc->vc_decor.tx;
164 -+ area.sy += vc->vc_decor.ty;
165 -+ area.dx += vc->vc_decor.tx;
166 -+ area.dy += vc->vc_decor.ty;
167 -+ }
168 ++ if (fbcon_decor_active(info, vc)) {
169 ++ area.sx += vc->vc_decor.tx;
170 ++ area.sy += vc->vc_decor.ty;
171 ++ area.dx += vc->vc_decor.tx;
172 ++ area.dy += vc->vc_decor.ty;
173 ++ }
174 +
175 - info->fbops->fb_copyarea(info, &area);
176 + info->fbops->fb_copyarea(info, &area);
177 }
178
179 @@ -380,11 +388,15 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode,
180 - cursor.image.depth = 1;
181 - cursor.rop = ROP_XOR;
182 + cursor.image.depth = 1;
183 + cursor.rop = ROP_XOR;
184
185 -- if (info->fbops->fb_cursor)
186 -- err = info->fbops->fb_cursor(info, &cursor);
187 -+ if (fbcon_decor_active(info, vc)) {
188 -+ fbcon_decor_cursor(info, &cursor);
189 -+ } else {
190 -+ if (info->fbops->fb_cursor)
191 -+ err = info->fbops->fb_cursor(info, &cursor);
192 +- if (info->fbops->fb_cursor)
193 +- err = info->fbops->fb_cursor(info, &cursor);
194 ++ if (fbcon_decor_active(info, vc)) {
195 ++ fbcon_decor_cursor(info, &cursor);
196 ++ } else {
197 ++ if (info->fbops->fb_cursor)
198 ++ err = info->fbops->fb_cursor(info, &cursor);
199
200 -- if (err)
201 -- soft_cursor(info, &cursor);
202 -+ if (err)
203 -+ soft_cursor(info, &cursor);
204 -+ }
205 +- if (err)
206 +- soft_cursor(info, &cursor);
207 ++ if (err)
208 ++ soft_cursor(info, &cursor);
209 ++ }
210
211 - ops->cursor_reset = 0;
212 + ops->cursor_reset = 0;
213 }
214 diff --git a/drivers/video/console/cfbcondecor.c b/drivers/video/console/cfbcondecor.c
215 new file mode 100644
216 @@ -418,448 +394,448 @@
217 +#include "fbcon.h"
218 +#include "fbcondecor.h"
219 +
220 -+#define parse_pixel(shift,bpp,type) \
221 -+ do { \
222 -+ if (d & (0x80 >> (shift))) \
223 -+ dd2[(shift)] = fgx; \
224 -+ else \
225 -+ dd2[(shift)] = transparent ? *(type *)decor_src : bgx; \
226 -+ decor_src += (bpp); \
227 -+ } while (0) \
228 ++#define parse_pixel(shift,bpp,type) \
229 ++ do { \
230 ++ if (d & (0x80 >> (shift))) \
231 ++ dd2[(shift)] = fgx; \
232 ++ else \
233 ++ dd2[(shift)] = transparent ? *(type *)decor_src : bgx; \
234 ++ decor_src += (bpp); \
235 ++ } while (0) \
236 +
237 +extern int get_color(struct vc_data *vc, struct fb_info *info,
238 -+ u16 c, int is_fg);
239 ++ u16 c, int is_fg);
240 +
241 +void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc)
242 +{
243 -+ int i, j, k;
244 -+ int minlen = min(min(info->var.red.length, info->var.green.length),
245 -+ info->var.blue.length);
246 -+ u32 col;
247 ++ int i, j, k;
248 ++ int minlen = min(min(info->var.red.length, info->var.green.length),
249 ++ info->var.blue.length);
250 ++ u32 col;
251 +
252 -+ for (j = i = 0; i < 16; i++) {
253 -+ k = color_table[i];
254 ++ for (j = i = 0; i < 16; i++) {
255 ++ k = color_table[i];
256 +
257 -+ col = ((vc->vc_palette[j++] >> (8-minlen))
258 -+ << info->var.red.offset);
259 -+ col |= ((vc->vc_palette[j++] >> (8-minlen))
260 -+ << info->var.green.offset);
261 -+ col |= ((vc->vc_palette[j++] >> (8-minlen))
262 -+ << info->var.blue.offset);
263 -+ ((u32 *)info->pseudo_palette)[k] = col;
264 -+ }
265 ++ col = ((vc->vc_palette[j++] >> (8-minlen))
266 ++ << info->var.red.offset);
267 ++ col |= ((vc->vc_palette[j++] >> (8-minlen))
268 ++ << info->var.green.offset);
269 ++ col |= ((vc->vc_palette[j++] >> (8-minlen))
270 ++ << info->var.blue.offset);
271 ++ ((u32 *)info->pseudo_palette)[k] = col;
272 ++ }
273 +}
274 +
275 +void fbcon_decor_renderc(struct fb_info *info, int ypos, int xpos, int height,
276 -+ int width, u8* src, u32 fgx, u32 bgx, u8 transparent)
277 ++ int width, u8* src, u32 fgx, u32 bgx, u8 transparent)
278 +{
279 -+ unsigned int x, y;
280 -+ u32 dd;
281 -+ int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
282 -+ unsigned int d = ypos * info->fix.line_length + xpos * bytespp;
283 -+ unsigned int ds = (ypos * info->var.xres + xpos) * bytespp;
284 -+ u16 dd2[4];
285 ++ unsigned int x, y;
286 ++ u32 dd;
287 ++ int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
288 ++ unsigned int d = ypos * info->fix.line_length + xpos * bytespp;
289 ++ unsigned int ds = (ypos * info->var.xres + xpos) * bytespp;
290 ++ u16 dd2[4];
291 +
292 -+ u8* decor_src = (u8 *)(info->bgdecor.data + ds);
293 -+ u8* dst = (u8 *)(info->screen_base + d);
294 ++ u8* decor_src = (u8 *)(info->bgdecor.data + ds);
295 ++ u8* dst = (u8 *)(info->screen_base + d);
296 +
297 -+ if ((ypos + height) > info->var.yres || (xpos + width) > info->var.xres)
298 -+ return;
299 ++ if ((ypos + height) > info->var.yres || (xpos + width) > info->var.xres)
300 ++ return;
301 +
302 -+ for (y = 0; y < height; y++) {
303 -+ switch (info->var.bits_per_pixel) {
304 ++ for (y = 0; y < height; y++) {
305 ++ switch (info->var.bits_per_pixel) {
306 +
307 -+ case 32:
308 -+ for (x = 0; x < width; x++) {
309 ++ case 32:
310 ++ for (x = 0; x < width; x++) {
311 +
312 -+ if ((x & 7) == 0)
313 -+ d = *src++;
314 -+ if (d & 0x80)
315 -+ dd = fgx;
316 -+ else
317 -+ dd = transparent ?
318 -+ *(u32 *)decor_src : bgx;
319 ++ if ((x & 7) == 0)
320 ++ d = *src++;
321 ++ if (d & 0x80)
322 ++ dd = fgx;
323 ++ else
324 ++ dd = transparent ?
325 ++ *(u32 *)decor_src : bgx;
326 +
327 -+ d <<= 1;
328 -+ decor_src += 4;
329 -+ fb_writel(dd, dst);
330 -+ dst += 4;
331 -+ }
332 -+ break;
333 -+ case 24:
334 -+ for (x = 0; x < width; x++) {
335 ++ d <<= 1;
336 ++ decor_src += 4;
337 ++ fb_writel(dd, dst);
338 ++ dst += 4;
339 ++ }
340 ++ break;
341 ++ case 24:
342 ++ for (x = 0; x < width; x++) {
343 +
344 -+ if ((x & 7) == 0)
345 -+ d = *src++;
346 -+ if (d & 0x80)
347 -+ dd = fgx;
348 -+ else
349 -+ dd = transparent ?
350 -+ (*(u32 *)decor_src & 0xffffff) : bgx;
351 ++ if ((x & 7) == 0)
352 ++ d = *src++;
353 ++ if (d & 0x80)
354 ++ dd = fgx;
355 ++ else
356 ++ dd = transparent ?
357 ++ (*(u32 *)decor_src & 0xffffff) : bgx;
358 +
359 -+ d <<= 1;
360 -+ decor_src += 3;
361 ++ d <<= 1;
362 ++ decor_src += 3;
363 +#ifdef __LITTLE_ENDIAN
364 -+ fb_writew(dd & 0xffff, dst);
365 -+ dst += 2;
366 -+ fb_writeb((dd >> 16), dst);
367 ++ fb_writew(dd & 0xffff, dst);
368 ++ dst += 2;
369 ++ fb_writeb((dd >> 16), dst);
370 +#else
371 -+ fb_writew(dd >> 8, dst);
372 -+ dst += 2;
373 -+ fb_writeb(dd & 0xff, dst);
374 ++ fb_writew(dd >> 8, dst);
375 ++ dst += 2;
376 ++ fb_writeb(dd & 0xff, dst);
377 +#endif
378 -+ dst++;
379 -+ }
380 -+ break;
381 -+ case 16:
382 -+ for (x = 0; x < width; x += 2) {
383 -+ if ((x & 7) == 0)
384 -+ d = *src++;
385 ++ dst++;
386 ++ }
387 ++ break;
388 ++ case 16:
389 ++ for (x = 0; x < width; x += 2) {
390 ++ if ((x & 7) == 0)
391 ++ d = *src++;
392 +
393 -+ parse_pixel(0, 2, u16);
394 -+ parse_pixel(1, 2, u16);
395 ++ parse_pixel(0, 2, u16);
396 ++ parse_pixel(1, 2, u16);
397 +#ifdef __LITTLE_ENDIAN
398 -+ dd = dd2[0] | (dd2[1] << 16);
399 ++ dd = dd2[0] | (dd2[1] << 16);
400 +#else
401 -+ dd = dd2[1] | (dd2[0] << 16);
402 ++ dd = dd2[1] | (dd2[0] << 16);
403 +#endif
404 -+ d <<= 2;
405 -+ fb_writel(dd, dst);
406 -+ dst += 4;
407 -+ }
408 -+ break;
409 ++ d <<= 2;
410 ++ fb_writel(dd, dst);
411 ++ dst += 4;
412 ++ }
413 ++ break;
414 +
415 -+ case 8:
416 -+ for (x = 0; x < width; x += 4) {
417 -+ if ((x & 7) == 0)
418 -+ d = *src++;
419 ++ case 8:
420 ++ for (x = 0; x < width; x += 4) {
421 ++ if ((x & 7) == 0)
422 ++ d = *src++;
423 +
424 -+ parse_pixel(0, 1, u8);
425 -+ parse_pixel(1, 1, u8);
426 -+ parse_pixel(2, 1, u8);
427 -+ parse_pixel(3, 1, u8);
428 ++ parse_pixel(0, 1, u8);
429 ++ parse_pixel(1, 1, u8);
430 ++ parse_pixel(2, 1, u8);
431 ++ parse_pixel(3, 1, u8);
432 +
433 +#ifdef __LITTLE_ENDIAN
434 -+ dd = dd2[0] | (dd2[1] << 8) | (dd2[2] << 16) | (dd2[3] << 24);
435 ++ dd = dd2[0] | (dd2[1] << 8) | (dd2[2] << 16) | (dd2[3] << 24);
436 +#else
437 -+ dd = dd2[3] | (dd2[2] << 8) | (dd2[1] << 16) | (dd2[0] << 24);
438 ++ dd = dd2[3] | (dd2[2] << 8) | (dd2[1] << 16) | (dd2[0] << 24);
439 +#endif
440 -+ d <<= 4;
441 -+ fb_writel(dd, dst);
442 -+ dst += 4;
443 -+ }
444 -+ }
445 ++ d <<= 4;
446 ++ fb_writel(dd, dst);
447 ++ dst += 4;
448 ++ }
449 ++ }
450 +
451 -+ dst += info->fix.line_length - width * bytespp;
452 -+ decor_src += (info->var.xres - width) * bytespp;
453 -+ }
454 ++ dst += info->fix.line_length - width * bytespp;
455 ++ decor_src += (info->var.xres - width) * bytespp;
456 ++ }
457 +}
458 +
459 -+#define cc2cx(a) \
460 -+ ((info->fix.visual == FB_VISUAL_TRUECOLOR || \
461 -+ info->fix.visual == FB_VISUAL_DIRECTCOLOR) ? \
462 -+ ((u32*)info->pseudo_palette)[a] : a)
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)
467 +
468 +void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info,
469 -+ const unsigned short *s, int count, int yy, int xx)
470 ++ const unsigned short *s, int count, int yy, int xx)
471 +{
472 -+ unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
473 -+ struct fbcon_ops *ops = info->fbcon_par;
474 -+ int fg_color, bg_color, transparent;
475 -+ u8 *src;
476 -+ u32 bgx, fgx;
477 -+ u16 c = scr_readw(s);
478 ++ unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
479 ++ struct fbcon_ops *ops = info->fbcon_par;
480 ++ int fg_color, bg_color, transparent;
481 ++ u8 *src;
482 ++ u32 bgx, fgx;
483 ++ u16 c = scr_readw(s);
484 +
485 -+ fg_color = get_color(vc, info, c, 1);
486 ++ fg_color = get_color(vc, info, c, 1);
487 + bg_color = get_color(vc, info, c, 0);
488 +
489 -+ /* Don't paint the background image if console is blanked */
490 -+ transparent = ops->blank_state ? 0 :
491 -+ (vc->vc_decor.bg_color == bg_color);
492 ++ /* Don't paint the background image if console is blanked */
493 ++ transparent = ops->blank_state ? 0 :
494 ++ (vc->vc_decor.bg_color == bg_color);
495 +
496 -+ xx = xx * vc->vc_font.width + vc->vc_decor.tx;
497 -+ yy = yy * vc->vc_font.height + vc->vc_decor.ty;
498 ++ xx = xx * vc->vc_font.width + vc->vc_decor.tx;
499 ++ yy = yy * vc->vc_font.height + vc->vc_decor.ty;
500 +
501 -+ fgx = cc2cx(fg_color);
502 -+ bgx = cc2cx(bg_color);
503 ++ fgx = cc2cx(fg_color);
504 ++ bgx = cc2cx(bg_color);
505 +
506 -+ while (count--) {
507 -+ c = scr_readw(s++);
508 -+ src = vc->vc_font.data + (c & charmask) * vc->vc_font.height *
509 -+ ((vc->vc_font.width + 7) >> 3);
510 ++ while (count--) {
511 ++ c = scr_readw(s++);
512 ++ src = vc->vc_font.data + (c & charmask) * vc->vc_font.height *
513 ++ ((vc->vc_font.width + 7) >> 3);
514 +
515 -+ fbcon_decor_renderc(info, yy, xx, vc->vc_font.height,
516 -+ vc->vc_font.width, src, fgx, bgx, transparent);
517 -+ xx += vc->vc_font.width;
518 -+ }
519 ++ fbcon_decor_renderc(info, yy, xx, vc->vc_font.height,
520 ++ vc->vc_font.width, src, fgx, bgx, transparent);
521 ++ xx += vc->vc_font.width;
522 ++ }
523 +}
524 +
525 +void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor)
526 +{
527 -+ int i;
528 -+ unsigned int dsize, s_pitch;
529 -+ struct fbcon_ops *ops = info->fbcon_par;
530 -+ struct vc_data* vc;
531 -+ u8 *src;
532 ++ int i;
533 ++ unsigned int dsize, s_pitch;
534 ++ struct fbcon_ops *ops = info->fbcon_par;
535 ++ struct vc_data* vc;
536 ++ u8 *src;
537 +
538 -+ /* we really don't need any cursors while the console is blanked */
539 -+ if (info->state != FBINFO_STATE_RUNNING || ops->blank_state)
540 -+ return;
541 ++ /* we really don't need any cursors while the console is blanked */
542 ++ if (info->state != FBINFO_STATE_RUNNING || ops->blank_state)
543 ++ return;
544 +
545 -+ vc = vc_cons[ops->currcon].d;
546 ++ vc = vc_cons[ops->currcon].d;
547 +
548 -+ src = kmalloc(64 + sizeof(struct fb_image), GFP_ATOMIC);
549 -+ if (!src)
550 -+ return;
551 ++ src = kmalloc(64 + sizeof(struct fb_image), GFP_ATOMIC);
552 ++ if (!src)
553 ++ return;
554 +
555 -+ s_pitch = (cursor->image.width + 7) >> 3;
556 -+ dsize = s_pitch * cursor->image.height;
557 -+ if (cursor->enable) {
558 -+ switch (cursor->rop) {
559 -+ case ROP_XOR:
560 -+ for (i = 0; i < dsize; i++)
561 -+ src[i] = cursor->image.data[i] ^ cursor->mask[i];
562 ++ s_pitch = (cursor->image.width + 7) >> 3;
563 ++ dsize = s_pitch * cursor->image.height;
564 ++ if (cursor->enable) {
565 ++ switch (cursor->rop) {
566 ++ case ROP_XOR:
567 ++ for (i = 0; i < dsize; i++)
568 ++ src[i] = cursor->image.data[i] ^ cursor->mask[i];
569 + break;
570 -+ case ROP_COPY:
571 -+ default:
572 -+ for (i = 0; i < dsize; i++)
573 -+ src[i] = cursor->image.data[i] & cursor->mask[i];
574 -+ break;
575 -+ }
576 -+ } else
577 -+ memcpy(src, cursor->image.data, dsize);
578 ++ case ROP_COPY:
579 ++ default:
580 ++ for (i = 0; i < dsize; i++)
581 ++ src[i] = cursor->image.data[i] & cursor->mask[i];
582 ++ break;
583 ++ }
584 ++ } else
585 ++ memcpy(src, cursor->image.data, dsize);
586 +
587 -+ fbcon_decor_renderc(info,
588 -+ cursor->image.dy + vc->vc_decor.ty,
589 -+ cursor->image.dx + vc->vc_decor.tx,
590 -+ cursor->image.height,
591 -+ cursor->image.width,
592 -+ (u8*)src,
593 -+ cc2cx(cursor->image.fg_color),
594 -+ cc2cx(cursor->image.bg_color),
595 -+ cursor->image.bg_color == vc->vc_decor.bg_color);
596 ++ fbcon_decor_renderc(info,
597 ++ cursor->image.dy + vc->vc_decor.ty,
598 ++ cursor->image.dx + vc->vc_decor.tx,
599 ++ cursor->image.height,
600 ++ cursor->image.width,
601 ++ (u8*)src,
602 ++ cc2cx(cursor->image.fg_color),
603 ++ cc2cx(cursor->image.bg_color),
604 ++ cursor->image.bg_color == vc->vc_decor.bg_color);
605 +
606 -+ kfree(src);
607 ++ kfree(src);
608 +}
609 +
610 +static void decorset(u8 *dst, int height, int width, int dstbytes,
611 -+ u32 bgx, int bpp)
612 ++ u32 bgx, int bpp)
613 +{
614 -+ int i;
615 ++ int i;
616 +
617 -+ if (bpp == 8)
618 -+ bgx |= bgx << 8;
619 -+ if (bpp == 16 || bpp == 8)
620 -+ bgx |= bgx << 16;
621 ++ if (bpp == 8)
622 ++ bgx |= bgx << 8;
623 ++ if (bpp == 16 || bpp == 8)
624 ++ bgx |= bgx << 16;
625 +
626 -+ while (height-- > 0) {
627 -+ u8 *p = dst;
628 ++ while (height-- > 0) {
629 ++ u8 *p = dst;
630 +
631 -+ switch (bpp) {
632 ++ switch (bpp) {
633 +
634 -+ case 32:
635 -+ for (i=0; i < width; i++) {
636 -+ fb_writel(bgx, p); p += 4;
637 -+ }
638 -+ break;
639 -+ case 24:
640 -+ for (i=0; i < width; i++) {
641 ++ case 32:
642 ++ for (i=0; i < width; i++) {
643 ++ fb_writel(bgx, p); p += 4;
644 ++ }
645 ++ break;
646 ++ case 24:
647 ++ for (i=0; i < width; i++) {
648 +#ifdef __LITTLE_ENDIAN
649 -+ fb_writew((bgx & 0xffff),(u16*)p); p += 2;
650 -+ fb_writeb((bgx >> 16),p++);
651 ++ fb_writew((bgx & 0xffff),(u16*)p); p += 2;
652 ++ fb_writeb((bgx >> 16),p++);
653 +#else
654 -+ fb_writew((bgx >> 8),(u16*)p); p += 2;
655 -+ fb_writeb((bgx & 0xff),p++);
656 ++ fb_writew((bgx >> 8),(u16*)p); p += 2;
657 ++ fb_writeb((bgx & 0xff),p++);
658 +#endif
659 -+ }
660 -+ case 16:
661 -+ for (i=0; i < width/4; i++) {
662 -+ fb_writel(bgx,p); p += 4;
663 -+ fb_writel(bgx,p); p += 4;
664 -+ }
665 -+ if (width & 2) {
666 -+ fb_writel(bgx,p); p += 4;
667 -+ }
668 -+ if (width & 1)
669 -+ fb_writew(bgx,(u16*)p);
670 -+ break;
671 -+ case 8:
672 -+ for (i=0; i < width/4; i++) {
673 -+ fb_writel(bgx,p); p += 4;
674 -+ }
675 ++ }
676 ++ case 16:
677 ++ for (i=0; i < width/4; i++) {
678 ++ fb_writel(bgx,p); p += 4;
679 ++ fb_writel(bgx,p); p += 4;
680 ++ }
681 ++ if (width & 2) {
682 ++ fb_writel(bgx,p); p += 4;
683 ++ }
684 ++ if (width & 1)
685 ++ fb_writew(bgx,(u16*)p);
686 ++ break;
687 ++ case 8:
688 ++ for (i=0; i < width/4; i++) {
689 ++ fb_writel(bgx,p); p += 4;
690 ++ }
691 +
692 -+ if (width & 2) {
693 -+ fb_writew(bgx,p); p += 2;
694 -+ }
695 -+ if (width & 1)
696 -+ fb_writeb(bgx,(u8*)p);
697 -+ break;
698 ++ if (width & 2) {
699 ++ fb_writew(bgx,p); p += 2;
700 ++ }
701 ++ if (width & 1)
702 ++ fb_writeb(bgx,(u8*)p);
703 ++ break;
704 +
705 -+ }
706 -+ dst += dstbytes;
707 -+ }
708 ++ }
709 ++ dst += dstbytes;
710 ++ }
711 +}
712 +
713 +void fbcon_decor_copy(u8 *dst, u8 *src, int height, int width, int linebytes,
714 -+ int srclinebytes, int bpp)
715 ++ int srclinebytes, int bpp)
716 +{
717 -+ int i;
718 ++ int i;
719 +
720 -+ while (height-- > 0) {
721 -+ u32 *p = (u32 *)dst;
722 -+ u32 *q = (u32 *)src;
723 ++ while (height-- > 0) {
724 ++ u32 *p = (u32 *)dst;
725 ++ u32 *q = (u32 *)src;
726 +
727 -+ switch (bpp) {
728 ++ switch (bpp) {
729 +
730 -+ case 32:
731 -+ for (i=0; i < width; i++)
732 -+ fb_writel(*q++, p++);
733 -+ break;
734 -+ case 24:
735 -+ for (i=0; i < (width*3/4); i++)
736 -+ fb_writel(*q++, p++);
737 -+ if ((width*3) % 4) {
738 -+ if (width & 2) {
739 -+ fb_writeb(*(u8*)q, (u8*)p);
740 -+ } else if (width & 1) {
741 -+ fb_writew(*(u16*)q, (u16*)p);
742 -+ fb_writeb(*(u8*)((u16*)q+1),(u8*)((u16*)p+2));
743 -+ }
744 -+ }
745 -+ break;
746 -+ case 16:
747 -+ for (i=0; i < width/4; i++) {
748 -+ fb_writel(*q++, p++);
749 -+ fb_writel(*q++, p++);
750 -+ }
751 -+ if (width & 2)
752 -+ fb_writel(*q++, p++);
753 -+ if (width & 1)
754 -+ fb_writew(*(u16*)q, (u16*)p);
755 -+ break;
756 -+ case 8:
757 -+ for (i=0; i < width/4; i++)
758 -+ fb_writel(*q++, p++);
759 ++ case 32:
760 ++ for (i=0; i < width; i++)
761 ++ fb_writel(*q++, p++);
762 ++ break;
763 ++ case 24:
764 ++ for (i=0; i < (width*3/4); i++)
765 ++ fb_writel(*q++, p++);
766 ++ if ((width*3) % 4) {
767 ++ if (width & 2) {
768 ++ fb_writeb(*(u8*)q, (u8*)p);
769 ++ } else if (width & 1) {
770 ++ fb_writew(*(u16*)q, (u16*)p);
771 ++ fb_writeb(*(u8*)((u16*)q+1),(u8*)((u16*)p+2));
772 ++ }
773 ++ }
774 ++ break;
775 ++ case 16:
776 ++ for (i=0; i < width/4; i++) {
777 ++ fb_writel(*q++, p++);
778 ++ fb_writel(*q++, p++);
779 ++ }
780 ++ if (width & 2)
781 ++ fb_writel(*q++, p++);
782 ++ if (width & 1)
783 ++ fb_writew(*(u16*)q, (u16*)p);
784 ++ break;
785 ++ case 8:
786 ++ for (i=0; i < width/4; i++)
787 ++ fb_writel(*q++, p++);
788 +
789 -+ if (width & 2) {
790 -+ fb_writew(*(u16*)q, (u16*)p);
791 -+ q = (u32*) ((u16*)q + 1);
792 -+ p = (u32*) ((u16*)p + 1);
793 -+ }
794 -+ if (width & 1)
795 -+ fb_writeb(*(u8*)q, (u8*)p);
796 -+ break;
797 -+ }
798 ++ if (width & 2) {
799 ++ fb_writew(*(u16*)q, (u16*)p);
800 ++ q = (u32*) ((u16*)q + 1);
801 ++ p = (u32*) ((u16*)p + 1);
802 ++ }
803 ++ if (width & 1)
804 ++ fb_writeb(*(u8*)q, (u8*)p);
805 ++ break;
806 ++ }
807 +
808 -+ dst += linebytes;
809 -+ src += srclinebytes;
810 -+ }
811 ++ dst += linebytes;
812 ++ src += srclinebytes;
813 ++ }
814 +}
815 +
816 +static void decorfill(struct fb_info *info, int sy, int sx, int height,
817 -+ int width)
818 ++ int width)
819 +{
820 -+ int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
821 -+ int d = sy * info->fix.line_length + sx * bytespp;
822 -+ int ds = (sy * info->var.xres + sx) * bytespp;
823 ++ int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
824 ++ int d = sy * info->fix.line_length + sx * bytespp;
825 ++ int ds = (sy * info->var.xres + sx) * bytespp;
826 +
827 -+ fbcon_decor_copy((u8 *)(info->screen_base + d), (u8 *)(info->bgdecor.data + ds),
828 -+ height, width, info->fix.line_length, info->var.xres * bytespp,
829 -+ info->var.bits_per_pixel);
830 ++ fbcon_decor_copy((u8 *)(info->screen_base + d), (u8 *)(info->bgdecor.data + ds),
831 ++ height, width, info->fix.line_length, info->var.xres * bytespp,
832 ++ info->var.bits_per_pixel);
833 +}
834 +
835 +void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx,
836 -+ int height, int width)
837 ++ int height, int width)
838 +{
839 -+ int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
840 -+ struct fbcon_ops *ops = info->fbcon_par;
841 -+ u8 *dst;
842 -+ int transparent, bg_color = attr_bgcol_ec(bgshift, vc, info);
843 ++ int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
844 ++ struct fbcon_ops *ops = info->fbcon_par;
845 ++ u8 *dst;
846 ++ int transparent, bg_color = attr_bgcol_ec(bgshift, vc, info);
847 +
848 -+ transparent = (vc->vc_decor.bg_color == bg_color);
849 -+ sy = sy * vc->vc_font.height + vc->vc_decor.ty;
850 -+ sx = sx * vc->vc_font.width + vc->vc_decor.tx;
851 -+ height *= vc->vc_font.height;
852 -+ width *= vc->vc_font.width;
853 ++ transparent = (vc->vc_decor.bg_color == bg_color);
854 ++ sy = sy * vc->vc_font.height + vc->vc_decor.ty;
855 ++ sx = sx * vc->vc_font.width + vc->vc_decor.tx;
856 ++ height *= vc->vc_font.height;
857 ++ width *= vc->vc_font.width;
858 +
859 -+ /* Don't paint the background image if console is blanked */
860 -+ if (transparent && !ops->blank_state) {
861 -+ decorfill(info, sy, sx, height, width);
862 -+ } else {
863 -+ dst = (u8 *)(info->screen_base + sy * info->fix.line_length +
864 -+ sx * ((info->var.bits_per_pixel + 7) >> 3));
865 -+ decorset(dst, height, width, info->fix.line_length, cc2cx(bg_color),
866 -+ info->var.bits_per_pixel);
867 -+ }
868 ++ /* Don't paint the background image if console is blanked */
869 ++ if (transparent && !ops->blank_state) {
870 ++ decorfill(info, sy, sx, height, width);
871 ++ } else {
872 ++ dst = (u8 *)(info->screen_base + sy * info->fix.line_length +
873 ++ sx * ((info->var.bits_per_pixel + 7) >> 3));
874 ++ decorset(dst, height, width, info->fix.line_length, cc2cx(bg_color),
875 ++ info->var.bits_per_pixel);
876 ++ }
877 +}
878 +
879 +void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info,
880 -+ int bottom_only)
881 ++ int bottom_only)
882 +{
883 -+ unsigned int tw = vc->vc_cols*vc->vc_font.width;
884 -+ unsigned int th = vc->vc_rows*vc->vc_font.height;
885 ++ unsigned int tw = vc->vc_cols*vc->vc_font.width;
886 ++ unsigned int th = vc->vc_rows*vc->vc_font.height;
887 +
888 -+ if (!bottom_only) {
889 -+ /* top margin */
890 -+ decorfill(info, 0, 0, vc->vc_decor.ty, info->var.xres);
891 -+ /* left margin */
892 -+ decorfill(info, vc->vc_decor.ty, 0, th, vc->vc_decor.tx);
893 -+ /* right margin */
894 -+ decorfill(info, vc->vc_decor.ty, vc->vc_decor.tx + tw, th,
895 -+ info->var.xres - vc->vc_decor.tx - tw);
896 -+ }
897 -+ decorfill(info, vc->vc_decor.ty + th, 0,
898 -+ info->var.yres - vc->vc_decor.ty - th, info->var.xres);
899 ++ if (!bottom_only) {
900 ++ /* top margin */
901 ++ decorfill(info, 0, 0, vc->vc_decor.ty, info->var.xres);
902 ++ /* left margin */
903 ++ decorfill(info, vc->vc_decor.ty, 0, th, vc->vc_decor.tx);
904 ++ /* right margin */
905 ++ decorfill(info, vc->vc_decor.ty, vc->vc_decor.tx + tw, th,
906 ++ info->var.xres - vc->vc_decor.tx - tw);
907 ++ }
908 ++ decorfill(info, vc->vc_decor.ty + th, 0,
909 ++ info->var.yres - vc->vc_decor.ty - th, info->var.xres);
910 +}
911 +
912 +void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y,
913 -+ int sx, int dx, int width)
914 ++ int sx, int dx, int width)
915 +{
916 -+ u16 *d = (u16 *) (vc->vc_origin + vc->vc_size_row * y + dx * 2);
917 -+ u16 *s = d + (dx - sx);
918 -+ u16 *start = d;
919 -+ u16 *ls = d;
920 -+ u16 *le = d + width;
921 -+ u16 c;
922 -+ int x = dx;
923 -+ u16 attr = 1;
924 ++ u16 *d = (u16 *) (vc->vc_origin + vc->vc_size_row * y + dx * 2);
925 ++ u16 *s = d + (dx - sx);
926 ++ u16 *start = d;
927 ++ u16 *ls = d;
928 ++ u16 *le = d + width;
929 ++ u16 c;
930 ++ int x = dx;
931 ++ u16 attr = 1;
932 +
933 -+ do {
934 -+ c = scr_readw(d);
935 -+ if (attr != (c & 0xff00)) {
936 -+ attr = c & 0xff00;
937 -+ if (d > start) {
938 -+ fbcon_decor_putcs(vc, info, start, d - start, y, x);
939 -+ x += d - start;
940 -+ start = d;
941 -+ }
942 -+ }
943 -+ if (s >= ls && s < le && c == scr_readw(s)) {
944 -+ if (d > start) {
945 -+ fbcon_decor_putcs(vc, info, start, d - start, y, x);
946 -+ x += d - start + 1;
947 -+ start = d + 1;
948 -+ } else {
949 -+ x++;
950 -+ start++;
951 -+ }
952 -+ }
953 -+ s++;
954 -+ d++;
955 -+ } while (d < le);
956 -+ if (d > start)
957 -+ fbcon_decor_putcs(vc, info, start, d - start, y, x);
958 ++ do {
959 ++ c = scr_readw(d);
960 ++ if (attr != (c & 0xff00)) {
961 ++ attr = c & 0xff00;
962 ++ if (d > start) {
963 ++ fbcon_decor_putcs(vc, info, start, d - start, y, x);
964 ++ x += d - start;
965 ++ start = d;
966 ++ }
967 ++ }
968 ++ if (s >= ls && s < le && c == scr_readw(s)) {
969 ++ if (d > start) {
970 ++ fbcon_decor_putcs(vc, info, start, d - start, y, x);
971 ++ x += d - start + 1;
972 ++ start = d + 1;
973 ++ } else {
974 ++ x++;
975 ++ start++;
976 ++ }
977 ++ }
978 ++ s++;
979 ++ d++;
980 ++ } while (d < le);
981 ++ if (d > start)
982 ++ fbcon_decor_putcs(vc, info, start, d - start, y, x);
983 +}
984 +
985 +void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank)
986 +{
987 -+ if (blank) {
988 -+ decorset((u8 *)info->screen_base, info->var.yres, info->var.xres,
989 -+ info->fix.line_length, 0, info->var.bits_per_pixel);
990 -+ } else {
991 -+ update_screen(vc);
992 -+ fbcon_decor_clear_margins(vc, info, 0);
993 -+ }
994 ++ if (blank) {
995 ++ decorset((u8 *)info->screen_base, info->var.yres, info->var.xres,
996 ++ info->fix.line_length, 0, info->var.bits_per_pixel);
997 ++ } else {
998 ++ update_screen(vc);
999 ++ fbcon_decor_clear_margins(vc, info, 0);
1000 ++ }
1001 +}
1002 diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
1003 index 9c092b8..e763778 100644
1004 @@ -883,366 +859,366 @@
1005
1006 static int logo_lines;
1007 @@ -287,7 +288,7 @@ static inline int fbcon_is_inactive(struct vc_data *vc, struct fb_info *info)
1008 - !vt_force_oops_output(vc);
1009 + !vt_force_oops_output(vc);
1010 }
1011
1012 -static int get_color(struct vc_data *vc, struct fb_info *info,
1013 +inline int get_color(struct vc_data *vc, struct fb_info *info,
1014 - u16 c, int is_fg)
1015 + u16 c, int is_fg)
1016 {
1017 - int depth = fb_get_color_depth(&info->var, &info->fix);
1018 + int depth = fb_get_color_depth(&info->var, &info->fix);
1019 @@ -528,6 +529,9 @@ static int search_for_mapped_con(void)
1020 static int fbcon_takeover(int show_logo)
1021 {
1022 - int err, i;
1023 + int err, i;
1024 +#ifdef CONFIG_FB_CON_DECOR
1025 -+ struct fb_info *info;
1026 ++ struct fb_info *info;
1027 +#endif
1028
1029 - if (!num_registered_fb)
1030 - return -ENODEV;
1031 + if (!num_registered_fb)
1032 + return -ENODEV;
1033 @@ -548,6 +552,12 @@ static int fbcon_takeover(int show_logo)
1034 - info_idx = -1;
1035 - } else {
1036 - fbcon_has_console_bind = 1;
1037 + info_idx = -1;
1038 + } else {
1039 + fbcon_has_console_bind = 1;
1040 +#ifdef CONFIG_FB_CON_DECOR
1041 -+ info = registered_fb[info_idx];
1042 -+ unlock_fb_info(info);
1043 -+ fbcon_decor_init();
1044 -+ lock_fb_info(info);
1045 ++ info = registered_fb[info_idx];
1046 ++ unlock_fb_info(info);
1047 ++ fbcon_decor_init();
1048 ++ lock_fb_info(info);
1049 +#endif
1050 - }
1051 + }
1052
1053 - return err;
1054 + return err;
1055 @@ -1002,6 +1012,12 @@ static const char *fbcon_startup(void)
1056 - rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1057 - cols /= vc->vc_font.width;
1058 - rows /= vc->vc_font.height;
1059 + rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1060 + cols /= vc->vc_font.width;
1061 + rows /= vc->vc_font.height;
1062 +
1063 -+ if (fbcon_decor_active(info, vc)) {
1064 -+ cols = vc->vc_decor.twidth / vc->vc_font.width;
1065 -+ rows = vc->vc_decor.theight / vc->vc_font.height;
1066 -+ }
1067 ++ if (fbcon_decor_active(info, vc)) {
1068 ++ cols = vc->vc_decor.twidth / vc->vc_font.width;
1069 ++ rows = vc->vc_decor.theight / vc->vc_font.height;
1070 ++ }
1071 +
1072 - vc_resize(vc, cols, rows);
1073 + vc_resize(vc, cols, rows);
1074
1075 - DPRINTK("mode: %s\n", info->fix.id);
1076 + DPRINTK("mode: %s\n", info->fix.id);
1077 @@ -1031,7 +1047,7 @@ static void fbcon_init(struct vc_data *vc, int init)
1078 - cap = info->flags;
1079 + cap = info->flags;
1080
1081 - if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
1082 -- (info->fix.type == FB_TYPE_TEXT))
1083 -+ (info->fix.type == FB_TYPE_TEXT) || fbcon_decor_active(info, vc))
1084 - logo = 0;
1085 + if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
1086 +- (info->fix.type == FB_TYPE_TEXT))
1087 ++ (info->fix.type == FB_TYPE_TEXT) || fbcon_decor_active(info, vc))
1088 + logo = 0;
1089
1090 - if (var_to_display(p, &info->var, info))
1091 + if (var_to_display(p, &info->var, info))
1092 @@ -1241,6 +1257,11 @@ static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
1093 - if (sy < vc->vc_top && vc->vc_top == logo_lines)
1094 - vc->vc_top = 0;
1095 + if (sy < vc->vc_top && vc->vc_top == logo_lines)
1096 + vc->vc_top = 0;
1097
1098 -+ if (fbcon_decor_active(info, vc)) {
1099 -+ fbcon_decor_clear(vc, info, sy, sx, height, width);
1100 -+ return;
1101 -+ }
1102 ++ if (fbcon_decor_active(info, vc)) {
1103 ++ fbcon_decor_clear(vc, info, sy, sx, height, width);
1104 ++ return;
1105 ++ }
1106 +
1107 - /* Split blits that cross physical y_wrap boundary */
1108 + /* Split blits that cross physical y_wrap boundary */
1109
1110 - y_break = p->vrows - p->yscroll;
1111 + y_break = p->vrows - p->yscroll;
1112 @@ -1260,10 +1281,15 @@ static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
1113 - struct display *p = &fb_display[vc->vc_num];
1114 - struct fbcon_ops *ops = info->fbcon_par;
1115 + struct display *p = &fb_display[vc->vc_num];
1116 + struct fbcon_ops *ops = info->fbcon_par;
1117
1118 -- if (!fbcon_is_inactive(vc, info))
1119 -- ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
1120 -- get_color(vc, info, scr_readw(s), 1),
1121 -- get_color(vc, info, scr_readw(s), 0));
1122 -+ if (!fbcon_is_inactive(vc, info)) {
1123 +- if (!fbcon_is_inactive(vc, info))
1124 +- ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
1125 +- get_color(vc, info, scr_readw(s), 1),
1126 +- get_color(vc, info, scr_readw(s), 0));
1127 ++ if (!fbcon_is_inactive(vc, info)) {
1128 +
1129 -+ if (fbcon_decor_active(info, vc))
1130 -+ fbcon_decor_putcs(vc, info, s, count, ypos, xpos);
1131 -+ else
1132 -+ ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
1133 -+ get_color(vc, info, scr_readw(s), 1),
1134 -+ get_color(vc, info, scr_readw(s), 0));
1135 -+ }
1136 ++ if (fbcon_decor_active(info, vc))
1137 ++ fbcon_decor_putcs(vc, info, s, count, ypos, xpos);
1138 ++ else
1139 ++ ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
1140 ++ get_color(vc, info, scr_readw(s), 1),
1141 ++ get_color(vc, info, scr_readw(s), 0));
1142 ++ }
1143 }
1144
1145 static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
1146 @@ -1279,8 +1305,13 @@ static void fbcon_clear_margins(struct vc_data *vc, int bottom_only)
1147 - struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1148 - struct fbcon_ops *ops = info->fbcon_par;
1149 + struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1150 + struct fbcon_ops *ops = info->fbcon_par;
1151
1152 -- if (!fbcon_is_inactive(vc, info))
1153 -- ops->clear_margins(vc, info, bottom_only);
1154 -+ if (!fbcon_is_inactive(vc, info)) {
1155 -+ if (fbcon_decor_active(info, vc)) {
1156 -+ fbcon_decor_clear_margins(vc, info, bottom_only);
1157 -+ } else {
1158 -+ ops->clear_margins(vc, info, bottom_only);
1159 -+ }
1160 -+ }
1161 +- if (!fbcon_is_inactive(vc, info))
1162 +- ops->clear_margins(vc, info, bottom_only);
1163 ++ if (!fbcon_is_inactive(vc, info)) {
1164 ++ if (fbcon_decor_active(info, vc)) {
1165 ++ fbcon_decor_clear_margins(vc, info, bottom_only);
1166 ++ } else {
1167 ++ ops->clear_margins(vc, info, bottom_only);
1168 ++ }
1169 ++ }
1170 }
1171
1172 static void fbcon_cursor(struct vc_data *vc, int mode)
1173 @@ -1800,7 +1831,7 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1174 - count = vc->vc_rows;
1175 - if (softback_top)
1176 - fbcon_softback_note(vc, t, count);
1177 -- if (logo_shown >= 0)
1178 -+ if (logo_shown >= 0 || fbcon_decor_active(info, vc))
1179 - goto redraw_up;
1180 - switch (p->scrollmode) {
1181 - case SCROLL_MOVE:
1182 + count = vc->vc_rows;
1183 + if (softback_top)
1184 + fbcon_softback_note(vc, t, count);
1185 +- if (logo_shown >= 0)
1186 ++ if (logo_shown >= 0 || fbcon_decor_active(info, vc))
1187 + goto redraw_up;
1188 + switch (p->scrollmode) {
1189 + case SCROLL_MOVE:
1190 @@ -1893,6 +1924,8 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1191 - count = vc->vc_rows;
1192 - if (logo_shown >= 0)
1193 - goto redraw_down;
1194 -+ if (fbcon_decor_active(info, vc))
1195 -+ goto redraw_down;
1196 - switch (p->scrollmode) {
1197 - case SCROLL_MOVE:
1198 - fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
1199 + count = vc->vc_rows;
1200 + if (logo_shown >= 0)
1201 + goto redraw_down;
1202 ++ if (fbcon_decor_active(info, vc))
1203 ++ goto redraw_down;
1204 + switch (p->scrollmode) {
1205 + case SCROLL_MOVE:
1206 + fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
1207 @@ -2041,6 +2074,13 @@ static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int s
1208 - }
1209 - return;
1210 - }
1211 + }
1212 + return;
1213 + }
1214 +
1215 -+ if (fbcon_decor_active(info, vc) && sy == dy && height == 1) {
1216 -+ /* must use slower redraw bmove to keep background pic intact */
1217 -+ fbcon_decor_bmove_redraw(vc, info, sy, sx, dx, width);
1218 -+ return;
1219 -+ }
1220 ++ if (fbcon_decor_active(info, vc) && sy == dy && height == 1) {
1221 ++ /* must use slower redraw bmove to keep background pic intact */
1222 ++ fbcon_decor_bmove_redraw(vc, info, sy, sx, dx, width);
1223 ++ return;
1224 ++ }
1225 +
1226 - ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
1227 - height, width);
1228 + ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
1229 + height, width);
1230 }
1231 @@ -2111,8 +2151,8 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width,
1232 - var.yres = virt_h * virt_fh;
1233 - x_diff = info->var.xres - var.xres;
1234 - y_diff = info->var.yres - var.yres;
1235 -- if (x_diff < 0 || x_diff > virt_fw ||
1236 -- y_diff < 0 || y_diff > virt_fh) {
1237 -+ if ((x_diff < 0 || x_diff > virt_fw ||
1238 -+ y_diff < 0 || y_diff > virt_fh) && !vc->vc_decor.state) {
1239 - const struct fb_videomode *mode;
1240 + var.yres = virt_h * virt_fh;
1241 + x_diff = info->var.xres - var.xres;
1242 + y_diff = info->var.yres - var.yres;
1243 +- if (x_diff < 0 || x_diff > virt_fw ||
1244 +- y_diff < 0 || y_diff > virt_fh) {
1245 ++ if ((x_diff < 0 || x_diff > virt_fw ||
1246 ++ y_diff < 0 || y_diff > virt_fh) && !vc->vc_decor.state) {
1247 + const struct fb_videomode *mode;
1248
1249 - DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
1250 + DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
1251 @@ -2148,6 +2188,21 @@ static int fbcon_switch(struct vc_data *vc)
1252
1253 - info = registered_fb[con2fb_map[vc->vc_num]];
1254 - ops = info->fbcon_par;
1255 -+ prev_console = ops->currcon;
1256 -+ if (prev_console != -1)
1257 -+ old_info = registered_fb[con2fb_map[prev_console]];
1258 + info = registered_fb[con2fb_map[vc->vc_num]];
1259 + ops = info->fbcon_par;
1260 ++ prev_console = ops->currcon;
1261 ++ if (prev_console != -1)
1262 ++ old_info = registered_fb[con2fb_map[prev_console]];
1263 +
1264 +#ifdef CONFIG_FB_CON_DECOR
1265 -+ if (!fbcon_decor_active_vc(vc) && info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
1266 -+ struct vc_data *vc_curr = vc_cons[prev_console].d;
1267 -+ if (vc_curr && fbcon_decor_active_vc(vc_curr)) {
1268 -+ /* Clear the screen to avoid displaying funky colors during
1269 -+ * palette updates. */
1270 -+ memset((u8 *)info->screen_base + info->fix.line_length * info->var.yoffset,
1271 -+ 0, info->var.yres * info->fix.line_length);
1272 -+ }
1273 -+ }
1274 ++ if (!fbcon_decor_active_vc(vc) && info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
1275 ++ struct vc_data *vc_curr = vc_cons[prev_console].d;
1276 ++ if (vc_curr && fbcon_decor_active_vc(vc_curr)) {
1277 ++ /* Clear the screen to avoid displaying funky colors during
1278 ++ * palette updates. */
1279 ++ memset((u8 *)info->screen_base + info->fix.line_length * info->var.yoffset,
1280 ++ 0, info->var.yres * info->fix.line_length);
1281 ++ }
1282 ++ }
1283 +#endif
1284
1285 - if (softback_top) {
1286 - if (softback_lines)
1287 + if (softback_top) {
1288 + if (softback_lines)
1289 @@ -2166,9 +2221,6 @@ static int fbcon_switch(struct vc_data *vc)
1290 - logo_shown = FBCON_LOGO_CANSHOW;
1291 - }
1292 + logo_shown = FBCON_LOGO_CANSHOW;
1293 + }
1294
1295 -- prev_console = ops->currcon;
1296 -- if (prev_console != -1)
1297 -- old_info = registered_fb[con2fb_map[prev_console]];
1298 - /*
1299 - * FIXME: If we have multiple fbdev's loaded, we need to
1300 - * update all info->currcon. Perhaps, we can place this
1301 +- prev_console = ops->currcon;
1302 +- if (prev_console != -1)
1303 +- old_info = registered_fb[con2fb_map[prev_console]];
1304 + /*
1305 + * FIXME: If we have multiple fbdev's loaded, we need to
1306 + * update all info->currcon. Perhaps, we can place this
1307 @@ -2212,6 +2264,18 @@ static int fbcon_switch(struct vc_data *vc)
1308 - fbcon_del_cursor_timer(old_info);
1309 - }
1310 + fbcon_del_cursor_timer(old_info);
1311 + }
1312
1313 -+ if (fbcon_decor_active_vc(vc)) {
1314 -+ struct vc_data *vc_curr = vc_cons[prev_console].d;
1315 ++ if (fbcon_decor_active_vc(vc)) {
1316 ++ struct vc_data *vc_curr = vc_cons[prev_console].d;
1317 +
1318 -+ if (!vc_curr->vc_decor.theme ||
1319 -+ strcmp(vc->vc_decor.theme, vc_curr->vc_decor.theme) ||
1320 -+ (fbcon_decor_active_nores(info, vc_curr) &&
1321 -+ !fbcon_decor_active(info, vc_curr))) {
1322 -+ if (fbcon_decor_call_helper("modechange", vc->vc_num))
1323 -+ fbcon_decor_disable(vc, 0);
1324 -+ }
1325 -+ }
1326 ++ if (!vc_curr->vc_decor.theme ||
1327 ++ strcmp(vc->vc_decor.theme, vc_curr->vc_decor.theme) ||
1328 ++ (fbcon_decor_active_nores(info, vc_curr) &&
1329 ++ !fbcon_decor_active(info, vc_curr))) {
1330 ++ if (fbcon_decor_call_helper("modechange", vc->vc_num))
1331 ++ fbcon_decor_disable(vc, 0);
1332 ++ }
1333 ++ }
1334 +
1335 - if (fbcon_is_inactive(vc, info) ||
1336 - ops->blank_state != FB_BLANK_UNBLANK)
1337 - fbcon_del_cursor_timer(info);
1338 + if (fbcon_is_inactive(vc, info) ||
1339 + ops->blank_state != FB_BLANK_UNBLANK)
1340 + fbcon_del_cursor_timer(info);
1341 @@ -2320,15 +2384,20 @@ static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)
1342 - }
1343 - }
1344 + }
1345 + }
1346
1347 -- if (!fbcon_is_inactive(vc, info)) {
1348 -+ if (!fbcon_is_inactive(vc, info)) {
1349 - if (ops->blank_state != blank) {
1350 - ops->blank_state = blank;
1351 - fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
1352 - ops->cursor_flash = (!blank);
1353 +- if (!fbcon_is_inactive(vc, info)) {
1354 ++ if (!fbcon_is_inactive(vc, info)) {
1355 + if (ops->blank_state != blank) {
1356 + ops->blank_state = blank;
1357 + fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
1358 + ops->cursor_flash = (!blank);
1359
1360 -- if (!(info->flags & FBINFO_MISC_USEREVENT))
1361 -- if (fb_blank(info, blank))
1362 -- fbcon_generic_blank(vc, info, blank);
1363 -+ if (!(info->flags & FBINFO_MISC_USEREVENT)) {
1364 -+ if (fb_blank(info, blank)) {
1365 -+ if (fbcon_decor_active(info, vc))
1366 -+ fbcon_decor_blank(vc, info, blank);
1367 -+ else
1368 -+ fbcon_generic_blank(vc, info, blank);
1369 -+ }
1370 -+ }
1371 - }
1372 +- if (!(info->flags & FBINFO_MISC_USEREVENT))
1373 +- if (fb_blank(info, blank))
1374 +- fbcon_generic_blank(vc, info, blank);
1375 ++ if (!(info->flags & FBINFO_MISC_USEREVENT)) {
1376 ++ if (fb_blank(info, blank)) {
1377 ++ if (fbcon_decor_active(info, vc))
1378 ++ fbcon_decor_blank(vc, info, blank);
1379 ++ else
1380 ++ fbcon_generic_blank(vc, info, blank);
1381 ++ }
1382 ++ }
1383 + }
1384
1385 - if (!blank)
1386 + if (!blank)
1387 @@ -2503,13 +2572,22 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
1388 - }
1389 + }
1390
1391 - if (resize) {
1392 -+ /* reset wrap/pan */
1393 - int cols, rows;
1394 + if (resize) {
1395 ++ /* reset wrap/pan */
1396 + int cols, rows;
1397
1398 - cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
1399 - rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1400 + cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
1401 + rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1402 +
1403 -+ if (fbcon_decor_active(info, vc)) {
1404 -+ info->var.xoffset = info->var.yoffset = p->yscroll = 0;
1405 -+ cols = vc->vc_decor.twidth;
1406 -+ rows = vc->vc_decor.theight;
1407 -+ }
1408 - cols /= w;
1409 - rows /= h;
1410 ++ if (fbcon_decor_active(info, vc)) {
1411 ++ info->var.xoffset = info->var.yoffset = p->yscroll = 0;
1412 ++ cols = vc->vc_decor.twidth;
1413 ++ rows = vc->vc_decor.theight;
1414 ++ }
1415 + cols /= w;
1416 + rows /= h;
1417 +
1418 - vc_resize(vc, cols, rows);
1419 + vc_resize(vc, cols, rows);
1420 +
1421 - if (CON_IS_VISIBLE(vc) && softback_buf)
1422 - fbcon_update_softback(vc);
1423 - } else if (CON_IS_VISIBLE(vc)
1424 + if (CON_IS_VISIBLE(vc) && softback_buf)
1425 + fbcon_update_softback(vc);
1426 + } else if (CON_IS_VISIBLE(vc)
1427 @@ -2638,7 +2716,11 @@ static int fbcon_set_palette(struct vc_data *vc, unsigned char *table)
1428 - int i, j, k, depth;
1429 - u8 val;
1430 + int i, j, k, depth;
1431 + u8 val;
1432
1433 -- if (fbcon_is_inactive(vc, info))
1434 -+ if (fbcon_is_inactive(vc, info)
1435 +- if (fbcon_is_inactive(vc, info))
1436 ++ if (fbcon_is_inactive(vc, info)
1437 +#ifdef CONFIG_FB_CON_DECOR
1438 -+ || vc->vc_num != fg_console
1439 ++ || vc->vc_num != fg_console
1440 +#endif
1441 -+ )
1442 - return -EINVAL;
1443 ++ )
1444 + return -EINVAL;
1445
1446 - if (!CON_IS_VISIBLE(vc))
1447 + if (!CON_IS_VISIBLE(vc))
1448 @@ -2664,7 +2746,49 @@ static int fbcon_set_palette(struct vc_data *vc, unsigned char *table)
1449 - } else
1450 - fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap);
1451 + } else
1452 + fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap);
1453
1454 -- return fb_set_cmap(&palette_cmap, info);
1455 -+ if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
1456 -+ info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
1457 +- return fb_set_cmap(&palette_cmap, info);
1458 ++ if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
1459 ++ info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
1460 +
1461 -+ u16 *red, *green, *blue;
1462 -+ int minlen = min(min(info->var.red.length, info->var.green.length),
1463 -+ info->var.blue.length);
1464 -+ int h;
1465 ++ u16 *red, *green, *blue;
1466 ++ int minlen = min(min(info->var.red.length, info->var.green.length),
1467 ++ info->var.blue.length);
1468 ++ int h;
1469 +
1470 -+ struct fb_cmap cmap = {
1471 -+ .start = 0,
1472 -+ .len = (1 << minlen),
1473 -+ .red = NULL,
1474 -+ .green = NULL,
1475 -+ .blue = NULL,
1476 -+ .transp = NULL
1477 -+ };
1478 ++ struct fb_cmap cmap = {
1479 ++ .start = 0,
1480 ++ .len = (1 << minlen),
1481 ++ .red = NULL,
1482 ++ .green = NULL,
1483 ++ .blue = NULL,
1484 ++ .transp = NULL
1485 ++ };
1486 +
1487 -+ red = kmalloc(256 * sizeof(u16) * 3, GFP_KERNEL);
1488 ++ red = kmalloc(256 * sizeof(u16) * 3, GFP_KERNEL);
1489 +
1490 -+ if (!red)
1491 -+ goto out;
1492 ++ if (!red)
1493 ++ goto out;
1494 +
1495 -+ green = red + 256;
1496 -+ blue = green + 256;
1497 -+ cmap.red = red;
1498 -+ cmap.green = green;
1499 -+ cmap.blue = blue;
1500 ++ green = red + 256;
1501 ++ blue = green + 256;
1502 ++ cmap.red = red;
1503 ++ cmap.green = green;
1504 ++ cmap.blue = blue;
1505 +
1506 -+ for (i = 0; i < cmap.len; i++) {
1507 -+ red[i] = green[i] = blue[i] = (0xffff * i)/(cmap.len-1);
1508 -+ }
1509 ++ for (i = 0; i < cmap.len; i++) {
1510 ++ red[i] = green[i] = blue[i] = (0xffff * i)/(cmap.len-1);
1511 ++ }
1512 +
1513 -+ h = fb_set_cmap(&cmap, info);
1514 -+ fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
1515 -+ kfree(red);
1516 ++ h = fb_set_cmap(&cmap, info);
1517 ++ fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
1518 ++ kfree(red);
1519 +
1520 -+ return h;
1521 ++ return h;
1522 +
1523 -+ } else if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
1524 -+ info->var.bits_per_pixel == 8 && info->bgdecor.cmap.red != NULL)
1525 -+ fb_set_cmap(&info->bgdecor.cmap, info);
1526 ++ } else if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
1527 ++ info->var.bits_per_pixel == 8 && info->bgdecor.cmap.red != NULL)
1528 ++ fb_set_cmap(&info->bgdecor.cmap, info);
1529 +
1530 -+out: return fb_set_cmap(&palette_cmap, info);
1531 ++out: return fb_set_cmap(&palette_cmap, info);
1532 }
1533
1534 static u16 *fbcon_screen_pos(struct vc_data *vc, int offset)
1535 @@ -2872,7 +2996,7 @@ static void fbcon_modechanged(struct fb_info *info)
1536 - struct fbcon_ops *ops = info->fbcon_par;
1537 - struct vc_data *vc;
1538 - struct display *p;
1539 -- int rows, cols;
1540 -+ int rows, cols, res;
1541 + struct fbcon_ops *ops = info->fbcon_par;
1542 + struct vc_data *vc;
1543 + struct display *p;
1544 +- int rows, cols;
1545 ++ int rows, cols, res;
1546
1547 - if (!ops || ops->currcon < 0)
1548 - return;
1549 + if (!ops || ops->currcon < 0)
1550 + return;
1551 @@ -2890,7 +3014,18 @@ static void fbcon_modechanged(struct fb_info *info)
1552 - rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1553 - cols /= vc->vc_font.width;
1554 - rows /= vc->vc_font.height;
1555 -- vc_resize(vc, cols, rows);
1556 + rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1557 + cols /= vc->vc_font.width;
1558 + rows /= vc->vc_font.height;
1559 +- vc_resize(vc, cols, rows);
1560 +
1561 -+ if (!fbcon_decor_active_nores(info, vc)) {
1562 -+ vc_resize(vc, cols, rows);
1563 -+ } else {
1564 -+ /* HACK: Do this properly at some point.. */
1565 -+ unlock_fb_info(info);
1566 -+ res = fbcon_decor_call_helper("modechange", vc->vc_num);
1567 -+ lock_fb_info(info);
1568 -+ if (res)
1569 -+ fbcon_decor_disable(vc, 0);
1570 -+ }
1571 ++ if (!fbcon_decor_active_nores(info, vc)) {
1572 ++ vc_resize(vc, cols, rows);
1573 ++ } else {
1574 ++ /* HACK: Do this properly at some point.. */
1575 ++ unlock_fb_info(info);
1576 ++ res = fbcon_decor_call_helper("modechange", vc->vc_num);
1577 ++ lock_fb_info(info);
1578 ++ if (res)
1579 ++ fbcon_decor_disable(vc, 0);
1580 ++ }
1581 +
1582 - updatescrollmode(p, info, vc);
1583 - scrollback_max = 0;
1584 - scrollback_current = 0;
1585 + updatescrollmode(p, info, vc);
1586 + scrollback_max = 0;
1587 + scrollback_current = 0;
1588 @@ -3321,7 +3456,7 @@ static ssize_t store_rotate(struct device *device,
1589 - if (fbcon_has_exited)
1590 - return count;
1591 + if (fbcon_has_exited)
1592 + return count;
1593
1594 -- console_lock();
1595 -+ console_unlock();
1596 - idx = con2fb_map[fg_console];
1597 +- console_lock();
1598 ++ console_unlock();
1599 + idx = con2fb_map[fg_console];
1600
1601 - if (idx == -1 || registered_fb[idx] == NULL)
1602 + if (idx == -1 || registered_fb[idx] == NULL)
1603 @@ -3369,7 +3504,7 @@ static ssize_t show_rotate(struct device *device,
1604 - if (fbcon_has_exited)
1605 - return 0;
1606 + if (fbcon_has_exited)
1607 + return 0;
1608
1609 -- console_lock();
1610 -+ console_unlock();
1611 - idx = con2fb_map[fg_console];
1612 +- console_lock();
1613 ++ console_unlock();
1614 + idx = con2fb_map[fg_console];
1615
1616 - if (idx == -1 || registered_fb[idx] == NULL)
1617 + if (idx == -1 || registered_fb[idx] == NULL)
1618 @@ -3545,6 +3680,7 @@ static void fbcon_exit(void)
1619 - }
1620 - }
1621 + }
1622 + }
1623
1624 -+ fbcon_decor_exit();
1625 - fbcon_has_exited = 1;
1626 ++ fbcon_decor_exit();
1627 + fbcon_has_exited = 1;
1628 }
1629
1630 diff --git a/drivers/video/console/fbcondecor.c b/drivers/video/console/fbcondecor.c
1631 @@ -1303,513 +1279,513 @@
1632 +
1633 +int fbcon_decor_call_helper(char* cmd, unsigned short vc)
1634 +{
1635 -+ char *envp[] = {
1636 -+ "HOME=/",
1637 -+ "PATH=/sbin:/bin",
1638 -+ NULL
1639 -+ };
1640 ++ char *envp[] = {
1641 ++ "HOME=/",
1642 ++ "PATH=/sbin:/bin",
1643 ++ NULL
1644 ++ };
1645 +
1646 -+ char tfb[5];
1647 -+ char tcons[5];
1648 -+ unsigned char fb = (int) con2fb_map[vc];
1649 ++ char tfb[5];
1650 ++ char tcons[5];
1651 ++ unsigned char fb = (int) con2fb_map[vc];
1652 +
1653 -+ char *argv[] = {
1654 -+ fbcon_decor_path,
1655 -+ "2",
1656 -+ cmd,
1657 -+ tcons,
1658 -+ tfb,
1659 -+ vc_cons[vc].d->vc_decor.theme,
1660 -+ NULL
1661 -+ };
1662 ++ char *argv[] = {
1663 ++ fbcon_decor_path,
1664 ++ "2",
1665 ++ cmd,
1666 ++ tcons,
1667 ++ tfb,
1668 ++ vc_cons[vc].d->vc_decor.theme,
1669 ++ NULL
1670 ++ };
1671 +
1672 -+ snprintf(tfb,5,"%d",fb);
1673 -+ snprintf(tcons,5,"%d",vc);
1674 ++ snprintf(tfb,5,"%d",fb);
1675 ++ snprintf(tcons,5,"%d",vc);
1676 +
1677 -+ return call_usermodehelper(fbcon_decor_path, argv, envp, 1);
1678 ++ return call_usermodehelper(fbcon_decor_path, argv, envp, 1);
1679 +}
1680 +
1681 +/* Disables fbcondecor on a virtual console; called with console sem held. */
1682 +int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw)
1683 +{
1684 -+ struct fb_info* info;
1685 ++ struct fb_info* info;
1686 +
1687 -+ if (!vc->vc_decor.state)
1688 -+ return -EINVAL;
1689 ++ if (!vc->vc_decor.state)
1690 ++ return -EINVAL;
1691 +
1692 -+ info = registered_fb[(int) con2fb_map[vc->vc_num]];
1693 ++ info = registered_fb[(int) con2fb_map[vc->vc_num]];
1694 +
1695 -+ if (info == NULL)
1696 -+ return -EINVAL;
1697 ++ if (info == NULL)
1698 ++ return -EINVAL;
1699 +
1700 -+ vc->vc_decor.state = 0;
1701 -+ vc_resize(vc, info->var.xres / vc->vc_font.width,
1702 -+ info->var.yres / vc->vc_font.height);
1703 ++ vc->vc_decor.state = 0;
1704 ++ vc_resize(vc, info->var.xres / vc->vc_font.width,
1705 ++ info->var.yres / vc->vc_font.height);
1706 +
1707 -+ if (fg_console == vc->vc_num && redraw) {
1708 -+ redraw_screen(vc, 0);
1709 -+ update_region(vc, vc->vc_origin +
1710 -+ vc->vc_size_row * vc->vc_top,
1711 -+ vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1712 -+ }
1713 ++ if (fg_console == vc->vc_num && redraw) {
1714 ++ redraw_screen(vc, 0);
1715 ++ update_region(vc, vc->vc_origin +
1716 ++ vc->vc_size_row * vc->vc_top,
1717 ++ vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1718 ++ }
1719 +
1720 -+ printk(KERN_INFO "fbcondecor: switched decor state to 'off' on console %d\n",
1721 -+ vc->vc_num);
1722 ++ printk(KERN_INFO "fbcondecor: switched decor state to 'off' on console %d\n",
1723 ++ vc->vc_num);
1724 +
1725 -+ return 0;
1726 ++ return 0;
1727 +}
1728 +
1729 +/* Enables fbcondecor on a virtual console; called with console sem held. */
1730 +static int fbcon_decor_enable(struct vc_data *vc)
1731 +{
1732 -+ struct fb_info* info;
1733 ++ struct fb_info* info;
1734 +
1735 -+ info = registered_fb[(int) con2fb_map[vc->vc_num]];
1736 ++ info = registered_fb[(int) con2fb_map[vc->vc_num]];
1737 +
1738 -+ if (vc->vc_decor.twidth == 0 || vc->vc_decor.theight == 0 ||
1739 -+ info == NULL || vc->vc_decor.state || (!info->bgdecor.data &&
1740 -+ vc->vc_num == fg_console))
1741 -+ return -EINVAL;
1742 ++ if (vc->vc_decor.twidth == 0 || vc->vc_decor.theight == 0 ||
1743 ++ info == NULL || vc->vc_decor.state || (!info->bgdecor.data &&
1744 ++ vc->vc_num == fg_console))
1745 ++ return -EINVAL;
1746 +
1747 -+ vc->vc_decor.state = 1;
1748 -+ vc_resize(vc, vc->vc_decor.twidth / vc->vc_font.width,
1749 -+ vc->vc_decor.theight / vc->vc_font.height);
1750 ++ vc->vc_decor.state = 1;
1751 ++ vc_resize(vc, vc->vc_decor.twidth / vc->vc_font.width,
1752 ++ vc->vc_decor.theight / vc->vc_font.height);
1753 +
1754 -+ if (fg_console == vc->vc_num) {
1755 -+ redraw_screen(vc, 0);
1756 -+ update_region(vc, vc->vc_origin +
1757 -+ vc->vc_size_row * vc->vc_top,
1758 -+ vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1759 -+ fbcon_decor_clear_margins(vc, info, 0);
1760 -+ }
1761 ++ if (fg_console == vc->vc_num) {
1762 ++ redraw_screen(vc, 0);
1763 ++ update_region(vc, vc->vc_origin +
1764 ++ vc->vc_size_row * vc->vc_top,
1765 ++ vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1766 ++ fbcon_decor_clear_margins(vc, info, 0);
1767 ++ }
1768 +
1769 -+ printk(KERN_INFO "fbcondecor: switched decor state to 'on' on console %d\n",
1770 -+ vc->vc_num);
1771 ++ printk(KERN_INFO "fbcondecor: switched decor state to 'on' on console %d\n",
1772 ++ vc->vc_num);
1773 +
1774 -+ return 0;
1775 ++ return 0;
1776 +}
1777 +
1778 +static inline long fbcon_decor_ioctl_dosetstate(struct vc_data *vc, unsigned int state, unsigned char origin)
1779 +{
1780 -+ int ret;
1781 ++ int ret;
1782 +
1783 -+ if (origin == FBCON_DECOR_IO_ORIG_USER)
1784 -+ console_lock();
1785 -+ if (!state)
1786 -+ ret = fbcon_decor_disable(vc, 1);
1787 -+ else
1788 -+ ret = fbcon_decor_enable(vc);
1789 -+ if (origin == FBCON_DECOR_IO_ORIG_USER)
1790 -+ console_unlock();
1791 ++ if (origin == FBCON_DECOR_IO_ORIG_USER)
1792 ++ console_lock();
1793 ++ if (!state)
1794 ++ ret = fbcon_decor_disable(vc, 1);
1795 ++ else
1796 ++ ret = fbcon_decor_enable(vc);
1797 ++ if (origin == FBCON_DECOR_IO_ORIG_USER)
1798 ++ console_unlock();
1799 +
1800 -+ return ret;
1801 ++ return ret;
1802 +}
1803 +
1804 +static inline void fbcon_decor_ioctl_dogetstate(struct vc_data *vc, unsigned int *state)
1805 +{
1806 -+ *state = vc->vc_decor.state;
1807 ++ *state = vc->vc_decor.state;
1808 +}
1809 +
1810 +static long fbcon_decor_ioctl_dosetcfg(struct vc_data *vc, struct vc_decor *cfg, unsigned char origin)
1811 +{
1812 -+ struct fb_info *info;
1813 -+ int len;
1814 -+ char *tmp;
1815 ++ struct fb_info *info;
1816 ++ int len;
1817 ++ char *tmp;
1818 +
1819 -+ info = registered_fb[(int) con2fb_map[vc->vc_num]];
1820 ++ info = registered_fb[(int) con2fb_map[vc->vc_num]];
1821 +
1822 -+ if (info == NULL || !cfg->twidth || !cfg->theight ||
1823 -+ cfg->tx + cfg->twidth > info->var.xres ||
1824 -+ cfg->ty + cfg->theight > info->var.yres)
1825 -+ return -EINVAL;
1826 ++ if (info == NULL || !cfg->twidth || !cfg->theight ||
1827 ++ cfg->tx + cfg->twidth > info->var.xres ||
1828 ++ cfg->ty + cfg->theight > info->var.yres)
1829 ++ return -EINVAL;
1830 +
1831 -+ len = strlen_user(cfg->theme);
1832 -+ if (!len || len > FBCON_DECOR_THEME_LEN)
1833 -+ return -EINVAL;
1834 -+ tmp = kmalloc(len, GFP_KERNEL);
1835 -+ if (!tmp)
1836 -+ return -ENOMEM;
1837 -+ if (copy_from_user(tmp, (void __user *)cfg->theme, len))
1838 -+ return -EFAULT;
1839 -+ cfg->theme = tmp;
1840 -+ cfg->state = 0;
1841 ++ len = strlen_user(cfg->theme);
1842 ++ if (!len || len > FBCON_DECOR_THEME_LEN)
1843 ++ return -EINVAL;
1844 ++ tmp = kmalloc(len, GFP_KERNEL);
1845 ++ if (!tmp)
1846 ++ return -ENOMEM;
1847 ++ if (copy_from_user(tmp, (void __user *)cfg->theme, len))
1848 ++ return -EFAULT;
1849 ++ cfg->theme = tmp;
1850 ++ cfg->state = 0;
1851 +
1852 -+ /* If this ioctl is a response to a request from kernel, the console sem
1853 -+ * is already held; we also don't need to disable decor because either the
1854 -+ * new config and background picture will be successfully loaded, and the
1855 -+ * decor will stay on, or in case of a failure it'll be turned off in fbcon. */
1856 -+ if (origin == FBCON_DECOR_IO_ORIG_USER) {
1857 -+ console_lock();
1858 -+ if (vc->vc_decor.state)
1859 -+ fbcon_decor_disable(vc, 1);
1860 -+ }
1861 ++ /* If this ioctl is a response to a request from kernel, the console sem
1862 ++ * is already held; we also don't need to disable decor because either the
1863 ++ * new config and background picture will be successfully loaded, and the
1864 ++ * decor will stay on, or in case of a failure it'll be turned off in fbcon. */
1865 ++ if (origin == FBCON_DECOR_IO_ORIG_USER) {
1866 ++ console_lock();
1867 ++ if (vc->vc_decor.state)
1868 ++ fbcon_decor_disable(vc, 1);
1869 ++ }
1870 +
1871 -+ if (vc->vc_decor.theme)
1872 -+ kfree(vc->vc_decor.theme);
1873 ++ if (vc->vc_decor.theme)
1874 ++ kfree(vc->vc_decor.theme);
1875 +
1876 -+ vc->vc_decor = *cfg;
1877 ++ vc->vc_decor = *cfg;
1878 +
1879 -+ if (origin == FBCON_DECOR_IO_ORIG_USER)
1880 -+ console_unlock();
1881 ++ if (origin == FBCON_DECOR_IO_ORIG_USER)
1882 ++ console_unlock();
1883 +
1884 -+ printk(KERN_INFO "fbcondecor: console %d using theme '%s'\n",
1885 -+ vc->vc_num, vc->vc_decor.theme);
1886 -+ return 0;
1887 ++ printk(KERN_INFO "fbcondecor: console %d using theme '%s'\n",
1888 ++ vc->vc_num, vc->vc_decor.theme);
1889 ++ return 0;
1890 +}
1891 +
1892 +static long fbcon_decor_ioctl_dogetcfg(struct vc_data *vc, struct vc_decor *decor)
1893 +{
1894 -+ char __user *tmp;
1895 ++ char __user *tmp;
1896 +
1897 -+ tmp = decor->theme;
1898 -+ *decor = vc->vc_decor;
1899 -+ decor->theme = tmp;
1900 ++ tmp = decor->theme;
1901 ++ *decor = vc->vc_decor;
1902 ++ decor->theme = tmp;
1903 +
1904 -+ if (vc->vc_decor.theme) {
1905 -+ if (copy_to_user(tmp, vc->vc_decor.theme, strlen(vc->vc_decor.theme) + 1))
1906 -+ return -EFAULT;
1907 -+ } else
1908 -+ if (put_user(0, tmp))
1909 -+ return -EFAULT;
1910 ++ if (vc->vc_decor.theme) {
1911 ++ if (copy_to_user(tmp, vc->vc_decor.theme, strlen(vc->vc_decor.theme) + 1))
1912 ++ return -EFAULT;
1913 ++ } else
1914 ++ if (put_user(0, tmp))
1915 ++ return -EFAULT;
1916 +
1917 -+ return 0;
1918 ++ return 0;
1919 +}
1920 +
1921 +static long fbcon_decor_ioctl_dosetpic(struct vc_data *vc, struct fb_image *img, unsigned char origin)
1922 +{
1923 -+ struct fb_info *info;
1924 -+ int len;
1925 -+ u8 *tmp;
1926 ++ struct fb_info *info;
1927 ++ int len;
1928 ++ u8 *tmp;
1929 +
1930 -+ if (vc->vc_num != fg_console)
1931 -+ return -EINVAL;
1932 ++ if (vc->vc_num != fg_console)
1933 ++ return -EINVAL;
1934 +
1935 -+ info = registered_fb[(int) con2fb_map[vc->vc_num]];
1936 ++ info = registered_fb[(int) con2fb_map[vc->vc_num]];
1937 +
1938 -+ if (info == NULL)
1939 -+ return -EINVAL;
1940 ++ if (info == NULL)
1941 ++ return -EINVAL;
1942 +
1943 -+ if (img->width != info->var.xres || img->height != info->var.yres) {
1944 -+ printk(KERN_ERR "fbcondecor: picture dimensions mismatch\n");
1945 -+ printk(KERN_ERR "%dx%d vs %dx%d\n", img->width, img->height, info->var.xres, info->var.yres);
1946 -+ return -EINVAL;
1947 -+ }
1948 ++ if (img->width != info->var.xres || img->height != info->var.yres) {
1949 ++ printk(KERN_ERR "fbcondecor: picture dimensions mismatch\n");
1950 ++ printk(KERN_ERR "%dx%d vs %dx%d\n", img->width, img->height, info->var.xres, info->var.yres);
1951 ++ return -EINVAL;
1952 ++ }
1953 +
1954 -+ if (img->depth != info->var.bits_per_pixel) {
1955 -+ printk(KERN_ERR "fbcondecor: picture depth mismatch\n");
1956 -+ return -EINVAL;
1957 -+ }
1958 ++ if (img->depth != info->var.bits_per_pixel) {
1959 ++ printk(KERN_ERR "fbcondecor: picture depth mismatch\n");
1960 ++ return -EINVAL;
1961 ++ }
1962 +
1963 -+ if (img->depth == 8) {
1964 -+ if (!img->cmap.len || !img->cmap.red || !img->cmap.green ||
1965 -+ !img->cmap.blue)
1966 -+ return -EINVAL;
1967 ++ if (img->depth == 8) {
1968 ++ if (!img->cmap.len || !img->cmap.red || !img->cmap.green ||
1969 ++ !img->cmap.blue)
1970 ++ return -EINVAL;
1971 +
1972 -+ tmp = vmalloc(img->cmap.len * 3 * 2);
1973 -+ if (!tmp)
1974 -+ return -ENOMEM;
1975 ++ tmp = vmalloc(img->cmap.len * 3 * 2);
1976 ++ if (!tmp)
1977 ++ return -ENOMEM;
1978 +
1979 -+ if (copy_from_user(tmp,
1980 -+ (void __user*)img->cmap.red, (img->cmap.len << 1)) ||
1981 -+ copy_from_user(tmp + (img->cmap.len << 1),
1982 -+ (void __user*)img->cmap.green, (img->cmap.len << 1)) ||
1983 -+ copy_from_user(tmp + (img->cmap.len << 2),
1984 -+ (void __user*)img->cmap.blue, (img->cmap.len << 1))) {
1985 -+ vfree(tmp);
1986 -+ return -EFAULT;
1987 -+ }
1988 ++ if (copy_from_user(tmp,
1989 ++ (void __user*)img->cmap.red, (img->cmap.len << 1)) ||
1990 ++ copy_from_user(tmp + (img->cmap.len << 1),
1991 ++ (void __user*)img->cmap.green, (img->cmap.len << 1)) ||
1992 ++ copy_from_user(tmp + (img->cmap.len << 2),
1993 ++ (void __user*)img->cmap.blue, (img->cmap.len << 1))) {
1994 ++ vfree(tmp);
1995 ++ return -EFAULT;
1996 ++ }
1997 +
1998 -+ img->cmap.transp = NULL;
1999 -+ img->cmap.red = (u16*)tmp;
2000 -+ img->cmap.green = img->cmap.red + img->cmap.len;
2001 -+ img->cmap.blue = img->cmap.green + img->cmap.len;
2002 -+ } else {
2003 -+ img->cmap.red = NULL;
2004 -+ }
2005 ++ img->cmap.transp = NULL;
2006 ++ img->cmap.red = (u16*)tmp;
2007 ++ img->cmap.green = img->cmap.red + img->cmap.len;
2008 ++ img->cmap.blue = img->cmap.green + img->cmap.len;
2009 ++ } else {
2010 ++ img->cmap.red = NULL;
2011 ++ }
2012 +
2013 -+ len = ((img->depth + 7) >> 3) * img->width * img->height;
2014 ++ len = ((img->depth + 7) >> 3) * img->width * img->height;
2015 +
2016 -+ /*
2017 -+ * Allocate an additional byte so that we never go outside of the
2018 -+ * buffer boundaries in the rendering functions in a 24 bpp mode.
2019 -+ */
2020 -+ tmp = vmalloc(len + 1);
2021 ++ /*
2022 ++ * Allocate an additional byte so that we never go outside of the
2023 ++ * buffer boundaries in the rendering functions in a 24 bpp mode.
2024 ++ */
2025 ++ tmp = vmalloc(len + 1);
2026 +
2027 -+ if (!tmp)
2028 -+ goto out;
2029 ++ if (!tmp)
2030 ++ goto out;
2031 +
2032 -+ if (copy_from_user(tmp, (void __user*)img->data, len))
2033 -+ goto out;
2034 ++ if (copy_from_user(tmp, (void __user*)img->data, len))
2035 ++ goto out;
2036 +
2037 -+ img->data = tmp;
2038 ++ img->data = tmp;
2039 +
2040 -+ /* If this ioctl is a response to a request from kernel, the console sem
2041 -+ * is already held. */
2042 -+ if (origin == FBCON_DECOR_IO_ORIG_USER)
2043 -+ console_lock();
2044 ++ /* If this ioctl is a response to a request from kernel, the console sem
2045 ++ * is already held. */
2046 ++ if (origin == FBCON_DECOR_IO_ORIG_USER)
2047 ++ console_lock();
2048 +
2049 -+ if (info->bgdecor.data)
2050 -+ vfree((u8*)info->bgdecor.data);
2051 -+ if (info->bgdecor.cmap.red)
2052 -+ vfree(info->bgdecor.cmap.red);
2053 ++ if (info->bgdecor.data)
2054 ++ vfree((u8*)info->bgdecor.data);
2055 ++ if (info->bgdecor.cmap.red)
2056 ++ vfree(info->bgdecor.cmap.red);
2057 +
2058 -+ info->bgdecor = *img;
2059 ++ info->bgdecor = *img;
2060 +
2061 -+ if (fbcon_decor_active_vc(vc) && fg_console == vc->vc_num) {
2062 -+ redraw_screen(vc, 0);
2063 -+ update_region(vc, vc->vc_origin +
2064 -+ vc->vc_size_row * vc->vc_top,
2065 -+ vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
2066 -+ fbcon_decor_clear_margins(vc, info, 0);
2067 -+ }
2068 ++ if (fbcon_decor_active_vc(vc) && fg_console == vc->vc_num) {
2069 ++ redraw_screen(vc, 0);
2070 ++ update_region(vc, vc->vc_origin +
2071 ++ vc->vc_size_row * vc->vc_top,
2072 ++ vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
2073 ++ fbcon_decor_clear_margins(vc, info, 0);
2074 ++ }
2075 +
2076 -+ if (origin == FBCON_DECOR_IO_ORIG_USER)
2077 -+ console_unlock();
2078 ++ if (origin == FBCON_DECOR_IO_ORIG_USER)
2079 ++ console_unlock();
2080 +
2081 -+ return 0;
2082 ++ return 0;
2083 +
2084 -+out: if (img->cmap.red)
2085 -+ vfree(img->cmap.red);
2086 ++out: if (img->cmap.red)
2087 ++ vfree(img->cmap.red);
2088 +
2089 -+ if (tmp)
2090 -+ vfree(tmp);
2091 -+ return -ENOMEM;
2092 ++ if (tmp)
2093 ++ vfree(tmp);
2094 ++ return -ENOMEM;
2095 +}
2096 +
2097 +static long fbcon_decor_ioctl(struct file *filp, u_int cmd,
2098 -+ u_long arg)
2099 ++ u_long arg)
2100 +{
2101 -+ struct fbcon_decor_iowrapper __user *wrapper = (void __user*) arg;
2102 -+ struct vc_data *vc = NULL;
2103 -+ unsigned short vc_num = 0;
2104 -+ unsigned char origin = 0;
2105 -+ void __user *data = NULL;
2106 ++ struct fbcon_decor_iowrapper __user *wrapper = (void __user*) arg;
2107 ++ struct vc_data *vc = NULL;
2108 ++ unsigned short vc_num = 0;
2109 ++ unsigned char origin = 0;
2110 ++ void __user *data = NULL;
2111 +
2112 -+ if (!access_ok(VERIFY_READ, wrapper,
2113 -+ sizeof(struct fbcon_decor_iowrapper)))
2114 -+ return -EFAULT;
2115 ++ if (!access_ok(VERIFY_READ, wrapper,
2116 ++ sizeof(struct fbcon_decor_iowrapper)))
2117 ++ return -EFAULT;
2118 +
2119 -+ __get_user(vc_num, &wrapper->vc);
2120 -+ __get_user(origin, &wrapper->origin);
2121 -+ __get_user(data, &wrapper->data);
2122 ++ __get_user(vc_num, &wrapper->vc);
2123 ++ __get_user(origin, &wrapper->origin);
2124 ++ __get_user(data, &wrapper->data);
2125 +
2126 -+ if (!vc_cons_allocated(vc_num))
2127 -+ return -EINVAL;
2128 ++ if (!vc_cons_allocated(vc_num))
2129 ++ return -EINVAL;
2130 +
2131 -+ vc = vc_cons[vc_num].d;
2132 ++ vc = vc_cons[vc_num].d;
2133 +
2134 -+ switch (cmd) {
2135 -+ case FBIOCONDECOR_SETPIC:
2136 -+ {
2137 -+ struct fb_image img;
2138 -+ if (copy_from_user(&img, (struct fb_image __user *)data, sizeof(struct fb_image)))
2139 -+ return -EFAULT;
2140 ++ switch (cmd) {
2141 ++ case FBIOCONDECOR_SETPIC:
2142 ++ {
2143 ++ struct fb_image img;
2144 ++ if (copy_from_user(&img, (struct fb_image __user *)data, sizeof(struct fb_image)))
2145 ++ return -EFAULT;
2146 +
2147 -+ return fbcon_decor_ioctl_dosetpic(vc, &img, origin);
2148 -+ }
2149 -+ case FBIOCONDECOR_SETCFG:
2150 -+ {
2151 -+ struct vc_decor cfg;
2152 -+ if (copy_from_user(&cfg, (struct vc_decor __user *)data, sizeof(struct vc_decor)))
2153 -+ return -EFAULT;
2154 ++ return fbcon_decor_ioctl_dosetpic(vc, &img, origin);
2155 ++ }
2156 ++ case FBIOCONDECOR_SETCFG:
2157 ++ {
2158 ++ struct vc_decor cfg;
2159 ++ if (copy_from_user(&cfg, (struct vc_decor __user *)data, sizeof(struct vc_decor)))
2160 ++ return -EFAULT;
2161 +
2162 -+ return fbcon_decor_ioctl_dosetcfg(vc, &cfg, origin);
2163 -+ }
2164 -+ case FBIOCONDECOR_GETCFG:
2165 -+ {
2166 -+ int rval;
2167 -+ struct vc_decor cfg;
2168 ++ return fbcon_decor_ioctl_dosetcfg(vc, &cfg, origin);
2169 ++ }
2170 ++ case FBIOCONDECOR_GETCFG:
2171 ++ {
2172 ++ int rval;
2173 ++ struct vc_decor cfg;
2174 +
2175 -+ if (copy_from_user(&cfg, (struct vc_decor __user *)data, sizeof(struct vc_decor)))
2176 -+ return -EFAULT;
2177 ++ if (copy_from_user(&cfg, (struct vc_decor __user *)data, sizeof(struct vc_decor)))
2178 ++ return -EFAULT;
2179 +
2180 -+ rval = fbcon_decor_ioctl_dogetcfg(vc, &cfg);
2181 ++ rval = fbcon_decor_ioctl_dogetcfg(vc, &cfg);
2182 +
2183 -+ if (copy_to_user(data, &cfg, sizeof(struct vc_decor)))
2184 -+ return -EFAULT;
2185 -+ return rval;
2186 -+ }
2187 -+ case FBIOCONDECOR_SETSTATE:
2188 -+ {
2189 -+ unsigned int state = 0;
2190 -+ if (get_user(state, (unsigned int __user *)data))
2191 -+ return -EFAULT;
2192 -+ return fbcon_decor_ioctl_dosetstate(vc, state, origin);
2193 -+ }
2194 -+ case FBIOCONDECOR_GETSTATE:
2195 -+ {
2196 -+ unsigned int state = 0;
2197 -+ fbcon_decor_ioctl_dogetstate(vc, &state);
2198 -+ return put_user(state, (unsigned int __user *)data);
2199 -+ }
2200 ++ if (copy_to_user(data, &cfg, sizeof(struct vc_decor)))
2201 ++ return -EFAULT;
2202 ++ return rval;
2203 ++ }
2204 ++ case FBIOCONDECOR_SETSTATE:
2205 ++ {
2206 ++ unsigned int state = 0;
2207 ++ if (get_user(state, (unsigned int __user *)data))
2208 ++ return -EFAULT;
2209 ++ return fbcon_decor_ioctl_dosetstate(vc, state, origin);
2210 ++ }
2211 ++ case FBIOCONDECOR_GETSTATE:
2212 ++ {
2213 ++ unsigned int state = 0;
2214 ++ fbcon_decor_ioctl_dogetstate(vc, &state);
2215 ++ return put_user(state, (unsigned int __user *)data);
2216 ++ }
2217 +
2218 -+ default:
2219 -+ return -ENOIOCTLCMD;
2220 -+ }
2221 ++ default:
2222 ++ return -ENOIOCTLCMD;
2223 ++ }
2224 +}
2225 +
2226 +#ifdef CONFIG_COMPAT
2227 +
2228 +static long fbcon_decor_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) {
2229 +
2230 -+ struct fbcon_decor_iowrapper32 __user *wrapper = (void __user *)arg;
2231 -+ struct vc_data *vc = NULL;
2232 -+ unsigned short vc_num = 0;
2233 -+ unsigned char origin = 0;
2234 -+ compat_uptr_t data_compat = 0;
2235 -+ void __user *data = NULL;
2236 ++ struct fbcon_decor_iowrapper32 __user *wrapper = (void __user *)arg;
2237 ++ struct vc_data *vc = NULL;
2238 ++ unsigned short vc_num = 0;
2239 ++ unsigned char origin = 0;
2240 ++ compat_uptr_t data_compat = 0;
2241 ++ void __user *data = NULL;
2242 +
2243 -+ if (!access_ok(VERIFY_READ, wrapper,
2244 ++ if (!access_ok(VERIFY_READ, wrapper,
2245 + sizeof(struct fbcon_decor_iowrapper32)))
2246 -+ return -EFAULT;
2247 ++ return -EFAULT;
2248 +
2249 -+ __get_user(vc_num, &wrapper->vc);
2250 -+ __get_user(origin, &wrapper->origin);
2251 -+ __get_user(data_compat, &wrapper->data);
2252 -+ data = compat_ptr(data_compat);
2253 ++ __get_user(vc_num, &wrapper->vc);
2254 ++ __get_user(origin, &wrapper->origin);
2255 ++ __get_user(data_compat, &wrapper->data);
2256 ++ data = compat_ptr(data_compat);
2257 +
2258 -+ if (!vc_cons_allocated(vc_num))
2259 -+ return -EINVAL;
2260 ++ if (!vc_cons_allocated(vc_num))
2261 ++ return -EINVAL;
2262 +
2263 -+ vc = vc_cons[vc_num].d;
2264 ++ vc = vc_cons[vc_num].d;
2265 +
2266 -+ switch (cmd) {
2267 -+ case FBIOCONDECOR_SETPIC32:
2268 -+ {
2269 -+ struct fb_image32 img_compat;
2270 -+ struct fb_image img;
2271 ++ switch (cmd) {
2272 ++ case FBIOCONDECOR_SETPIC32:
2273 ++ {
2274 ++ struct fb_image32 img_compat;
2275 ++ struct fb_image img;
2276 +
2277 -+ if (copy_from_user(&img_compat, (struct fb_image32 __user *)data, sizeof(struct fb_image32)))
2278 -+ return -EFAULT;
2279 ++ if (copy_from_user(&img_compat, (struct fb_image32 __user *)data, sizeof(struct fb_image32)))
2280 ++ return -EFAULT;
2281 +
2282 -+ fb_image_from_compat(img, img_compat);
2283 ++ fb_image_from_compat(img, img_compat);
2284 +
2285 -+ return fbcon_decor_ioctl_dosetpic(vc, &img, origin);
2286 -+ }
2287 ++ return fbcon_decor_ioctl_dosetpic(vc, &img, origin);
2288 ++ }
2289 +
2290 -+ case FBIOCONDECOR_SETCFG32:
2291 -+ {
2292 -+ struct vc_decor32 cfg_compat;
2293 -+ struct vc_decor cfg;
2294 ++ case FBIOCONDECOR_SETCFG32:
2295 ++ {
2296 ++ struct vc_decor32 cfg_compat;
2297 ++ struct vc_decor cfg;
2298 +
2299 -+ if (copy_from_user(&cfg_compat, (struct vc_decor32 __user *)data, sizeof(struct vc_decor32)))
2300 -+ return -EFAULT;
2301 ++ if (copy_from_user(&cfg_compat, (struct vc_decor32 __user *)data, sizeof(struct vc_decor32)))
2302 ++ return -EFAULT;
2303 +
2304 -+ vc_decor_from_compat(cfg, cfg_compat);
2305 ++ vc_decor_from_compat(cfg, cfg_compat);
2306 +
2307 -+ return fbcon_decor_ioctl_dosetcfg(vc, &cfg, origin);
2308 -+ }
2309 ++ return fbcon_decor_ioctl_dosetcfg(vc, &cfg, origin);
2310 ++ }
2311 +
2312 -+ case FBIOCONDECOR_GETCFG32:
2313 -+ {
2314 -+ int rval;
2315 -+ struct vc_decor32 cfg_compat;
2316 -+ struct vc_decor cfg;
2317 ++ case FBIOCONDECOR_GETCFG32:
2318 ++ {
2319 ++ int rval;
2320 ++ struct vc_decor32 cfg_compat;
2321 ++ struct vc_decor cfg;
2322 +
2323 -+ if (copy_from_user(&cfg_compat, (struct vc_decor32 __user *)data, sizeof(struct vc_decor32)))
2324 -+ return -EFAULT;
2325 -+ cfg.theme = compat_ptr(cfg_compat.theme);
2326 ++ if (copy_from_user(&cfg_compat, (struct vc_decor32 __user *)data, sizeof(struct vc_decor32)))
2327 ++ return -EFAULT;
2328 ++ cfg.theme = compat_ptr(cfg_compat.theme);
2329 +
2330 -+ rval = fbcon_decor_ioctl_dogetcfg(vc, &cfg);
2331 ++ rval = fbcon_decor_ioctl_dogetcfg(vc, &cfg);
2332 +
2333 -+ vc_decor_to_compat(cfg_compat, cfg);
2334 ++ vc_decor_to_compat(cfg_compat, cfg);
2335 +
2336 -+ if (copy_to_user((struct vc_decor32 __user *)data, &cfg_compat, sizeof(struct vc_decor32)))
2337 -+ return -EFAULT;
2338 -+ return rval;
2339 -+ }
2340 ++ if (copy_to_user((struct vc_decor32 __user *)data, &cfg_compat, sizeof(struct vc_decor32)))
2341 ++ return -EFAULT;
2342 ++ return rval;
2343 ++ }
2344 +
2345 -+ case FBIOCONDECOR_SETSTATE32:
2346 -+ {
2347 -+ compat_uint_t state_compat = 0;
2348 -+ unsigned int state = 0;
2349 ++ case FBIOCONDECOR_SETSTATE32:
2350 ++ {
2351 ++ compat_uint_t state_compat = 0;
2352 ++ unsigned int state = 0;
2353 +
2354 -+ if (get_user(state_compat, (compat_uint_t __user *)data))
2355 -+ return -EFAULT;
2356 ++ if (get_user(state_compat, (compat_uint_t __user *)data))
2357 ++ return -EFAULT;
2358 +
2359 -+ state = (unsigned int)state_compat;
2360 ++ state = (unsigned int)state_compat;
2361 +
2362 -+ return fbcon_decor_ioctl_dosetstate(vc, state, origin);
2363 -+ }
2364 ++ return fbcon_decor_ioctl_dosetstate(vc, state, origin);
2365 ++ }
2366 +
2367 -+ case FBIOCONDECOR_GETSTATE32:
2368 -+ {
2369 -+ compat_uint_t state_compat = 0;
2370 -+ unsigned int state = 0;
2371 ++ case FBIOCONDECOR_GETSTATE32:
2372 ++ {
2373 ++ compat_uint_t state_compat = 0;
2374 ++ unsigned int state = 0;
2375 +
2376 -+ fbcon_decor_ioctl_dogetstate(vc, &state);
2377 -+ state_compat = (compat_uint_t)state;
2378 ++ fbcon_decor_ioctl_dogetstate(vc, &state);
2379 ++ state_compat = (compat_uint_t)state;
2380 +
2381 -+ return put_user(state_compat, (compat_uint_t __user *)data);
2382 -+ }
2383 ++ return put_user(state_compat, (compat_uint_t __user *)data);
2384 ++ }
2385 +
2386 -+ default:
2387 -+ return -ENOIOCTLCMD;
2388 -+ }
2389 ++ default:
2390 ++ return -ENOIOCTLCMD;
2391 ++ }
2392 +}
2393 +#else
2394 + #define fbcon_decor_compat_ioctl NULL
2395 +#endif
2396 +
2397 +static struct file_operations fbcon_decor_ops = {
2398 -+ .owner = THIS_MODULE,
2399 -+ .unlocked_ioctl = fbcon_decor_ioctl,
2400 -+ .compat_ioctl = fbcon_decor_compat_ioctl
2401 ++ .owner = THIS_MODULE,
2402 ++ .unlocked_ioctl = fbcon_decor_ioctl,
2403 ++ .compat_ioctl = fbcon_decor_compat_ioctl
2404 +};
2405 +
2406 +static struct miscdevice fbcon_decor_dev = {
2407 -+ .minor = MISC_DYNAMIC_MINOR,
2408 -+ .name = "fbcondecor",
2409 -+ .fops = &fbcon_decor_ops
2410 ++ .minor = MISC_DYNAMIC_MINOR,
2411 ++ .name = "fbcondecor",
2412 ++ .fops = &fbcon_decor_ops
2413 +};
2414 +
2415 +void fbcon_decor_reset(void)
2416 +{
2417 -+ struct fb_info *info;
2418 -+ struct vc_data *vc;
2419 -+ int i;
2420 ++ struct fb_info *info;
2421 ++ struct vc_data *vc;
2422 ++ int i;
2423 +
2424 -+ vc = vc_cons[0].d;
2425 -+ info = registered_fb[0];
2426 ++ vc = vc_cons[0].d;
2427 ++ info = registered_fb[0];
2428 +
2429 -+ for (i = 0; i < num_registered_fb; i++) {
2430 -+ registered_fb[i]->bgdecor.data = NULL;
2431 -+ registered_fb[i]->bgdecor.cmap.red = NULL;
2432 -+ }
2433 ++ for (i = 0; i < num_registered_fb; i++) {
2434 ++ registered_fb[i]->bgdecor.data = NULL;
2435 ++ registered_fb[i]->bgdecor.cmap.red = NULL;
2436 ++ }
2437 +
2438 -+ for (i = 0; i < MAX_NR_CONSOLES && vc_cons[i].d; i++) {
2439 -+ vc_cons[i].d->vc_decor.state = vc_cons[i].d->vc_decor.twidth =
2440 -+ vc_cons[i].d->vc_decor.theight = 0;
2441 -+ vc_cons[i].d->vc_decor.theme = NULL;
2442 -+ }
2443 ++ for (i = 0; i < MAX_NR_CONSOLES && vc_cons[i].d; i++) {
2444 ++ vc_cons[i].d->vc_decor.state = vc_cons[i].d->vc_decor.twidth =
2445 ++ vc_cons[i].d->vc_decor.theight = 0;
2446 ++ vc_cons[i].d->vc_decor.theme = NULL;
2447 ++ }
2448 +
2449 -+ return;
2450 ++ return;
2451 +}
2452 +
2453 +int fbcon_decor_init(void)
2454 +{
2455 -+ int i;
2456 ++ int i;
2457 +
2458 -+ fbcon_decor_reset();
2459 ++ fbcon_decor_reset();
2460 +
2461 -+ if (initialized)
2462 -+ return 0;
2463 ++ if (initialized)
2464 ++ return 0;
2465 +
2466 -+ i = misc_register(&fbcon_decor_dev);
2467 -+ if (i) {
2468 -+ printk(KERN_ERR "fbcondecor: failed to register device\n");
2469 -+ return i;
2470 -+ }
2471 ++ i = misc_register(&fbcon_decor_dev);
2472 ++ if (i) {
2473 ++ printk(KERN_ERR "fbcondecor: failed to register device\n");
2474 ++ return i;
2475 ++ }
2476 +
2477 -+ fbcon_decor_call_helper("init", 0);
2478 -+ initialized = 1;
2479 -+ return 0;
2480 ++ fbcon_decor_call_helper("init", 0);
2481 ++ initialized = 1;
2482 ++ return 0;
2483 +}
2484 +
2485 +int fbcon_decor_exit(void)
2486 +{
2487 -+ fbcon_decor_reset();
2488 -+ return 0;
2489 ++ fbcon_decor_reset();
2490 ++ return 0;
2491 +}
2492 +
2493 +EXPORT_SYMBOL(fbcon_decor_path);
2494 @@ -1869,10 +1845,10 @@
2495 +#define fbcon_decor_active_nores(x,y) (x->bgdecor.data && fbcon_decor_active_vc(y))
2496 +
2497 +/* struct fb_info *x, struct vc_data *y */
2498 -+#define fbcon_decor_active(x,y) (fbcon_decor_active_nores(x,y) && \
2499 -+ x->bgdecor.width == x->var.xres && \
2500 -+ x->bgdecor.height == x->var.yres && \
2501 -+ x->bgdecor.depth == x->var.bits_per_pixel)
2502 ++#define fbcon_decor_active(x,y) (fbcon_decor_active_nores(x,y) && \
2503 ++ x->bgdecor.width == x->var.xres && \
2504 ++ x->bgdecor.height == x->var.yres && \
2505 ++ x->bgdecor.depth == x->var.bits_per_pixel)
2506 +
2507 +
2508 +#else /* CONFIG_FB_CON_DECOR */
2509 @@ -1911,18 +1887,18 @@
2510 0x0000, 0xaaaa
2511 };
2512 @@ -254,9 +256,12 @@ int fb_set_cmap(struct fb_cmap *cmap, struct fb_info *info)
2513 - break;
2514 - }
2515 - }
2516 -- if (rc == 0)
2517 -+ if (rc == 0) {
2518 - fb_copy_cmap(cmap, &info->cmap);
2519 + break;
2520 + }
2521 + }
2522 +- if (rc == 0)
2523 ++ if (rc == 0) {
2524 + fb_copy_cmap(cmap, &info->cmap);
2525 -
2526 -+ if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
2527 -+ info->fix.visual == FB_VISUAL_DIRECTCOLOR)
2528 -+ fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
2529 -+ }
2530 - return rc;
2531 ++ if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
2532 ++ info->fix.visual == FB_VISUAL_DIRECTCOLOR)
2533 ++ fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
2534 ++ }
2535 + return rc;
2536 }
2537
2538 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
2539 @@ -1930,20 +1906,20 @@
2540 --- a/drivers/video/fbmem.c
2541 +++ b/drivers/video/fbmem.c
2542 @@ -1166,15 +1166,6 @@ struct fb_fix_screeninfo32 {
2543 - u16 reserved[3];
2544 + u16 reserved[3];
2545 };
2546
2547 -struct fb_cmap32 {
2548 -- u32 start;
2549 -- u32 len;
2550 -- compat_caddr_t red;
2551 -- compat_caddr_t green;
2552 -- compat_caddr_t blue;
2553 -- compat_caddr_t transp;
2554 +- u32 start;
2555 +- u32 len;
2556 +- compat_caddr_t red;
2557 +- compat_caddr_t green;
2558 +- compat_caddr_t blue;
2559 +- compat_caddr_t transp;
2560 -};
2561 -
2562 static int fb_getput_cmap(struct fb_info *info, unsigned int cmd,
2563 - unsigned long arg)
2564 + unsigned long arg)
2565 {
2566 diff --git a/include/linux/console_decor.h b/include/linux/console_decor.h
2567 new file mode 100644
2568 @@ -1956,11 +1932,11 @@
2569 +
2570 +/* A structure used by the framebuffer console decorations (drivers/video/console/fbcondecor.c) */