fblogo.patch 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057
  1. diff -Nur linux-3.18.9.orig/Documentation/fb/00-INDEX linux-3.18.9/Documentation/fb/00-INDEX
  2. --- linux-3.18.9.orig/Documentation/fb/00-INDEX 2015-03-06 16:53:42.000000000 -0600
  3. +++ linux-3.18.9/Documentation/fb/00-INDEX 2015-03-15 14:34:13.068143682 -0500
  4. @@ -23,6 +23,8 @@
  5. - info on the driver for EP93xx LCD controller.
  6. fbcon.txt
  7. - intro to and usage guide for the framebuffer console (fbcon).
  8. +fbcondecor.txt
  9. + - info on the Framebuffer Console Decoration
  10. framebuffer.txt
  11. - introduction to frame buffer devices.
  12. gxfb.txt
  13. diff -Nur linux-3.18.9.orig/Documentation/fb/fbcondecor.txt linux-3.18.9/Documentation/fb/fbcondecor.txt
  14. --- linux-3.18.9.orig/Documentation/fb/fbcondecor.txt 1969-12-31 18:00:00.000000000 -0600
  15. +++ linux-3.18.9/Documentation/fb/fbcondecor.txt 2015-03-15 14:34:13.068143682 -0500
  16. @@ -0,0 +1,207 @@
  17. +What is it?
  18. +-----------
  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.18.9.orig/drivers/Makefile linux-3.18.9/drivers/Makefile
  225. --- linux-3.18.9.orig/drivers/Makefile 2015-03-06 16:53:42.000000000 -0600
  226. +++ linux-3.18.9/drivers/Makefile 2015-03-15 14:34:13.068143682 -0500
  227. @@ -17,6 +17,10 @@
  228. obj-$(CONFIG_PCI) += pci/
  229. obj-$(CONFIG_PARISC) += parisc/
  230. obj-$(CONFIG_RAPIDIO) += rapidio/
  231. +# tty/ comes before char/ so that the VT console is the boot-time
  232. +# default.
  233. +obj-y += tty/
  234. +obj-y += char/
  235. obj-y += video/
  236. obj-y += idle/
  237. @@ -45,11 +49,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.18.9.orig/drivers/video/console/bitblit.c linux-3.18.9/drivers/video/console/bitblit.c
  248. --- linux-3.18.9.orig/drivers/video/console/bitblit.c 2015-03-06 16:53:42.000000000 -0600
  249. +++ linux-3.18.9/drivers/video/console/bitblit.c 2015-03-15 14:34:13.068143682 -0500
  250. @@ -18,6 +18,7 @@
  251. #include <linux/console.h>
  252. #include <asm/types.h>
  253. #include "fbcon.h"
  254. +#include "fbcondecor.h"
  255. /*
  256. * Accelerated handlers.
  257. @@ -55,6 +56,13 @@
  258. area.height = height * vc->vc_font.height;
  259. area.width = width * vc->vc_font.width;
  260. + if (fbcon_decor_active(info, vc)) {
  261. + area.sx += vc->vc_decor.tx;
  262. + area.sy += vc->vc_decor.ty;
  263. + area.dx += vc->vc_decor.tx;
  264. + area.dy += vc->vc_decor.ty;
  265. + }
  266. +
  267. info->fbops->fb_copyarea(info, &area);
  268. }
  269. @@ -379,11 +387,15 @@
  270. cursor.image.depth = 1;
  271. cursor.rop = ROP_XOR;
  272. - if (info->fbops->fb_cursor)
  273. - err = info->fbops->fb_cursor(info, &cursor);
  274. + if (fbcon_decor_active(info, vc)) {
  275. + fbcon_decor_cursor(info, &cursor);
  276. + } else {
  277. + if (info->fbops->fb_cursor)
  278. + err = info->fbops->fb_cursor(info, &cursor);
  279. - if (err)
  280. - soft_cursor(info, &cursor);
  281. + if (err)
  282. + soft_cursor(info, &cursor);
  283. + }
  284. ops->cursor_reset = 0;
  285. }
  286. diff -Nur linux-3.18.9.orig/drivers/video/console/cfbcondecor.c linux-3.18.9/drivers/video/console/cfbcondecor.c
  287. --- linux-3.18.9.orig/drivers/video/console/cfbcondecor.c 1969-12-31 18:00:00.000000000 -0600
  288. +++ linux-3.18.9/drivers/video/console/cfbcondecor.c 2015-03-15 14:34:13.072143681 -0500
  289. @@ -0,0 +1,471 @@
  290. +/*
  291. + * linux/drivers/video/cfbcon_decor.c -- Framebuffer decor render functions
  292. + *
  293. + * Copyright (C) 2004 Michal Januszewski <michalj+fbcondecor@gmail.com>
  294. + *
  295. + * Code based upon "Bootdecor" (C) 2001-2003
  296. + * Volker Poplawski <volker@poplawski.de>,
  297. + * Stefan Reinauer <stepan@suse.de>,
  298. + * Steffen Winterfeldt <snwint@suse.de>,
  299. + * Michael Schroeder <mls@suse.de>,
  300. + * Ken Wimer <wimer@suse.de>.
  301. + *
  302. + * This file is subject to the terms and conditions of the GNU General Public
  303. + * License. See the file COPYING in the main directory of this archive for
  304. + * more details.
  305. + */
  306. +#include <linux/module.h>
  307. +#include <linux/types.h>
  308. +#include <linux/fb.h>
  309. +#include <linux/selection.h>
  310. +#include <linux/slab.h>
  311. +#include <linux/vt_kern.h>
  312. +#include <asm/irq.h>
  313. +
  314. +#include "fbcon.h"
  315. +#include "fbcondecor.h"
  316. +
  317. +#define parse_pixel(shift,bpp,type) \
  318. + do { \
  319. + if (d & (0x80 >> (shift))) \
  320. + dd2[(shift)] = fgx; \
  321. + else \
  322. + dd2[(shift)] = transparent ? *(type *)decor_src : bgx; \
  323. + decor_src += (bpp); \
  324. + } while (0) \
  325. +
  326. +extern int get_color(struct vc_data *vc, struct fb_info *info,
  327. + u16 c, int is_fg);
  328. +
  329. +void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc)
  330. +{
  331. + int i, j, k;
  332. + int minlen = min(min(info->var.red.length, info->var.green.length),
  333. + info->var.blue.length);
  334. + u32 col;
  335. +
  336. + for (j = i = 0; i < 16; i++) {
  337. + k = color_table[i];
  338. +
  339. + col = ((vc->vc_palette[j++] >> (8-minlen))
  340. + << info->var.red.offset);
  341. + col |= ((vc->vc_palette[j++] >> (8-minlen))
  342. + << info->var.green.offset);
  343. + col |= ((vc->vc_palette[j++] >> (8-minlen))
  344. + << info->var.blue.offset);
  345. + ((u32 *)info->pseudo_palette)[k] = col;
  346. + }
  347. +}
  348. +
  349. +void fbcon_decor_renderc(struct fb_info *info, int ypos, int xpos, int height,
  350. + int width, u8* src, u32 fgx, u32 bgx, u8 transparent)
  351. +{
  352. + unsigned int x, y;
  353. + u32 dd;
  354. + int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
  355. + unsigned int d = ypos * info->fix.line_length + xpos * bytespp;
  356. + unsigned int ds = (ypos * info->var.xres + xpos) * bytespp;
  357. + u16 dd2[4];
  358. +
  359. + u8* decor_src = (u8 *)(info->bgdecor.data + ds);
  360. + u8* dst = (u8 *)(info->screen_base + d);
  361. +
  362. + if ((ypos + height) > info->var.yres || (xpos + width) > info->var.xres)
  363. + return;
  364. +
  365. + for (y = 0; y < height; y++) {
  366. + switch (info->var.bits_per_pixel) {
  367. +
  368. + case 32:
  369. + for (x = 0; x < width; x++) {
  370. +
  371. + if ((x & 7) == 0)
  372. + d = *src++;
  373. + if (d & 0x80)
  374. + dd = fgx;
  375. + else
  376. + dd = transparent ?
  377. + *(u32 *)decor_src : bgx;
  378. +
  379. + d <<= 1;
  380. + decor_src += 4;
  381. + fb_writel(dd, dst);
  382. + dst += 4;
  383. + }
  384. + break;
  385. + case 24:
  386. + for (x = 0; x < width; x++) {
  387. +
  388. + if ((x & 7) == 0)
  389. + d = *src++;
  390. + if (d & 0x80)
  391. + dd = fgx;
  392. + else
  393. + dd = transparent ?
  394. + (*(u32 *)decor_src & 0xffffff) : bgx;
  395. +
  396. + d <<= 1;
  397. + decor_src += 3;
  398. +#ifdef __LITTLE_ENDIAN
  399. + fb_writew(dd & 0xffff, dst);
  400. + dst += 2;
  401. + fb_writeb((dd >> 16), dst);
  402. +#else
  403. + fb_writew(dd >> 8, dst);
  404. + dst += 2;
  405. + fb_writeb(dd & 0xff, dst);
  406. +#endif
  407. + dst++;
  408. + }
  409. + break;
  410. + case 16:
  411. + for (x = 0; x < width; x += 2) {
  412. + if ((x & 7) == 0)
  413. + d = *src++;
  414. +
  415. + parse_pixel(0, 2, u16);
  416. + parse_pixel(1, 2, u16);
  417. +#ifdef __LITTLE_ENDIAN
  418. + dd = dd2[0] | (dd2[1] << 16);
  419. +#else
  420. + dd = dd2[1] | (dd2[0] << 16);
  421. +#endif
  422. + d <<= 2;
  423. + fb_writel(dd, dst);
  424. + dst += 4;
  425. + }
  426. + break;
  427. +
  428. + case 8:
  429. + for (x = 0; x < width; x += 4) {
  430. + if ((x & 7) == 0)
  431. + d = *src++;
  432. +
  433. + parse_pixel(0, 1, u8);
  434. + parse_pixel(1, 1, u8);
  435. + parse_pixel(2, 1, u8);
  436. + parse_pixel(3, 1, u8);
  437. +
  438. +#ifdef __LITTLE_ENDIAN
  439. + dd = dd2[0] | (dd2[1] << 8) | (dd2[2] << 16) | (dd2[3] << 24);
  440. +#else
  441. + dd = dd2[3] | (dd2[2] << 8) | (dd2[1] << 16) | (dd2[0] << 24);
  442. +#endif
  443. + d <<= 4;
  444. + fb_writel(dd, dst);
  445. + dst += 4;
  446. + }
  447. + }
  448. +
  449. + dst += info->fix.line_length - width * bytespp;
  450. + decor_src += (info->var.xres - width) * bytespp;
  451. + }
  452. +}
  453. +
  454. +#define cc2cx(a) \
  455. + ((info->fix.visual == FB_VISUAL_TRUECOLOR || \
  456. + info->fix.visual == FB_VISUAL_DIRECTCOLOR) ? \
  457. + ((u32*)info->pseudo_palette)[a] : a)
  458. +
  459. +void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info,
  460. + const unsigned short *s, int count, int yy, int xx)
  461. +{
  462. + unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
  463. + struct fbcon_ops *ops = info->fbcon_par;
  464. + int fg_color, bg_color, transparent;
  465. + u8 *src;
  466. + u32 bgx, fgx;
  467. + u16 c = scr_readw(s);
  468. +
  469. + fg_color = get_color(vc, info, c, 1);
  470. + bg_color = get_color(vc, info, c, 0);
  471. +
  472. + /* Don't paint the background image if console is blanked */
  473. + transparent = ops->blank_state ? 0 :
  474. + (vc->vc_decor.bg_color == bg_color);
  475. +
  476. + xx = xx * vc->vc_font.width + vc->vc_decor.tx;
  477. + yy = yy * vc->vc_font.height + vc->vc_decor.ty;
  478. +
  479. + fgx = cc2cx(fg_color);
  480. + bgx = cc2cx(bg_color);
  481. +
  482. + while (count--) {
  483. + c = scr_readw(s++);
  484. + src = vc->vc_font.data + (c & charmask) * vc->vc_font.height *
  485. + ((vc->vc_font.width + 7) >> 3);
  486. +
  487. + fbcon_decor_renderc(info, yy, xx, vc->vc_font.height,
  488. + vc->vc_font.width, src, fgx, bgx, transparent);
  489. + xx += vc->vc_font.width;
  490. + }
  491. +}
  492. +
  493. +void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor)
  494. +{
  495. + int i;
  496. + unsigned int dsize, s_pitch;
  497. + struct fbcon_ops *ops = info->fbcon_par;
  498. + struct vc_data* vc;
  499. + u8 *src;
  500. +
  501. + /* we really don't need any cursors while the console is blanked */
  502. + if (info->state != FBINFO_STATE_RUNNING || ops->blank_state)
  503. + return;
  504. +
  505. + vc = vc_cons[ops->currcon].d;
  506. +
  507. + src = kmalloc(64 + sizeof(struct fb_image), GFP_ATOMIC);
  508. + if (!src)
  509. + return;
  510. +
  511. + s_pitch = (cursor->image.width + 7) >> 3;
  512. + dsize = s_pitch * cursor->image.height;
  513. + if (cursor->enable) {
  514. + switch (cursor->rop) {
  515. + case ROP_XOR:
  516. + for (i = 0; i < dsize; i++)
  517. + src[i] = cursor->image.data[i] ^ cursor->mask[i];
  518. + break;
  519. + case ROP_COPY:
  520. + default:
  521. + for (i = 0; i < dsize; i++)
  522. + src[i] = cursor->image.data[i] & cursor->mask[i];
  523. + break;
  524. + }
  525. + } else
  526. + memcpy(src, cursor->image.data, dsize);
  527. +
  528. + fbcon_decor_renderc(info,
  529. + cursor->image.dy + vc->vc_decor.ty,
  530. + cursor->image.dx + vc->vc_decor.tx,
  531. + cursor->image.height,
  532. + cursor->image.width,
  533. + (u8*)src,
  534. + cc2cx(cursor->image.fg_color),
  535. + cc2cx(cursor->image.bg_color),
  536. + cursor->image.bg_color == vc->vc_decor.bg_color);
  537. +
  538. + kfree(src);
  539. +}
  540. +
  541. +static void decorset(u8 *dst, int height, int width, int dstbytes,
  542. + u32 bgx, int bpp)
  543. +{
  544. + int i;
  545. +
  546. + if (bpp == 8)
  547. + bgx |= bgx << 8;
  548. + if (bpp == 16 || bpp == 8)
  549. + bgx |= bgx << 16;
  550. +
  551. + while (height-- > 0) {
  552. + u8 *p = dst;
  553. +
  554. + switch (bpp) {
  555. +
  556. + case 32:
  557. + for (i=0; i < width; i++) {
  558. + fb_writel(bgx, p); p += 4;
  559. + }
  560. + break;
  561. + case 24:
  562. + for (i=0; i < width; i++) {
  563. +#ifdef __LITTLE_ENDIAN
  564. + fb_writew((bgx & 0xffff),(u16*)p); p += 2;
  565. + fb_writeb((bgx >> 16),p++);
  566. +#else
  567. + fb_writew((bgx >> 8),(u16*)p); p += 2;
  568. + fb_writeb((bgx & 0xff),p++);
  569. +#endif
  570. + }
  571. + case 16:
  572. + for (i=0; i < width/4; i++) {
  573. + fb_writel(bgx,p); p += 4;
  574. + fb_writel(bgx,p); p += 4;
  575. + }
  576. + if (width & 2) {
  577. + fb_writel(bgx,p); p += 4;
  578. + }
  579. + if (width & 1)
  580. + fb_writew(bgx,(u16*)p);
  581. + break;
  582. + case 8:
  583. + for (i=0; i < width/4; i++) {
  584. + fb_writel(bgx,p); p += 4;
  585. + }
  586. +
  587. + if (width & 2) {
  588. + fb_writew(bgx,p); p += 2;
  589. + }
  590. + if (width & 1)
  591. + fb_writeb(bgx,(u8*)p);
  592. + break;
  593. +
  594. + }
  595. + dst += dstbytes;
  596. + }
  597. +}
  598. +
  599. +void fbcon_decor_copy(u8 *dst, u8 *src, int height, int width, int linebytes,
  600. + int srclinebytes, int bpp)
  601. +{
  602. + int i;
  603. +
  604. + while (height-- > 0) {
  605. + u32 *p = (u32 *)dst;
  606. + u32 *q = (u32 *)src;
  607. +
  608. + switch (bpp) {
  609. +
  610. + case 32:
  611. + for (i=0; i < width; i++)
  612. + fb_writel(*q++, p++);
  613. + break;
  614. + case 24:
  615. + for (i=0; i < (width*3/4); i++)
  616. + fb_writel(*q++, p++);
  617. + if ((width*3) % 4) {
  618. + if (width & 2) {
  619. + fb_writeb(*(u8*)q, (u8*)p);
  620. + } else if (width & 1) {
  621. + fb_writew(*(u16*)q, (u16*)p);
  622. + fb_writeb(*(u8*)((u16*)q+1),(u8*)((u16*)p+2));
  623. + }
  624. + }
  625. + break;
  626. + case 16:
  627. + for (i=0; i < width/4; i++) {
  628. + fb_writel(*q++, p++);
  629. + fb_writel(*q++, p++);
  630. + }
  631. + if (width & 2)
  632. + fb_writel(*q++, p++);
  633. + if (width & 1)
  634. + fb_writew(*(u16*)q, (u16*)p);
  635. + break;
  636. + case 8:
  637. + for (i=0; i < width/4; i++)
  638. + fb_writel(*q++, p++);
  639. +
  640. + if (width & 2) {
  641. + fb_writew(*(u16*)q, (u16*)p);
  642. + q = (u32*) ((u16*)q + 1);
  643. + p = (u32*) ((u16*)p + 1);
  644. + }
  645. + if (width & 1)
  646. + fb_writeb(*(u8*)q, (u8*)p);
  647. + break;
  648. + }
  649. +
  650. + dst += linebytes;
  651. + src += srclinebytes;
  652. + }
  653. +}
  654. +
  655. +static void decorfill(struct fb_info *info, int sy, int sx, int height,
  656. + int width)
  657. +{
  658. + int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
  659. + int d = sy * info->fix.line_length + sx * bytespp;
  660. + int ds = (sy * info->var.xres + sx) * bytespp;
  661. +
  662. + fbcon_decor_copy((u8 *)(info->screen_base + d), (u8 *)(info->bgdecor.data + ds),
  663. + height, width, info->fix.line_length, info->var.xres * bytespp,
  664. + info->var.bits_per_pixel);
  665. +}
  666. +
  667. +void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx,
  668. + int height, int width)
  669. +{
  670. + int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
  671. + struct fbcon_ops *ops = info->fbcon_par;
  672. + u8 *dst;
  673. + int transparent, bg_color = attr_bgcol_ec(bgshift, vc, info);
  674. +
  675. + transparent = (vc->vc_decor.bg_color == bg_color);
  676. + sy = sy * vc->vc_font.height + vc->vc_decor.ty;
  677. + sx = sx * vc->vc_font.width + vc->vc_decor.tx;
  678. + height *= vc->vc_font.height;
  679. + width *= vc->vc_font.width;
  680. +
  681. + /* Don't paint the background image if console is blanked */
  682. + if (transparent && !ops->blank_state) {
  683. + decorfill(info, sy, sx, height, width);
  684. + } else {
  685. + dst = (u8 *)(info->screen_base + sy * info->fix.line_length +
  686. + sx * ((info->var.bits_per_pixel + 7) >> 3));
  687. + decorset(dst, height, width, info->fix.line_length, cc2cx(bg_color),
  688. + info->var.bits_per_pixel);
  689. + }
  690. +}
  691. +
  692. +void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info,
  693. + int bottom_only)
  694. +{
  695. + unsigned int tw = vc->vc_cols*vc->vc_font.width;
  696. + unsigned int th = vc->vc_rows*vc->vc_font.height;
  697. +
  698. + if (!bottom_only) {
  699. + /* top margin */
  700. + decorfill(info, 0, 0, vc->vc_decor.ty, info->var.xres);
  701. + /* left margin */
  702. + decorfill(info, vc->vc_decor.ty, 0, th, vc->vc_decor.tx);
  703. + /* right margin */
  704. + decorfill(info, vc->vc_decor.ty, vc->vc_decor.tx + tw, th,
  705. + info->var.xres - vc->vc_decor.tx - tw);
  706. + }
  707. + decorfill(info, vc->vc_decor.ty + th, 0,
  708. + info->var.yres - vc->vc_decor.ty - th, info->var.xres);
  709. +}
  710. +
  711. +void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y,
  712. + int sx, int dx, int width)
  713. +{
  714. + u16 *d = (u16 *) (vc->vc_origin + vc->vc_size_row * y + dx * 2);
  715. + u16 *s = d + (dx - sx);
  716. + u16 *start = d;
  717. + u16 *ls = d;
  718. + u16 *le = d + width;
  719. + u16 c;
  720. + int x = dx;
  721. + u16 attr = 1;
  722. +
  723. + do {
  724. + c = scr_readw(d);
  725. + if (attr != (c & 0xff00)) {
  726. + attr = c & 0xff00;
  727. + if (d > start) {
  728. + fbcon_decor_putcs(vc, info, start, d - start, y, x);
  729. + x += d - start;
  730. + start = d;
  731. + }
  732. + }
  733. + if (s >= ls && s < le && c == scr_readw(s)) {
  734. + if (d > start) {
  735. + fbcon_decor_putcs(vc, info, start, d - start, y, x);
  736. + x += d - start + 1;
  737. + start = d + 1;
  738. + } else {
  739. + x++;
  740. + start++;
  741. + }
  742. + }
  743. + s++;
  744. + d++;
  745. + } while (d < le);
  746. + if (d > start)
  747. + fbcon_decor_putcs(vc, info, start, d - start, y, x);
  748. +}
  749. +
  750. +void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank)
  751. +{
  752. + if (blank) {
  753. + decorset((u8 *)info->screen_base, info->var.yres, info->var.xres,
  754. + info->fix.line_length, 0, info->var.bits_per_pixel);
  755. + } else {
  756. + update_screen(vc);
  757. + fbcon_decor_clear_margins(vc, info, 0);
  758. + }
  759. +}
  760. +
  761. diff -Nur linux-3.18.9.orig/drivers/video/console/fbcon.c linux-3.18.9/drivers/video/console/fbcon.c
  762. --- linux-3.18.9.orig/drivers/video/console/fbcon.c 2015-03-06 16:53:42.000000000 -0600
  763. +++ linux-3.18.9/drivers/video/console/fbcon.c 2015-03-15 14:34:13.072143681 -0500
  764. @@ -79,6 +79,7 @@
  765. #include <asm/irq.h>
  766. #include "fbcon.h"
  767. +#include "fbcondecor.h"
  768. #ifdef FBCONDEBUG
  769. # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
  770. @@ -94,7 +95,7 @@
  771. static struct display fb_display[MAX_NR_CONSOLES];
  772. -static signed char con2fb_map[MAX_NR_CONSOLES];
  773. +signed char con2fb_map[MAX_NR_CONSOLES];
  774. static signed char con2fb_map_boot[MAX_NR_CONSOLES];
  775. static int logo_lines;
  776. @@ -286,7 +287,7 @@
  777. !vt_force_oops_output(vc);
  778. }
  779. -static int get_color(struct vc_data *vc, struct fb_info *info,
  780. +int get_color(struct vc_data *vc, struct fb_info *info,
  781. u16 c, int is_fg)
  782. {
  783. int depth = fb_get_color_depth(&info->var, &info->fix);
  784. @@ -550,6 +551,9 @@
  785. info_idx = -1;
  786. } else {
  787. fbcon_has_console_bind = 1;
  788. +#ifdef CONFIG_FB_CON_DECOR
  789. + fbcon_decor_init();
  790. +#endif
  791. }
  792. return err;
  793. @@ -1007,6 +1011,12 @@
  794. rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
  795. cols /= vc->vc_font.width;
  796. rows /= vc->vc_font.height;
  797. +
  798. + if (fbcon_decor_active(info, vc)) {
  799. + cols = vc->vc_decor.twidth / vc->vc_font.width;
  800. + rows = vc->vc_decor.theight / vc->vc_font.height;
  801. + }
  802. +
  803. vc_resize(vc, cols, rows);
  804. DPRINTK("mode: %s\n", info->fix.id);
  805. @@ -1036,7 +1046,7 @@
  806. cap = info->flags;
  807. if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
  808. - (info->fix.type == FB_TYPE_TEXT))
  809. + (info->fix.type == FB_TYPE_TEXT) || fbcon_decor_active(info, vc))
  810. logo = 0;
  811. if (var_to_display(p, &info->var, info))
  812. @@ -1260,6 +1270,11 @@
  813. fbcon_clear_margins(vc, 0);
  814. }
  815. + if (fbcon_decor_active(info, vc)) {
  816. + fbcon_decor_clear(vc, info, sy, sx, height, width);
  817. + return;
  818. + }
  819. +
  820. /* Split blits that cross physical y_wrap boundary */
  821. y_break = p->vrows - p->yscroll;
  822. @@ -1279,10 +1294,15 @@
  823. struct display *p = &fb_display[vc->vc_num];
  824. struct fbcon_ops *ops = info->fbcon_par;
  825. - if (!fbcon_is_inactive(vc, info))
  826. - ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
  827. - get_color(vc, info, scr_readw(s), 1),
  828. - get_color(vc, info, scr_readw(s), 0));
  829. + if (!fbcon_is_inactive(vc, info)) {
  830. +
  831. + if (fbcon_decor_active(info, vc))
  832. + fbcon_decor_putcs(vc, info, s, count, ypos, xpos);
  833. + else
  834. + ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
  835. + get_color(vc, info, scr_readw(s), 1),
  836. + get_color(vc, info, scr_readw(s), 0));
  837. + }
  838. }
  839. static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
  840. @@ -1298,8 +1318,13 @@
  841. struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
  842. struct fbcon_ops *ops = info->fbcon_par;
  843. - if (!fbcon_is_inactive(vc, info))
  844. - ops->clear_margins(vc, info, bottom_only);
  845. + if (!fbcon_is_inactive(vc, info)) {
  846. + if (fbcon_decor_active(info, vc)) {
  847. + fbcon_decor_clear_margins(vc, info, bottom_only);
  848. + } else {
  849. + ops->clear_margins(vc, info, bottom_only);
  850. + }
  851. + }
  852. }
  853. static void fbcon_cursor(struct vc_data *vc, int mode)
  854. @@ -1819,7 +1844,7 @@
  855. count = vc->vc_rows;
  856. if (softback_top)
  857. fbcon_softback_note(vc, t, count);
  858. - if (logo_shown >= 0)
  859. + if (logo_shown >= 0 || fbcon_decor_active(info, vc))
  860. goto redraw_up;
  861. switch (p->scrollmode) {
  862. case SCROLL_MOVE:
  863. @@ -1912,6 +1937,8 @@
  864. count = vc->vc_rows;
  865. if (logo_shown >= 0)
  866. goto redraw_down;
  867. + if (fbcon_decor_active(info, vc))
  868. + goto redraw_down;
  869. switch (p->scrollmode) {
  870. case SCROLL_MOVE:
  871. fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
  872. @@ -2060,6 +2087,13 @@
  873. }
  874. return;
  875. }
  876. +
  877. + if (fbcon_decor_active(info, vc) && sy == dy && height == 1) {
  878. + /* must use slower redraw bmove to keep background pic intact */
  879. + fbcon_decor_bmove_redraw(vc, info, sy, sx, dx, width);
  880. + return;
  881. + }
  882. +
  883. ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
  884. height, width);
  885. }
  886. @@ -2130,8 +2164,8 @@
  887. var.yres = virt_h * virt_fh;
  888. x_diff = info->var.xres - var.xres;
  889. y_diff = info->var.yres - var.yres;
  890. - if (x_diff < 0 || x_diff > virt_fw ||
  891. - y_diff < 0 || y_diff > virt_fh) {
  892. + if ((x_diff < 0 || x_diff > virt_fw ||
  893. + y_diff < 0 || y_diff > virt_fh) && !vc->vc_decor.state) {
  894. const struct fb_videomode *mode;
  895. DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
  896. @@ -2167,6 +2201,21 @@
  897. info = registered_fb[con2fb_map[vc->vc_num]];
  898. ops = info->fbcon_par;
  899. + prev_console = ops->currcon;
  900. + if (prev_console != -1)
  901. + old_info = registered_fb[con2fb_map[prev_console]];
  902. +
  903. +#ifdef CONFIG_FB_CON_DECOR
  904. + if (!fbcon_decor_active_vc(vc) && info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
  905. + struct vc_data *vc_curr = vc_cons[prev_console].d;
  906. + if (vc_curr && fbcon_decor_active_vc(vc_curr)) {
  907. + /* Clear the screen to avoid displaying funky colors during
  908. + * palette updates. */
  909. + memset((u8*)info->screen_base + info->fix.line_length * info->var.yoffset,
  910. + 0, info->var.yres * info->fix.line_length);
  911. + }
  912. + }
  913. +#endif
  914. if (softback_top) {
  915. if (softback_lines)
  916. @@ -2185,9 +2234,6 @@
  917. logo_shown = FBCON_LOGO_CANSHOW;
  918. }
  919. - prev_console = ops->currcon;
  920. - if (prev_console != -1)
  921. - old_info = registered_fb[con2fb_map[prev_console]];
  922. /*
  923. * FIXME: If we have multiple fbdev's loaded, we need to
  924. * update all info->currcon. Perhaps, we can place this
  925. @@ -2231,6 +2277,18 @@
  926. fbcon_del_cursor_timer(old_info);
  927. }
  928. + if (fbcon_decor_active_vc(vc)) {
  929. + struct vc_data *vc_curr = vc_cons[prev_console].d;
  930. +
  931. + if (!vc_curr->vc_decor.theme ||
  932. + strcmp(vc->vc_decor.theme, vc_curr->vc_decor.theme) ||
  933. + (fbcon_decor_active_nores(info, vc_curr) &&
  934. + !fbcon_decor_active(info, vc_curr))) {
  935. + fbcon_decor_disable(vc, 0);
  936. + fbcon_decor_call_helper("modechange", vc->vc_num);
  937. + }
  938. + }
  939. +
  940. if (fbcon_is_inactive(vc, info) ||
  941. ops->blank_state != FB_BLANK_UNBLANK)
  942. fbcon_del_cursor_timer(info);
  943. @@ -2339,15 +2397,20 @@
  944. }
  945. }
  946. - if (!fbcon_is_inactive(vc, info)) {
  947. + if (!fbcon_is_inactive(vc, info)) {
  948. if (ops->blank_state != blank) {
  949. ops->blank_state = blank;
  950. fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
  951. ops->cursor_flash = (!blank);
  952. - if (!(info->flags & FBINFO_MISC_USEREVENT))
  953. - if (fb_blank(info, blank))
  954. - fbcon_generic_blank(vc, info, blank);
  955. + if (!(info->flags & FBINFO_MISC_USEREVENT)) {
  956. + if (fb_blank(info, blank)) {
  957. + if (fbcon_decor_active(info, vc))
  958. + fbcon_decor_blank(vc, info, blank);
  959. + else
  960. + fbcon_generic_blank(vc, info, blank);
  961. + }
  962. + }
  963. }
  964. if (!blank)
  965. @@ -2522,13 +2585,22 @@
  966. }
  967. if (resize) {
  968. + /* reset wrap/pan */
  969. int cols, rows;
  970. cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
  971. rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
  972. +
  973. + if (fbcon_decor_active(info, vc)) {
  974. + info->var.xoffset = info->var.yoffset = p->yscroll = 0;
  975. + cols = vc->vc_decor.twidth;
  976. + rows = vc->vc_decor.theight;
  977. + }
  978. cols /= w;
  979. rows /= h;
  980. +
  981. vc_resize(vc, cols, rows);
  982. +
  983. if (CON_IS_VISIBLE(vc) && softback_buf)
  984. fbcon_update_softback(vc);
  985. } else if (CON_IS_VISIBLE(vc)
  986. @@ -2657,7 +2729,11 @@
  987. int i, j, k, depth;
  988. u8 val;
  989. - if (fbcon_is_inactive(vc, info))
  990. + if (fbcon_is_inactive(vc, info)
  991. +#ifdef CONFIG_FB_CON_DECOR
  992. + || vc->vc_num != fg_console
  993. +#endif
  994. + )
  995. return -EINVAL;
  996. if (!CON_IS_VISIBLE(vc))
  997. @@ -2683,14 +2759,56 @@
  998. } else
  999. fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap);
  1000. - return fb_set_cmap(&palette_cmap, info);
  1001. + if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
  1002. + info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
  1003. +
  1004. + u16 *red, *green, *blue;
  1005. + int minlen = min(min(info->var.red.length, info->var.green.length),
  1006. + info->var.blue.length);
  1007. + int h;
  1008. +
  1009. + struct fb_cmap cmap = {
  1010. + .start = 0,
  1011. + .len = (1 << minlen),
  1012. + .red = NULL,
  1013. + .green = NULL,
  1014. + .blue = NULL,
  1015. + .transp = NULL
  1016. + };
  1017. +
  1018. + red = kmalloc(256 * sizeof(u16) * 3, GFP_KERNEL);
  1019. +
  1020. + if (!red)
  1021. + goto out;
  1022. +
  1023. + green = red + 256;
  1024. + blue = green + 256;
  1025. + cmap.red = red;
  1026. + cmap.green = green;
  1027. + cmap.blue = blue;
  1028. +
  1029. + for (i = 0; i < cmap.len; i++) {
  1030. + red[i] = green[i] = blue[i] = (0xffff * i)/(cmap.len-1);
  1031. + }
  1032. +
  1033. + h = fb_set_cmap(&cmap, info);
  1034. + fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
  1035. + kfree(red);
  1036. +
  1037. + return h;
  1038. +
  1039. + } else if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
  1040. + info->var.bits_per_pixel == 8 && info->bgdecor.cmap.red != NULL)
  1041. + fb_set_cmap(&info->bgdecor.cmap, info);
  1042. +
  1043. +out: return fb_set_cmap(&palette_cmap, info);
  1044. }
  1045. static u16 *fbcon_screen_pos(struct vc_data *vc, int offset)
  1046. {
  1047. unsigned long p;
  1048. int line;
  1049. -
  1050. +
  1051. if (vc->vc_num != fg_console || !softback_lines)
  1052. return (u16 *) (vc->vc_origin + offset);
  1053. line = offset / vc->vc_size_row;
  1054. @@ -2909,7 +3027,14 @@
  1055. rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
  1056. cols /= vc->vc_font.width;
  1057. rows /= vc->vc_font.height;
  1058. - vc_resize(vc, cols, rows);
  1059. +
  1060. + if (!fbcon_decor_active_nores(info, vc)) {
  1061. + vc_resize(vc, cols, rows);
  1062. + } else {
  1063. + fbcon_decor_disable(vc, 0);
  1064. + fbcon_decor_call_helper("modechange", vc->vc_num);
  1065. + }
  1066. +
  1067. updatescrollmode(p, info, vc);
  1068. scrollback_max = 0;
  1069. scrollback_current = 0;
  1070. @@ -2954,7 +3079,9 @@
  1071. rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
  1072. cols /= vc->vc_font.width;
  1073. rows /= vc->vc_font.height;
  1074. - vc_resize(vc, cols, rows);
  1075. + if (!fbcon_decor_active_nores(info, vc)) {
  1076. + vc_resize(vc, cols, rows);
  1077. + }
  1078. }
  1079. if (fg != -1)
  1080. @@ -3596,6 +3723,7 @@
  1081. }
  1082. }
  1083. + fbcon_decor_exit();
  1084. fbcon_has_exited = 1;
  1085. }
  1086. diff -Nur linux-3.18.9.orig/drivers/video/console/fbcondecor.c linux-3.18.9/drivers/video/console/fbcondecor.c
  1087. --- linux-3.18.9.orig/drivers/video/console/fbcondecor.c 1969-12-31 18:00:00.000000000 -0600
  1088. +++ linux-3.18.9/drivers/video/console/fbcondecor.c 2015-03-15 14:34:13.076143680 -0500
  1089. @@ -0,0 +1,555 @@
  1090. +/*
  1091. + * linux/drivers/video/console/fbcondecor.c -- Framebuffer console decorations
  1092. + *
  1093. + * Copyright (C) 2004-2009 Michal Januszewski <michalj+fbcondecor@gmail.com>
  1094. + *
  1095. + * Code based upon "Bootsplash" (C) 2001-2003
  1096. + * Volker Poplawski <volker@poplawski.de>,
  1097. + * Stefan Reinauer <stepan@suse.de>,
  1098. + * Steffen Winterfeldt <snwint@suse.de>,
  1099. + * Michael Schroeder <mls@suse.de>,
  1100. + * Ken Wimer <wimer@suse.de>.
  1101. + *
  1102. + * Compat ioctl support by Thorsten Klein <TK@Thorsten-Klein.de>.
  1103. + *
  1104. + * This file is subject to the terms and conditions of the GNU General Public
  1105. + * License. See the file COPYING in the main directory of this archive for
  1106. + * more details.
  1107. + *
  1108. + */
  1109. +#include <linux/module.h>
  1110. +#include <linux/kernel.h>
  1111. +#include <linux/string.h>
  1112. +#include <linux/types.h>
  1113. +#include <linux/fb.h>
  1114. +#include <linux/vt_kern.h>
  1115. +#include <linux/vmalloc.h>
  1116. +#include <linux/unistd.h>
  1117. +#include <linux/syscalls.h>
  1118. +#include <linux/init.h>
  1119. +#include <linux/proc_fs.h>
  1120. +#include <linux/workqueue.h>
  1121. +#include <linux/kmod.h>
  1122. +#include <linux/miscdevice.h>
  1123. +#include <linux/device.h>
  1124. +#include <linux/fs.h>
  1125. +#include <linux/compat.h>
  1126. +#include <linux/console.h>
  1127. +
  1128. +#include <asm/uaccess.h>
  1129. +#include <asm/irq.h>
  1130. +
  1131. +#include "fbcon.h"
  1132. +#include "fbcondecor.h"
  1133. +
  1134. +extern signed char con2fb_map[];
  1135. +static int fbcon_decor_enable(struct vc_data *vc);
  1136. +char fbcon_decor_path[KMOD_PATH_LEN] = "/sbin/fbcondecor_helper";
  1137. +static int initialized = 0;
  1138. +
  1139. +int fbcon_decor_call_helper(char* cmd, unsigned short vc)
  1140. +{
  1141. + char *envp[] = {
  1142. + "HOME=/",
  1143. + "PATH=/sbin:/bin",
  1144. + NULL
  1145. + };
  1146. +
  1147. + char tfb[5];
  1148. + char tcons[5];
  1149. + unsigned char fb = (int) con2fb_map[vc];
  1150. +
  1151. + char *argv[] = {
  1152. + fbcon_decor_path,
  1153. + "2",
  1154. + cmd,
  1155. + tcons,
  1156. + tfb,
  1157. + vc_cons[vc].d->vc_decor.theme,
  1158. + NULL
  1159. + };
  1160. +
  1161. + snprintf(tfb,5,"%d",fb);
  1162. + snprintf(tcons,5,"%d",vc);
  1163. +
  1164. + return call_usermodehelper(fbcon_decor_path, argv, envp, UMH_WAIT_EXEC);
  1165. +}
  1166. +
  1167. +/* Disables fbcondecor on a virtual console; called with console sem held. */
  1168. +int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw)
  1169. +{
  1170. + struct fb_info* info;
  1171. +
  1172. + if (!vc->vc_decor.state)
  1173. + return -EINVAL;
  1174. +
  1175. + info = registered_fb[(int) con2fb_map[vc->vc_num]];
  1176. +
  1177. + if (info == NULL)
  1178. + return -EINVAL;
  1179. +
  1180. + vc->vc_decor.state = 0;
  1181. + vc_resize(vc, info->var.xres / vc->vc_font.width,
  1182. + info->var.yres / vc->vc_font.height);
  1183. +
  1184. + if (fg_console == vc->vc_num && redraw) {
  1185. + redraw_screen(vc, 0);
  1186. + update_region(vc, vc->vc_origin +
  1187. + vc->vc_size_row * vc->vc_top,
  1188. + vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
  1189. + }
  1190. +
  1191. + printk(KERN_INFO "fbcondecor: switched decor state to 'off' on console %d\n",
  1192. + vc->vc_num);
  1193. +
  1194. + return 0;
  1195. +}
  1196. +
  1197. +/* Enables fbcondecor on a virtual console; called with console sem held. */
  1198. +static int fbcon_decor_enable(struct vc_data *vc)
  1199. +{
  1200. + struct fb_info* info;
  1201. +
  1202. + info = registered_fb[(int) con2fb_map[vc->vc_num]];
  1203. +
  1204. + if (vc->vc_decor.twidth == 0 || vc->vc_decor.theight == 0 ||
  1205. + info == NULL || vc->vc_decor.state || (!info->bgdecor.data &&
  1206. + vc->vc_num == fg_console))
  1207. + return -EINVAL;
  1208. +
  1209. + vc->vc_decor.state = 1;
  1210. + vc_resize(vc, vc->vc_decor.twidth / vc->vc_font.width,
  1211. + vc->vc_decor.theight / vc->vc_font.height);
  1212. +
  1213. + if (fg_console == vc->vc_num) {
  1214. + redraw_screen(vc, 0);
  1215. + update_region(vc, vc->vc_origin +
  1216. + vc->vc_size_row * vc->vc_top,
  1217. + vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
  1218. + fbcon_decor_clear_margins(vc, info, 0);
  1219. + }
  1220. +
  1221. + printk(KERN_INFO "fbcondecor: switched decor state to 'on' on console %d\n",
  1222. + vc->vc_num);
  1223. +
  1224. + return 0;
  1225. +}
  1226. +
  1227. +static inline int fbcon_decor_ioctl_dosetstate(struct vc_data *vc, unsigned int state, unsigned char origin)
  1228. +{
  1229. + int ret;
  1230. +
  1231. +// if (origin == FBCON_DECOR_IO_ORIG_USER)
  1232. + console_lock();
  1233. + if (!state)
  1234. + ret = fbcon_decor_disable(vc, 1);
  1235. + else
  1236. + ret = fbcon_decor_enable(vc);
  1237. +// if (origin == FBCON_DECOR_IO_ORIG_USER)
  1238. + console_unlock();
  1239. +
  1240. + return ret;
  1241. +}
  1242. +
  1243. +static inline void fbcon_decor_ioctl_dogetstate(struct vc_data *vc, unsigned int *state)
  1244. +{
  1245. + *state = vc->vc_decor.state;
  1246. +}
  1247. +
  1248. +static int fbcon_decor_ioctl_dosetcfg(struct vc_data *vc, struct vc_decor *cfg, unsigned char origin)
  1249. +{
  1250. + struct fb_info *info;
  1251. + int len;
  1252. + char *tmp;
  1253. +
  1254. + info = registered_fb[(int) con2fb_map[vc->vc_num]];
  1255. +
  1256. + if (info == NULL || !cfg->twidth || !cfg->theight ||
  1257. + cfg->tx + cfg->twidth > info->var.xres ||
  1258. + cfg->ty + cfg->theight > info->var.yres)
  1259. + return -EINVAL;
  1260. +
  1261. + len = strlen_user(cfg->theme);
  1262. + if (!len || len > FBCON_DECOR_THEME_LEN)
  1263. + return -EINVAL;
  1264. + tmp = kmalloc(len, GFP_KERNEL);
  1265. + if (!tmp)
  1266. + return -ENOMEM;
  1267. + if (copy_from_user(tmp, (void __user *)cfg->theme, len))
  1268. + return -EFAULT;
  1269. + cfg->theme = tmp;
  1270. + cfg->state = 0;
  1271. +
  1272. + /* If this ioctl is a response to a request from kernel, the console sem
  1273. + * is already held; we also don't need to disable decor because either the
  1274. + * new config and background picture will be successfully loaded, and the
  1275. + * decor will stay on, or in case of a failure it'll be turned off in fbcon. */
  1276. +// if (origin == FBCON_DECOR_IO_ORIG_USER) {
  1277. + console_lock();
  1278. + if (vc->vc_decor.state)
  1279. + fbcon_decor_disable(vc, 1);
  1280. +// }
  1281. +
  1282. + if (vc->vc_decor.theme)
  1283. + kfree(vc->vc_decor.theme);
  1284. +
  1285. + vc->vc_decor = *cfg;
  1286. +
  1287. +// if (origin == FBCON_DECOR_IO_ORIG_USER)
  1288. + console_unlock();
  1289. +
  1290. + printk(KERN_INFO "fbcondecor: console %d using theme '%s'\n",
  1291. + vc->vc_num, vc->vc_decor.theme);
  1292. + return 0;
  1293. +}
  1294. +
  1295. +static int fbcon_decor_ioctl_dogetcfg(struct vc_data *vc, struct vc_decor *decor)
  1296. +{
  1297. + char __user *tmp;
  1298. +
  1299. + tmp = decor->theme;
  1300. + *decor = vc->vc_decor;
  1301. + decor->theme = tmp;
  1302. +
  1303. + if (vc->vc_decor.theme) {
  1304. + if (copy_to_user(tmp, vc->vc_decor.theme, strlen(vc->vc_decor.theme) + 1))
  1305. + return -EFAULT;
  1306. + } else
  1307. + if (put_user(0, tmp))
  1308. + return -EFAULT;
  1309. +
  1310. + return 0;
  1311. +}
  1312. +
  1313. +static int fbcon_decor_ioctl_dosetpic(struct vc_data *vc, struct fb_image *img, unsigned char origin)
  1314. +{
  1315. + struct fb_info *info;
  1316. + int len;
  1317. + u8 *tmp;
  1318. +
  1319. + if (vc->vc_num != fg_console)
  1320. + return -EINVAL;
  1321. +
  1322. + info = registered_fb[(int) con2fb_map[vc->vc_num]];
  1323. +
  1324. + if (info == NULL)
  1325. + return -EINVAL;
  1326. +
  1327. + if (img->width != info->var.xres || img->height != info->var.yres) {
  1328. + printk(KERN_ERR "fbcondecor: picture dimensions mismatch\n");
  1329. + printk(KERN_ERR "%dx%d vs %dx%d\n", img->width, img->height, info->var.xres, info->var.yres);
  1330. + return -EINVAL;
  1331. + }
  1332. +
  1333. + if (img->depth != info->var.bits_per_pixel) {
  1334. + printk(KERN_ERR "fbcondecor: picture depth mismatch\n");
  1335. + return -EINVAL;
  1336. + }
  1337. +
  1338. + if (img->depth == 8) {
  1339. + if (!img->cmap.len || !img->cmap.red || !img->cmap.green ||
  1340. + !img->cmap.blue)
  1341. + return -EINVAL;
  1342. +
  1343. + tmp = vmalloc(img->cmap.len * 3 * 2);
  1344. + if (!tmp)
  1345. + return -ENOMEM;
  1346. +
  1347. + if (copy_from_user(tmp,
  1348. + (void __user*)img->cmap.red, (img->cmap.len << 1)) ||
  1349. + copy_from_user(tmp + (img->cmap.len << 1),
  1350. + (void __user*)img->cmap.green, (img->cmap.len << 1)) ||
  1351. + copy_from_user(tmp + (img->cmap.len << 2),
  1352. + (void __user*)img->cmap.blue, (img->cmap.len << 1))) {
  1353. + vfree(tmp);
  1354. + return -EFAULT;
  1355. + }
  1356. +
  1357. + img->cmap.transp = NULL;
  1358. + img->cmap.red = (u16*)tmp;
  1359. + img->cmap.green = img->cmap.red + img->cmap.len;
  1360. + img->cmap.blue = img->cmap.green + img->cmap.len;
  1361. + } else {
  1362. + img->cmap.red = NULL;
  1363. + }
  1364. +
  1365. + len = ((img->depth + 7) >> 3) * img->width * img->height;
  1366. +
  1367. + /*
  1368. + * Allocate an additional byte so that we never go outside of the
  1369. + * buffer boundaries in the rendering functions in a 24 bpp mode.
  1370. + */
  1371. + tmp = vmalloc(len + 1);
  1372. +
  1373. + if (!tmp)
  1374. + goto out;
  1375. +
  1376. + if (copy_from_user(tmp, (void __user*)img->data, len))
  1377. + goto out;
  1378. +
  1379. + img->data = tmp;
  1380. +
  1381. + /* If this ioctl is a response to a request from kernel, the console sem
  1382. + * is already held. */
  1383. +// if (origin == FBCON_DECOR_IO_ORIG_USER)
  1384. + console_lock();
  1385. +
  1386. + if (info->bgdecor.data)
  1387. + vfree((u8*)info->bgdecor.data);
  1388. + if (info->bgdecor.cmap.red)
  1389. + vfree(info->bgdecor.cmap.red);
  1390. +
  1391. + info->bgdecor = *img;
  1392. +
  1393. + if (fbcon_decor_active_vc(vc) && fg_console == vc->vc_num) {
  1394. + redraw_screen(vc, 0);
  1395. + update_region(vc, vc->vc_origin +
  1396. + vc->vc_size_row * vc->vc_top,
  1397. + vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
  1398. + fbcon_decor_clear_margins(vc, info, 0);
  1399. + }
  1400. +
  1401. +// if (origin == FBCON_DECOR_IO_ORIG_USER)
  1402. + console_unlock();
  1403. +
  1404. + return 0;
  1405. +
  1406. +out: if (img->cmap.red)
  1407. + vfree(img->cmap.red);
  1408. +
  1409. + if (tmp)
  1410. + vfree(tmp);
  1411. + return -ENOMEM;
  1412. +}
  1413. +
  1414. +static long fbcon_decor_ioctl(struct file *filp, u_int cmd, u_long arg)
  1415. +{
  1416. + struct fbcon_decor_iowrapper __user *wrapper = (void __user*) arg;
  1417. + struct vc_data *vc = NULL;
  1418. + unsigned short vc_num = 0;
  1419. + unsigned char origin = 0;
  1420. + void __user *data = NULL;
  1421. +
  1422. + if (!access_ok(VERIFY_READ, wrapper,
  1423. + sizeof(struct fbcon_decor_iowrapper)))
  1424. + return -EFAULT;
  1425. +
  1426. + __get_user(vc_num, &wrapper->vc);
  1427. + __get_user(origin, &wrapper->origin);
  1428. + __get_user(data, &wrapper->data);
  1429. +
  1430. + if (!vc_cons_allocated(vc_num))
  1431. + return -EINVAL;
  1432. +
  1433. + vc = vc_cons[vc_num].d;
  1434. +
  1435. + switch (cmd) {
  1436. + case FBIOCONDECOR_SETPIC:
  1437. + {
  1438. + struct fb_image img;
  1439. + if (copy_from_user(&img, (struct fb_image __user *)data, sizeof(struct fb_image)))
  1440. + return -EFAULT;
  1441. +
  1442. + return fbcon_decor_ioctl_dosetpic(vc, &img, origin);
  1443. + }
  1444. + case FBIOCONDECOR_SETCFG:
  1445. + {
  1446. + struct vc_decor cfg;
  1447. + if (copy_from_user(&cfg, (struct vc_decor __user *)data, sizeof(struct vc_decor)))
  1448. + return -EFAULT;
  1449. +
  1450. + return fbcon_decor_ioctl_dosetcfg(vc, &cfg, origin);
  1451. + }
  1452. + case FBIOCONDECOR_GETCFG:
  1453. + {
  1454. + int rval;
  1455. + struct vc_decor cfg;
  1456. +
  1457. + if (copy_from_user(&cfg, (struct vc_decor __user *)data, sizeof(struct vc_decor)))
  1458. + return -EFAULT;
  1459. +
  1460. + rval = fbcon_decor_ioctl_dogetcfg(vc, &cfg);
  1461. +
  1462. + if (copy_to_user(data, &cfg, sizeof(struct vc_decor)))
  1463. + return -EFAULT;
  1464. + return rval;
  1465. + }
  1466. + case FBIOCONDECOR_SETSTATE:
  1467. + {
  1468. + unsigned int state = 0;
  1469. + if (get_user(state, (unsigned int __user *)data))
  1470. + return -EFAULT;
  1471. + return fbcon_decor_ioctl_dosetstate(vc, state, origin);
  1472. + }
  1473. + case FBIOCONDECOR_GETSTATE:
  1474. + {
  1475. + unsigned int state = 0;
  1476. + fbcon_decor_ioctl_dogetstate(vc, &state);
  1477. + return put_user(state, (unsigned int __user *)data);
  1478. + }
  1479. +
  1480. + default:
  1481. + return -ENOIOCTLCMD;
  1482. + }
  1483. +}
  1484. +
  1485. +#ifdef CONFIG_COMPAT
  1486. +
  1487. +static long fbcon_decor_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) {
  1488. +
  1489. + struct fbcon_decor_iowrapper32 __user *wrapper = (void __user *)arg;
  1490. + struct vc_data *vc = NULL;
  1491. + unsigned short vc_num = 0;
  1492. + unsigned char origin = 0;
  1493. + compat_uptr_t data_compat = 0;
  1494. + void __user *data = NULL;
  1495. +
  1496. + if (!access_ok(VERIFY_READ, wrapper,
  1497. + sizeof(struct fbcon_decor_iowrapper32)))
  1498. + return -EFAULT;
  1499. +
  1500. + __get_user(vc_num, &wrapper->vc);
  1501. + __get_user(origin, &wrapper->origin);
  1502. + __get_user(data_compat, &wrapper->data);
  1503. + data = compat_ptr(data_compat);
  1504. +
  1505. + if (!vc_cons_allocated(vc_num))
  1506. + return -EINVAL;
  1507. +
  1508. + vc = vc_cons[vc_num].d;
  1509. +
  1510. + switch (cmd) {
  1511. + case FBIOCONDECOR_SETPIC32:
  1512. + {
  1513. + struct fb_image32 img_compat;
  1514. + struct fb_image img;
  1515. +
  1516. + if (copy_from_user(&img_compat, (struct fb_image32 __user *)data, sizeof(struct fb_image32)))
  1517. + return -EFAULT;
  1518. +
  1519. + fb_image_from_compat(img, img_compat);
  1520. +
  1521. + return fbcon_decor_ioctl_dosetpic(vc, &img, origin);
  1522. + }
  1523. +
  1524. + case FBIOCONDECOR_SETCFG32:
  1525. + {
  1526. + struct vc_decor32 cfg_compat;
  1527. + struct vc_decor cfg;
  1528. +
  1529. + if (copy_from_user(&cfg_compat, (struct vc_decor32 __user *)data, sizeof(struct vc_decor32)))
  1530. + return -EFAULT;
  1531. +
  1532. + vc_decor_from_compat(cfg, cfg_compat);
  1533. +
  1534. + return fbcon_decor_ioctl_dosetcfg(vc, &cfg, origin);
  1535. + }
  1536. +
  1537. + case FBIOCONDECOR_GETCFG32:
  1538. + {
  1539. + int rval;
  1540. + struct vc_decor32 cfg_compat;
  1541. + struct vc_decor cfg;
  1542. +
  1543. + if (copy_from_user(&cfg_compat, (struct vc_decor32 __user *)data, sizeof(struct vc_decor32)))
  1544. + return -EFAULT;
  1545. + cfg.theme = compat_ptr(cfg_compat.theme);
  1546. +
  1547. + rval = fbcon_decor_ioctl_dogetcfg(vc, &cfg);
  1548. +
  1549. + vc_decor_to_compat(cfg_compat, cfg);
  1550. +
  1551. + if (copy_to_user((struct vc_decor32 __user *)data, &cfg_compat, sizeof(struct vc_decor32)))
  1552. + return -EFAULT;
  1553. + return rval;
  1554. + }
  1555. +
  1556. + case FBIOCONDECOR_SETSTATE32:
  1557. + {
  1558. + compat_uint_t state_compat = 0;
  1559. + unsigned int state = 0;
  1560. +
  1561. + if (get_user(state_compat, (compat_uint_t __user *)data))
  1562. + return -EFAULT;
  1563. +
  1564. + state = (unsigned int)state_compat;
  1565. +
  1566. + return fbcon_decor_ioctl_dosetstate(vc, state, origin);
  1567. + }
  1568. +
  1569. + case FBIOCONDECOR_GETSTATE32:
  1570. + {
  1571. + compat_uint_t state_compat = 0;
  1572. + unsigned int state = 0;
  1573. +
  1574. + fbcon_decor_ioctl_dogetstate(vc, &state);
  1575. + state_compat = (compat_uint_t)state;
  1576. +
  1577. + return put_user(state_compat, (compat_uint_t __user *)data);
  1578. + }
  1579. +
  1580. + default:
  1581. + return -ENOIOCTLCMD;
  1582. + }
  1583. +}
  1584. +#else
  1585. + #define fbcon_decor_compat_ioctl NULL
  1586. +#endif
  1587. +
  1588. +static struct file_operations fbcon_decor_ops = {
  1589. + .owner = THIS_MODULE,
  1590. + .unlocked_ioctl = fbcon_decor_ioctl,
  1591. + .compat_ioctl = fbcon_decor_compat_ioctl
  1592. +};
  1593. +
  1594. +static struct miscdevice fbcon_decor_dev = {
  1595. + .minor = MISC_DYNAMIC_MINOR,
  1596. + .name = "fbcondecor",
  1597. + .fops = &fbcon_decor_ops
  1598. +};
  1599. +
  1600. +void fbcon_decor_reset()
  1601. +{
  1602. + int i;
  1603. +
  1604. + for (i = 0; i < num_registered_fb; i++) {
  1605. + registered_fb[i]->bgdecor.data = NULL;
  1606. + registered_fb[i]->bgdecor.cmap.red = NULL;
  1607. + }
  1608. +
  1609. + for (i = 0; i < MAX_NR_CONSOLES && vc_cons[i].d; i++) {
  1610. + vc_cons[i].d->vc_decor.state = vc_cons[i].d->vc_decor.twidth =
  1611. + vc_cons[i].d->vc_decor.theight = 0;
  1612. + vc_cons[i].d->vc_decor.theme = NULL;
  1613. + }
  1614. +
  1615. + return;
  1616. +}
  1617. +
  1618. +int fbcon_decor_init()
  1619. +{
  1620. + int i;
  1621. +
  1622. + fbcon_decor_reset();
  1623. +
  1624. + if (initialized)
  1625. + return 0;
  1626. +
  1627. + i = misc_register(&fbcon_decor_dev);
  1628. + if (i) {
  1629. + printk(KERN_ERR "fbcondecor: failed to register device\n");
  1630. + return i;
  1631. + }
  1632. +
  1633. + fbcon_decor_call_helper("init", 0);
  1634. + initialized = 1;
  1635. + return 0;
  1636. +}
  1637. +
  1638. +int fbcon_decor_exit(void)
  1639. +{
  1640. + fbcon_decor_reset();
  1641. + return 0;
  1642. +}
  1643. +
  1644. +EXPORT_SYMBOL(fbcon_decor_path);
  1645. diff -Nur linux-3.18.9.orig/drivers/video/console/fbcondecor.h linux-3.18.9/drivers/video/console/fbcondecor.h
  1646. --- linux-3.18.9.orig/drivers/video/console/fbcondecor.h 1969-12-31 18:00:00.000000000 -0600
  1647. +++ linux-3.18.9/drivers/video/console/fbcondecor.h 2015-03-15 14:34:13.076143680 -0500
  1648. @@ -0,0 +1,79 @@
  1649. +/*
  1650. + * linux/drivers/video/console/fbcondecor.h -- Framebuffer Console Decoration headers
  1651. + *
  1652. + * Copyright (C) 2004 Michal Januszewski <michalj+fbcondecor@gmail.com>
  1653. + *
  1654. + */
  1655. +
  1656. +#ifndef __FBCON_DECOR_H
  1657. +#define __FBCON_DECOR_H
  1658. +
  1659. +#ifndef _LINUX_FB_H
  1660. +#include <linux/fb.h>
  1661. +#endif
  1662. +
  1663. +/* This is needed for vc_cons in fbcmap.c */
  1664. +#include <linux/vt_kern.h>
  1665. +
  1666. +struct fb_cursor;
  1667. +struct fb_info;
  1668. +struct vc_data;
  1669. +
  1670. +#ifdef CONFIG_FB_CON_DECOR
  1671. +/* fbcondecor.c */
  1672. +int fbcon_decor_init(void);
  1673. +void fbcon_decor_reset(void);
  1674. +int fbcon_decor_exit(void);
  1675. +int fbcon_decor_call_helper(char* cmd, unsigned short cons);
  1676. +int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw);
  1677. +
  1678. +/* cfbcondecor.c */
  1679. +void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx);
  1680. +void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor);
  1681. +void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width);
  1682. +void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only);
  1683. +void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank);
  1684. +void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width);
  1685. +void fbcon_decor_copy(u8 *dst, u8 *src, int height, int width, int linebytes, int srclinesbytes, int bpp);
  1686. +void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc);
  1687. +
  1688. +/* vt.c */
  1689. +void acquire_console_sem(void);
  1690. +void release_console_sem(void);
  1691. +void do_unblank_screen(int entering_gfx);
  1692. +
  1693. +/* struct vc_data *y */
  1694. +#define fbcon_decor_active_vc(y) (y->vc_decor.state && y->vc_decor.theme)
  1695. +
  1696. +/* struct fb_info *x, struct vc_data *y */
  1697. +#define fbcon_decor_active_nores(x,y) (x->bgdecor.data && fbcon_decor_active_vc(y))
  1698. +
  1699. +/* struct fb_info *x, struct vc_data *y */
  1700. +#define fbcon_decor_active(x,y) (fbcon_decor_active_nores(x,y) && \
  1701. + x->bgdecor.width == x->var.xres && \
  1702. + x->bgdecor.height == x->var.yres && \
  1703. + x->bgdecor.depth == x->var.bits_per_pixel)
  1704. +
  1705. +
  1706. +#else /* CONFIG_FB_CON_DECOR */
  1707. +
  1708. +static inline void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx) {}
  1709. +static inline void fbcon_decor_putc(struct vc_data *vc, struct fb_info *info, int c, int ypos, int xpos) {}
  1710. +static inline void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor) {}
  1711. +static inline void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) {}
  1712. +static inline void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only) {}
  1713. +static inline void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank) {}
  1714. +static inline void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width) {}
  1715. +static inline void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc) {}
  1716. +static inline int fbcon_decor_call_helper(char* cmd, unsigned short cons) { return 0; }
  1717. +static inline int fbcon_decor_init(void) { return 0; }
  1718. +static inline int fbcon_decor_exit(void) { return 0; }
  1719. +static inline int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw) { return 0; }
  1720. +
  1721. +#define fbcon_decor_active_vc(y) (0)
  1722. +#define fbcon_decor_active_nores(x,y) (0)
  1723. +#define fbcon_decor_active(x,y) (0)
  1724. +
  1725. +#endif /* CONFIG_FB_CON_DECOR */
  1726. +
  1727. +#endif /* __FBCON_DECOR_H */
  1728. diff -Nur linux-3.18.9.orig/drivers/video/console/Kconfig linux-3.18.9/drivers/video/console/Kconfig
  1729. --- linux-3.18.9.orig/drivers/video/console/Kconfig 2015-03-06 16:53:42.000000000 -0600
  1730. +++ linux-3.18.9/drivers/video/console/Kconfig 2015-03-15 14:34:13.068143682 -0500
  1731. @@ -126,6 +126,19 @@
  1732. such that other users of the framebuffer will remain normally
  1733. oriented.
  1734. +config FB_CON_DECOR
  1735. + bool "Support for the Framebuffer Console Decorations"
  1736. + depends on FRAMEBUFFER_CONSOLE=y && !FB_TILEBLITTING
  1737. + default n
  1738. + ---help---
  1739. + This option enables support for framebuffer console decorations which
  1740. + makes it possible to display images in the background of the system
  1741. + consoles. Note that userspace utilities are necessary in order to take
  1742. + advantage of these features. Refer to Documentation/fb/fbcondecor.txt
  1743. + for more information.
  1744. +
  1745. + If unsure, say N.
  1746. +
  1747. config STI_CONSOLE
  1748. bool "STI text console"
  1749. depends on PARISC
  1750. diff -Nur linux-3.18.9.orig/drivers/video/console/Makefile linux-3.18.9/drivers/video/console/Makefile
  1751. --- linux-3.18.9.orig/drivers/video/console/Makefile 2015-03-06 16:53:42.000000000 -0600
  1752. +++ linux-3.18.9/drivers/video/console/Makefile 2015-03-15 14:34:13.068143682 -0500
  1753. @@ -16,4 +16,5 @@
  1754. fbcon_ccw.o
  1755. endif
  1756. +obj-$(CONFIG_FB_CON_DECOR) += fbcondecor.o cfbcondecor.o
  1757. obj-$(CONFIG_FB_STI) += sticore.o
  1758. diff -Nur linux-3.18.9.orig/drivers/video/fbdev/core/fbcmap.c linux-3.18.9/drivers/video/fbdev/core/fbcmap.c
  1759. --- linux-3.18.9.orig/drivers/video/fbdev/core/fbcmap.c 2015-03-06 16:53:42.000000000 -0600
  1760. +++ linux-3.18.9/drivers/video/fbdev/core/fbcmap.c 2015-03-15 14:34:13.076143680 -0500
  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.18.9.orig/include/linux/console_decor.h linux-3.18.9/include/linux/console_decor.h
  1779. --- linux-3.18.9.orig/include/linux/console_decor.h 1969-12-31 18:00:00.000000000 -0600
  1780. +++ linux-3.18.9/include/linux/console_decor.h 2015-03-15 14:34:13.076143680 -0500
  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.18.9.orig/include/linux/console_struct.h linux-3.18.9/include/linux/console_struct.h
  1829. --- linux-3.18.9.orig/include/linux/console_struct.h 2015-03-06 16:53:42.000000000 -0600
  1830. +++ linux-3.18.9/include/linux/console_struct.h 2015-03-15 14:34:13.076143680 -0500
  1831. @@ -20,6 +20,7 @@
  1832. struct uni_pagedir;
  1833. #define NPAR 16
  1834. +#include <linux/console_decor.h>
  1835. struct vc_data {
  1836. struct tty_port port; /* Upper level data */
  1837. @@ -108,6 +109,8 @@
  1838. struct uni_pagedir *vc_uni_pagedir;
  1839. struct uni_pagedir **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.18.9.orig/include/linux/fb.h linux-3.18.9/include/linux/fb.h
  1846. --- linux-3.18.9.orig/include/linux/fb.h 2015-03-06 16:53:42.000000000 -0600
  1847. +++ linux-3.18.9/include/linux/fb.h 2015-03-15 14:34:13.080143679 -0500
  1848. @@ -220,6 +220,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. @@ -490,6 +518,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.18.9.orig/include/uapi/linux/fb.h linux-3.18.9/include/uapi/linux/fb.h
  1893. --- linux-3.18.9.orig/include/uapi/linux/fb.h 2015-03-06 16:53:42.000000000 -0600
  1894. +++ linux-3.18.9/include/uapi/linux/fb.h 2015-03-15 14:34:13.080143679 -0500
  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.18.9.orig/kernel/sysctl.c linux-3.18.9/kernel/sysctl.c
  1974. --- linux-3.18.9.orig/kernel/sysctl.c 2015-03-06 16:53:42.000000000 -0600
  1975. +++ linux-3.18.9/kernel/sysctl.c 2015-03-15 14:34:13.080143679 -0500
  1976. @@ -145,6 +145,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. @@ -257,6 +261,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. };