fblogo.patch 59 KB

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