Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:3.18 commit in: /
Date: Wed, 26 Nov 2014 00:36:14
Message-Id: 1416962158.05f871e03f13d99674e5ccce73f8a6dcee968ac8.mpagano@gentoo
1 commit: 05f871e03f13d99674e5ccce73f8a6dcee968ac8
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Wed Nov 26 00:35:58 2014 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Wed Nov 26 00:35:58 2014 +0000
6 URL: http://sources.gentoo.org/gitweb/?p=proj/linux-patches.git;a=commit;h=05f871e0
7
8 Support for namespace user.pax.* on tmpfs. ACPI: Disable Windows 8 compatibility for some Lenovo ThinkPads.Ensure that /dev/root doesn't appear in /proc/mounts when bootint without an initramfs. Do not lock when UMH is waiting on current thread spawned by linuxrc. (bug #481344). Bootsplash ported by Uladzimir Bely (bug #513334).Add Gentoo Linux support config settings and defaults.Kernel patch enables gcc optimizations for additional CPUs.
9
10 ---
11 0000_README | 20 +
12 2700_ThinkPad-30-brightness-control-fix.patch | 67 +
13 2900_dev-root-proc-mount-fix.patch | 30 +
14 2905_2disk-resume-image-fix.patch | 24 +
15 4200_fbcondecor-3.16.patch | 2119 ++++++++++++++++++++
16 ...able-additional-cpu-optimizations-for-gcc.patch | 327 +++
17 6 files changed, 2587 insertions(+)
18
19 diff --git a/0000_README b/0000_README
20 index 36c2b96..7a25c41 100644
21 --- a/0000_README
22 +++ b/0000_README
23 @@ -47,6 +47,26 @@ Patch: 1500_XATTR_USER_PREFIX.patch
24 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
25 Desc: Support for namespace user.pax.* on tmpfs.
26
27 +Patch: 2700_ThinkPad-30-brightness-control-fix.patch
28 +From: Seth Forshee <seth.forshee@×××××××××.com>
29 +Desc: ACPI: Disable Windows 8 compatibility for some Lenovo ThinkPads.
30 +
31 +Patch: 2900_dev-root-proc-mount-fix.patch
32 +From: https://bugs.gentoo.org/show_bug.cgi?id=438380
33 +Desc: Ensure that /dev/root doesn't appear in /proc/mounts when bootint without an initramfs.
34 +
35 +Patch: 2905_s2disk-resume-image-fix.patch
36 +From: Al Viro <viro <at> ZenIV.linux.org.uk>
37 +Desc: Do not lock when UMH is waiting on current thread spawned by linuxrc. (bug #481344)
38 +
39 +Patch: 4200_fbcondecor-3.16.patch
40 +From: http://www.mepiscommunity.org/fbcondecor
41 +Desc: Bootsplash ported by Uladzimir Bely (bug #513334)
42 +
43 Patch: 4567_distro-Gentoo-Kconfig.patch
44 From: Tom Wijsman <TomWij@g.o>
45 Desc: Add Gentoo Linux support config settings and defaults.
46 +
47 +Patch: 5000_enable-additional-cpu-optimizations-for-gcc.patch
48 +From: https://github.com/graysky2/kernel_gcc_patch/
49 +Desc: Kernel patch enables gcc optimizations for additional CPUs.
50
51 diff --git a/2700_ThinkPad-30-brightness-control-fix.patch b/2700_ThinkPad-30-brightness-control-fix.patch
52 new file mode 100644
53 index 0000000..b548c6d
54 --- /dev/null
55 +++ b/2700_ThinkPad-30-brightness-control-fix.patch
56 @@ -0,0 +1,67 @@
57 +diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
58 +index cb96296..6c242ed 100644
59 +--- a/drivers/acpi/blacklist.c
60 ++++ b/drivers/acpi/blacklist.c
61 +@@ -269,6 +276,61 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
62 + },
63 +
64 + /*
65 ++ * The following Lenovo models have a broken workaround in the
66 ++ * acpi_video backlight implementation to meet the Windows 8
67 ++ * requirement of 101 backlight levels. Reverting to pre-Win8
68 ++ * behavior fixes the problem.
69 ++ */
70 ++ {
71 ++ .callback = dmi_disable_osi_win8,
72 ++ .ident = "Lenovo ThinkPad L430",
73 ++ .matches = {
74 ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
75 ++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad L430"),
76 ++ },
77 ++ },
78 ++ {
79 ++ .callback = dmi_disable_osi_win8,
80 ++ .ident = "Lenovo ThinkPad T430s",
81 ++ .matches = {
82 ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
83 ++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T430s"),
84 ++ },
85 ++ },
86 ++ {
87 ++ .callback = dmi_disable_osi_win8,
88 ++ .ident = "Lenovo ThinkPad T530",
89 ++ .matches = {
90 ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
91 ++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T530"),
92 ++ },
93 ++ },
94 ++ {
95 ++ .callback = dmi_disable_osi_win8,
96 ++ .ident = "Lenovo ThinkPad W530",
97 ++ .matches = {
98 ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
99 ++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad W530"),
100 ++ },
101 ++ },
102 ++ {
103 ++ .callback = dmi_disable_osi_win8,
104 ++ .ident = "Lenovo ThinkPad X1 Carbon",
105 ++ .matches = {
106 ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
107 ++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X1 Carbon"),
108 ++ },
109 ++ },
110 ++ {
111 ++ .callback = dmi_disable_osi_win8,
112 ++ .ident = "Lenovo ThinkPad X230",
113 ++ .matches = {
114 ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
115 ++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X230"),
116 ++ },
117 ++ },
118 ++
119 ++ /*
120 + * BIOS invocation of _OSI(Linux) is almost always a BIOS bug.
121 + * Linux ignores it, except for the machines enumerated below.
122 + */
123 +
124
125 diff --git a/2900_dev-root-proc-mount-fix.patch b/2900_dev-root-proc-mount-fix.patch
126 new file mode 100644
127 index 0000000..6ea86e2
128 --- /dev/null
129 +++ b/2900_dev-root-proc-mount-fix.patch
130 @@ -0,0 +1,30 @@
131 +--- a/init/do_mounts.c 2014-08-26 08:03:30.000013100 -0400
132 ++++ b/init/do_mounts.c 2014-08-26 08:11:19.720014712 -0400
133 +@@ -484,7 +484,10 @@ void __init change_floppy(char *fmt, ...
134 + va_start(args, fmt);
135 + vsprintf(buf, fmt, args);
136 + va_end(args);
137 +- fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
138 ++ if (saved_root_name[0])
139 ++ fd = sys_open(saved_root_name, O_RDWR | O_NDELAY, 0);
140 ++ else
141 ++ fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
142 + if (fd >= 0) {
143 + sys_ioctl(fd, FDEJECT, 0);
144 + sys_close(fd);
145 +@@ -527,8 +530,13 @@ void __init mount_root(void)
146 + }
147 + #endif
148 + #ifdef CONFIG_BLOCK
149 +- create_dev("/dev/root", ROOT_DEV);
150 +- mount_block_root("/dev/root", root_mountflags);
151 ++ if (saved_root_name[0]) {
152 ++ create_dev(saved_root_name, ROOT_DEV);
153 ++ mount_block_root(saved_root_name, root_mountflags);
154 ++ } else {
155 ++ create_dev("/dev/root", ROOT_DEV);
156 ++ mount_block_root("/dev/root", root_mountflags);
157 ++ }
158 + #endif
159 + }
160 +
161
162 diff --git a/2905_2disk-resume-image-fix.patch b/2905_2disk-resume-image-fix.patch
163 new file mode 100644
164 index 0000000..7e95d29
165 --- /dev/null
166 +++ b/2905_2disk-resume-image-fix.patch
167 @@ -0,0 +1,24 @@
168 +diff --git a/kernel/kmod.c b/kernel/kmod.c
169 +index fb32636..d968882 100644
170 +--- a/kernel/kmod.c
171 ++++ b/kernel/kmod.c
172 +@@ -575,7 +575,8 @@
173 + call_usermodehelper_freeinfo(sub_info);
174 + return -EINVAL;
175 + }
176 +- helper_lock();
177 ++ if (!(current->flags & PF_FREEZER_SKIP))
178 ++ helper_lock();
179 + if (!khelper_wq || usermodehelper_disabled) {
180 + retval = -EBUSY;
181 + goto out;
182 +@@ -611,7 +612,8 @@ wait_done:
183 + out:
184 + call_usermodehelper_freeinfo(sub_info);
185 + unlock:
186 +- helper_unlock();
187 ++ if (!(current->flags & PF_FREEZER_SKIP))
188 ++ helper_unlock();
189 + return retval;
190 + }
191 + EXPORT_SYMBOL(call_usermodehelper_exec);
192
193 diff --git a/4200_fbcondecor-3.16.patch b/4200_fbcondecor-3.16.patch
194 new file mode 100644
195 index 0000000..c96e5dc
196 --- /dev/null
197 +++ b/4200_fbcondecor-3.16.patch
198 @@ -0,0 +1,2119 @@
199 +diff --git a/Documentation/fb/00-INDEX b/Documentation/fb/00-INDEX
200 +index fe85e7c..2230930 100644
201 +--- a/Documentation/fb/00-INDEX
202 ++++ b/Documentation/fb/00-INDEX
203 +@@ -23,6 +23,8 @@ ep93xx-fb.txt
204 + - info on the driver for EP93xx LCD controller.
205 + fbcon.txt
206 + - intro to and usage guide for the framebuffer console (fbcon).
207 ++fbcondecor.txt
208 ++ - info on the Framebuffer Console Decoration
209 + framebuffer.txt
210 + - introduction to frame buffer devices.
211 + gxfb.txt
212 +diff --git a/Documentation/fb/fbcondecor.txt b/Documentation/fb/fbcondecor.txt
213 +new file mode 100644
214 +index 0000000..3388c61
215 +--- /dev/null
216 ++++ b/Documentation/fb/fbcondecor.txt
217 +@@ -0,0 +1,207 @@
218 ++What is it?
219 ++-----------
220 ++
221 ++The framebuffer decorations are a kernel feature which allows displaying a
222 ++background picture on selected consoles.
223 ++
224 ++What do I need to get it to work?
225 ++---------------------------------
226 ++
227 ++To get fbcondecor up-and-running you will have to:
228 ++ 1) get a copy of splashutils [1] or a similar program
229 ++ 2) get some fbcondecor themes
230 ++ 3) build the kernel helper program
231 ++ 4) build your kernel with the FB_CON_DECOR option enabled.
232 ++
233 ++To get fbcondecor operational right after fbcon initialization is finished, you
234 ++will have to include a theme and the kernel helper into your initramfs image.
235 ++Please refer to splashutils documentation for instructions on how to do that.
236 ++
237 ++[1] The splashutils package can be downloaded from:
238 ++ http://github.com/alanhaggai/fbsplash
239 ++
240 ++The userspace helper
241 ++--------------------
242 ++
243 ++The userspace fbcondecor helper (by default: /sbin/fbcondecor_helper) is called by the
244 ++kernel whenever an important event occurs and the kernel needs some kind of
245 ++job to be carried out. Important events include console switches and video
246 ++mode switches (the kernel requests background images and configuration
247 ++parameters for the current console). The fbcondecor helper must be accessible at
248 ++all times. If it's not, fbcondecor will be switched off automatically.
249 ++
250 ++It's possible to set path to the fbcondecor helper by writing it to
251 ++/proc/sys/kernel/fbcondecor.
252 ++
253 ++*****************************************************************************
254 ++
255 ++The information below is mostly technical stuff. There's probably no need to
256 ++read it unless you plan to develop a userspace helper.
257 ++
258 ++The fbcondecor protocol
259 ++-----------------------
260 ++
261 ++The fbcondecor protocol defines a communication interface between the kernel and
262 ++the userspace fbcondecor helper.
263 ++
264 ++The kernel side is responsible for:
265 ++
266 ++ * rendering console text, using an image as a background (instead of a
267 ++ standard solid color fbcon uses),
268 ++ * accepting commands from the user via ioctls on the fbcondecor device,
269 ++ * calling the userspace helper to set things up as soon as the fb subsystem
270 ++ is initialized.
271 ++
272 ++The userspace helper is responsible for everything else, including parsing
273 ++configuration files, decompressing the image files whenever the kernel needs
274 ++it, and communicating with the kernel if necessary.
275 ++
276 ++The fbcondecor protocol specifies how communication is done in both ways:
277 ++kernel->userspace and userspace->helper.
278 ++
279 ++Kernel -> Userspace
280 ++-------------------
281 ++
282 ++The kernel communicates with the userspace helper by calling it and specifying
283 ++the task to be done in a series of arguments.
284 ++
285 ++The arguments follow the pattern:
286 ++<fbcondecor protocol version> <command> <parameters>
287 ++
288 ++All commands defined in fbcondecor protocol v2 have the following parameters:
289 ++ virtual console
290 ++ framebuffer number
291 ++ theme
292 ++
293 ++Fbcondecor protocol v1 specified an additional 'fbcondecor mode' after the
294 ++framebuffer number. Fbcondecor protocol v1 is deprecated and should not be used.
295 ++
296 ++Fbcondecor protocol v2 specifies the following commands:
297 ++
298 ++getpic
299 ++------
300 ++ The kernel issues this command to request image data. It's up to the
301 ++ userspace helper to find a background image appropriate for the specified
302 ++ theme and the current resolution. The userspace helper should respond by
303 ++ issuing the FBIOCONDECOR_SETPIC ioctl.
304 ++
305 ++init
306 ++----
307 ++ The kernel issues this command after the fbcondecor device is created and
308 ++ the fbcondecor interface is initialized. Upon receiving 'init', the userspace
309 ++ helper should parse the kernel command line (/proc/cmdline) or otherwise
310 ++ decide whether fbcondecor is to be activated.
311 ++
312 ++ To activate fbcondecor on the first console the helper should issue the
313 ++ FBIOCONDECOR_SETCFG, FBIOCONDECOR_SETPIC and FBIOCONDECOR_SETSTATE commands,
314 ++ in the above-mentioned order.
315 ++
316 ++ When the userspace helper is called in an early phase of the boot process
317 ++ (right after the initialization of fbcon), no filesystems will be mounted.
318 ++ The helper program should mount sysfs and then create the appropriate
319 ++ framebuffer, fbcondecor and tty0 devices (if they don't already exist) to get
320 ++ current display settings and to be able to communicate with the kernel side.
321 ++ It should probably also mount the procfs to be able to parse the kernel
322 ++ command line parameters.
323 ++
324 ++ Note that the console sem is not held when the kernel calls fbcondecor_helper
325 ++ with the 'init' command. The fbcondecor helper should perform all ioctls with
326 ++ origin set to FBCON_DECOR_IO_ORIG_USER.
327 ++
328 ++modechange
329 ++----------
330 ++ The kernel issues this command on a mode change. The helper's response should
331 ++ be similar to the response to the 'init' command. Note that this time the
332 ++ console sem is held and all ioctls must be performed with origin set to
333 ++ FBCON_DECOR_IO_ORIG_KERNEL.
334 ++
335 ++
336 ++Userspace -> Kernel
337 ++-------------------
338 ++
339 ++Userspace programs can communicate with fbcondecor via ioctls on the
340 ++fbcondecor device. These ioctls are to be used by both the userspace helper
341 ++(called only by the kernel) and userspace configuration tools (run by the users).
342 ++
343 ++The fbcondecor helper should set the origin field to FBCON_DECOR_IO_ORIG_KERNEL
344 ++when doing the appropriate ioctls. All userspace configuration tools should
345 ++use FBCON_DECOR_IO_ORIG_USER. Failure to set the appropriate value in the origin
346 ++field when performing ioctls from the kernel helper will most likely result
347 ++in a console deadlock.
348 ++
349 ++FBCON_DECOR_IO_ORIG_KERNEL instructs fbcondecor not to try to acquire the console
350 ++semaphore. Not surprisingly, FBCON_DECOR_IO_ORIG_USER instructs it to acquire
351 ++the console sem.
352 ++
353 ++The framebuffer console decoration provides the following ioctls (all defined in
354 ++linux/fb.h):
355 ++
356 ++FBIOCONDECOR_SETPIC
357 ++description: loads a background picture for a virtual console
358 ++argument: struct fbcon_decor_iowrapper*; data: struct fb_image*
359 ++notes:
360 ++If called for consoles other than the current foreground one, the picture data
361 ++will be ignored.
362 ++
363 ++If the current virtual console is running in a 8-bpp mode, the cmap substruct
364 ++of fb_image has to be filled appropriately: start should be set to 16 (first
365 ++16 colors are reserved for fbcon), len to a value <= 240 and red, green and
366 ++blue should point to valid cmap data. The transp field is ingored. The fields
367 ++dx, dy, bg_color, fg_color in fb_image are ignored as well.
368 ++
369 ++FBIOCONDECOR_SETCFG
370 ++description: sets the fbcondecor config for a virtual console
371 ++argument: struct fbcon_decor_iowrapper*; data: struct vc_decor*
372 ++notes: The structure has to be filled with valid data.
373 ++
374 ++FBIOCONDECOR_GETCFG
375 ++description: gets the fbcondecor config for a virtual console
376 ++argument: struct fbcon_decor_iowrapper*; data: struct vc_decor*
377 ++
378 ++FBIOCONDECOR_SETSTATE
379 ++description: sets the fbcondecor state for a virtual console
380 ++argument: struct fbcon_decor_iowrapper*; data: unsigned int*
381 ++ values: 0 = disabled, 1 = enabled.
382 ++
383 ++FBIOCONDECOR_GETSTATE
384 ++description: gets the fbcondecor state for a virtual console
385 ++argument: struct fbcon_decor_iowrapper*; data: unsigned int*
386 ++ values: as in FBIOCONDECOR_SETSTATE
387 ++
388 ++Info on used structures:
389 ++
390 ++Definition of struct vc_decor can be found in linux/console_decor.h. It's
391 ++heavily commented. Note that the 'theme' field should point to a string
392 ++no longer than FBCON_DECOR_THEME_LEN. When FBIOCONDECOR_GETCFG call is
393 ++performed, the theme field should point to a char buffer of length
394 ++FBCON_DECOR_THEME_LEN.
395 ++
396 ++Definition of struct fbcon_decor_iowrapper can be found in linux/fb.h.
397 ++The fields in this struct have the following meaning:
398 ++
399 ++vc:
400 ++Virtual console number.
401 ++
402 ++origin:
403 ++Specifies if the ioctl is performed as a response to a kernel request. The
404 ++fbcondecor helper should set this field to FBCON_DECOR_IO_ORIG_KERNEL, userspace
405 ++programs should set it to FBCON_DECOR_IO_ORIG_USER. This field is necessary to
406 ++avoid console semaphore deadlocks.
407 ++
408 ++data:
409 ++Pointer to a data structure appropriate for the performed ioctl. Type of
410 ++the data struct is specified in the ioctls description.
411 ++
412 ++*****************************************************************************
413 ++
414 ++Credit
415 ++------
416 ++
417 ++Original 'bootsplash' project & implementation by:
418 ++ Volker Poplawski <volker@×××××××××.de>, Stefan Reinauer <stepan@××××.de>,
419 ++ Steffen Winterfeldt <snwint@××××.de>, Michael Schroeder <mls@××××.de>,
420 ++ Ken Wimer <wimer@××××.de>.
421 ++
422 ++Fbcondecor, fbcondecor protocol design, current implementation & docs by:
423 ++ Michal Januszewski <michalj+fbcondecor@×××××.com>
424 ++
425 +diff --git a/drivers/Makefile b/drivers/Makefile
426 +index 7183b6a..d576148 100644
427 +--- a/drivers/Makefile
428 ++++ b/drivers/Makefile
429 +@@ -17,6 +17,10 @@ obj-y += pwm/
430 + obj-$(CONFIG_PCI) += pci/
431 + obj-$(CONFIG_PARISC) += parisc/
432 + obj-$(CONFIG_RAPIDIO) += rapidio/
433 ++# tty/ comes before char/ so that the VT console is the boot-time
434 ++# default.
435 ++obj-y += tty/
436 ++obj-y += char/
437 + obj-y += video/
438 + obj-y += idle/
439 +
440 +@@ -42,11 +46,6 @@ obj-$(CONFIG_REGULATOR) += regulator/
441 + # reset controllers early, since gpu drivers might rely on them to initialize
442 + obj-$(CONFIG_RESET_CONTROLLER) += reset/
443 +
444 +-# tty/ comes before char/ so that the VT console is the boot-time
445 +-# default.
446 +-obj-y += tty/
447 +-obj-y += char/
448 +-
449 + # gpu/ comes after char for AGP vs DRM startup
450 + obj-y += gpu/
451 +
452 +diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
453 +index fe1cd01..6d2e87a 100644
454 +--- a/drivers/video/console/Kconfig
455 ++++ b/drivers/video/console/Kconfig
456 +@@ -126,6 +126,19 @@ config FRAMEBUFFER_CONSOLE_ROTATION
457 + such that other users of the framebuffer will remain normally
458 + oriented.
459 +
460 ++config FB_CON_DECOR
461 ++ bool "Support for the Framebuffer Console Decorations"
462 ++ depends on FRAMEBUFFER_CONSOLE=y && !FB_TILEBLITTING
463 ++ default n
464 ++ ---help---
465 ++ This option enables support for framebuffer console decorations which
466 ++ makes it possible to display images in the background of the system
467 ++ consoles. Note that userspace utilities are necessary in order to take
468 ++ advantage of these features. Refer to Documentation/fb/fbcondecor.txt
469 ++ for more information.
470 ++
471 ++ If unsure, say N.
472 ++
473 + config STI_CONSOLE
474 + bool "STI text console"
475 + depends on PARISC
476 +diff --git a/drivers/video/console/Makefile b/drivers/video/console/Makefile
477 +index 43bfa48..cc104b6 100644
478 +--- a/drivers/video/console/Makefile
479 ++++ b/drivers/video/console/Makefile
480 +@@ -16,4 +16,5 @@ obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += fbcon_rotate.o fbcon_cw.o fbcon_ud.o \
481 + fbcon_ccw.o
482 + endif
483 +
484 ++obj-$(CONFIG_FB_CON_DECOR) += fbcondecor.o cfbcondecor.o
485 + obj-$(CONFIG_FB_STI) += sticore.o
486 +diff --git a/drivers/video/console/bitblit.c b/drivers/video/console/bitblit.c
487 +index 61b182b..984384b 100644
488 +--- a/drivers/video/console/bitblit.c
489 ++++ b/drivers/video/console/bitblit.c
490 +@@ -18,6 +18,7 @@
491 + #include <linux/console.h>
492 + #include <asm/types.h>
493 + #include "fbcon.h"
494 ++#include "fbcondecor.h"
495 +
496 + /*
497 + * Accelerated handlers.
498 +@@ -55,6 +56,13 @@ static void bit_bmove(struct vc_data *vc, struct fb_info *info, int sy,
499 + area.height = height * vc->vc_font.height;
500 + area.width = width * vc->vc_font.width;
501 +
502 ++ if (fbcon_decor_active(info, vc)) {
503 ++ area.sx += vc->vc_decor.tx;
504 ++ area.sy += vc->vc_decor.ty;
505 ++ area.dx += vc->vc_decor.tx;
506 ++ area.dy += vc->vc_decor.ty;
507 ++ }
508 ++
509 + info->fbops->fb_copyarea(info, &area);
510 + }
511 +
512 +@@ -380,11 +388,15 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode,
513 + cursor.image.depth = 1;
514 + cursor.rop = ROP_XOR;
515 +
516 +- if (info->fbops->fb_cursor)
517 +- err = info->fbops->fb_cursor(info, &cursor);
518 ++ if (fbcon_decor_active(info, vc)) {
519 ++ fbcon_decor_cursor(info, &cursor);
520 ++ } else {
521 ++ if (info->fbops->fb_cursor)
522 ++ err = info->fbops->fb_cursor(info, &cursor);
523 +
524 +- if (err)
525 +- soft_cursor(info, &cursor);
526 ++ if (err)
527 ++ soft_cursor(info, &cursor);
528 ++ }
529 +
530 + ops->cursor_reset = 0;
531 + }
532 +diff --git a/drivers/video/console/cfbcondecor.c b/drivers/video/console/cfbcondecor.c
533 +new file mode 100644
534 +index 0000000..a2b4497
535 +--- /dev/null
536 ++++ b/drivers/video/console/cfbcondecor.c
537 +@@ -0,0 +1,471 @@
538 ++/*
539 ++ * linux/drivers/video/cfbcon_decor.c -- Framebuffer decor render functions
540 ++ *
541 ++ * Copyright (C) 2004 Michal Januszewski <michalj+fbcondecor@×××××.com>
542 ++ *
543 ++ * Code based upon "Bootdecor" (C) 2001-2003
544 ++ * Volker Poplawski <volker@×××××××××.de>,
545 ++ * Stefan Reinauer <stepan@××××.de>,
546 ++ * Steffen Winterfeldt <snwint@××××.de>,
547 ++ * Michael Schroeder <mls@××××.de>,
548 ++ * Ken Wimer <wimer@××××.de>.
549 ++ *
550 ++ * This file is subject to the terms and conditions of the GNU General Public
551 ++ * License. See the file COPYING in the main directory of this archive for
552 ++ * more details.
553 ++ */
554 ++#include <linux/module.h>
555 ++#include <linux/types.h>
556 ++#include <linux/fb.h>
557 ++#include <linux/selection.h>
558 ++#include <linux/slab.h>
559 ++#include <linux/vt_kern.h>
560 ++#include <asm/irq.h>
561 ++
562 ++#include "fbcon.h"
563 ++#include "fbcondecor.h"
564 ++
565 ++#define parse_pixel(shift,bpp,type) \
566 ++ do { \
567 ++ if (d & (0x80 >> (shift))) \
568 ++ dd2[(shift)] = fgx; \
569 ++ else \
570 ++ dd2[(shift)] = transparent ? *(type *)decor_src : bgx; \
571 ++ decor_src += (bpp); \
572 ++ } while (0) \
573 ++
574 ++extern int get_color(struct vc_data *vc, struct fb_info *info,
575 ++ u16 c, int is_fg);
576 ++
577 ++void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc)
578 ++{
579 ++ int i, j, k;
580 ++ int minlen = min(min(info->var.red.length, info->var.green.length),
581 ++ info->var.blue.length);
582 ++ u32 col;
583 ++
584 ++ for (j = i = 0; i < 16; i++) {
585 ++ k = color_table[i];
586 ++
587 ++ col = ((vc->vc_palette[j++] >> (8-minlen))
588 ++ << info->var.red.offset);
589 ++ col |= ((vc->vc_palette[j++] >> (8-minlen))
590 ++ << info->var.green.offset);
591 ++ col |= ((vc->vc_palette[j++] >> (8-minlen))
592 ++ << info->var.blue.offset);
593 ++ ((u32 *)info->pseudo_palette)[k] = col;
594 ++ }
595 ++}
596 ++
597 ++void fbcon_decor_renderc(struct fb_info *info, int ypos, int xpos, int height,
598 ++ int width, u8* src, u32 fgx, u32 bgx, u8 transparent)
599 ++{
600 ++ unsigned int x, y;
601 ++ u32 dd;
602 ++ int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
603 ++ unsigned int d = ypos * info->fix.line_length + xpos * bytespp;
604 ++ unsigned int ds = (ypos * info->var.xres + xpos) * bytespp;
605 ++ u16 dd2[4];
606 ++
607 ++ u8* decor_src = (u8 *)(info->bgdecor.data + ds);
608 ++ u8* dst = (u8 *)(info->screen_base + d);
609 ++
610 ++ if ((ypos + height) > info->var.yres || (xpos + width) > info->var.xres)
611 ++ return;
612 ++
613 ++ for (y = 0; y < height; y++) {
614 ++ switch (info->var.bits_per_pixel) {
615 ++
616 ++ case 32:
617 ++ for (x = 0; x < width; x++) {
618 ++
619 ++ if ((x & 7) == 0)
620 ++ d = *src++;
621 ++ if (d & 0x80)
622 ++ dd = fgx;
623 ++ else
624 ++ dd = transparent ?
625 ++ *(u32 *)decor_src : bgx;
626 ++
627 ++ d <<= 1;
628 ++ decor_src += 4;
629 ++ fb_writel(dd, dst);
630 ++ dst += 4;
631 ++ }
632 ++ break;
633 ++ case 24:
634 ++ for (x = 0; x < width; x++) {
635 ++
636 ++ if ((x & 7) == 0)
637 ++ d = *src++;
638 ++ if (d & 0x80)
639 ++ dd = fgx;
640 ++ else
641 ++ dd = transparent ?
642 ++ (*(u32 *)decor_src & 0xffffff) : bgx;
643 ++
644 ++ d <<= 1;
645 ++ decor_src += 3;
646 ++#ifdef __LITTLE_ENDIAN
647 ++ fb_writew(dd & 0xffff, dst);
648 ++ dst += 2;
649 ++ fb_writeb((dd >> 16), dst);
650 ++#else
651 ++ fb_writew(dd >> 8, dst);
652 ++ dst += 2;
653 ++ fb_writeb(dd & 0xff, dst);
654 ++#endif
655 ++ dst++;
656 ++ }
657 ++ break;
658 ++ case 16:
659 ++ for (x = 0; x < width; x += 2) {
660 ++ if ((x & 7) == 0)
661 ++ d = *src++;
662 ++
663 ++ parse_pixel(0, 2, u16);
664 ++ parse_pixel(1, 2, u16);
665 ++#ifdef __LITTLE_ENDIAN
666 ++ dd = dd2[0] | (dd2[1] << 16);
667 ++#else
668 ++ dd = dd2[1] | (dd2[0] << 16);
669 ++#endif
670 ++ d <<= 2;
671 ++ fb_writel(dd, dst);
672 ++ dst += 4;
673 ++ }
674 ++ break;
675 ++
676 ++ case 8:
677 ++ for (x = 0; x < width; x += 4) {
678 ++ if ((x & 7) == 0)
679 ++ d = *src++;
680 ++
681 ++ parse_pixel(0, 1, u8);
682 ++ parse_pixel(1, 1, u8);
683 ++ parse_pixel(2, 1, u8);
684 ++ parse_pixel(3, 1, u8);
685 ++
686 ++#ifdef __LITTLE_ENDIAN
687 ++ dd = dd2[0] | (dd2[1] << 8) | (dd2[2] << 16) | (dd2[3] << 24);
688 ++#else
689 ++ dd = dd2[3] | (dd2[2] << 8) | (dd2[1] << 16) | (dd2[0] << 24);
690 ++#endif
691 ++ d <<= 4;
692 ++ fb_writel(dd, dst);
693 ++ dst += 4;
694 ++ }
695 ++ }
696 ++
697 ++ dst += info->fix.line_length - width * bytespp;
698 ++ decor_src += (info->var.xres - width) * bytespp;
699 ++ }
700 ++}
701 ++
702 ++#define cc2cx(a) \
703 ++ ((info->fix.visual == FB_VISUAL_TRUECOLOR || \
704 ++ info->fix.visual == FB_VISUAL_DIRECTCOLOR) ? \
705 ++ ((u32*)info->pseudo_palette)[a] : a)
706 ++
707 ++void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info,
708 ++ const unsigned short *s, int count, int yy, int xx)
709 ++{
710 ++ unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
711 ++ struct fbcon_ops *ops = info->fbcon_par;
712 ++ int fg_color, bg_color, transparent;
713 ++ u8 *src;
714 ++ u32 bgx, fgx;
715 ++ u16 c = scr_readw(s);
716 ++
717 ++ fg_color = get_color(vc, info, c, 1);
718 ++ bg_color = get_color(vc, info, c, 0);
719 ++
720 ++ /* Don't paint the background image if console is blanked */
721 ++ transparent = ops->blank_state ? 0 :
722 ++ (vc->vc_decor.bg_color == bg_color);
723 ++
724 ++ xx = xx * vc->vc_font.width + vc->vc_decor.tx;
725 ++ yy = yy * vc->vc_font.height + vc->vc_decor.ty;
726 ++
727 ++ fgx = cc2cx(fg_color);
728 ++ bgx = cc2cx(bg_color);
729 ++
730 ++ while (count--) {
731 ++ c = scr_readw(s++);
732 ++ src = vc->vc_font.data + (c & charmask) * vc->vc_font.height *
733 ++ ((vc->vc_font.width + 7) >> 3);
734 ++
735 ++ fbcon_decor_renderc(info, yy, xx, vc->vc_font.height,
736 ++ vc->vc_font.width, src, fgx, bgx, transparent);
737 ++ xx += vc->vc_font.width;
738 ++ }
739 ++}
740 ++
741 ++void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor)
742 ++{
743 ++ int i;
744 ++ unsigned int dsize, s_pitch;
745 ++ struct fbcon_ops *ops = info->fbcon_par;
746 ++ struct vc_data* vc;
747 ++ u8 *src;
748 ++
749 ++ /* we really don't need any cursors while the console is blanked */
750 ++ if (info->state != FBINFO_STATE_RUNNING || ops->blank_state)
751 ++ return;
752 ++
753 ++ vc = vc_cons[ops->currcon].d;
754 ++
755 ++ src = kmalloc(64 + sizeof(struct fb_image), GFP_ATOMIC);
756 ++ if (!src)
757 ++ return;
758 ++
759 ++ s_pitch = (cursor->image.width + 7) >> 3;
760 ++ dsize = s_pitch * cursor->image.height;
761 ++ if (cursor->enable) {
762 ++ switch (cursor->rop) {
763 ++ case ROP_XOR:
764 ++ for (i = 0; i < dsize; i++)
765 ++ src[i] = cursor->image.data[i] ^ cursor->mask[i];
766 ++ break;
767 ++ case ROP_COPY:
768 ++ default:
769 ++ for (i = 0; i < dsize; i++)
770 ++ src[i] = cursor->image.data[i] & cursor->mask[i];
771 ++ break;
772 ++ }
773 ++ } else
774 ++ memcpy(src, cursor->image.data, dsize);
775 ++
776 ++ fbcon_decor_renderc(info,
777 ++ cursor->image.dy + vc->vc_decor.ty,
778 ++ cursor->image.dx + vc->vc_decor.tx,
779 ++ cursor->image.height,
780 ++ cursor->image.width,
781 ++ (u8*)src,
782 ++ cc2cx(cursor->image.fg_color),
783 ++ cc2cx(cursor->image.bg_color),
784 ++ cursor->image.bg_color == vc->vc_decor.bg_color);
785 ++
786 ++ kfree(src);
787 ++}
788 ++
789 ++static void decorset(u8 *dst, int height, int width, int dstbytes,
790 ++ u32 bgx, int bpp)
791 ++{
792 ++ int i;
793 ++
794 ++ if (bpp == 8)
795 ++ bgx |= bgx << 8;
796 ++ if (bpp == 16 || bpp == 8)
797 ++ bgx |= bgx << 16;
798 ++
799 ++ while (height-- > 0) {
800 ++ u8 *p = dst;
801 ++
802 ++ switch (bpp) {
803 ++
804 ++ case 32:
805 ++ for (i=0; i < width; i++) {
806 ++ fb_writel(bgx, p); p += 4;
807 ++ }
808 ++ break;
809 ++ case 24:
810 ++ for (i=0; i < width; i++) {
811 ++#ifdef __LITTLE_ENDIAN
812 ++ fb_writew((bgx & 0xffff),(u16*)p); p += 2;
813 ++ fb_writeb((bgx >> 16),p++);
814 ++#else
815 ++ fb_writew((bgx >> 8),(u16*)p); p += 2;
816 ++ fb_writeb((bgx & 0xff),p++);
817 ++#endif
818 ++ }
819 ++ case 16:
820 ++ for (i=0; i < width/4; i++) {
821 ++ fb_writel(bgx,p); p += 4;
822 ++ fb_writel(bgx,p); p += 4;
823 ++ }
824 ++ if (width & 2) {
825 ++ fb_writel(bgx,p); p += 4;
826 ++ }
827 ++ if (width & 1)
828 ++ fb_writew(bgx,(u16*)p);
829 ++ break;
830 ++ case 8:
831 ++ for (i=0; i < width/4; i++) {
832 ++ fb_writel(bgx,p); p += 4;
833 ++ }
834 ++
835 ++ if (width & 2) {
836 ++ fb_writew(bgx,p); p += 2;
837 ++ }
838 ++ if (width & 1)
839 ++ fb_writeb(bgx,(u8*)p);
840 ++ break;
841 ++
842 ++ }
843 ++ dst += dstbytes;
844 ++ }
845 ++}
846 ++
847 ++void fbcon_decor_copy(u8 *dst, u8 *src, int height, int width, int linebytes,
848 ++ int srclinebytes, int bpp)
849 ++{
850 ++ int i;
851 ++
852 ++ while (height-- > 0) {
853 ++ u32 *p = (u32 *)dst;
854 ++ u32 *q = (u32 *)src;
855 ++
856 ++ switch (bpp) {
857 ++
858 ++ case 32:
859 ++ for (i=0; i < width; i++)
860 ++ fb_writel(*q++, p++);
861 ++ break;
862 ++ case 24:
863 ++ for (i=0; i < (width*3/4); i++)
864 ++ fb_writel(*q++, p++);
865 ++ if ((width*3) % 4) {
866 ++ if (width & 2) {
867 ++ fb_writeb(*(u8*)q, (u8*)p);
868 ++ } else if (width & 1) {
869 ++ fb_writew(*(u16*)q, (u16*)p);
870 ++ fb_writeb(*(u8*)((u16*)q+1),(u8*)((u16*)p+2));
871 ++ }
872 ++ }
873 ++ break;
874 ++ case 16:
875 ++ for (i=0; i < width/4; i++) {
876 ++ fb_writel(*q++, p++);
877 ++ fb_writel(*q++, p++);
878 ++ }
879 ++ if (width & 2)
880 ++ fb_writel(*q++, p++);
881 ++ if (width & 1)
882 ++ fb_writew(*(u16*)q, (u16*)p);
883 ++ break;
884 ++ case 8:
885 ++ for (i=0; i < width/4; i++)
886 ++ fb_writel(*q++, p++);
887 ++
888 ++ if (width & 2) {
889 ++ fb_writew(*(u16*)q, (u16*)p);
890 ++ q = (u32*) ((u16*)q + 1);
891 ++ p = (u32*) ((u16*)p + 1);
892 ++ }
893 ++ if (width & 1)
894 ++ fb_writeb(*(u8*)q, (u8*)p);
895 ++ break;
896 ++ }
897 ++
898 ++ dst += linebytes;
899 ++ src += srclinebytes;
900 ++ }
901 ++}
902 ++
903 ++static void decorfill(struct fb_info *info, int sy, int sx, int height,
904 ++ int width)
905 ++{
906 ++ int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
907 ++ int d = sy * info->fix.line_length + sx * bytespp;
908 ++ int ds = (sy * info->var.xres + sx) * bytespp;
909 ++
910 ++ fbcon_decor_copy((u8 *)(info->screen_base + d), (u8 *)(info->bgdecor.data + ds),
911 ++ height, width, info->fix.line_length, info->var.xres * bytespp,
912 ++ info->var.bits_per_pixel);
913 ++}
914 ++
915 ++void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx,
916 ++ int height, int width)
917 ++{
918 ++ int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
919 ++ struct fbcon_ops *ops = info->fbcon_par;
920 ++ u8 *dst;
921 ++ int transparent, bg_color = attr_bgcol_ec(bgshift, vc, info);
922 ++
923 ++ transparent = (vc->vc_decor.bg_color == bg_color);
924 ++ sy = sy * vc->vc_font.height + vc->vc_decor.ty;
925 ++ sx = sx * vc->vc_font.width + vc->vc_decor.tx;
926 ++ height *= vc->vc_font.height;
927 ++ width *= vc->vc_font.width;
928 ++
929 ++ /* Don't paint the background image if console is blanked */
930 ++ if (transparent && !ops->blank_state) {
931 ++ decorfill(info, sy, sx, height, width);
932 ++ } else {
933 ++ dst = (u8 *)(info->screen_base + sy * info->fix.line_length +
934 ++ sx * ((info->var.bits_per_pixel + 7) >> 3));
935 ++ decorset(dst, height, width, info->fix.line_length, cc2cx(bg_color),
936 ++ info->var.bits_per_pixel);
937 ++ }
938 ++}
939 ++
940 ++void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info,
941 ++ int bottom_only)
942 ++{
943 ++ unsigned int tw = vc->vc_cols*vc->vc_font.width;
944 ++ unsigned int th = vc->vc_rows*vc->vc_font.height;
945 ++
946 ++ if (!bottom_only) {
947 ++ /* top margin */
948 ++ decorfill(info, 0, 0, vc->vc_decor.ty, info->var.xres);
949 ++ /* left margin */
950 ++ decorfill(info, vc->vc_decor.ty, 0, th, vc->vc_decor.tx);
951 ++ /* right margin */
952 ++ decorfill(info, vc->vc_decor.ty, vc->vc_decor.tx + tw, th,
953 ++ info->var.xres - vc->vc_decor.tx - tw);
954 ++ }
955 ++ decorfill(info, vc->vc_decor.ty + th, 0,
956 ++ info->var.yres - vc->vc_decor.ty - th, info->var.xres);
957 ++}
958 ++
959 ++void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y,
960 ++ int sx, int dx, int width)
961 ++{
962 ++ u16 *d = (u16 *) (vc->vc_origin + vc->vc_size_row * y + dx * 2);
963 ++ u16 *s = d + (dx - sx);
964 ++ u16 *start = d;
965 ++ u16 *ls = d;
966 ++ u16 *le = d + width;
967 ++ u16 c;
968 ++ int x = dx;
969 ++ u16 attr = 1;
970 ++
971 ++ do {
972 ++ c = scr_readw(d);
973 ++ if (attr != (c & 0xff00)) {
974 ++ attr = c & 0xff00;
975 ++ if (d > start) {
976 ++ fbcon_decor_putcs(vc, info, start, d - start, y, x);
977 ++ x += d - start;
978 ++ start = d;
979 ++ }
980 ++ }
981 ++ if (s >= ls && s < le && c == scr_readw(s)) {
982 ++ if (d > start) {
983 ++ fbcon_decor_putcs(vc, info, start, d - start, y, x);
984 ++ x += d - start + 1;
985 ++ start = d + 1;
986 ++ } else {
987 ++ x++;
988 ++ start++;
989 ++ }
990 ++ }
991 ++ s++;
992 ++ d++;
993 ++ } while (d < le);
994 ++ if (d > start)
995 ++ fbcon_decor_putcs(vc, info, start, d - start, y, x);
996 ++}
997 ++
998 ++void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank)
999 ++{
1000 ++ if (blank) {
1001 ++ decorset((u8 *)info->screen_base, info->var.yres, info->var.xres,
1002 ++ info->fix.line_length, 0, info->var.bits_per_pixel);
1003 ++ } else {
1004 ++ update_screen(vc);
1005 ++ fbcon_decor_clear_margins(vc, info, 0);
1006 ++ }
1007 ++}
1008 ++
1009 +diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
1010 +index f447734..1a840c2 100644
1011 +--- a/drivers/video/console/fbcon.c
1012 ++++ b/drivers/video/console/fbcon.c
1013 +@@ -79,6 +79,7 @@
1014 + #include <asm/irq.h>
1015 +
1016 + #include "fbcon.h"
1017 ++#include "fbcondecor.h"
1018 +
1019 + #ifdef FBCONDEBUG
1020 + # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
1021 +@@ -94,7 +95,7 @@ enum {
1022 +
1023 + static struct display fb_display[MAX_NR_CONSOLES];
1024 +
1025 +-static signed char con2fb_map[MAX_NR_CONSOLES];
1026 ++signed char con2fb_map[MAX_NR_CONSOLES];
1027 + static signed char con2fb_map_boot[MAX_NR_CONSOLES];
1028 +
1029 + static int logo_lines;
1030 +@@ -286,7 +287,7 @@ static inline int fbcon_is_inactive(struct vc_data *vc, struct fb_info *info)
1031 + !vt_force_oops_output(vc);
1032 + }
1033 +
1034 +-static int get_color(struct vc_data *vc, struct fb_info *info,
1035 ++int get_color(struct vc_data *vc, struct fb_info *info,
1036 + u16 c, int is_fg)
1037 + {
1038 + int depth = fb_get_color_depth(&info->var, &info->fix);
1039 +@@ -551,6 +552,9 @@ static int do_fbcon_takeover(int show_logo)
1040 + info_idx = -1;
1041 + } else {
1042 + fbcon_has_console_bind = 1;
1043 ++#ifdef CONFIG_FB_CON_DECOR
1044 ++ fbcon_decor_init();
1045 ++#endif
1046 + }
1047 +
1048 + return err;
1049 +@@ -1007,6 +1011,12 @@ static const char *fbcon_startup(void)
1050 + rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1051 + cols /= vc->vc_font.width;
1052 + rows /= vc->vc_font.height;
1053 ++
1054 ++ if (fbcon_decor_active(info, vc)) {
1055 ++ cols = vc->vc_decor.twidth / vc->vc_font.width;
1056 ++ rows = vc->vc_decor.theight / vc->vc_font.height;
1057 ++ }
1058 ++
1059 + vc_resize(vc, cols, rows);
1060 +
1061 + DPRINTK("mode: %s\n", info->fix.id);
1062 +@@ -1036,7 +1046,7 @@ static void fbcon_init(struct vc_data *vc, int init)
1063 + cap = info->flags;
1064 +
1065 + if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
1066 +- (info->fix.type == FB_TYPE_TEXT))
1067 ++ (info->fix.type == FB_TYPE_TEXT) || fbcon_decor_active(info, vc))
1068 + logo = 0;
1069 +
1070 + if (var_to_display(p, &info->var, info))
1071 +@@ -1260,6 +1270,11 @@ static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
1072 + fbcon_clear_margins(vc, 0);
1073 + }
1074 +
1075 ++ if (fbcon_decor_active(info, vc)) {
1076 ++ fbcon_decor_clear(vc, info, sy, sx, height, width);
1077 ++ return;
1078 ++ }
1079 ++
1080 + /* Split blits that cross physical y_wrap boundary */
1081 +
1082 + y_break = p->vrows - p->yscroll;
1083 +@@ -1279,10 +1294,15 @@ static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
1084 + struct display *p = &fb_display[vc->vc_num];
1085 + struct fbcon_ops *ops = info->fbcon_par;
1086 +
1087 +- if (!fbcon_is_inactive(vc, info))
1088 +- ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
1089 +- get_color(vc, info, scr_readw(s), 1),
1090 +- get_color(vc, info, scr_readw(s), 0));
1091 ++ if (!fbcon_is_inactive(vc, info)) {
1092 ++
1093 ++ if (fbcon_decor_active(info, vc))
1094 ++ fbcon_decor_putcs(vc, info, s, count, ypos, xpos);
1095 ++ else
1096 ++ ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
1097 ++ get_color(vc, info, scr_readw(s), 1),
1098 ++ get_color(vc, info, scr_readw(s), 0));
1099 ++ }
1100 + }
1101 +
1102 + static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
1103 +@@ -1298,8 +1318,13 @@ static void fbcon_clear_margins(struct vc_data *vc, int bottom_only)
1104 + struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1105 + struct fbcon_ops *ops = info->fbcon_par;
1106 +
1107 +- if (!fbcon_is_inactive(vc, info))
1108 +- ops->clear_margins(vc, info, bottom_only);
1109 ++ if (!fbcon_is_inactive(vc, info)) {
1110 ++ if (fbcon_decor_active(info, vc)) {
1111 ++ fbcon_decor_clear_margins(vc, info, bottom_only);
1112 ++ } else {
1113 ++ ops->clear_margins(vc, info, bottom_only);
1114 ++ }
1115 ++ }
1116 + }
1117 +
1118 + static void fbcon_cursor(struct vc_data *vc, int mode)
1119 +@@ -1819,7 +1844,7 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1120 + count = vc->vc_rows;
1121 + if (softback_top)
1122 + fbcon_softback_note(vc, t, count);
1123 +- if (logo_shown >= 0)
1124 ++ if (logo_shown >= 0 || fbcon_decor_active(info, vc))
1125 + goto redraw_up;
1126 + switch (p->scrollmode) {
1127 + case SCROLL_MOVE:
1128 +@@ -1912,6 +1937,8 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1129 + count = vc->vc_rows;
1130 + if (logo_shown >= 0)
1131 + goto redraw_down;
1132 ++ if (fbcon_decor_active(info, vc))
1133 ++ goto redraw_down;
1134 + switch (p->scrollmode) {
1135 + case SCROLL_MOVE:
1136 + fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
1137 +@@ -2060,6 +2087,13 @@ static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int s
1138 + }
1139 + return;
1140 + }
1141 ++
1142 ++ if (fbcon_decor_active(info, vc) && sy == dy && height == 1) {
1143 ++ /* must use slower redraw bmove to keep background pic intact */
1144 ++ fbcon_decor_bmove_redraw(vc, info, sy, sx, dx, width);
1145 ++ return;
1146 ++ }
1147 ++
1148 + ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
1149 + height, width);
1150 + }
1151 +@@ -2130,8 +2164,8 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width,
1152 + var.yres = virt_h * virt_fh;
1153 + x_diff = info->var.xres - var.xres;
1154 + y_diff = info->var.yres - var.yres;
1155 +- if (x_diff < 0 || x_diff > virt_fw ||
1156 +- y_diff < 0 || y_diff > virt_fh) {
1157 ++ if ((x_diff < 0 || x_diff > virt_fw ||
1158 ++ y_diff < 0 || y_diff > virt_fh) && !vc->vc_decor.state) {
1159 + const struct fb_videomode *mode;
1160 +
1161 + DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
1162 +@@ -2167,6 +2201,21 @@ static int fbcon_switch(struct vc_data *vc)
1163 +
1164 + info = registered_fb[con2fb_map[vc->vc_num]];
1165 + ops = info->fbcon_par;
1166 ++ prev_console = ops->currcon;
1167 ++ if (prev_console != -1)
1168 ++ old_info = registered_fb[con2fb_map[prev_console]];
1169 ++
1170 ++#ifdef CONFIG_FB_CON_DECOR
1171 ++ if (!fbcon_decor_active_vc(vc) && info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
1172 ++ struct vc_data *vc_curr = vc_cons[prev_console].d;
1173 ++ if (vc_curr && fbcon_decor_active_vc(vc_curr)) {
1174 ++ /* Clear the screen to avoid displaying funky colors during
1175 ++ * palette updates. */
1176 ++ memset((u8*)info->screen_base + info->fix.line_length * info->var.yoffset,
1177 ++ 0, info->var.yres * info->fix.line_length);
1178 ++ }
1179 ++ }
1180 ++#endif
1181 +
1182 + if (softback_top) {
1183 + if (softback_lines)
1184 +@@ -2185,9 +2234,6 @@ static int fbcon_switch(struct vc_data *vc)
1185 + logo_shown = FBCON_LOGO_CANSHOW;
1186 + }
1187 +
1188 +- prev_console = ops->currcon;
1189 +- if (prev_console != -1)
1190 +- old_info = registered_fb[con2fb_map[prev_console]];
1191 + /*
1192 + * FIXME: If we have multiple fbdev's loaded, we need to
1193 + * update all info->currcon. Perhaps, we can place this
1194 +@@ -2231,6 +2277,18 @@ static int fbcon_switch(struct vc_data *vc)
1195 + fbcon_del_cursor_timer(old_info);
1196 + }
1197 +
1198 ++ if (fbcon_decor_active_vc(vc)) {
1199 ++ struct vc_data *vc_curr = vc_cons[prev_console].d;
1200 ++
1201 ++ if (!vc_curr->vc_decor.theme ||
1202 ++ strcmp(vc->vc_decor.theme, vc_curr->vc_decor.theme) ||
1203 ++ (fbcon_decor_active_nores(info, vc_curr) &&
1204 ++ !fbcon_decor_active(info, vc_curr))) {
1205 ++ fbcon_decor_disable(vc, 0);
1206 ++ fbcon_decor_call_helper("modechange", vc->vc_num);
1207 ++ }
1208 ++ }
1209 ++
1210 + if (fbcon_is_inactive(vc, info) ||
1211 + ops->blank_state != FB_BLANK_UNBLANK)
1212 + fbcon_del_cursor_timer(info);
1213 +@@ -2339,15 +2397,20 @@ static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)
1214 + }
1215 + }
1216 +
1217 +- if (!fbcon_is_inactive(vc, info)) {
1218 ++ if (!fbcon_is_inactive(vc, info)) {
1219 + if (ops->blank_state != blank) {
1220 + ops->blank_state = blank;
1221 + fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
1222 + ops->cursor_flash = (!blank);
1223 +
1224 +- if (!(info->flags & FBINFO_MISC_USEREVENT))
1225 +- if (fb_blank(info, blank))
1226 +- fbcon_generic_blank(vc, info, blank);
1227 ++ if (!(info->flags & FBINFO_MISC_USEREVENT)) {
1228 ++ if (fb_blank(info, blank)) {
1229 ++ if (fbcon_decor_active(info, vc))
1230 ++ fbcon_decor_blank(vc, info, blank);
1231 ++ else
1232 ++ fbcon_generic_blank(vc, info, blank);
1233 ++ }
1234 ++ }
1235 + }
1236 +
1237 + if (!blank)
1238 +@@ -2522,13 +2585,22 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
1239 + }
1240 +
1241 + if (resize) {
1242 ++ /* reset wrap/pan */
1243 + int cols, rows;
1244 +
1245 + cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
1246 + rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1247 ++
1248 ++ if (fbcon_decor_active(info, vc)) {
1249 ++ info->var.xoffset = info->var.yoffset = p->yscroll = 0;
1250 ++ cols = vc->vc_decor.twidth;
1251 ++ rows = vc->vc_decor.theight;
1252 ++ }
1253 + cols /= w;
1254 + rows /= h;
1255 ++
1256 + vc_resize(vc, cols, rows);
1257 ++
1258 + if (CON_IS_VISIBLE(vc) && softback_buf)
1259 + fbcon_update_softback(vc);
1260 + } else if (CON_IS_VISIBLE(vc)
1261 +@@ -2657,7 +2729,11 @@ static int fbcon_set_palette(struct vc_data *vc, unsigned char *table)
1262 + int i, j, k, depth;
1263 + u8 val;
1264 +
1265 +- if (fbcon_is_inactive(vc, info))
1266 ++ if (fbcon_is_inactive(vc, info)
1267 ++#ifdef CONFIG_FB_CON_DECOR
1268 ++ || vc->vc_num != fg_console
1269 ++#endif
1270 ++ )
1271 + return -EINVAL;
1272 +
1273 + if (!CON_IS_VISIBLE(vc))
1274 +@@ -2683,14 +2759,56 @@ static int fbcon_set_palette(struct vc_data *vc, unsigned char *table)
1275 + } else
1276 + fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap);
1277 +
1278 +- return fb_set_cmap(&palette_cmap, info);
1279 ++ if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
1280 ++ info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
1281 ++
1282 ++ u16 *red, *green, *blue;
1283 ++ int minlen = min(min(info->var.red.length, info->var.green.length),
1284 ++ info->var.blue.length);
1285 ++ int h;
1286 ++
1287 ++ struct fb_cmap cmap = {
1288 ++ .start = 0,
1289 ++ .len = (1 << minlen),
1290 ++ .red = NULL,
1291 ++ .green = NULL,
1292 ++ .blue = NULL,
1293 ++ .transp = NULL
1294 ++ };
1295 ++
1296 ++ red = kmalloc(256 * sizeof(u16) * 3, GFP_KERNEL);
1297 ++
1298 ++ if (!red)
1299 ++ goto out;
1300 ++
1301 ++ green = red + 256;
1302 ++ blue = green + 256;
1303 ++ cmap.red = red;
1304 ++ cmap.green = green;
1305 ++ cmap.blue = blue;
1306 ++
1307 ++ for (i = 0; i < cmap.len; i++) {
1308 ++ red[i] = green[i] = blue[i] = (0xffff * i)/(cmap.len-1);
1309 ++ }
1310 ++
1311 ++ h = fb_set_cmap(&cmap, info);
1312 ++ fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
1313 ++ kfree(red);
1314 ++
1315 ++ return h;
1316 ++
1317 ++ } else if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
1318 ++ info->var.bits_per_pixel == 8 && info->bgdecor.cmap.red != NULL)
1319 ++ fb_set_cmap(&info->bgdecor.cmap, info);
1320 ++
1321 ++out: return fb_set_cmap(&palette_cmap, info);
1322 + }
1323 +
1324 + static u16 *fbcon_screen_pos(struct vc_data *vc, int offset)
1325 + {
1326 + unsigned long p;
1327 + int line;
1328 +-
1329 ++
1330 + if (vc->vc_num != fg_console || !softback_lines)
1331 + return (u16 *) (vc->vc_origin + offset);
1332 + line = offset / vc->vc_size_row;
1333 +@@ -2909,7 +3027,14 @@ static void fbcon_modechanged(struct fb_info *info)
1334 + rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1335 + cols /= vc->vc_font.width;
1336 + rows /= vc->vc_font.height;
1337 +- vc_resize(vc, cols, rows);
1338 ++
1339 ++ if (!fbcon_decor_active_nores(info, vc)) {
1340 ++ vc_resize(vc, cols, rows);
1341 ++ } else {
1342 ++ fbcon_decor_disable(vc, 0);
1343 ++ fbcon_decor_call_helper("modechange", vc->vc_num);
1344 ++ }
1345 ++
1346 + updatescrollmode(p, info, vc);
1347 + scrollback_max = 0;
1348 + scrollback_current = 0;
1349 +@@ -2954,7 +3079,9 @@ static void fbcon_set_all_vcs(struct fb_info *info)
1350 + rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1351 + cols /= vc->vc_font.width;
1352 + rows /= vc->vc_font.height;
1353 +- vc_resize(vc, cols, rows);
1354 ++ if (!fbcon_decor_active_nores(info, vc)) {
1355 ++ vc_resize(vc, cols, rows);
1356 ++ }
1357 + }
1358 +
1359 + if (fg != -1)
1360 +@@ -3596,6 +3723,7 @@ static void fbcon_exit(void)
1361 + }
1362 + }
1363 +
1364 ++ fbcon_decor_exit();
1365 + fbcon_has_exited = 1;
1366 + }
1367 +
1368 +diff --git a/drivers/video/console/fbcondecor.c b/drivers/video/console/fbcondecor.c
1369 +new file mode 100644
1370 +index 0000000..babc8c5
1371 +--- /dev/null
1372 ++++ b/drivers/video/console/fbcondecor.c
1373 +@@ -0,0 +1,555 @@
1374 ++/*
1375 ++ * linux/drivers/video/console/fbcondecor.c -- Framebuffer console decorations
1376 ++ *
1377 ++ * Copyright (C) 2004-2009 Michal Januszewski <michalj+fbcondecor@×××××.com>
1378 ++ *
1379 ++ * Code based upon "Bootsplash" (C) 2001-2003
1380 ++ * Volker Poplawski <volker@×××××××××.de>,
1381 ++ * Stefan Reinauer <stepan@××××.de>,
1382 ++ * Steffen Winterfeldt <snwint@××××.de>,
1383 ++ * Michael Schroeder <mls@××××.de>,
1384 ++ * Ken Wimer <wimer@××××.de>.
1385 ++ *
1386 ++ * Compat ioctl support by Thorsten Klein <TK@××××××××××××××.de>.
1387 ++ *
1388 ++ * This file is subject to the terms and conditions of the GNU General Public
1389 ++ * License. See the file COPYING in the main directory of this archive for
1390 ++ * more details.
1391 ++ *
1392 ++ */
1393 ++#include <linux/module.h>
1394 ++#include <linux/kernel.h>
1395 ++#include <linux/string.h>
1396 ++#include <linux/types.h>
1397 ++#include <linux/fb.h>
1398 ++#include <linux/vt_kern.h>
1399 ++#include <linux/vmalloc.h>
1400 ++#include <linux/unistd.h>
1401 ++#include <linux/syscalls.h>
1402 ++#include <linux/init.h>
1403 ++#include <linux/proc_fs.h>
1404 ++#include <linux/workqueue.h>
1405 ++#include <linux/kmod.h>
1406 ++#include <linux/miscdevice.h>
1407 ++#include <linux/device.h>
1408 ++#include <linux/fs.h>
1409 ++#include <linux/compat.h>
1410 ++#include <linux/console.h>
1411 ++
1412 ++#include <asm/uaccess.h>
1413 ++#include <asm/irq.h>
1414 ++
1415 ++#include "fbcon.h"
1416 ++#include "fbcondecor.h"
1417 ++
1418 ++extern signed char con2fb_map[];
1419 ++static int fbcon_decor_enable(struct vc_data *vc);
1420 ++char fbcon_decor_path[KMOD_PATH_LEN] = "/sbin/fbcondecor_helper";
1421 ++static int initialized = 0;
1422 ++
1423 ++int fbcon_decor_call_helper(char* cmd, unsigned short vc)
1424 ++{
1425 ++ char *envp[] = {
1426 ++ "HOME=/",
1427 ++ "PATH=/sbin:/bin",
1428 ++ NULL
1429 ++ };
1430 ++
1431 ++ char tfb[5];
1432 ++ char tcons[5];
1433 ++ unsigned char fb = (int) con2fb_map[vc];
1434 ++
1435 ++ char *argv[] = {
1436 ++ fbcon_decor_path,
1437 ++ "2",
1438 ++ cmd,
1439 ++ tcons,
1440 ++ tfb,
1441 ++ vc_cons[vc].d->vc_decor.theme,
1442 ++ NULL
1443 ++ };
1444 ++
1445 ++ snprintf(tfb,5,"%d",fb);
1446 ++ snprintf(tcons,5,"%d",vc);
1447 ++
1448 ++ return call_usermodehelper(fbcon_decor_path, argv, envp, UMH_WAIT_EXEC);
1449 ++}
1450 ++
1451 ++/* Disables fbcondecor on a virtual console; called with console sem held. */
1452 ++int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw)
1453 ++{
1454 ++ struct fb_info* info;
1455 ++
1456 ++ if (!vc->vc_decor.state)
1457 ++ return -EINVAL;
1458 ++
1459 ++ info = registered_fb[(int) con2fb_map[vc->vc_num]];
1460 ++
1461 ++ if (info == NULL)
1462 ++ return -EINVAL;
1463 ++
1464 ++ vc->vc_decor.state = 0;
1465 ++ vc_resize(vc, info->var.xres / vc->vc_font.width,
1466 ++ info->var.yres / vc->vc_font.height);
1467 ++
1468 ++ if (fg_console == vc->vc_num && redraw) {
1469 ++ redraw_screen(vc, 0);
1470 ++ update_region(vc, vc->vc_origin +
1471 ++ vc->vc_size_row * vc->vc_top,
1472 ++ vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1473 ++ }
1474 ++
1475 ++ printk(KERN_INFO "fbcondecor: switched decor state to 'off' on console %d\n",
1476 ++ vc->vc_num);
1477 ++
1478 ++ return 0;
1479 ++}
1480 ++
1481 ++/* Enables fbcondecor on a virtual console; called with console sem held. */
1482 ++static int fbcon_decor_enable(struct vc_data *vc)
1483 ++{
1484 ++ struct fb_info* info;
1485 ++
1486 ++ info = registered_fb[(int) con2fb_map[vc->vc_num]];
1487 ++
1488 ++ if (vc->vc_decor.twidth == 0 || vc->vc_decor.theight == 0 ||
1489 ++ info == NULL || vc->vc_decor.state || (!info->bgdecor.data &&
1490 ++ vc->vc_num == fg_console))
1491 ++ return -EINVAL;
1492 ++
1493 ++ vc->vc_decor.state = 1;
1494 ++ vc_resize(vc, vc->vc_decor.twidth / vc->vc_font.width,
1495 ++ vc->vc_decor.theight / vc->vc_font.height);
1496 ++
1497 ++ if (fg_console == vc->vc_num) {
1498 ++ redraw_screen(vc, 0);
1499 ++ update_region(vc, vc->vc_origin +
1500 ++ vc->vc_size_row * vc->vc_top,
1501 ++ vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1502 ++ fbcon_decor_clear_margins(vc, info, 0);
1503 ++ }
1504 ++
1505 ++ printk(KERN_INFO "fbcondecor: switched decor state to 'on' on console %d\n",
1506 ++ vc->vc_num);
1507 ++
1508 ++ return 0;
1509 ++}
1510 ++
1511 ++static inline int fbcon_decor_ioctl_dosetstate(struct vc_data *vc, unsigned int state, unsigned char origin)
1512 ++{
1513 ++ int ret;
1514 ++
1515 ++// if (origin == FBCON_DECOR_IO_ORIG_USER)
1516 ++ console_lock();
1517 ++ if (!state)
1518 ++ ret = fbcon_decor_disable(vc, 1);
1519 ++ else
1520 ++ ret = fbcon_decor_enable(vc);
1521 ++// if (origin == FBCON_DECOR_IO_ORIG_USER)
1522 ++ console_unlock();
1523 ++
1524 ++ return ret;
1525 ++}
1526 ++
1527 ++static inline void fbcon_decor_ioctl_dogetstate(struct vc_data *vc, unsigned int *state)
1528 ++{
1529 ++ *state = vc->vc_decor.state;
1530 ++}
1531 ++
1532 ++static int fbcon_decor_ioctl_dosetcfg(struct vc_data *vc, struct vc_decor *cfg, unsigned char origin)
1533 ++{
1534 ++ struct fb_info *info;
1535 ++ int len;
1536 ++ char *tmp;
1537 ++
1538 ++ info = registered_fb[(int) con2fb_map[vc->vc_num]];
1539 ++
1540 ++ if (info == NULL || !cfg->twidth || !cfg->theight ||
1541 ++ cfg->tx + cfg->twidth > info->var.xres ||
1542 ++ cfg->ty + cfg->theight > info->var.yres)
1543 ++ return -EINVAL;
1544 ++
1545 ++ len = strlen_user(cfg->theme);
1546 ++ if (!len || len > FBCON_DECOR_THEME_LEN)
1547 ++ return -EINVAL;
1548 ++ tmp = kmalloc(len, GFP_KERNEL);
1549 ++ if (!tmp)
1550 ++ return -ENOMEM;
1551 ++ if (copy_from_user(tmp, (void __user *)cfg->theme, len))
1552 ++ return -EFAULT;
1553 ++ cfg->theme = tmp;
1554 ++ cfg->state = 0;
1555 ++
1556 ++ /* If this ioctl is a response to a request from kernel, the console sem
1557 ++ * is already held; we also don't need to disable decor because either the
1558 ++ * new config and background picture will be successfully loaded, and the
1559 ++ * decor will stay on, or in case of a failure it'll be turned off in fbcon. */
1560 ++// if (origin == FBCON_DECOR_IO_ORIG_USER) {
1561 ++ console_lock();
1562 ++ if (vc->vc_decor.state)
1563 ++ fbcon_decor_disable(vc, 1);
1564 ++// }
1565 ++
1566 ++ if (vc->vc_decor.theme)
1567 ++ kfree(vc->vc_decor.theme);
1568 ++
1569 ++ vc->vc_decor = *cfg;
1570 ++
1571 ++// if (origin == FBCON_DECOR_IO_ORIG_USER)
1572 ++ console_unlock();
1573 ++
1574 ++ printk(KERN_INFO "fbcondecor: console %d using theme '%s'\n",
1575 ++ vc->vc_num, vc->vc_decor.theme);
1576 ++ return 0;
1577 ++}
1578 ++
1579 ++static int fbcon_decor_ioctl_dogetcfg(struct vc_data *vc, struct vc_decor *decor)
1580 ++{
1581 ++ char __user *tmp;
1582 ++
1583 ++ tmp = decor->theme;
1584 ++ *decor = vc->vc_decor;
1585 ++ decor->theme = tmp;
1586 ++
1587 ++ if (vc->vc_decor.theme) {
1588 ++ if (copy_to_user(tmp, vc->vc_decor.theme, strlen(vc->vc_decor.theme) + 1))
1589 ++ return -EFAULT;
1590 ++ } else
1591 ++ if (put_user(0, tmp))
1592 ++ return -EFAULT;
1593 ++
1594 ++ return 0;
1595 ++}
1596 ++
1597 ++static int fbcon_decor_ioctl_dosetpic(struct vc_data *vc, struct fb_image *img, unsigned char origin)
1598 ++{
1599 ++ struct fb_info *info;
1600 ++ int len;
1601 ++ u8 *tmp;
1602 ++
1603 ++ if (vc->vc_num != fg_console)
1604 ++ return -EINVAL;
1605 ++
1606 ++ info = registered_fb[(int) con2fb_map[vc->vc_num]];
1607 ++
1608 ++ if (info == NULL)
1609 ++ return -EINVAL;
1610 ++
1611 ++ if (img->width != info->var.xres || img->height != info->var.yres) {
1612 ++ printk(KERN_ERR "fbcondecor: picture dimensions mismatch\n");
1613 ++ printk(KERN_ERR "%dx%d vs %dx%d\n", img->width, img->height, info->var.xres, info->var.yres);
1614 ++ return -EINVAL;
1615 ++ }
1616 ++
1617 ++ if (img->depth != info->var.bits_per_pixel) {
1618 ++ printk(KERN_ERR "fbcondecor: picture depth mismatch\n");
1619 ++ return -EINVAL;
1620 ++ }
1621 ++
1622 ++ if (img->depth == 8) {
1623 ++ if (!img->cmap.len || !img->cmap.red || !img->cmap.green ||
1624 ++ !img->cmap.blue)
1625 ++ return -EINVAL;
1626 ++
1627 ++ tmp = vmalloc(img->cmap.len * 3 * 2);
1628 ++ if (!tmp)
1629 ++ return -ENOMEM;
1630 ++
1631 ++ if (copy_from_user(tmp,
1632 ++ (void __user*)img->cmap.red, (img->cmap.len << 1)) ||
1633 ++ copy_from_user(tmp + (img->cmap.len << 1),
1634 ++ (void __user*)img->cmap.green, (img->cmap.len << 1)) ||
1635 ++ copy_from_user(tmp + (img->cmap.len << 2),
1636 ++ (void __user*)img->cmap.blue, (img->cmap.len << 1))) {
1637 ++ vfree(tmp);
1638 ++ return -EFAULT;
1639 ++ }
1640 ++
1641 ++ img->cmap.transp = NULL;
1642 ++ img->cmap.red = (u16*)tmp;
1643 ++ img->cmap.green = img->cmap.red + img->cmap.len;
1644 ++ img->cmap.blue = img->cmap.green + img->cmap.len;
1645 ++ } else {
1646 ++ img->cmap.red = NULL;
1647 ++ }
1648 ++
1649 ++ len = ((img->depth + 7) >> 3) * img->width * img->height;
1650 ++
1651 ++ /*
1652 ++ * Allocate an additional byte so that we never go outside of the
1653 ++ * buffer boundaries in the rendering functions in a 24 bpp mode.
1654 ++ */
1655 ++ tmp = vmalloc(len + 1);
1656 ++
1657 ++ if (!tmp)
1658 ++ goto out;
1659 ++
1660 ++ if (copy_from_user(tmp, (void __user*)img->data, len))
1661 ++ goto out;
1662 ++
1663 ++ img->data = tmp;
1664 ++
1665 ++ /* If this ioctl is a response to a request from kernel, the console sem
1666 ++ * is already held. */
1667 ++// if (origin == FBCON_DECOR_IO_ORIG_USER)
1668 ++ console_lock();
1669 ++
1670 ++ if (info->bgdecor.data)
1671 ++ vfree((u8*)info->bgdecor.data);
1672 ++ if (info->bgdecor.cmap.red)
1673 ++ vfree(info->bgdecor.cmap.red);
1674 ++
1675 ++ info->bgdecor = *img;
1676 ++
1677 ++ if (fbcon_decor_active_vc(vc) && fg_console == vc->vc_num) {
1678 ++ redraw_screen(vc, 0);
1679 ++ update_region(vc, vc->vc_origin +
1680 ++ vc->vc_size_row * vc->vc_top,
1681 ++ vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1682 ++ fbcon_decor_clear_margins(vc, info, 0);
1683 ++ }
1684 ++
1685 ++// if (origin == FBCON_DECOR_IO_ORIG_USER)
1686 ++ console_unlock();
1687 ++
1688 ++ return 0;
1689 ++
1690 ++out: if (img->cmap.red)
1691 ++ vfree(img->cmap.red);
1692 ++
1693 ++ if (tmp)
1694 ++ vfree(tmp);
1695 ++ return -ENOMEM;
1696 ++}
1697 ++
1698 ++static long fbcon_decor_ioctl(struct file *filp, u_int cmd, u_long arg)
1699 ++{
1700 ++ struct fbcon_decor_iowrapper __user *wrapper = (void __user*) arg;
1701 ++ struct vc_data *vc = NULL;
1702 ++ unsigned short vc_num = 0;
1703 ++ unsigned char origin = 0;
1704 ++ void __user *data = NULL;
1705 ++
1706 ++ if (!access_ok(VERIFY_READ, wrapper,
1707 ++ sizeof(struct fbcon_decor_iowrapper)))
1708 ++ return -EFAULT;
1709 ++
1710 ++ __get_user(vc_num, &wrapper->vc);
1711 ++ __get_user(origin, &wrapper->origin);
1712 ++ __get_user(data, &wrapper->data);
1713 ++
1714 ++ if (!vc_cons_allocated(vc_num))
1715 ++ return -EINVAL;
1716 ++
1717 ++ vc = vc_cons[vc_num].d;
1718 ++
1719 ++ switch (cmd) {
1720 ++ case FBIOCONDECOR_SETPIC:
1721 ++ {
1722 ++ struct fb_image img;
1723 ++ if (copy_from_user(&img, (struct fb_image __user *)data, sizeof(struct fb_image)))
1724 ++ return -EFAULT;
1725 ++
1726 ++ return fbcon_decor_ioctl_dosetpic(vc, &img, origin);
1727 ++ }
1728 ++ case FBIOCONDECOR_SETCFG:
1729 ++ {
1730 ++ struct vc_decor cfg;
1731 ++ if (copy_from_user(&cfg, (struct vc_decor __user *)data, sizeof(struct vc_decor)))
1732 ++ return -EFAULT;
1733 ++
1734 ++ return fbcon_decor_ioctl_dosetcfg(vc, &cfg, origin);
1735 ++ }
1736 ++ case FBIOCONDECOR_GETCFG:
1737 ++ {
1738 ++ int rval;
1739 ++ struct vc_decor cfg;
1740 ++
1741 ++ if (copy_from_user(&cfg, (struct vc_decor __user *)data, sizeof(struct vc_decor)))
1742 ++ return -EFAULT;
1743 ++
1744 ++ rval = fbcon_decor_ioctl_dogetcfg(vc, &cfg);
1745 ++
1746 ++ if (copy_to_user(data, &cfg, sizeof(struct vc_decor)))
1747 ++ return -EFAULT;
1748 ++ return rval;
1749 ++ }
1750 ++ case FBIOCONDECOR_SETSTATE:
1751 ++ {
1752 ++ unsigned int state = 0;
1753 ++ if (get_user(state, (unsigned int __user *)data))
1754 ++ return -EFAULT;
1755 ++ return fbcon_decor_ioctl_dosetstate(vc, state, origin);
1756 ++ }
1757 ++ case FBIOCONDECOR_GETSTATE:
1758 ++ {
1759 ++ unsigned int state = 0;
1760 ++ fbcon_decor_ioctl_dogetstate(vc, &state);
1761 ++ return put_user(state, (unsigned int __user *)data);
1762 ++ }
1763 ++
1764 ++ default:
1765 ++ return -ENOIOCTLCMD;
1766 ++ }
1767 ++}
1768 ++
1769 ++#ifdef CONFIG_COMPAT
1770 ++
1771 ++static long fbcon_decor_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) {
1772 ++
1773 ++ struct fbcon_decor_iowrapper32 __user *wrapper = (void __user *)arg;
1774 ++ struct vc_data *vc = NULL;
1775 ++ unsigned short vc_num = 0;
1776 ++ unsigned char origin = 0;
1777 ++ compat_uptr_t data_compat = 0;
1778 ++ void __user *data = NULL;
1779 ++
1780 ++ if (!access_ok(VERIFY_READ, wrapper,
1781 ++ sizeof(struct fbcon_decor_iowrapper32)))
1782 ++ return -EFAULT;
1783 ++
1784 ++ __get_user(vc_num, &wrapper->vc);
1785 ++ __get_user(origin, &wrapper->origin);
1786 ++ __get_user(data_compat, &wrapper->data);
1787 ++ data = compat_ptr(data_compat);
1788 ++
1789 ++ if (!vc_cons_allocated(vc_num))
1790 ++ return -EINVAL;
1791 ++
1792 ++ vc = vc_cons[vc_num].d;
1793 ++
1794 ++ switch (cmd) {
1795 ++ case FBIOCONDECOR_SETPIC32:
1796 ++ {
1797 ++ struct fb_image32 img_compat;
1798 ++ struct fb_image img;
1799 ++
1800 ++ if (copy_from_user(&img_compat, (struct fb_image32 __user *)data, sizeof(struct fb_image32)))
1801 ++ return -EFAULT;
1802 ++
1803 ++ fb_image_from_compat(img, img_compat);
1804 ++
1805 ++ return fbcon_decor_ioctl_dosetpic(vc, &img, origin);
1806 ++ }
1807 ++
1808 ++ case FBIOCONDECOR_SETCFG32:
1809 ++ {
1810 ++ struct vc_decor32 cfg_compat;
1811 ++ struct vc_decor cfg;
1812 ++
1813 ++ if (copy_from_user(&cfg_compat, (struct vc_decor32 __user *)data, sizeof(struct vc_decor32)))
1814 ++ return -EFAULT;
1815 ++
1816 ++ vc_decor_from_compat(cfg, cfg_compat);
1817 ++
1818 ++ return fbcon_decor_ioctl_dosetcfg(vc, &cfg, origin);
1819 ++ }
1820 ++
1821 ++ case FBIOCONDECOR_GETCFG32:
1822 ++ {
1823 ++ int rval;
1824 ++ struct vc_decor32 cfg_compat;
1825 ++ struct vc_decor cfg;
1826 ++
1827 ++ if (copy_from_user(&cfg_compat, (struct vc_decor32 __user *)data, sizeof(struct vc_decor32)))
1828 ++ return -EFAULT;
1829 ++ cfg.theme = compat_ptr(cfg_compat.theme);
1830 ++
1831 ++ rval = fbcon_decor_ioctl_dogetcfg(vc, &cfg);
1832 ++
1833 ++ vc_decor_to_compat(cfg_compat, cfg);
1834 ++
1835 ++ if (copy_to_user((struct vc_decor32 __user *)data, &cfg_compat, sizeof(struct vc_decor32)))
1836 ++ return -EFAULT;
1837 ++ return rval;
1838 ++ }
1839 ++
1840 ++ case FBIOCONDECOR_SETSTATE32:
1841 ++ {
1842 ++ compat_uint_t state_compat = 0;
1843 ++ unsigned int state = 0;
1844 ++
1845 ++ if (get_user(state_compat, (compat_uint_t __user *)data))
1846 ++ return -EFAULT;
1847 ++
1848 ++ state = (unsigned int)state_compat;
1849 ++
1850 ++ return fbcon_decor_ioctl_dosetstate(vc, state, origin);
1851 ++ }
1852 ++
1853 ++ case FBIOCONDECOR_GETSTATE32:
1854 ++ {
1855 ++ compat_uint_t state_compat = 0;
1856 ++ unsigned int state = 0;
1857 ++
1858 ++ fbcon_decor_ioctl_dogetstate(vc, &state);
1859 ++ state_compat = (compat_uint_t)state;
1860 ++
1861 ++ return put_user(state_compat, (compat_uint_t __user *)data);
1862 ++ }
1863 ++
1864 ++ default:
1865 ++ return -ENOIOCTLCMD;
1866 ++ }
1867 ++}
1868 ++#else
1869 ++ #define fbcon_decor_compat_ioctl NULL
1870 ++#endif
1871 ++
1872 ++static struct file_operations fbcon_decor_ops = {
1873 ++ .owner = THIS_MODULE,
1874 ++ .unlocked_ioctl = fbcon_decor_ioctl,
1875 ++ .compat_ioctl = fbcon_decor_compat_ioctl
1876 ++};
1877 ++
1878 ++static struct miscdevice fbcon_decor_dev = {
1879 ++ .minor = MISC_DYNAMIC_MINOR,
1880 ++ .name = "fbcondecor",
1881 ++ .fops = &fbcon_decor_ops
1882 ++};
1883 ++
1884 ++void fbcon_decor_reset(void)
1885 ++{
1886 ++ int i;
1887 ++
1888 ++ for (i = 0; i < num_registered_fb; i++) {
1889 ++ registered_fb[i]->bgdecor.data = NULL;
1890 ++ registered_fb[i]->bgdecor.cmap.red = NULL;
1891 ++ }
1892 ++
1893 ++ for (i = 0; i < MAX_NR_CONSOLES && vc_cons[i].d; i++) {
1894 ++ vc_cons[i].d->vc_decor.state = vc_cons[i].d->vc_decor.twidth =
1895 ++ vc_cons[i].d->vc_decor.theight = 0;
1896 ++ vc_cons[i].d->vc_decor.theme = NULL;
1897 ++ }
1898 ++
1899 ++ return;
1900 ++}
1901 ++
1902 ++int fbcon_decor_init(void)
1903 ++{
1904 ++ int i;
1905 ++
1906 ++ fbcon_decor_reset();
1907 ++
1908 ++ if (initialized)
1909 ++ return 0;
1910 ++
1911 ++ i = misc_register(&fbcon_decor_dev);
1912 ++ if (i) {
1913 ++ printk(KERN_ERR "fbcondecor: failed to register device\n");
1914 ++ return i;
1915 ++ }
1916 ++
1917 ++ fbcon_decor_call_helper("init", 0);
1918 ++ initialized = 1;
1919 ++ return 0;
1920 ++}
1921 ++
1922 ++int fbcon_decor_exit(void)
1923 ++{
1924 ++ fbcon_decor_reset();
1925 ++ return 0;
1926 ++}
1927 ++
1928 ++EXPORT_SYMBOL(fbcon_decor_path);
1929 +diff --git a/drivers/video/console/fbcondecor.h b/drivers/video/console/fbcondecor.h
1930 +new file mode 100644
1931 +index 0000000..3b3724b
1932 +--- /dev/null
1933 ++++ b/drivers/video/console/fbcondecor.h
1934 +@@ -0,0 +1,78 @@
1935 ++/*
1936 ++ * linux/drivers/video/console/fbcondecor.h -- Framebuffer Console Decoration headers
1937 ++ *
1938 ++ * Copyright (C) 2004 Michal Januszewski <michalj+fbcondecor@×××××.com>
1939 ++ *
1940 ++ */
1941 ++
1942 ++#ifndef __FBCON_DECOR_H
1943 ++#define __FBCON_DECOR_H
1944 ++
1945 ++#ifndef _LINUX_FB_H
1946 ++#include <linux/fb.h>
1947 ++#endif
1948 ++
1949 ++/* This is needed for vc_cons in fbcmap.c */
1950 ++#include <linux/vt_kern.h>
1951 ++
1952 ++struct fb_cursor;
1953 ++struct fb_info;
1954 ++struct vc_data;
1955 ++
1956 ++#ifdef CONFIG_FB_CON_DECOR
1957 ++/* fbcondecor.c */
1958 ++int fbcon_decor_init(void);
1959 ++int fbcon_decor_exit(void);
1960 ++int fbcon_decor_call_helper(char* cmd, unsigned short cons);
1961 ++int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw);
1962 ++
1963 ++/* cfbcondecor.c */
1964 ++void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx);
1965 ++void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor);
1966 ++void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width);
1967 ++void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only);
1968 ++void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank);
1969 ++void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width);
1970 ++void fbcon_decor_copy(u8 *dst, u8 *src, int height, int width, int linebytes, int srclinesbytes, int bpp);
1971 ++void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc);
1972 ++
1973 ++/* vt.c */
1974 ++void acquire_console_sem(void);
1975 ++void release_console_sem(void);
1976 ++void do_unblank_screen(int entering_gfx);
1977 ++
1978 ++/* struct vc_data *y */
1979 ++#define fbcon_decor_active_vc(y) (y->vc_decor.state && y->vc_decor.theme)
1980 ++
1981 ++/* struct fb_info *x, struct vc_data *y */
1982 ++#define fbcon_decor_active_nores(x,y) (x->bgdecor.data && fbcon_decor_active_vc(y))
1983 ++
1984 ++/* struct fb_info *x, struct vc_data *y */
1985 ++#define fbcon_decor_active(x,y) (fbcon_decor_active_nores(x,y) && \
1986 ++ x->bgdecor.width == x->var.xres && \
1987 ++ x->bgdecor.height == x->var.yres && \
1988 ++ x->bgdecor.depth == x->var.bits_per_pixel)
1989 ++
1990 ++
1991 ++#else /* CONFIG_FB_CON_DECOR */
1992 ++
1993 ++static inline void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx) {}
1994 ++static inline void fbcon_decor_putc(struct vc_data *vc, struct fb_info *info, int c, int ypos, int xpos) {}
1995 ++static inline void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor) {}
1996 ++static inline void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) {}
1997 ++static inline void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only) {}
1998 ++static inline void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank) {}
1999 ++static inline void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width) {}
2000 ++static inline void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc) {}
2001 ++static inline int fbcon_decor_call_helper(char* cmd, unsigned short cons) { return 0; }
2002 ++static inline int fbcon_decor_init(void) { return 0; }
2003 ++static inline int fbcon_decor_exit(void) { return 0; }
2004 ++static inline int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw) { return 0; }
2005 ++
2006 ++#define fbcon_decor_active_vc(y) (0)
2007 ++#define fbcon_decor_active_nores(x,y) (0)
2008 ++#define fbcon_decor_active(x,y) (0)
2009 ++
2010 ++#endif /* CONFIG_FB_CON_DECOR */
2011 ++
2012 ++#endif /* __FBCON_DECOR_H */
2013 +diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
2014 +index e1f4727..2952e33 100644
2015 +--- a/drivers/video/fbdev/Kconfig
2016 ++++ b/drivers/video/fbdev/Kconfig
2017 +@@ -1204,7 +1204,6 @@ config FB_MATROX
2018 + select FB_CFB_FILLRECT
2019 + select FB_CFB_COPYAREA
2020 + select FB_CFB_IMAGEBLIT
2021 +- select FB_TILEBLITTING
2022 + select FB_MACMODES if PPC_PMAC
2023 + ---help---
2024 + Say Y here if you have a Matrox Millennium, Matrox Millennium II,
2025 +diff --git a/drivers/video/fbdev/core/fbcmap.c b/drivers/video/fbdev/core/fbcmap.c
2026 +index f89245b..05e036c 100644
2027 +--- a/drivers/video/fbdev/core/fbcmap.c
2028 ++++ b/drivers/video/fbdev/core/fbcmap.c
2029 +@@ -17,6 +17,8 @@
2030 + #include <linux/slab.h>
2031 + #include <linux/uaccess.h>
2032 +
2033 ++#include "../../console/fbcondecor.h"
2034 ++
2035 + static u16 red2[] __read_mostly = {
2036 + 0x0000, 0xaaaa
2037 + };
2038 +@@ -249,14 +251,17 @@ int fb_set_cmap(struct fb_cmap *cmap, struct fb_info *info)
2039 + if (transp)
2040 + htransp = *transp++;
2041 + if (info->fbops->fb_setcolreg(start++,
2042 +- hred, hgreen, hblue,
2043 ++ hred, hgreen, hblue,
2044 + htransp, info))
2045 + break;
2046 + }
2047 + }
2048 +- if (rc == 0)
2049 ++ if (rc == 0) {
2050 + fb_copy_cmap(cmap, &info->cmap);
2051 +-
2052 ++ if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
2053 ++ info->fix.visual == FB_VISUAL_DIRECTCOLOR)
2054 ++ fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
2055 ++ }
2056 + return rc;
2057 + }
2058 +
2059 +diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
2060 +index b6d5008..d6703f2 100644
2061 +--- a/drivers/video/fbdev/core/fbmem.c
2062 ++++ b/drivers/video/fbdev/core/fbmem.c
2063 +@@ -1250,15 +1250,6 @@ struct fb_fix_screeninfo32 {
2064 + u16 reserved[3];
2065 + };
2066 +
2067 +-struct fb_cmap32 {
2068 +- u32 start;
2069 +- u32 len;
2070 +- compat_caddr_t red;
2071 +- compat_caddr_t green;
2072 +- compat_caddr_t blue;
2073 +- compat_caddr_t transp;
2074 +-};
2075 +-
2076 + static int fb_getput_cmap(struct fb_info *info, unsigned int cmd,
2077 + unsigned long arg)
2078 + {
2079 +diff --git a/include/linux/console_decor.h b/include/linux/console_decor.h
2080 +new file mode 100644
2081 +index 0000000..04b8d80
2082 +--- /dev/null
2083 ++++ b/include/linux/console_decor.h
2084 +@@ -0,0 +1,46 @@
2085 ++#ifndef _LINUX_CONSOLE_DECOR_H_
2086 ++#define _LINUX_CONSOLE_DECOR_H_ 1
2087 ++
2088 ++/* A structure used by the framebuffer console decorations (drivers/video/console/fbcondecor.c) */
2089 ++struct vc_decor {
2090 ++ __u8 bg_color; /* The color that is to be treated as transparent */
2091 ++ __u8 state; /* Current decor state: 0 = off, 1 = on */
2092 ++ __u16 tx, ty; /* Top left corner coordinates of the text field */
2093 ++ __u16 twidth, theight; /* Width and height of the text field */
2094 ++ char* theme;
2095 ++};
2096 ++
2097 ++#ifdef __KERNEL__
2098 ++#ifdef CONFIG_COMPAT
2099 ++#include <linux/compat.h>
2100 ++
2101 ++struct vc_decor32 {
2102 ++ __u8 bg_color; /* The color that is to be treated as transparent */
2103 ++ __u8 state; /* Current decor state: 0 = off, 1 = on */
2104 ++ __u16 tx, ty; /* Top left corner coordinates of the text field */
2105 ++ __u16 twidth, theight; /* Width and height of the text field */
2106 ++ compat_uptr_t theme;
2107 ++};
2108 ++
2109 ++#define vc_decor_from_compat(to, from) \
2110 ++ (to).bg_color = (from).bg_color; \
2111 ++ (to).state = (from).state; \
2112 ++ (to).tx = (from).tx; \
2113 ++ (to).ty = (from).ty; \
2114 ++ (to).twidth = (from).twidth; \
2115 ++ (to).theight = (from).theight; \
2116 ++ (to).theme = compat_ptr((from).theme)
2117 ++
2118 ++#define vc_decor_to_compat(to, from) \
2119 ++ (to).bg_color = (from).bg_color; \
2120 ++ (to).state = (from).state; \
2121 ++ (to).tx = (from).tx; \
2122 ++ (to).ty = (from).ty; \
2123 ++ (to).twidth = (from).twidth; \
2124 ++ (to).theight = (from).theight; \
2125 ++ (to).theme = ptr_to_compat((from).theme)
2126 ++
2127 ++#endif /* CONFIG_COMPAT */
2128 ++#endif /* __KERNEL__ */
2129 ++
2130 ++#endif
2131 +diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h
2132 +index 7f0c329..98f5d60 100644
2133 +--- a/include/linux/console_struct.h
2134 ++++ b/include/linux/console_struct.h
2135 +@@ -19,6 +19,7 @@
2136 + struct vt_struct;
2137 +
2138 + #define NPAR 16
2139 ++#include <linux/console_decor.h>
2140 +
2141 + struct vc_data {
2142 + struct tty_port port; /* Upper level data */
2143 +@@ -107,6 +108,8 @@ struct vc_data {
2144 + unsigned long vc_uni_pagedir;
2145 + unsigned long *vc_uni_pagedir_loc; /* [!] Location of uni_pagedir variable for this console */
2146 + bool vc_panic_force_write; /* when oops/panic this VC can accept forced output/blanking */
2147 ++
2148 ++ struct vc_decor vc_decor;
2149 + /* additional information is in vt_kern.h */
2150 + };
2151 +
2152 +diff --git a/include/linux/fb.h b/include/linux/fb.h
2153 +index fe6ac95..1e36b03 100644
2154 +--- a/include/linux/fb.h
2155 ++++ b/include/linux/fb.h
2156 +@@ -219,6 +219,34 @@ struct fb_deferred_io {
2157 + };
2158 + #endif
2159 +
2160 ++#ifdef __KERNEL__
2161 ++#ifdef CONFIG_COMPAT
2162 ++struct fb_image32 {
2163 ++ __u32 dx; /* Where to place image */
2164 ++ __u32 dy;
2165 ++ __u32 width; /* Size of image */
2166 ++ __u32 height;
2167 ++ __u32 fg_color; /* Only used when a mono bitmap */
2168 ++ __u32 bg_color;
2169 ++ __u8 depth; /* Depth of the image */
2170 ++ const compat_uptr_t data; /* Pointer to image data */
2171 ++ struct fb_cmap32 cmap; /* color map info */
2172 ++};
2173 ++
2174 ++#define fb_image_from_compat(to, from) \
2175 ++ (to).dx = (from).dx; \
2176 ++ (to).dy = (from).dy; \
2177 ++ (to).width = (from).width; \
2178 ++ (to).height = (from).height; \
2179 ++ (to).fg_color = (from).fg_color; \
2180 ++ (to).bg_color = (from).bg_color; \
2181 ++ (to).depth = (from).depth; \
2182 ++ (to).data = compat_ptr((from).data); \
2183 ++ fb_cmap_from_compat((to).cmap, (from).cmap)
2184 ++
2185 ++#endif /* CONFIG_COMPAT */
2186 ++#endif /* __KERNEL__ */
2187 ++
2188 + /*
2189 + * Frame buffer operations
2190 + *
2191 +@@ -489,6 +517,9 @@ struct fb_info {
2192 + #define FBINFO_STATE_SUSPENDED 1
2193 + u32 state; /* Hardware state i.e suspend */
2194 + void *fbcon_par; /* fbcon use-only private area */
2195 ++
2196 ++ struct fb_image bgdecor;
2197 ++
2198 + /* From here on everything is device dependent */
2199 + void *par;
2200 + /* we need the PCI or similar aperture base/size not
2201 +diff --git a/include/uapi/linux/fb.h b/include/uapi/linux/fb.h
2202 +index fb795c3..dc77a03 100644
2203 +--- a/include/uapi/linux/fb.h
2204 ++++ b/include/uapi/linux/fb.h
2205 +@@ -8,6 +8,25 @@
2206 +
2207 + #define FB_MAX 32 /* sufficient for now */
2208 +
2209 ++struct fbcon_decor_iowrapper
2210 ++{
2211 ++ unsigned short vc; /* Virtual console */
2212 ++ unsigned char origin; /* Point of origin of the request */
2213 ++ void *data;
2214 ++};
2215 ++
2216 ++#ifdef __KERNEL__
2217 ++#ifdef CONFIG_COMPAT
2218 ++#include <linux/compat.h>
2219 ++struct fbcon_decor_iowrapper32
2220 ++{
2221 ++ unsigned short vc; /* Virtual console */
2222 ++ unsigned char origin; /* Point of origin of the request */
2223 ++ compat_uptr_t data;
2224 ++};
2225 ++#endif /* CONFIG_COMPAT */
2226 ++#endif /* __KERNEL__ */
2227 ++
2228 + /* ioctls
2229 + 0x46 is 'F' */
2230 + #define FBIOGET_VSCREENINFO 0x4600
2231 +@@ -35,6 +54,25 @@
2232 + #define FBIOGET_DISPINFO 0x4618
2233 + #define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
2234 +
2235 ++#define FBIOCONDECOR_SETCFG _IOWR('F', 0x19, struct fbcon_decor_iowrapper)
2236 ++#define FBIOCONDECOR_GETCFG _IOR('F', 0x1A, struct fbcon_decor_iowrapper)
2237 ++#define FBIOCONDECOR_SETSTATE _IOWR('F', 0x1B, struct fbcon_decor_iowrapper)
2238 ++#define FBIOCONDECOR_GETSTATE _IOR('F', 0x1C, struct fbcon_decor_iowrapper)
2239 ++#define FBIOCONDECOR_SETPIC _IOWR('F', 0x1D, struct fbcon_decor_iowrapper)
2240 ++#ifdef __KERNEL__
2241 ++#ifdef CONFIG_COMPAT
2242 ++#define FBIOCONDECOR_SETCFG32 _IOWR('F', 0x19, struct fbcon_decor_iowrapper32)
2243 ++#define FBIOCONDECOR_GETCFG32 _IOR('F', 0x1A, struct fbcon_decor_iowrapper32)
2244 ++#define FBIOCONDECOR_SETSTATE32 _IOWR('F', 0x1B, struct fbcon_decor_iowrapper32)
2245 ++#define FBIOCONDECOR_GETSTATE32 _IOR('F', 0x1C, struct fbcon_decor_iowrapper32)
2246 ++#define FBIOCONDECOR_SETPIC32 _IOWR('F', 0x1D, struct fbcon_decor_iowrapper32)
2247 ++#endif /* CONFIG_COMPAT */
2248 ++#endif /* __KERNEL__ */
2249 ++
2250 ++#define FBCON_DECOR_THEME_LEN 128 /* Maximum lenght of a theme name */
2251 ++#define FBCON_DECOR_IO_ORIG_KERNEL 0 /* Kernel ioctl origin */
2252 ++#define FBCON_DECOR_IO_ORIG_USER 1 /* User ioctl origin */
2253 ++
2254 + #define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */
2255 + #define FB_TYPE_PLANES 1 /* Non interleaved planes */
2256 + #define FB_TYPE_INTERLEAVED_PLANES 2 /* Interleaved planes */
2257 +@@ -277,6 +315,29 @@ struct fb_var_screeninfo {
2258 + __u32 reserved[4]; /* Reserved for future compatibility */
2259 + };
2260 +
2261 ++#ifdef __KERNEL__
2262 ++#ifdef CONFIG_COMPAT
2263 ++struct fb_cmap32 {
2264 ++ __u32 start;
2265 ++ __u32 len; /* Number of entries */
2266 ++ compat_uptr_t red; /* Red values */
2267 ++ compat_uptr_t green;
2268 ++ compat_uptr_t blue;
2269 ++ compat_uptr_t transp; /* transparency, can be NULL */
2270 ++};
2271 ++
2272 ++#define fb_cmap_from_compat(to, from) \
2273 ++ (to).start = (from).start; \
2274 ++ (to).len = (from).len; \
2275 ++ (to).red = compat_ptr((from).red); \
2276 ++ (to).green = compat_ptr((from).green); \
2277 ++ (to).blue = compat_ptr((from).blue); \
2278 ++ (to).transp = compat_ptr((from).transp)
2279 ++
2280 ++#endif /* CONFIG_COMPAT */
2281 ++#endif /* __KERNEL__ */
2282 ++
2283 ++
2284 + struct fb_cmap {
2285 + __u32 start; /* First entry */
2286 + __u32 len; /* Number of entries */
2287 +diff --git a/kernel/sysctl.c b/kernel/sysctl.c
2288 +index 74f5b58..6386ab0 100644
2289 +--- a/kernel/sysctl.c
2290 ++++ b/kernel/sysctl.c
2291 +@@ -146,6 +146,10 @@ static const int cap_last_cap = CAP_LAST_CAP;
2292 + static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
2293 + #endif
2294 +
2295 ++#ifdef CONFIG_FB_CON_DECOR
2296 ++extern char fbcon_decor_path[];
2297 ++#endif
2298 ++
2299 + #ifdef CONFIG_INOTIFY_USER
2300 + #include <linux/inotify.h>
2301 + #endif
2302 +@@ -255,6 +259,15 @@ static struct ctl_table sysctl_base_table[] = {
2303 + .mode = 0555,
2304 + .child = dev_table,
2305 + },
2306 ++#ifdef CONFIG_FB_CON_DECOR
2307 ++ {
2308 ++ .procname = "fbcondecor",
2309 ++ .data = &fbcon_decor_path,
2310 ++ .maxlen = KMOD_PATH_LEN,
2311 ++ .mode = 0644,
2312 ++ .proc_handler = &proc_dostring,
2313 ++ },
2314 ++#endif
2315 + { }
2316 + };
2317 +
2318
2319 diff --git a/5000_enable-additional-cpu-optimizations-for-gcc.patch b/5000_enable-additional-cpu-optimizations-for-gcc.patch
2320 new file mode 100644
2321 index 0000000..f7ab6f0
2322 --- /dev/null
2323 +++ b/5000_enable-additional-cpu-optimizations-for-gcc.patch
2324 @@ -0,0 +1,327 @@
2325 +This patch has been tested on and known to work with kernel versions from 3.2
2326 +up to the latest git version (pulled on 12/14/2013).
2327 +
2328 +This patch will expand the number of microarchitectures to include new
2329 +processors including: AMD K10-family, AMD Family 10h (Barcelona), AMD Family
2330 +14h (Bobcat), AMD Family 15h (Bulldozer), AMD Family 15h (Piledriver), AMD
2331 +Family 16h (Jaguar), Intel 1st Gen Core i3/i5/i7 (Nehalem), Intel 2nd Gen Core
2332 +i3/i5/i7 (Sandybridge), Intel 3rd Gen Core i3/i5/i7 (Ivybridge), and Intel 4th
2333 +Gen Core i3/i5/i7 (Haswell). It also offers the compiler the 'native' flag.
2334 +
2335 +Small but real speed increases are measurable using a make endpoint comparing
2336 +a generic kernel to one built with one of the respective microarchs.
2337 +
2338 +See the following experimental evidence supporting this statement:
2339 +https://github.com/graysky2/kernel_gcc_patch
2340 +
2341 +REQUIREMENTS
2342 +linux version >=3.15
2343 +gcc version <4.9
2344 +
2345 +---
2346 +diff -uprN a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
2347 +--- a/arch/x86/include/asm/module.h 2013-11-03 18:41:51.000000000 -0500
2348 ++++ b/arch/x86/include/asm/module.h 2013-12-15 06:21:24.351122516 -0500
2349 +@@ -15,6 +15,16 @@
2350 + #define MODULE_PROC_FAMILY "586MMX "
2351 + #elif defined CONFIG_MCORE2
2352 + #define MODULE_PROC_FAMILY "CORE2 "
2353 ++#elif defined CONFIG_MNATIVE
2354 ++#define MODULE_PROC_FAMILY "NATIVE "
2355 ++#elif defined CONFIG_MCOREI7
2356 ++#define MODULE_PROC_FAMILY "COREI7 "
2357 ++#elif defined CONFIG_MCOREI7AVX
2358 ++#define MODULE_PROC_FAMILY "COREI7AVX "
2359 ++#elif defined CONFIG_MCOREAVXI
2360 ++#define MODULE_PROC_FAMILY "COREAVXI "
2361 ++#elif defined CONFIG_MCOREAVX2
2362 ++#define MODULE_PROC_FAMILY "COREAVX2 "
2363 + #elif defined CONFIG_MATOM
2364 + #define MODULE_PROC_FAMILY "ATOM "
2365 + #elif defined CONFIG_M686
2366 +@@ -33,6 +43,18 @@
2367 + #define MODULE_PROC_FAMILY "K7 "
2368 + #elif defined CONFIG_MK8
2369 + #define MODULE_PROC_FAMILY "K8 "
2370 ++#elif defined CONFIG_MK10
2371 ++#define MODULE_PROC_FAMILY "K10 "
2372 ++#elif defined CONFIG_MBARCELONA
2373 ++#define MODULE_PROC_FAMILY "BARCELONA "
2374 ++#elif defined CONFIG_MBOBCAT
2375 ++#define MODULE_PROC_FAMILY "BOBCAT "
2376 ++#elif defined CONFIG_MBULLDOZER
2377 ++#define MODULE_PROC_FAMILY "BULLDOZER "
2378 ++#elif defined CONFIG_MPILEDRIVER
2379 ++#define MODULE_PROC_FAMILY "PILEDRIVER "
2380 ++#elif defined CONFIG_MJAGUAR
2381 ++#define MODULE_PROC_FAMILY "JAGUAR "
2382 + #elif defined CONFIG_MELAN
2383 + #define MODULE_PROC_FAMILY "ELAN "
2384 + #elif defined CONFIG_MCRUSOE
2385 +diff -uprN a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
2386 +--- a/arch/x86/Kconfig.cpu 2013-11-03 18:41:51.000000000 -0500
2387 ++++ b/arch/x86/Kconfig.cpu 2013-12-15 06:21:24.351122516 -0500
2388 +@@ -139,7 +139,7 @@ config MPENTIUM4
2389 +
2390 +
2391 + config MK6
2392 +- bool "K6/K6-II/K6-III"
2393 ++ bool "AMD K6/K6-II/K6-III"
2394 + depends on X86_32
2395 + ---help---
2396 + Select this for an AMD K6-family processor. Enables use of
2397 +@@ -147,7 +147,7 @@ config MK6
2398 + flags to GCC.
2399 +
2400 + config MK7
2401 +- bool "Athlon/Duron/K7"
2402 ++ bool "AMD Athlon/Duron/K7"
2403 + depends on X86_32
2404 + ---help---
2405 + Select this for an AMD Athlon K7-family processor. Enables use of
2406 +@@ -155,12 +155,55 @@ config MK7
2407 + flags to GCC.
2408 +
2409 + config MK8
2410 +- bool "Opteron/Athlon64/Hammer/K8"
2411 ++ bool "AMD Opteron/Athlon64/Hammer/K8"
2412 + ---help---
2413 + Select this for an AMD Opteron or Athlon64 Hammer-family processor.
2414 + Enables use of some extended instructions, and passes appropriate
2415 + optimization flags to GCC.
2416 +
2417 ++config MK10
2418 ++ bool "AMD 61xx/7x50/PhenomX3/X4/II/K10"
2419 ++ ---help---
2420 ++ Select this for an AMD 61xx Eight-Core Magny-Cours, Athlon X2 7x50,
2421 ++ Phenom X3/X4/II, Athlon II X2/X3/X4, or Turion II-family processor.
2422 ++ Enables use of some extended instructions, and passes appropriate
2423 ++ optimization flags to GCC.
2424 ++
2425 ++config MBARCELONA
2426 ++ bool "AMD Barcelona"
2427 ++ ---help---
2428 ++ Select this for AMD Barcelona and newer processors.
2429 ++
2430 ++ Enables -march=barcelona
2431 ++
2432 ++config MBOBCAT
2433 ++ bool "AMD Bobcat"
2434 ++ ---help---
2435 ++ Select this for AMD Bobcat processors.
2436 ++
2437 ++ Enables -march=btver1
2438 ++
2439 ++config MBULLDOZER
2440 ++ bool "AMD Bulldozer"
2441 ++ ---help---
2442 ++ Select this for AMD Bulldozer processors.
2443 ++
2444 ++ Enables -march=bdver1
2445 ++
2446 ++config MPILEDRIVER
2447 ++ bool "AMD Piledriver"
2448 ++ ---help---
2449 ++ Select this for AMD Piledriver processors.
2450 ++
2451 ++ Enables -march=bdver2
2452 ++
2453 ++config MJAGUAR
2454 ++ bool "AMD Jaguar"
2455 ++ ---help---
2456 ++ Select this for AMD Jaguar processors.
2457 ++
2458 ++ Enables -march=btver2
2459 ++
2460 + config MCRUSOE
2461 + bool "Crusoe"
2462 + depends on X86_32
2463 +@@ -251,8 +294,17 @@ config MPSC
2464 + using the cpu family field
2465 + in /proc/cpuinfo. Family 15 is an older Xeon, Family 6 a newer one.
2466 +
2467 ++config MATOM
2468 ++ bool "Intel Atom"
2469 ++ ---help---
2470 ++
2471 ++ Select this for the Intel Atom platform. Intel Atom CPUs have an
2472 ++ in-order pipelining architecture and thus can benefit from
2473 ++ accordingly optimized code. Use a recent GCC with specific Atom
2474 ++ support in order to fully benefit from selecting this option.
2475 ++
2476 + config MCORE2
2477 +- bool "Core 2/newer Xeon"
2478 ++ bool "Intel Core 2"
2479 + ---help---
2480 +
2481 + Select this for Intel Core 2 and newer Core 2 Xeons (Xeon 51xx and
2482 +@@ -260,14 +312,40 @@ config MCORE2
2483 + family in /proc/cpuinfo. Newer ones have 6 and older ones 15
2484 + (not a typo)
2485 +
2486 +-config MATOM
2487 +- bool "Intel Atom"
2488 ++ Enables -march=core2
2489 ++
2490 ++config MCOREI7
2491 ++ bool "Intel Core i7"
2492 + ---help---
2493 +
2494 +- Select this for the Intel Atom platform. Intel Atom CPUs have an
2495 +- in-order pipelining architecture and thus can benefit from
2496 +- accordingly optimized code. Use a recent GCC with specific Atom
2497 +- support in order to fully benefit from selecting this option.
2498 ++ Select this for the Intel Nehalem platform. Intel Nehalem proecessors
2499 ++ include Core i3, i5, i7, Xeon: 34xx, 35xx, 55xx, 56xx, 75xx processors.
2500 ++
2501 ++ Enables -march=corei7
2502 ++
2503 ++config MCOREI7AVX
2504 ++ bool "Intel Core 2nd Gen AVX"
2505 ++ ---help---
2506 ++
2507 ++ Select this for 2nd Gen Core processors including Sandy Bridge.
2508 ++
2509 ++ Enables -march=corei7-avx
2510 ++
2511 ++config MCOREAVXI
2512 ++ bool "Intel Core 3rd Gen AVX"
2513 ++ ---help---
2514 ++
2515 ++ Select this for 3rd Gen Core processors including Ivy Bridge.
2516 ++
2517 ++ Enables -march=core-avx-i
2518 ++
2519 ++config MCOREAVX2
2520 ++ bool "Intel Core AVX2"
2521 ++ ---help---
2522 ++
2523 ++ Select this for AVX2 enabled processors including Haswell.
2524 ++
2525 ++ Enables -march=core-avx2
2526 +
2527 + config GENERIC_CPU
2528 + bool "Generic-x86-64"
2529 +@@ -276,6 +354,19 @@ config GENERIC_CPU
2530 + Generic x86-64 CPU.
2531 + Run equally well on all x86-64 CPUs.
2532 +
2533 ++config MNATIVE
2534 ++ bool "Native optimizations autodetected by GCC"
2535 ++ ---help---
2536 ++
2537 ++ GCC 4.2 and above support -march=native, which automatically detects
2538 ++ the optimum settings to use based on your processor. -march=native
2539 ++ also detects and applies additional settings beyond -march specific
2540 ++ to your CPU, (eg. -msse4). Unless you have a specific reason not to
2541 ++ (e.g. distcc cross-compiling), you should probably be using
2542 ++ -march=native rather than anything listed below.
2543 ++
2544 ++ Enables -march=native
2545 ++
2546 + endchoice
2547 +
2548 + config X86_GENERIC
2549 +@@ -300,7 +391,7 @@ config X86_INTERNODE_CACHE_SHIFT
2550 + config X86_L1_CACHE_SHIFT
2551 + int
2552 + default "7" if MPENTIUM4 || MPSC
2553 +- default "6" if MK7 || MK8 || MPENTIUMM || MCORE2 || MATOM || MVIAC7 || X86_GENERIC || GENERIC_CPU
2554 ++ default "6" if MK7 || MK8 || MK10 || MBARCELONA || MBOBCAT || MBULLDOZER || MPILEDRIVER || MJAGUAR || MPENTIUMM || MCORE2 || MCOREI7 || MCOREI7AVX || MCOREAVXI || MCOREAVX2 || MATOM || MVIAC7 || X86_GENERIC || MNATIVE || GENERIC_CPU
2555 + default "4" if MELAN || M486 || MGEODEGX1
2556 + default "5" if MWINCHIP3D || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODE_LX
2557 +
2558 +@@ -331,11 +422,11 @@ config X86_ALIGNMENT_16
2559 +
2560 + config X86_INTEL_USERCOPY
2561 + def_bool y
2562 +- depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK7 || MEFFICEON || MCORE2
2563 ++ depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || MNATIVE || X86_GENERIC || MK8 || MK7 || MK10 || MBARCELONA || MEFFICEON || MCORE2 || MCOREI7 || MCOREI7AVX || MCOREAVXI || MCOREAVX2
2564 +
2565 + config X86_USE_PPRO_CHECKSUM
2566 + def_bool y
2567 +- depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 || MVIAC7 || MEFFICEON || MGEODE_LX || MCORE2 || MATOM
2568 ++ depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MK10 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 || MVIAC7 || MEFFICEON || MGEODE_LX || MCORE2 || MCOREI7 || MCOREI7AVX || MCOREAVXI || MCOREAVX2 || MATOM || MNATIVE
2569 +
2570 + config X86_USE_3DNOW
2571 + def_bool y
2572 +@@ -363,17 +454,17 @@ config X86_P6_NOP
2573 +
2574 + config X86_TSC
2575 + def_bool y
2576 +- depends on (MWINCHIP3D || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MVIAC7 || MGEODEGX1 || MGEODE_LX || MCORE2 || MATOM) || X86_64
2577 ++ depends on (MWINCHIP3D || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MK10 || MBARCELONA || MBOBCAT || MBULLDOZER || MPILEDRIVER || MJAGUAR || MVIAC3_2 || MVIAC7 || MGEODEGX1 || MGEODE_LX || MCORE2 || MCOREI7 || MCOREI7-AVX || MATOM) || X86_64 || MNATIVE
2578 +
2579 + config X86_CMPXCHG64
2580 + def_bool y
2581 +- depends on X86_PAE || X86_64 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MATOM
2582 ++ depends on X86_PAE || X86_64 || MCORE2 || MCOREI7 || MCOREI7AVX || MCOREAVXI || MCOREAVX2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MATOM || MNATIVE
2583 +
2584 + # this should be set for all -march=.. options where the compiler
2585 + # generates cmov.
2586 + config X86_CMOV
2587 + def_bool y
2588 +- depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
2589 ++ depends on (MK8 || MK10 || MBARCELONA || MBOBCAT || MBULLDOZER || MPILEDRIVER || MJAGUAR || MK7 || MCORE2 || MCOREI7 || MCOREI7AVX || MCOREAVXI || MCOREAVX2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MNATIVE || MATOM || MGEODE_LX)
2590 +
2591 + config X86_MINIMUM_CPU_FAMILY
2592 + int
2593 +diff -uprN a/arch/x86/Makefile b/arch/x86/Makefile
2594 +--- a/arch/x86/Makefile 2013-11-03 18:41:51.000000000 -0500
2595 ++++ b/arch/x86/Makefile 2013-12-15 06:21:24.354455723 -0500
2596 +@@ -61,11 +61,26 @@ else
2597 + KBUILD_CFLAGS += $(call cc-option,-mno-sse -mpreferred-stack-boundary=3)
2598 +
2599 + # FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu)
2600 ++ cflags-$(CONFIG_MNATIVE) += $(call cc-option,-march=native)
2601 + cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
2602 ++ cflags-$(CONFIG_MK10) += $(call cc-option,-march=amdfam10)
2603 ++ cflags-$(CONFIG_MBARCELONA) += $(call cc-option,-march=barcelona)
2604 ++ cflags-$(CONFIG_MBOBCAT) += $(call cc-option,-march=btver1)
2605 ++ cflags-$(CONFIG_MBULLDOZER) += $(call cc-option,-march=bdver1)
2606 ++ cflags-$(CONFIG_MPILEDRIVER) += $(call cc-option,-march=bdver2)
2607 ++ cflags-$(CONFIG_MJAGUAR) += $(call cc-option,-march=btver2)
2608 + cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
2609 +
2610 + cflags-$(CONFIG_MCORE2) += \
2611 +- $(call cc-option,-march=core2,$(call cc-option,-mtune=generic))
2612 ++ $(call cc-option,-march=core2,$(call cc-option,-mtune=core2))
2613 ++ cflags-$(CONFIG_MCOREI7) += \
2614 ++ $(call cc-option,-march=corei7,$(call cc-option,-mtune=corei7))
2615 ++ cflags-$(CONFIG_MCOREI7AVX) += \
2616 ++ $(call cc-option,-march=corei7-avx,$(call cc-option,-mtune=corei7-avx))
2617 ++ cflags-$(CONFIG_MCOREAVXI) += \
2618 ++ $(call cc-option,-march=core-avx-i,$(call cc-option,-mtune=core-avx-i))
2619 ++ cflags-$(CONFIG_MCOREAVX2) += \
2620 ++ $(call cc-option,-march=core-avx2,$(call cc-option,-mtune=core-avx2))
2621 + cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom) \
2622 + $(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
2623 + cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
2624 +diff -uprN a/arch/x86/Makefile_32.cpu b/arch/x86/Makefile_32.cpu
2625 +--- a/arch/x86/Makefile_32.cpu 2013-11-03 18:41:51.000000000 -0500
2626 ++++ b/arch/x86/Makefile_32.cpu 2013-12-15 06:21:24.354455723 -0500
2627 +@@ -23,7 +23,14 @@ cflags-$(CONFIG_MK6) += -march=k6
2628 + # Please note, that patches that add -march=athlon-xp and friends are pointless.
2629 + # They make zero difference whatsosever to performance at this time.
2630 + cflags-$(CONFIG_MK7) += -march=athlon
2631 ++cflags-$(CONFIG_MNATIVE) += $(call cc-option,-march=native)
2632 + cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8,-march=athlon)
2633 ++cflags-$(CONFIG_MK10) += $(call cc-option,-march=amdfam10,-march=athlon)
2634 ++cflags-$(CONFIG_MBARCELONA) += $(call cc-option,-march=barcelona,-march=athlon)
2635 ++cflags-$(CONFIG_MBOBCAT) += $(call cc-option,-march=btver1,-march=athlon)
2636 ++cflags-$(CONFIG_MBULLDOZER) += $(call cc-option,-march=bdver1,-march=athlon)
2637 ++cflags-$(CONFIG_MPILEDRIVER) += $(call cc-option,-march=bdver2,-march=athlon)
2638 ++cflags-$(CONFIG_MJAGUAR) += $(call cc-option,-march=btver2,-march=athlon)
2639 + cflags-$(CONFIG_MCRUSOE) += -march=i686 $(align)-functions=0 $(align)-jumps=0 $(align)-loops=0
2640 + cflags-$(CONFIG_MEFFICEON) += -march=i686 $(call tune,pentium3) $(align)-functions=0 $(align)-jumps=0 $(align)-loops=0
2641 + cflags-$(CONFIG_MWINCHIPC6) += $(call cc-option,-march=winchip-c6,-march=i586)
2642 +@@ -32,6 +39,10 @@ cflags-$(CONFIG_MCYRIXIII) += $(call cc-
2643 + cflags-$(CONFIG_MVIAC3_2) += $(call cc-option,-march=c3-2,-march=i686)
2644 + cflags-$(CONFIG_MVIAC7) += -march=i686
2645 + cflags-$(CONFIG_MCORE2) += -march=i686 $(call tune,core2)
2646 ++cflags-$(CONFIG_MCOREI7) += -march=i686 $(call tune,corei7)
2647 ++cflags-$(CONFIG_MCOREI7AVX) += -march=i686 $(call tune,corei7-avx)
2648 ++cflags-$(CONFIG_MCOREAVXI) += -march=i686 $(call tune,core-avx-i)
2649 ++cflags-$(CONFIG_MCOREAVX2) += -march=i686 $(call tune,core-avx2)
2650 + cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom,$(call cc-option,-march=core2,-march=i686)) \
2651 + $(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))