patch-fblogo 60 KB

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