fbcon.c 76 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039
  1. /*
  2. * linux/drivers/video/fbcon.c -- Low level frame buffer based console driver
  3. *
  4. * Copyright (C) 1995 Geert Uytterhoeven
  5. *
  6. *
  7. * This file is based on the original Amiga console driver (amicon.c):
  8. *
  9. * Copyright (C) 1993 Hamish Macdonald
  10. * Greg Harp
  11. * Copyright (C) 1994 David Carter [carter@compsci.bristol.ac.uk]
  12. *
  13. * with work by William Rucklidge (wjr@cs.cornell.edu)
  14. * Geert Uytterhoeven
  15. * Jes Sorensen (jds@kom.auc.dk)
  16. * Martin Apel
  17. *
  18. * and on the original Atari console driver (atacon.c):
  19. *
  20. * Copyright (C) 1993 Bjoern Brauel
  21. * Roman Hodek
  22. *
  23. * with work by Guenther Kelleter
  24. * Martin Schaller
  25. * Andreas Schwab
  26. *
  27. * Hardware cursor support added by Emmanuel Marty (core@ggi-project.org)
  28. * Smart redraw scrolling, arbitrary font width support, 512char font support
  29. * and software scrollback added by
  30. * Jakub Jelinek (jj@ultra.linux.cz)
  31. *
  32. * Random hacking by Martin Mares <mj@ucw.cz>
  33. *
  34. * 2001 - Documented with DocBook
  35. * - Brad Douglas <brad@neruo.com>
  36. *
  37. * The low level operations for the various display memory organizations are
  38. * now in separate source files.
  39. *
  40. * Currently the following organizations are supported:
  41. *
  42. * o afb Amiga bitplanes
  43. * o cfb{2,4,8,16,24,32} Packed pixels
  44. * o ilbm Amiga interleaved bitplanes
  45. * o iplan2p[248] Atari interleaved bitplanes
  46. * o mfb Monochrome
  47. * o vga VGA characters/attributes
  48. *
  49. * To do:
  50. *
  51. * - Implement 16 plane mode (iplan2p16)
  52. *
  53. *
  54. * This file is subject to the terms and conditions of the GNU General Public
  55. * License. See the file COPYING in the main directory of this archive for
  56. * more details.
  57. */
  58. #undef FBCONDEBUG
  59. #include <linux/config.h>
  60. #include <linux/module.h>
  61. #include <linux/types.h>
  62. #include <linux/sched.h>
  63. #include <linux/fs.h>
  64. #include <linux/kernel.h>
  65. #include <linux/delay.h> /* MSch: for IRQ probe */
  66. #include <linux/tty.h>
  67. #include <linux/console.h>
  68. #include <linux/string.h>
  69. #include <linux/kd.h>
  70. #include <linux/slab.h>
  71. #include <linux/fb.h>
  72. #include <linux/vt_kern.h>
  73. #include <linux/selection.h>
  74. #include <linux/font.h>
  75. #include <linux/smp.h>
  76. #include <linux/init.h>
  77. #include <linux/interrupt.h>
  78. #include <linux/crc32.h> /* For counting font checksums */
  79. #include <asm/irq.h>
  80. #include <asm/system.h>
  81. #include <asm/uaccess.h>
  82. #ifdef CONFIG_ATARI
  83. #include <asm/atariints.h>
  84. #endif
  85. #ifdef CONFIG_MAC
  86. #include <asm/macints.h>
  87. #endif
  88. #if defined(__mc68000__) || defined(CONFIG_APUS)
  89. #include <asm/machdep.h>
  90. #include <asm/setup.h>
  91. #endif
  92. #include "fbcon.h"
  93. #ifdef FBCONDEBUG
  94. # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
  95. #else
  96. # define DPRINTK(fmt, args...)
  97. #endif
  98. enum {
  99. FBCON_LOGO_CANSHOW = -1, /* the logo can be shown */
  100. FBCON_LOGO_DRAW = -2, /* draw the logo to a console */
  101. FBCON_LOGO_DONTSHOW = -3 /* do not show the logo */
  102. };
  103. static struct display fb_display[MAX_NR_CONSOLES];
  104. static signed char con2fb_map[MAX_NR_CONSOLES];
  105. static signed char con2fb_map_boot[MAX_NR_CONSOLES];
  106. static int logo_height;
  107. static int logo_lines;
  108. /* logo_shown is an index to vc_cons when >= 0; otherwise follows FBCON_LOGO
  109. enums. */
  110. static int logo_shown = FBCON_LOGO_CANSHOW;
  111. /* Software scrollback */
  112. static int fbcon_softback_size = 32768;
  113. static unsigned long softback_buf, softback_curr;
  114. static unsigned long softback_in;
  115. static unsigned long softback_top, softback_end;
  116. static int softback_lines;
  117. /* console mappings */
  118. static int first_fb_vc;
  119. static int last_fb_vc = MAX_NR_CONSOLES - 1;
  120. static int fbcon_is_default = 1;
  121. /* font data */
  122. static char fontname[40];
  123. /* current fb_info */
  124. static int info_idx = -1;
  125. /* console rotation */
  126. static int rotate;
  127. static const struct consw fb_con;
  128. #define CM_SOFTBACK (8)
  129. #define advance_row(p, delta) (unsigned short *)((unsigned long)(p) + (delta) * vc->vc_size_row)
  130. static void fbcon_free_font(struct display *);
  131. static int fbcon_set_origin(struct vc_data *);
  132. #define CURSOR_DRAW_DELAY (1)
  133. /* # VBL ints between cursor state changes */
  134. #define ATARI_CURSOR_BLINK_RATE (42)
  135. #define MAC_CURSOR_BLINK_RATE (32)
  136. #define DEFAULT_CURSOR_BLINK_RATE (20)
  137. static int vbl_cursor_cnt;
  138. #define divides(a, b) ((!(a) || (b)%(a)) ? 0 : 1)
  139. /*
  140. * Interface used by the world
  141. */
  142. static const char *fbcon_startup(void);
  143. static void fbcon_init(struct vc_data *vc, int init);
  144. static void fbcon_deinit(struct vc_data *vc);
  145. static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
  146. int width);
  147. static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos);
  148. static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
  149. int count, int ypos, int xpos);
  150. static void fbcon_clear_margins(struct vc_data *vc, int bottom_only);
  151. static void fbcon_cursor(struct vc_data *vc, int mode);
  152. static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
  153. int count);
  154. static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx,
  155. int height, int width);
  156. static int fbcon_switch(struct vc_data *vc);
  157. static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch);
  158. static int fbcon_set_palette(struct vc_data *vc, unsigned char *table);
  159. static int fbcon_scrolldelta(struct vc_data *vc, int lines);
  160. /*
  161. * Internal routines
  162. */
  163. static __inline__ void ywrap_up(struct vc_data *vc, int count);
  164. static __inline__ void ywrap_down(struct vc_data *vc, int count);
  165. static __inline__ void ypan_up(struct vc_data *vc, int count);
  166. static __inline__ void ypan_down(struct vc_data *vc, int count);
  167. static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int sx,
  168. int dy, int dx, int height, int width, u_int y_break);
  169. static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var,
  170. struct vc_data *vc);
  171. static void fbcon_preset_disp(struct fb_info *info, struct fb_var_screeninfo *var,
  172. int unit);
  173. static void fbcon_redraw_move(struct vc_data *vc, struct display *p,
  174. int line, int count, int dy);
  175. static void fbcon_modechanged(struct fb_info *info);
  176. static void fbcon_set_all_vcs(struct fb_info *info);
  177. #ifdef CONFIG_MAC
  178. /*
  179. * On the Macintoy, there may or may not be a working VBL int. We need to probe
  180. */
  181. static int vbl_detected;
  182. static irqreturn_t fb_vbl_detect(int irq, void *dummy, struct pt_regs *fp)
  183. {
  184. vbl_detected++;
  185. return IRQ_HANDLED;
  186. }
  187. #endif
  188. #ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION
  189. static inline void fbcon_set_rotation(struct fb_info *info, struct display *p)
  190. {
  191. struct fbcon_ops *ops = info->fbcon_par;
  192. if (!(info->flags & FBINFO_MISC_TILEBLITTING) &&
  193. p->con_rotate < 4)
  194. ops->rotate = p->con_rotate;
  195. else
  196. ops->rotate = 0;
  197. }
  198. static void fbcon_rotate(struct fb_info *info, u32 rotate)
  199. {
  200. struct fbcon_ops *ops= info->fbcon_par;
  201. struct fb_info *fb_info;
  202. if (!ops || ops->currcon == -1)
  203. return;
  204. fb_info = registered_fb[con2fb_map[ops->currcon]];
  205. if (info == fb_info) {
  206. struct display *p = &fb_display[ops->currcon];
  207. if (rotate < 4)
  208. p->con_rotate = rotate;
  209. else
  210. p->con_rotate = 0;
  211. fbcon_modechanged(info);
  212. }
  213. }
  214. static void fbcon_rotate_all(struct fb_info *info, u32 rotate)
  215. {
  216. struct fbcon_ops *ops = info->fbcon_par;
  217. struct vc_data *vc;
  218. struct display *p;
  219. int i;
  220. if (!ops || ops->currcon < 0 || rotate > 3)
  221. return;
  222. for (i = 0; i < MAX_NR_CONSOLES; i++) {
  223. vc = vc_cons[i].d;
  224. if (!vc || vc->vc_mode != KD_TEXT ||
  225. registered_fb[con2fb_map[i]] != info)
  226. continue;
  227. p = &fb_display[vc->vc_num];
  228. p->con_rotate = rotate;
  229. }
  230. fbcon_set_all_vcs(info);
  231. }
  232. #else
  233. static inline void fbcon_set_rotation(struct fb_info *info, struct display *p)
  234. {
  235. struct fbcon_ops *ops = info->fbcon_par;
  236. ops->rotate = FB_ROTATE_UR;
  237. }
  238. static void fbcon_rotate(struct fb_info *info, u32 rotate)
  239. {
  240. return;
  241. }
  242. static void fbcon_rotate_all(struct fb_info *info, u32 rotate)
  243. {
  244. return;
  245. }
  246. #endif /* CONFIG_FRAMEBUFFER_CONSOLE_ROTATION */
  247. static int fbcon_get_rotate(struct fb_info *info)
  248. {
  249. struct fbcon_ops *ops = info->fbcon_par;
  250. return (ops) ? ops->rotate : 0;
  251. }
  252. static inline int fbcon_is_inactive(struct vc_data *vc, struct fb_info *info)
  253. {
  254. struct fbcon_ops *ops = info->fbcon_par;
  255. return (info->state != FBINFO_STATE_RUNNING ||
  256. vc->vc_mode != KD_TEXT || ops->graphics);
  257. }
  258. static inline int get_color(struct vc_data *vc, struct fb_info *info,
  259. u16 c, int is_fg)
  260. {
  261. int depth = fb_get_color_depth(&info->var, &info->fix);
  262. int color = 0;
  263. if (console_blanked) {
  264. unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
  265. c = vc->vc_video_erase_char & charmask;
  266. }
  267. if (depth != 1)
  268. color = (is_fg) ? attr_fgcol((vc->vc_hi_font_mask) ? 9 : 8, c)
  269. : attr_bgcol((vc->vc_hi_font_mask) ? 13 : 12, c);
  270. switch (depth) {
  271. case 1:
  272. {
  273. int col = ~(0xfff << (max(info->var.green.length,
  274. max(info->var.red.length,
  275. info->var.blue.length)))) & 0xff;
  276. /* 0 or 1 */
  277. int fg = (info->fix.visual != FB_VISUAL_MONO01) ? col : 0;
  278. int bg = (info->fix.visual != FB_VISUAL_MONO01) ? 0 : col;
  279. if (console_blanked)
  280. fg = bg;
  281. color = (is_fg) ? fg : bg;
  282. break;
  283. }
  284. case 2:
  285. /*
  286. * Scale down 16-colors to 4 colors. Default 4-color palette
  287. * is grayscale. However, simply dividing the values by 4
  288. * will not work, as colors 1, 2 and 3 will be scaled-down
  289. * to zero rendering them invisible. So empirically convert
  290. * colors to a sane 4-level grayscale.
  291. */
  292. switch (color) {
  293. case 0:
  294. color = 0; /* black */
  295. break;
  296. case 1 ... 6:
  297. color = 2; /* white */
  298. break;
  299. case 7 ... 8:
  300. color = 1; /* gray */
  301. break;
  302. default:
  303. color = 3; /* intense white */
  304. break;
  305. }
  306. break;
  307. case 3:
  308. /*
  309. * Last 8 entries of default 16-color palette is a more intense
  310. * version of the first 8 (i.e., same chrominance, different
  311. * luminance).
  312. */
  313. color &= 7;
  314. break;
  315. }
  316. return color;
  317. }
  318. static void fbcon_update_softback(struct vc_data *vc)
  319. {
  320. int l = fbcon_softback_size / vc->vc_size_row;
  321. if (l > 5)
  322. softback_end = softback_buf + l * vc->vc_size_row;
  323. else
  324. /* Smaller scrollback makes no sense, and 0 would screw
  325. the operation totally */
  326. softback_top = 0;
  327. }
  328. static void fb_flashcursor(void *private)
  329. {
  330. struct fb_info *info = private;
  331. struct fbcon_ops *ops = info->fbcon_par;
  332. struct display *p;
  333. struct vc_data *vc = NULL;
  334. int c;
  335. int mode;
  336. if (ops->currcon != -1)
  337. vc = vc_cons[ops->currcon].d;
  338. if (!vc || !CON_IS_VISIBLE(vc) ||
  339. fbcon_is_inactive(vc, info) ||
  340. registered_fb[con2fb_map[vc->vc_num]] != info ||
  341. vc_cons[ops->currcon].d->vc_deccm != 1)
  342. return;
  343. acquire_console_sem();
  344. p = &fb_display[vc->vc_num];
  345. c = scr_readw((u16 *) vc->vc_pos);
  346. mode = (!ops->cursor_flash || ops->cursor_state.enable) ?
  347. CM_ERASE : CM_DRAW;
  348. ops->cursor(vc, info, p, mode, softback_lines, get_color(vc, info, c, 1),
  349. get_color(vc, info, c, 0));
  350. release_console_sem();
  351. }
  352. #if defined(CONFIG_ATARI) || defined(CONFIG_MAC)
  353. static int cursor_blink_rate;
  354. static irqreturn_t fb_vbl_handler(int irq, void *dev_id, struct pt_regs *fp)
  355. {
  356. struct fb_info *info = dev_id;
  357. if (vbl_cursor_cnt && --vbl_cursor_cnt == 0) {
  358. schedule_work(&info->queue);
  359. vbl_cursor_cnt = cursor_blink_rate;
  360. }
  361. return IRQ_HANDLED;
  362. }
  363. #endif
  364. static void cursor_timer_handler(unsigned long dev_addr)
  365. {
  366. struct fb_info *info = (struct fb_info *) dev_addr;
  367. struct fbcon_ops *ops = info->fbcon_par;
  368. schedule_work(&info->queue);
  369. mod_timer(&ops->cursor_timer, jiffies + HZ/5);
  370. }
  371. static void fbcon_add_cursor_timer(struct fb_info *info)
  372. {
  373. struct fbcon_ops *ops = info->fbcon_par;
  374. if ((!info->queue.func || info->queue.func == fb_flashcursor) &&
  375. !(ops->flags & FBCON_FLAGS_CURSOR_TIMER)) {
  376. if (!info->queue.func)
  377. INIT_WORK(&info->queue, fb_flashcursor, info);
  378. init_timer(&ops->cursor_timer);
  379. ops->cursor_timer.function = cursor_timer_handler;
  380. ops->cursor_timer.expires = jiffies + HZ / 5;
  381. ops->cursor_timer.data = (unsigned long ) info;
  382. add_timer(&ops->cursor_timer);
  383. ops->flags |= FBCON_FLAGS_CURSOR_TIMER;
  384. }
  385. }
  386. static void fbcon_del_cursor_timer(struct fb_info *info)
  387. {
  388. struct fbcon_ops *ops = info->fbcon_par;
  389. if (info->queue.func == fb_flashcursor &&
  390. ops->flags & FBCON_FLAGS_CURSOR_TIMER) {
  391. del_timer_sync(&ops->cursor_timer);
  392. ops->flags &= ~FBCON_FLAGS_CURSOR_TIMER;
  393. }
  394. }
  395. #ifndef MODULE
  396. static int __init fb_console_setup(char *this_opt)
  397. {
  398. char *options;
  399. int i, j;
  400. if (!this_opt || !*this_opt)
  401. return 0;
  402. while ((options = strsep(&this_opt, ",")) != NULL) {
  403. if (!strncmp(options, "font:", 5))
  404. strcpy(fontname, options + 5);
  405. if (!strncmp(options, "scrollback:", 11)) {
  406. options += 11;
  407. if (*options) {
  408. fbcon_softback_size = simple_strtoul(options, &options, 0);
  409. if (*options == 'k' || *options == 'K') {
  410. fbcon_softback_size *= 1024;
  411. options++;
  412. }
  413. if (*options != ',')
  414. return 0;
  415. options++;
  416. } else
  417. return 0;
  418. }
  419. if (!strncmp(options, "map:", 4)) {
  420. options += 4;
  421. if (*options)
  422. for (i = 0, j = 0; i < MAX_NR_CONSOLES; i++) {
  423. if (!options[j])
  424. j = 0;
  425. con2fb_map_boot[i] =
  426. (options[j++]-'0') % FB_MAX;
  427. }
  428. return 0;
  429. }
  430. if (!strncmp(options, "vc:", 3)) {
  431. options += 3;
  432. if (*options)
  433. first_fb_vc = simple_strtoul(options, &options, 10) - 1;
  434. if (first_fb_vc < 0)
  435. first_fb_vc = 0;
  436. if (*options++ == '-')
  437. last_fb_vc = simple_strtoul(options, &options, 10) - 1;
  438. fbcon_is_default = 0;
  439. }
  440. if (!strncmp(options, "rotate:", 7)) {
  441. options += 7;
  442. if (*options)
  443. rotate = simple_strtoul(options, &options, 0);
  444. if (rotate > 3)
  445. rotate = 0;
  446. }
  447. }
  448. return 0;
  449. }
  450. __setup("fbcon=", fb_console_setup);
  451. #endif
  452. static int search_fb_in_map(int idx)
  453. {
  454. int i, retval = 0;
  455. for (i = 0; i < MAX_NR_CONSOLES; i++) {
  456. if (con2fb_map[i] == idx)
  457. retval = 1;
  458. }
  459. return retval;
  460. }
  461. static int search_for_mapped_con(void)
  462. {
  463. int i, retval = 0;
  464. for (i = 0; i < MAX_NR_CONSOLES; i++) {
  465. if (con2fb_map[i] != -1)
  466. retval = 1;
  467. }
  468. return retval;
  469. }
  470. static int fbcon_takeover(int show_logo)
  471. {
  472. int err, i;
  473. if (!num_registered_fb)
  474. return -ENODEV;
  475. if (!show_logo)
  476. logo_shown = FBCON_LOGO_DONTSHOW;
  477. for (i = first_fb_vc; i <= last_fb_vc; i++)
  478. con2fb_map[i] = info_idx;
  479. err = take_over_console(&fb_con, first_fb_vc, last_fb_vc,
  480. fbcon_is_default);
  481. if (err) {
  482. for (i = first_fb_vc; i <= last_fb_vc; i++) {
  483. con2fb_map[i] = -1;
  484. }
  485. info_idx = -1;
  486. }
  487. return err;
  488. }
  489. static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
  490. int cols, int rows, int new_cols, int new_rows)
  491. {
  492. /* Need to make room for the logo */
  493. struct fbcon_ops *ops = info->fbcon_par;
  494. int cnt, erase = vc->vc_video_erase_char, step;
  495. unsigned short *save = NULL, *r, *q;
  496. /*
  497. * remove underline attribute from erase character
  498. * if black and white framebuffer.
  499. */
  500. if (fb_get_color_depth(&info->var, &info->fix) == 1)
  501. erase &= ~0x400;
  502. logo_height = fb_prepare_logo(info, ops->rotate);
  503. logo_lines = (logo_height + vc->vc_font.height - 1) /
  504. vc->vc_font.height;
  505. q = (unsigned short *) (vc->vc_origin +
  506. vc->vc_size_row * rows);
  507. step = logo_lines * cols;
  508. for (r = q - logo_lines * cols; r < q; r++)
  509. if (scr_readw(r) != vc->vc_video_erase_char)
  510. break;
  511. if (r != q && new_rows >= rows + logo_lines) {
  512. save = kmalloc(logo_lines * new_cols * 2, GFP_KERNEL);
  513. if (save) {
  514. int i = cols < new_cols ? cols : new_cols;
  515. scr_memsetw(save, erase, logo_lines * new_cols * 2);
  516. r = q - step;
  517. for (cnt = 0; cnt < logo_lines; cnt++, r += i)
  518. scr_memcpyw(save + cnt * new_cols, r, 2 * i);
  519. r = q;
  520. }
  521. }
  522. if (r == q) {
  523. /* We can scroll screen down */
  524. r = q - step - cols;
  525. for (cnt = rows - logo_lines; cnt > 0; cnt--) {
  526. scr_memcpyw(r + step, r, vc->vc_size_row);
  527. r -= cols;
  528. }
  529. if (!save) {
  530. vc->vc_y += logo_lines;
  531. vc->vc_pos += logo_lines * vc->vc_size_row;
  532. }
  533. }
  534. scr_memsetw((unsigned short *) vc->vc_origin,
  535. erase,
  536. vc->vc_size_row * logo_lines);
  537. if (CON_IS_VISIBLE(vc) && vc->vc_mode == KD_TEXT) {
  538. fbcon_clear_margins(vc, 0);
  539. update_screen(vc);
  540. }
  541. if (save) {
  542. q = (unsigned short *) (vc->vc_origin +
  543. vc->vc_size_row *
  544. rows);
  545. scr_memcpyw(q, save, logo_lines * new_cols * 2);
  546. vc->vc_y += logo_lines;
  547. vc->vc_pos += logo_lines * vc->vc_size_row;
  548. kfree(save);
  549. }
  550. if (logo_lines > vc->vc_bottom) {
  551. logo_shown = FBCON_LOGO_CANSHOW;
  552. printk(KERN_INFO
  553. "fbcon_init: disable boot-logo (boot-logo bigger than screen).\n");
  554. } else if (logo_shown != FBCON_LOGO_DONTSHOW) {
  555. logo_shown = FBCON_LOGO_DRAW;
  556. vc->vc_top = logo_lines;
  557. }
  558. }
  559. #ifdef CONFIG_FB_TILEBLITTING
  560. static void set_blitting_type(struct vc_data *vc, struct fb_info *info,
  561. struct display *p)
  562. {
  563. struct fbcon_ops *ops = info->fbcon_par;
  564. ops->p = (p) ? p : &fb_display[vc->vc_num];
  565. if ((info->flags & FBINFO_MISC_TILEBLITTING))
  566. fbcon_set_tileops(vc, info, p, ops);
  567. else {
  568. fbcon_set_rotation(info, ops->p);
  569. fbcon_set_bitops(ops);
  570. }
  571. }
  572. #else
  573. static void set_blitting_type(struct vc_data *vc, struct fb_info *info,
  574. struct display *p)
  575. {
  576. struct fbcon_ops *ops = info->fbcon_par;
  577. info->flags &= ~FBINFO_MISC_TILEBLITTING;
  578. ops->p = (p) ? p : &fb_display[vc->vc_num];
  579. fbcon_set_rotation(info, ops->p);
  580. fbcon_set_bitops(ops);
  581. }
  582. #endif /* CONFIG_MISC_TILEBLITTING */
  583. static int con2fb_acquire_newinfo(struct vc_data *vc, struct fb_info *info,
  584. int unit, int oldidx)
  585. {
  586. struct fbcon_ops *ops = NULL;
  587. int err = 0;
  588. if (!try_module_get(info->fbops->owner))
  589. err = -ENODEV;
  590. if (!err && info->fbops->fb_open &&
  591. info->fbops->fb_open(info, 0))
  592. err = -ENODEV;
  593. if (!err) {
  594. ops = kmalloc(sizeof(struct fbcon_ops), GFP_KERNEL);
  595. if (!ops)
  596. err = -ENOMEM;
  597. }
  598. if (!err) {
  599. memset(ops, 0, sizeof(struct fbcon_ops));
  600. info->fbcon_par = ops;
  601. set_blitting_type(vc, info, NULL);
  602. }
  603. if (err) {
  604. con2fb_map[unit] = oldidx;
  605. module_put(info->fbops->owner);
  606. }
  607. return err;
  608. }
  609. static int con2fb_release_oldinfo(struct vc_data *vc, struct fb_info *oldinfo,
  610. struct fb_info *newinfo, int unit,
  611. int oldidx, int found)
  612. {
  613. struct fbcon_ops *ops = oldinfo->fbcon_par;
  614. int err = 0;
  615. if (oldinfo->fbops->fb_release &&
  616. oldinfo->fbops->fb_release(oldinfo, 0)) {
  617. con2fb_map[unit] = oldidx;
  618. if (!found && newinfo->fbops->fb_release)
  619. newinfo->fbops->fb_release(newinfo, 0);
  620. if (!found)
  621. module_put(newinfo->fbops->owner);
  622. err = -ENODEV;
  623. }
  624. if (!err) {
  625. fbcon_del_cursor_timer(oldinfo);
  626. kfree(ops->cursor_state.mask);
  627. kfree(ops->cursor_data);
  628. kfree(ops->fontbuffer);
  629. kfree(oldinfo->fbcon_par);
  630. oldinfo->fbcon_par = NULL;
  631. module_put(oldinfo->fbops->owner);
  632. /*
  633. If oldinfo and newinfo are driving the same hardware,
  634. the fb_release() method of oldinfo may attempt to
  635. restore the hardware state. This will leave the
  636. newinfo in an undefined state. Thus, a call to
  637. fb_set_par() may be needed for the newinfo.
  638. */
  639. if (newinfo->fbops->fb_set_par)
  640. newinfo->fbops->fb_set_par(newinfo);
  641. }
  642. return err;
  643. }
  644. static void con2fb_init_display(struct vc_data *vc, struct fb_info *info,
  645. int unit, int show_logo)
  646. {
  647. struct fbcon_ops *ops = info->fbcon_par;
  648. ops->currcon = fg_console;
  649. if (info->fbops->fb_set_par && !(ops->flags & FBCON_FLAGS_INIT))
  650. info->fbops->fb_set_par(info);
  651. ops->flags |= FBCON_FLAGS_INIT;
  652. ops->graphics = 0;
  653. if (vc)
  654. fbcon_set_disp(info, &info->var, vc);
  655. else
  656. fbcon_preset_disp(info, &info->var, unit);
  657. if (show_logo) {
  658. struct vc_data *fg_vc = vc_cons[fg_console].d;
  659. struct fb_info *fg_info =
  660. registered_fb[con2fb_map[fg_console]];
  661. fbcon_prepare_logo(fg_vc, fg_info, fg_vc->vc_cols,
  662. fg_vc->vc_rows, fg_vc->vc_cols,
  663. fg_vc->vc_rows);
  664. }
  665. update_screen(vc_cons[fg_console].d);
  666. }
  667. /**
  668. * set_con2fb_map - map console to frame buffer device
  669. * @unit: virtual console number to map
  670. * @newidx: frame buffer index to map virtual console to
  671. * @user: user request
  672. *
  673. * Maps a virtual console @unit to a frame buffer device
  674. * @newidx.
  675. */
  676. static int set_con2fb_map(int unit, int newidx, int user)
  677. {
  678. struct vc_data *vc = vc_cons[unit].d;
  679. int oldidx = con2fb_map[unit];
  680. struct fb_info *info = registered_fb[newidx];
  681. struct fb_info *oldinfo = NULL;
  682. int found, err = 0;
  683. if (oldidx == newidx)
  684. return 0;
  685. if (!info)
  686. err = -EINVAL;
  687. if (!err && !search_for_mapped_con()) {
  688. info_idx = newidx;
  689. return fbcon_takeover(0);
  690. }
  691. if (oldidx != -1)
  692. oldinfo = registered_fb[oldidx];
  693. found = search_fb_in_map(newidx);
  694. acquire_console_sem();
  695. con2fb_map[unit] = newidx;
  696. if (!err && !found)
  697. err = con2fb_acquire_newinfo(vc, info, unit, oldidx);
  698. /*
  699. * If old fb is not mapped to any of the consoles,
  700. * fbcon should release it.
  701. */
  702. if (!err && oldinfo && !search_fb_in_map(oldidx))
  703. err = con2fb_release_oldinfo(vc, oldinfo, info, unit, oldidx,
  704. found);
  705. if (!err) {
  706. int show_logo = (fg_console == 0 && !user &&
  707. logo_shown != FBCON_LOGO_DONTSHOW);
  708. if (!found)
  709. fbcon_add_cursor_timer(info);
  710. con2fb_map_boot[unit] = newidx;
  711. con2fb_init_display(vc, info, unit, show_logo);
  712. }
  713. release_console_sem();
  714. return err;
  715. }
  716. /*
  717. * Low Level Operations
  718. */
  719. /* NOTE: fbcon cannot be __init: it may be called from take_over_console later */
  720. static int var_to_display(struct display *disp,
  721. struct fb_var_screeninfo *var,
  722. struct fb_info *info)
  723. {
  724. disp->xres_virtual = var->xres_virtual;
  725. disp->yres_virtual = var->yres_virtual;
  726. disp->bits_per_pixel = var->bits_per_pixel;
  727. disp->grayscale = var->grayscale;
  728. disp->nonstd = var->nonstd;
  729. disp->accel_flags = var->accel_flags;
  730. disp->height = var->height;
  731. disp->width = var->width;
  732. disp->red = var->red;
  733. disp->green = var->green;
  734. disp->blue = var->blue;
  735. disp->transp = var->transp;
  736. disp->rotate = var->rotate;
  737. disp->mode = fb_match_mode(var, &info->modelist);
  738. if (disp->mode == NULL)
  739. /* This should not happen */
  740. return -EINVAL;
  741. return 0;
  742. }
  743. static void display_to_var(struct fb_var_screeninfo *var,
  744. struct display *disp)
  745. {
  746. fb_videomode_to_var(var, disp->mode);
  747. var->xres_virtual = disp->xres_virtual;
  748. var->yres_virtual = disp->yres_virtual;
  749. var->bits_per_pixel = disp->bits_per_pixel;
  750. var->grayscale = disp->grayscale;
  751. var->nonstd = disp->nonstd;
  752. var->accel_flags = disp->accel_flags;
  753. var->height = disp->height;
  754. var->width = disp->width;
  755. var->red = disp->red;
  756. var->green = disp->green;
  757. var->blue = disp->blue;
  758. var->transp = disp->transp;
  759. var->rotate = disp->rotate;
  760. }
  761. static const char *fbcon_startup(void)
  762. {
  763. const char *display_desc = "frame buffer device";
  764. struct display *p = &fb_display[fg_console];
  765. struct vc_data *vc = vc_cons[fg_console].d;
  766. const struct font_desc *font = NULL;
  767. struct module *owner;
  768. struct fb_info *info = NULL;
  769. struct fbcon_ops *ops;
  770. int rows, cols;
  771. int irqres;
  772. irqres = 1;
  773. /*
  774. * If num_registered_fb is zero, this is a call for the dummy part.
  775. * The frame buffer devices weren't initialized yet.
  776. */
  777. if (!num_registered_fb || info_idx == -1)
  778. return display_desc;
  779. /*
  780. * Instead of blindly using registered_fb[0], we use info_idx, set by
  781. * fb_console_init();
  782. */
  783. info = registered_fb[info_idx];
  784. if (!info)
  785. return NULL;
  786. owner = info->fbops->owner;
  787. if (!try_module_get(owner))
  788. return NULL;
  789. if (info->fbops->fb_open && info->fbops->fb_open(info, 0)) {
  790. module_put(owner);
  791. return NULL;
  792. }
  793. ops = kmalloc(sizeof(struct fbcon_ops), GFP_KERNEL);
  794. if (!ops) {
  795. module_put(owner);
  796. return NULL;
  797. }
  798. memset(ops, 0, sizeof(struct fbcon_ops));
  799. ops->currcon = -1;
  800. ops->graphics = 1;
  801. ops->cur_rotate = -1;
  802. info->fbcon_par = ops;
  803. p->con_rotate = rotate;
  804. set_blitting_type(vc, info, NULL);
  805. if (info->fix.type != FB_TYPE_TEXT) {
  806. if (fbcon_softback_size) {
  807. if (!softback_buf) {
  808. softback_buf =
  809. (unsigned long)
  810. kmalloc(fbcon_softback_size,
  811. GFP_KERNEL);
  812. if (!softback_buf) {
  813. fbcon_softback_size = 0;
  814. softback_top = 0;
  815. }
  816. }
  817. } else {
  818. if (softback_buf) {
  819. kfree((void *) softback_buf);
  820. softback_buf = 0;
  821. softback_top = 0;
  822. }
  823. }
  824. if (softback_buf)
  825. softback_in = softback_top = softback_curr =
  826. softback_buf;
  827. softback_lines = 0;
  828. }
  829. /* Setup default font */
  830. if (!p->fontdata) {
  831. if (!fontname[0] || !(font = find_font(fontname)))
  832. font = get_default_font(info->var.xres,
  833. info->var.yres);
  834. vc->vc_font.width = font->width;
  835. vc->vc_font.height = font->height;
  836. vc->vc_font.data = (void *)(p->fontdata = font->data);
  837. vc->vc_font.charcount = 256; /* FIXME Need to support more fonts */
  838. }
  839. cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
  840. rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
  841. cols /= vc->vc_font.width;
  842. rows /= vc->vc_font.height;
  843. vc_resize(vc, cols, rows);
  844. DPRINTK("mode: %s\n", info->fix.id);
  845. DPRINTK("visual: %d\n", info->fix.visual);
  846. DPRINTK("res: %dx%d-%d\n", info->var.xres,
  847. info->var.yres,
  848. info->var.bits_per_pixel);
  849. #ifdef CONFIG_ATARI
  850. if (MACH_IS_ATARI) {
  851. cursor_blink_rate = ATARI_CURSOR_BLINK_RATE;
  852. irqres =
  853. request_irq(IRQ_AUTO_4, fb_vbl_handler,
  854. IRQ_TYPE_PRIO, "framebuffer vbl",
  855. info);
  856. }
  857. #endif /* CONFIG_ATARI */
  858. #ifdef CONFIG_MAC
  859. /*
  860. * On a Macintoy, the VBL interrupt may or may not be active.
  861. * As interrupt based cursor is more reliable and race free, we
  862. * probe for VBL interrupts.
  863. */
  864. if (MACH_IS_MAC) {
  865. int ct = 0;
  866. /*
  867. * Probe for VBL: set temp. handler ...
  868. */
  869. irqres = request_irq(IRQ_MAC_VBL, fb_vbl_detect, 0,
  870. "framebuffer vbl", info);
  871. vbl_detected = 0;
  872. /*
  873. * ... and spin for 20 ms ...
  874. */
  875. while (!vbl_detected && ++ct < 1000)
  876. udelay(20);
  877. if (ct == 1000)
  878. printk
  879. ("fbcon_startup: No VBL detected, using timer based cursor.\n");
  880. free_irq(IRQ_MAC_VBL, fb_vbl_detect);
  881. if (vbl_detected) {
  882. /*
  883. * interrupt based cursor ok
  884. */
  885. cursor_blink_rate = MAC_CURSOR_BLINK_RATE;
  886. irqres =
  887. request_irq(IRQ_MAC_VBL, fb_vbl_handler, 0,
  888. "framebuffer vbl", info);
  889. } else {
  890. /*
  891. * VBL not detected: fall through, use timer based cursor
  892. */
  893. irqres = 1;
  894. }
  895. }
  896. #endif /* CONFIG_MAC */
  897. fbcon_add_cursor_timer(info);
  898. return display_desc;
  899. }
  900. static void fbcon_init(struct vc_data *vc, int init)
  901. {
  902. struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
  903. struct fbcon_ops *ops;
  904. struct vc_data **default_mode = vc->vc_display_fg;
  905. struct vc_data *svc = *default_mode;
  906. struct display *t, *p = &fb_display[vc->vc_num];
  907. int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256;
  908. int cap;
  909. if (info_idx == -1 || info == NULL)
  910. return;
  911. cap = info->flags;
  912. if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
  913. (info->fix.type == FB_TYPE_TEXT))
  914. logo = 0;
  915. if (var_to_display(p, &info->var, info))
  916. return;
  917. /* If we are not the first console on this
  918. fb, copy the font from that console */
  919. t = &fb_display[svc->vc_num];
  920. if (!vc->vc_font.data) {
  921. vc->vc_font.data = (void *)(p->fontdata = t->fontdata);
  922. vc->vc_font.width = (*default_mode)->vc_font.width;
  923. vc->vc_font.height = (*default_mode)->vc_font.height;
  924. p->userfont = t->userfont;
  925. if (p->userfont)
  926. REFCOUNT(p->fontdata)++;
  927. }
  928. if (p->userfont)
  929. charcnt = FNTCHARCNT(p->fontdata);
  930. vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1);
  931. vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
  932. if (charcnt == 256) {
  933. vc->vc_hi_font_mask = 0;
  934. } else {
  935. vc->vc_hi_font_mask = 0x100;
  936. if (vc->vc_can_do_color)
  937. vc->vc_complement_mask <<= 1;
  938. }
  939. if (!*svc->vc_uni_pagedir_loc)
  940. con_set_default_unimap(svc);
  941. if (!*vc->vc_uni_pagedir_loc)
  942. con_copy_unimap(vc, svc);
  943. ops = info->fbcon_par;
  944. p->con_rotate = rotate;
  945. set_blitting_type(vc, info, NULL);
  946. cols = vc->vc_cols;
  947. rows = vc->vc_rows;
  948. new_cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
  949. new_rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
  950. new_cols /= vc->vc_font.width;
  951. new_rows /= vc->vc_font.height;
  952. vc_resize(vc, new_cols, new_rows);
  953. /*
  954. * We must always set the mode. The mode of the previous console
  955. * driver could be in the same resolution but we are using different
  956. * hardware so we have to initialize the hardware.
  957. *
  958. * We need to do it in fbcon_init() to prevent screen corruption.
  959. */
  960. if (CON_IS_VISIBLE(vc)) {
  961. if (info->fbops->fb_set_par &&
  962. !(ops->flags & FBCON_FLAGS_INIT))
  963. info->fbops->fb_set_par(info);
  964. ops->flags |= FBCON_FLAGS_INIT;
  965. }
  966. ops->graphics = 0;
  967. if ((cap & FBINFO_HWACCEL_COPYAREA) &&
  968. !(cap & FBINFO_HWACCEL_DISABLED))
  969. p->scrollmode = SCROLL_MOVE;
  970. else /* default to something safe */
  971. p->scrollmode = SCROLL_REDRAW;
  972. /*
  973. * ++guenther: console.c:vc_allocate() relies on initializing
  974. * vc_{cols,rows}, but we must not set those if we are only
  975. * resizing the console.
  976. */
  977. if (!init) {
  978. vc->vc_cols = new_cols;
  979. vc->vc_rows = new_rows;
  980. }
  981. if (logo)
  982. fbcon_prepare_logo(vc, info, cols, rows, new_cols, new_rows);
  983. if (vc == svc && softback_buf)
  984. fbcon_update_softback(vc);
  985. if (ops->rotate_font && ops->rotate_font(info, vc, p)) {
  986. ops->rotate = FB_ROTATE_UR;
  987. set_blitting_type(vc, info, p);
  988. }
  989. }
  990. static void fbcon_deinit(struct vc_data *vc)
  991. {
  992. struct display *p = &fb_display[vc->vc_num];
  993. if (info_idx != -1)
  994. return;
  995. fbcon_free_font(p);
  996. }
  997. /* ====================================================================== */
  998. /* fbcon_XXX routines - interface used by the world
  999. *
  1000. * This system is now divided into two levels because of complications
  1001. * caused by hardware scrolling. Top level functions:
  1002. *
  1003. * fbcon_bmove(), fbcon_clear(), fbcon_putc(), fbcon_clear_margins()
  1004. *
  1005. * handles y values in range [0, scr_height-1] that correspond to real
  1006. * screen positions. y_wrap shift means that first line of bitmap may be
  1007. * anywhere on this display. These functions convert lineoffsets to
  1008. * bitmap offsets and deal with the wrap-around case by splitting blits.
  1009. *
  1010. * fbcon_bmove_physical_8() -- These functions fast implementations
  1011. * fbcon_clear_physical_8() -- of original fbcon_XXX fns.
  1012. * fbcon_putc_physical_8() -- (font width != 8) may be added later
  1013. *
  1014. * WARNING:
  1015. *
  1016. * At the moment fbcon_putc() cannot blit across vertical wrap boundary
  1017. * Implies should only really hardware scroll in rows. Only reason for
  1018. * restriction is simplicity & efficiency at the moment.
  1019. */
  1020. static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
  1021. int width)
  1022. {
  1023. struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
  1024. struct fbcon_ops *ops = info->fbcon_par;
  1025. struct display *p = &fb_display[vc->vc_num];
  1026. u_int y_break;
  1027. if (fbcon_is_inactive(vc, info))
  1028. return;
  1029. if (!height || !width)
  1030. return;
  1031. /* Split blits that cross physical y_wrap boundary */
  1032. y_break = p->vrows - p->yscroll;
  1033. if (sy < y_break && sy + height - 1 >= y_break) {
  1034. u_int b = y_break - sy;
  1035. ops->clear(vc, info, real_y(p, sy), sx, b, width);
  1036. ops->clear(vc, info, real_y(p, sy + b), sx, height - b,
  1037. width);
  1038. } else
  1039. ops->clear(vc, info, real_y(p, sy), sx, height, width);
  1040. }
  1041. static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
  1042. int count, int ypos, int xpos)
  1043. {
  1044. struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
  1045. struct display *p = &fb_display[vc->vc_num];
  1046. struct fbcon_ops *ops = info->fbcon_par;
  1047. if (!fbcon_is_inactive(vc, info))
  1048. ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
  1049. get_color(vc, info, scr_readw(s), 1),
  1050. get_color(vc, info, scr_readw(s), 0));
  1051. }
  1052. static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
  1053. {
  1054. unsigned short chr;
  1055. scr_writew(c, &chr);
  1056. fbcon_putcs(vc, &chr, 1, ypos, xpos);
  1057. }
  1058. static void fbcon_clear_margins(struct vc_data *vc, int bottom_only)
  1059. {
  1060. struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
  1061. struct fbcon_ops *ops = info->fbcon_par;
  1062. if (!fbcon_is_inactive(vc, info))
  1063. ops->clear_margins(vc, info, bottom_only);
  1064. }
  1065. static void fbcon_cursor(struct vc_data *vc, int mode)
  1066. {
  1067. struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
  1068. struct fbcon_ops *ops = info->fbcon_par;
  1069. struct display *p = &fb_display[vc->vc_num];
  1070. int y;
  1071. int c = scr_readw((u16 *) vc->vc_pos);
  1072. if (fbcon_is_inactive(vc, info))
  1073. return;
  1074. ops->cursor_flash = (mode == CM_ERASE) ? 0 : 1;
  1075. if (mode & CM_SOFTBACK) {
  1076. mode &= ~CM_SOFTBACK;
  1077. y = softback_lines;
  1078. } else {
  1079. if (softback_lines)
  1080. fbcon_set_origin(vc);
  1081. y = 0;
  1082. }
  1083. ops->cursor(vc, info, p, mode, y, get_color(vc, info, c, 1),
  1084. get_color(vc, info, c, 0));
  1085. vbl_cursor_cnt = CURSOR_DRAW_DELAY;
  1086. }
  1087. static int scrollback_phys_max = 0;
  1088. static int scrollback_max = 0;
  1089. static int scrollback_current = 0;
  1090. /*
  1091. * If no vc is existent yet, just set struct display
  1092. */
  1093. static void fbcon_preset_disp(struct fb_info *info, struct fb_var_screeninfo *var,
  1094. int unit)
  1095. {
  1096. struct display *p = &fb_display[unit];
  1097. struct display *t = &fb_display[fg_console];
  1098. if (var_to_display(p, var, info))
  1099. return;
  1100. p->fontdata = t->fontdata;
  1101. p->userfont = t->userfont;
  1102. if (p->userfont)
  1103. REFCOUNT(p->fontdata)++;
  1104. }
  1105. static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var,
  1106. struct vc_data *vc)
  1107. {
  1108. struct display *p = &fb_display[vc->vc_num], *t;
  1109. struct vc_data **default_mode = vc->vc_display_fg;
  1110. struct vc_data *svc = *default_mode;
  1111. struct fbcon_ops *ops = info->fbcon_par;
  1112. int rows, cols, charcnt = 256;
  1113. if (var_to_display(p, var, info))
  1114. return;
  1115. t = &fb_display[svc->vc_num];
  1116. if (!vc->vc_font.data) {
  1117. vc->vc_font.data = (void *)(p->fontdata = t->fontdata);
  1118. vc->vc_font.width = (*default_mode)->vc_font.width;
  1119. vc->vc_font.height = (*default_mode)->vc_font.height;
  1120. p->userfont = t->userfont;
  1121. if (p->userfont)
  1122. REFCOUNT(p->fontdata)++;
  1123. }
  1124. if (p->userfont)
  1125. charcnt = FNTCHARCNT(p->fontdata);
  1126. var->activate = FB_ACTIVATE_NOW;
  1127. info->var.activate = var->activate;
  1128. var->yoffset = info->var.yoffset;
  1129. var->xoffset = info->var.xoffset;
  1130. fb_set_var(info, var);
  1131. ops->var = info->var;
  1132. vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1);
  1133. vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
  1134. if (charcnt == 256) {
  1135. vc->vc_hi_font_mask = 0;
  1136. } else {
  1137. vc->vc_hi_font_mask = 0x100;
  1138. if (vc->vc_can_do_color)
  1139. vc->vc_complement_mask <<= 1;
  1140. }
  1141. if (!*svc->vc_uni_pagedir_loc)
  1142. con_set_default_unimap(svc);
  1143. if (!*vc->vc_uni_pagedir_loc)
  1144. con_copy_unimap(vc, svc);
  1145. cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
  1146. rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
  1147. cols /= vc->vc_font.width;
  1148. rows /= vc->vc_font.height;
  1149. vc_resize(vc, cols, rows);
  1150. if (CON_IS_VISIBLE(vc)) {
  1151. update_screen(vc);
  1152. if (softback_buf)
  1153. fbcon_update_softback(vc);
  1154. }
  1155. }
  1156. static __inline__ void ywrap_up(struct vc_data *vc, int count)
  1157. {
  1158. struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
  1159. struct fbcon_ops *ops = info->fbcon_par;
  1160. struct display *p = &fb_display[vc->vc_num];
  1161. p->yscroll += count;
  1162. if (p->yscroll >= p->vrows) /* Deal with wrap */
  1163. p->yscroll -= p->vrows;
  1164. ops->var.xoffset = 0;
  1165. ops->var.yoffset = p->yscroll * vc->vc_font.height;
  1166. ops->var.vmode |= FB_VMODE_YWRAP;
  1167. ops->update_start(info);
  1168. scrollback_max += count;
  1169. if (scrollback_max > scrollback_phys_max)
  1170. scrollback_max = scrollback_phys_max;
  1171. scrollback_current = 0;
  1172. }
  1173. static __inline__ void ywrap_down(struct vc_data *vc, int count)
  1174. {
  1175. struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
  1176. struct fbcon_ops *ops = info->fbcon_par;
  1177. struct display *p = &fb_display[vc->vc_num];
  1178. p->yscroll -= count;
  1179. if (p->yscroll < 0) /* Deal with wrap */
  1180. p->yscroll += p->vrows;
  1181. ops->var.xoffset = 0;
  1182. ops->var.yoffset = p->yscroll * vc->vc_font.height;
  1183. ops->var.vmode |= FB_VMODE_YWRAP;
  1184. ops->update_start(info);
  1185. scrollback_max -= count;
  1186. if (scrollback_max < 0)
  1187. scrollback_max = 0;
  1188. scrollback_current = 0;
  1189. }
  1190. static __inline__ void ypan_up(struct vc_data *vc, int count)
  1191. {
  1192. struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
  1193. struct display *p = &fb_display[vc->vc_num];
  1194. struct fbcon_ops *ops = info->fbcon_par;
  1195. p->yscroll += count;
  1196. if (p->yscroll > p->vrows - vc->vc_rows) {
  1197. ops->bmove(vc, info, p->vrows - vc->vc_rows,
  1198. 0, 0, 0, vc->vc_rows, vc->vc_cols);
  1199. p->yscroll -= p->vrows - vc->vc_rows;
  1200. }
  1201. ops->var.xoffset = 0;
  1202. ops->var.yoffset = p->yscroll * vc->vc_font.height;
  1203. ops->var.vmode &= ~FB_VMODE_YWRAP;
  1204. ops->update_start(info);
  1205. fbcon_clear_margins(vc, 1);
  1206. scrollback_max += count;
  1207. if (scrollback_max > scrollback_phys_max)
  1208. scrollback_max = scrollback_phys_max;
  1209. scrollback_current = 0;
  1210. }
  1211. static __inline__ void ypan_up_redraw(struct vc_data *vc, int t, int count)
  1212. {
  1213. struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
  1214. struct fbcon_ops *ops = info->fbcon_par;
  1215. struct display *p = &fb_display[vc->vc_num];
  1216. int redraw = 0;
  1217. p->yscroll += count;
  1218. if (p->yscroll > p->vrows - vc->vc_rows) {
  1219. p->yscroll -= p->vrows - vc->vc_rows;
  1220. redraw = 1;
  1221. }
  1222. if (redraw)
  1223. fbcon_redraw_move(vc, p, t + count, vc->vc_rows - count, t);
  1224. ops->var.xoffset = 0;
  1225. ops->var.yoffset = p->yscroll * vc->vc_font.height;
  1226. ops->var.vmode &= ~FB_VMODE_YWRAP;
  1227. ops->update_start(info);
  1228. fbcon_clear_margins(vc, 1);
  1229. scrollback_max += count;
  1230. if (scrollback_max > scrollback_phys_max)
  1231. scrollback_max = scrollback_phys_max;
  1232. scrollback_current = 0;
  1233. }
  1234. static __inline__ void ypan_down(struct vc_data *vc, int count)
  1235. {
  1236. struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
  1237. struct display *p = &fb_display[vc->vc_num];
  1238. struct fbcon_ops *ops = info->fbcon_par;
  1239. p->yscroll -= count;
  1240. if (p->yscroll < 0) {
  1241. ops->bmove(vc, info, 0, 0, p->vrows - vc->vc_rows,
  1242. 0, vc->vc_rows, vc->vc_cols);
  1243. p->yscroll += p->vrows - vc->vc_rows;
  1244. }
  1245. ops->var.xoffset = 0;
  1246. ops->var.yoffset = p->yscroll * vc->vc_font.height;
  1247. ops->var.vmode &= ~FB_VMODE_YWRAP;
  1248. ops->update_start(info);
  1249. fbcon_clear_margins(vc, 1);
  1250. scrollback_max -= count;
  1251. if (scrollback_max < 0)
  1252. scrollback_max = 0;
  1253. scrollback_current = 0;
  1254. }
  1255. static __inline__ void ypan_down_redraw(struct vc_data *vc, int t, int count)
  1256. {
  1257. struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
  1258. struct fbcon_ops *ops = info->fbcon_par;
  1259. struct display *p = &fb_display[vc->vc_num];
  1260. int redraw = 0;
  1261. p->yscroll -= count;
  1262. if (p->yscroll < 0) {
  1263. p->yscroll += p->vrows - vc->vc_rows;
  1264. redraw = 1;
  1265. }
  1266. if (redraw)
  1267. fbcon_redraw_move(vc, p, t, vc->vc_rows - count, t + count);
  1268. ops->var.xoffset = 0;
  1269. ops->var.yoffset = p->yscroll * vc->vc_font.height;
  1270. ops->var.vmode &= ~FB_VMODE_YWRAP;
  1271. ops->update_start(info);
  1272. fbcon_clear_margins(vc, 1);
  1273. scrollback_max -= count;
  1274. if (scrollback_max < 0)
  1275. scrollback_max = 0;
  1276. scrollback_current = 0;
  1277. }
  1278. static void fbcon_redraw_softback(struct vc_data *vc, struct display *p,
  1279. long delta)
  1280. {
  1281. int count = vc->vc_rows;
  1282. unsigned short *d, *s;
  1283. unsigned long n;
  1284. int line = 0;
  1285. d = (u16 *) softback_curr;
  1286. if (d == (u16 *) softback_in)
  1287. d = (u16 *) vc->vc_origin;
  1288. n = softback_curr + delta * vc->vc_size_row;
  1289. softback_lines -= delta;
  1290. if (delta < 0) {
  1291. if (softback_curr < softback_top && n < softback_buf) {
  1292. n += softback_end - softback_buf;
  1293. if (n < softback_top) {
  1294. softback_lines -=
  1295. (softback_top - n) / vc->vc_size_row;
  1296. n = softback_top;
  1297. }
  1298. } else if (softback_curr >= softback_top
  1299. && n < softback_top) {
  1300. softback_lines -=
  1301. (softback_top - n) / vc->vc_size_row;
  1302. n = softback_top;
  1303. }
  1304. } else {
  1305. if (softback_curr > softback_in && n >= softback_end) {
  1306. n += softback_buf - softback_end;
  1307. if (n > softback_in) {
  1308. n = softback_in;
  1309. softback_lines = 0;
  1310. }
  1311. } else if (softback_curr <= softback_in && n > softback_in) {
  1312. n = softback_in;
  1313. softback_lines = 0;
  1314. }
  1315. }
  1316. if (n == softback_curr)
  1317. return;
  1318. softback_curr = n;
  1319. s = (u16 *) softback_curr;
  1320. if (s == (u16 *) softback_in)
  1321. s = (u16 *) vc->vc_origin;
  1322. while (count--) {
  1323. unsigned short *start;
  1324. unsigned short *le;
  1325. unsigned short c;
  1326. int x = 0;
  1327. unsigned short attr = 1;
  1328. start = s;
  1329. le = advance_row(s, 1);
  1330. do {
  1331. c = scr_readw(s);
  1332. if (attr != (c & 0xff00)) {
  1333. attr = c & 0xff00;
  1334. if (s > start) {
  1335. fbcon_putcs(vc, start, s - start,
  1336. line, x);
  1337. x += s - start;
  1338. start = s;
  1339. }
  1340. }
  1341. if (c == scr_readw(d)) {
  1342. if (s > start) {
  1343. fbcon_putcs(vc, start, s - start,
  1344. line, x);
  1345. x += s - start + 1;
  1346. start = s + 1;
  1347. } else {
  1348. x++;
  1349. start++;
  1350. }
  1351. }
  1352. s++;
  1353. d++;
  1354. } while (s < le);
  1355. if (s > start)
  1356. fbcon_putcs(vc, start, s - start, line, x);
  1357. line++;
  1358. if (d == (u16 *) softback_end)
  1359. d = (u16 *) softback_buf;
  1360. if (d == (u16 *) softback_in)
  1361. d = (u16 *) vc->vc_origin;
  1362. if (s == (u16 *) softback_end)
  1363. s = (u16 *) softback_buf;
  1364. if (s == (u16 *) softback_in)
  1365. s = (u16 *) vc->vc_origin;
  1366. }
  1367. }
  1368. static void fbcon_redraw_move(struct vc_data *vc, struct display *p,
  1369. int line, int count, int dy)
  1370. {
  1371. unsigned short *s = (unsigned short *)
  1372. (vc->vc_origin + vc->vc_size_row * line);
  1373. while (count--) {
  1374. unsigned short *start = s;
  1375. unsigned short *le = advance_row(s, 1);
  1376. unsigned short c;
  1377. int x = 0;
  1378. unsigned short attr = 1;
  1379. do {
  1380. c = scr_readw(s);
  1381. if (attr != (c & 0xff00)) {
  1382. attr = c & 0xff00;
  1383. if (s > start) {
  1384. fbcon_putcs(vc, start, s - start,
  1385. dy, x);
  1386. x += s - start;
  1387. start = s;
  1388. }
  1389. }
  1390. console_conditional_schedule();
  1391. s++;
  1392. } while (s < le);
  1393. if (s > start)
  1394. fbcon_putcs(vc, start, s - start, dy, x);
  1395. console_conditional_schedule();
  1396. dy++;
  1397. }
  1398. }
  1399. static void fbcon_redraw(struct vc_data *vc, struct display *p,
  1400. int line, int count, int offset)
  1401. {
  1402. unsigned short *d = (unsigned short *)
  1403. (vc->vc_origin + vc->vc_size_row * line);
  1404. unsigned short *s = d + offset;
  1405. while (count--) {
  1406. unsigned short *start = s;
  1407. unsigned short *le = advance_row(s, 1);
  1408. unsigned short c;
  1409. int x = 0;
  1410. unsigned short attr = 1;
  1411. do {
  1412. c = scr_readw(s);
  1413. if (attr != (c & 0xff00)) {
  1414. attr = c & 0xff00;
  1415. if (s > start) {
  1416. fbcon_putcs(vc, start, s - start,
  1417. line, x);
  1418. x += s - start;
  1419. start = s;
  1420. }
  1421. }
  1422. if (c == scr_readw(d)) {
  1423. if (s > start) {
  1424. fbcon_putcs(vc, start, s - start,
  1425. line, x);
  1426. x += s - start + 1;
  1427. start = s + 1;
  1428. } else {
  1429. x++;
  1430. start++;
  1431. }
  1432. }
  1433. scr_writew(c, d);
  1434. console_conditional_schedule();
  1435. s++;
  1436. d++;
  1437. } while (s < le);
  1438. if (s > start)
  1439. fbcon_putcs(vc, start, s - start, line, x);
  1440. console_conditional_schedule();
  1441. if (offset > 0)
  1442. line++;
  1443. else {
  1444. line--;
  1445. /* NOTE: We subtract two lines from these pointers */
  1446. s -= vc->vc_size_row;
  1447. d -= vc->vc_size_row;
  1448. }
  1449. }
  1450. }
  1451. static inline void fbcon_softback_note(struct vc_data *vc, int t,
  1452. int count)
  1453. {
  1454. unsigned short *p;
  1455. if (vc->vc_num != fg_console)
  1456. return;
  1457. p = (unsigned short *) (vc->vc_origin + t * vc->vc_size_row);
  1458. while (count) {
  1459. scr_memcpyw((u16 *) softback_in, p, vc->vc_size_row);
  1460. count--;
  1461. p = advance_row(p, 1);
  1462. softback_in += vc->vc_size_row;
  1463. if (softback_in == softback_end)
  1464. softback_in = softback_buf;
  1465. if (softback_in == softback_top) {
  1466. softback_top += vc->vc_size_row;
  1467. if (softback_top == softback_end)
  1468. softback_top = softback_buf;
  1469. }
  1470. }
  1471. softback_curr = softback_in;
  1472. }
  1473. static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
  1474. int count)
  1475. {
  1476. struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
  1477. struct display *p = &fb_display[vc->vc_num];
  1478. struct fbcon_ops *ops = info->fbcon_par;
  1479. int scroll_partial = info->flags & FBINFO_PARTIAL_PAN_OK;
  1480. if (fbcon_is_inactive(vc, info))
  1481. return -EINVAL;
  1482. fbcon_cursor(vc, CM_ERASE);
  1483. /*
  1484. * ++Geert: Only use ywrap/ypan if the console is in text mode
  1485. * ++Andrew: Only use ypan on hardware text mode when scrolling the
  1486. * whole screen (prevents flicker).
  1487. */
  1488. switch (dir) {
  1489. case SM_UP:
  1490. if (count > vc->vc_rows) /* Maximum realistic size */
  1491. count = vc->vc_rows;
  1492. if (softback_top)
  1493. fbcon_softback_note(vc, t, count);
  1494. if (logo_shown >= 0)
  1495. goto redraw_up;
  1496. switch (p->scrollmode) {
  1497. case SCROLL_MOVE:
  1498. ops->bmove(vc, info, t + count, 0, t, 0,
  1499. b - t - count, vc->vc_cols);
  1500. ops->clear(vc, info, b - count, 0, count,
  1501. vc->vc_cols);
  1502. break;
  1503. case SCROLL_WRAP_MOVE:
  1504. if (b - t - count > 3 * vc->vc_rows >> 2) {
  1505. if (t > 0)
  1506. fbcon_bmove(vc, 0, 0, count, 0, t,
  1507. vc->vc_cols);
  1508. ywrap_up(vc, count);
  1509. if (vc->vc_rows - b > 0)
  1510. fbcon_bmove(vc, b - count, 0, b, 0,
  1511. vc->vc_rows - b,
  1512. vc->vc_cols);
  1513. } else if (info->flags & FBINFO_READS_FAST)
  1514. fbcon_bmove(vc, t + count, 0, t, 0,
  1515. b - t - count, vc->vc_cols);
  1516. else
  1517. goto redraw_up;
  1518. fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
  1519. break;
  1520. case SCROLL_PAN_REDRAW:
  1521. if ((p->yscroll + count <=
  1522. 2 * (p->vrows - vc->vc_rows))
  1523. && ((!scroll_partial && (b - t == vc->vc_rows))
  1524. || (scroll_partial
  1525. && (b - t - count >
  1526. 3 * vc->vc_rows >> 2)))) {
  1527. if (t > 0)
  1528. fbcon_redraw_move(vc, p, 0, t, count);
  1529. ypan_up_redraw(vc, t, count);
  1530. if (vc->vc_rows - b > 0)
  1531. fbcon_redraw_move(vc, p, b - count,
  1532. vc->vc_rows - b, b);
  1533. } else
  1534. fbcon_redraw_move(vc, p, t + count, b - t - count, t);
  1535. fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
  1536. break;
  1537. case SCROLL_PAN_MOVE:
  1538. if ((p->yscroll + count <=
  1539. 2 * (p->vrows - vc->vc_rows))
  1540. && ((!scroll_partial && (b - t == vc->vc_rows))
  1541. || (scroll_partial
  1542. && (b - t - count >
  1543. 3 * vc->vc_rows >> 2)))) {
  1544. if (t > 0)
  1545. fbcon_bmove(vc, 0, 0, count, 0, t,
  1546. vc->vc_cols);
  1547. ypan_up(vc, count);
  1548. if (vc->vc_rows - b > 0)
  1549. fbcon_bmove(vc, b - count, 0, b, 0,
  1550. vc->vc_rows - b,
  1551. vc->vc_cols);
  1552. } else if (info->flags & FBINFO_READS_FAST)
  1553. fbcon_bmove(vc, t + count, 0, t, 0,
  1554. b - t - count, vc->vc_cols);
  1555. else
  1556. goto redraw_up;
  1557. fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
  1558. break;
  1559. case SCROLL_REDRAW:
  1560. redraw_up:
  1561. fbcon_redraw(vc, p, t, b - t - count,
  1562. count * vc->vc_cols);
  1563. fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
  1564. scr_memsetw((unsigned short *) (vc->vc_origin +
  1565. vc->vc_size_row *
  1566. (b - count)),
  1567. vc->vc_video_erase_char,
  1568. vc->vc_size_row * count);
  1569. return 1;
  1570. }
  1571. break;
  1572. case SM_DOWN:
  1573. if (count > vc->vc_rows) /* Maximum realistic size */
  1574. count = vc->vc_rows;
  1575. if (logo_shown >= 0)
  1576. goto redraw_down;
  1577. switch (p->scrollmode) {
  1578. case SCROLL_MOVE:
  1579. ops->bmove(vc, info, t, 0, t + count, 0,
  1580. b - t - count, vc->vc_cols);
  1581. ops->clear(vc, info, t, 0, count, vc->vc_cols);
  1582. break;
  1583. case SCROLL_WRAP_MOVE:
  1584. if (b - t - count > 3 * vc->vc_rows >> 2) {
  1585. if (vc->vc_rows - b > 0)
  1586. fbcon_bmove(vc, b, 0, b - count, 0,
  1587. vc->vc_rows - b,
  1588. vc->vc_cols);
  1589. ywrap_down(vc, count);
  1590. if (t > 0)
  1591. fbcon_bmove(vc, count, 0, 0, 0, t,
  1592. vc->vc_cols);
  1593. } else if (info->flags & FBINFO_READS_FAST)
  1594. fbcon_bmove(vc, t, 0, t + count, 0,
  1595. b - t - count, vc->vc_cols);
  1596. else
  1597. goto redraw_down;
  1598. fbcon_clear(vc, t, 0, count, vc->vc_cols);
  1599. break;
  1600. case SCROLL_PAN_MOVE:
  1601. if ((count - p->yscroll <= p->vrows - vc->vc_rows)
  1602. && ((!scroll_partial && (b - t == vc->vc_rows))
  1603. || (scroll_partial
  1604. && (b - t - count >
  1605. 3 * vc->vc_rows >> 2)))) {
  1606. if (vc->vc_rows - b > 0)
  1607. fbcon_bmove(vc, b, 0, b - count, 0,
  1608. vc->vc_rows - b,
  1609. vc->vc_cols);
  1610. ypan_down(vc, count);
  1611. if (t > 0)
  1612. fbcon_bmove(vc, count, 0, 0, 0, t,
  1613. vc->vc_cols);
  1614. } else if (info->flags & FBINFO_READS_FAST)
  1615. fbcon_bmove(vc, t, 0, t + count, 0,
  1616. b - t - count, vc->vc_cols);
  1617. else
  1618. goto redraw_down;
  1619. fbcon_clear(vc, t, 0, count, vc->vc_cols);
  1620. break;
  1621. case SCROLL_PAN_REDRAW:
  1622. if ((count - p->yscroll <= p->vrows - vc->vc_rows)
  1623. && ((!scroll_partial && (b - t == vc->vc_rows))
  1624. || (scroll_partial
  1625. && (b - t - count >
  1626. 3 * vc->vc_rows >> 2)))) {
  1627. if (vc->vc_rows - b > 0)
  1628. fbcon_redraw_move(vc, p, b, vc->vc_rows - b,
  1629. b - count);
  1630. ypan_down_redraw(vc, t, count);
  1631. if (t > 0)
  1632. fbcon_redraw_move(vc, p, count, t, 0);
  1633. } else
  1634. fbcon_redraw_move(vc, p, t, b - t - count, t + count);
  1635. fbcon_clear(vc, t, 0, count, vc->vc_cols);
  1636. break;
  1637. case SCROLL_REDRAW:
  1638. redraw_down:
  1639. fbcon_redraw(vc, p, b - 1, b - t - count,
  1640. -count * vc->vc_cols);
  1641. fbcon_clear(vc, t, 0, count, vc->vc_cols);
  1642. scr_memsetw((unsigned short *) (vc->vc_origin +
  1643. vc->vc_size_row *
  1644. t),
  1645. vc->vc_video_erase_char,
  1646. vc->vc_size_row * count);
  1647. return 1;
  1648. }
  1649. }
  1650. return 0;
  1651. }
  1652. static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx,
  1653. int height, int width)
  1654. {
  1655. struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
  1656. struct display *p = &fb_display[vc->vc_num];
  1657. if (fbcon_is_inactive(vc, info))
  1658. return;
  1659. if (!width || !height)
  1660. return;
  1661. /* Split blits that cross physical y_wrap case.
  1662. * Pathological case involves 4 blits, better to use recursive
  1663. * code rather than unrolled case
  1664. *
  1665. * Recursive invocations don't need to erase the cursor over and
  1666. * over again, so we use fbcon_bmove_rec()
  1667. */
  1668. fbcon_bmove_rec(vc, p, sy, sx, dy, dx, height, width,
  1669. p->vrows - p->yscroll);
  1670. }
  1671. static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int sx,
  1672. int dy, int dx, int height, int width, u_int y_break)
  1673. {
  1674. struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
  1675. struct fbcon_ops *ops = info->fbcon_par;
  1676. u_int b;
  1677. if (sy < y_break && sy + height > y_break) {
  1678. b = y_break - sy;
  1679. if (dy < sy) { /* Avoid trashing self */
  1680. fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
  1681. y_break);
  1682. fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
  1683. height - b, width, y_break);
  1684. } else {
  1685. fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
  1686. height - b, width, y_break);
  1687. fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
  1688. y_break);
  1689. }
  1690. return;
  1691. }
  1692. if (dy < y_break && dy + height > y_break) {
  1693. b = y_break - dy;
  1694. if (dy < sy) { /* Avoid trashing self */
  1695. fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
  1696. y_break);
  1697. fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
  1698. height - b, width, y_break);
  1699. } else {
  1700. fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx,
  1701. height - b, width, y_break);
  1702. fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width,
  1703. y_break);
  1704. }
  1705. return;
  1706. }
  1707. ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
  1708. height, width);
  1709. }
  1710. static __inline__ void updatescrollmode(struct display *p,
  1711. struct fb_info *info,
  1712. struct vc_data *vc)
  1713. {
  1714. struct fbcon_ops *ops = info->fbcon_par;
  1715. int fh = vc->vc_font.height;
  1716. int cap = info->flags;
  1717. u16 t = 0;
  1718. int ypan = FBCON_SWAP(ops->rotate, info->fix.ypanstep,
  1719. info->fix.xpanstep);
  1720. int ywrap = FBCON_SWAP(ops->rotate, info->fix.ywrapstep, t);
  1721. int yres = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
  1722. int vyres = FBCON_SWAP(ops->rotate, info->var.yres_virtual,
  1723. info->var.xres_virtual);
  1724. int good_pan = (cap & FBINFO_HWACCEL_YPAN) &&
  1725. divides(ypan, vc->vc_font.height) && vyres > yres;
  1726. int good_wrap = (cap & FBINFO_HWACCEL_YWRAP) &&
  1727. divides(ywrap, vc->vc_font.height) &&
  1728. divides(vc->vc_font.height, vyres);
  1729. int reading_fast = cap & FBINFO_READS_FAST;
  1730. int fast_copyarea = (cap & FBINFO_HWACCEL_COPYAREA) &&
  1731. !(cap & FBINFO_HWACCEL_DISABLED);
  1732. int fast_imageblit = (cap & FBINFO_HWACCEL_IMAGEBLIT) &&
  1733. !(cap & FBINFO_HWACCEL_DISABLED);
  1734. p->vrows = vyres/fh;
  1735. if (yres > (fh * (vc->vc_rows + 1)))
  1736. p->vrows -= (yres - (fh * vc->vc_rows)) / fh;
  1737. if ((yres % fh) && (vyres % fh < yres % fh))
  1738. p->vrows--;
  1739. if (good_wrap || good_pan) {
  1740. if (reading_fast || fast_copyarea)
  1741. p->scrollmode = good_wrap ?
  1742. SCROLL_WRAP_MOVE : SCROLL_PAN_MOVE;
  1743. else
  1744. p->scrollmode = good_wrap ? SCROLL_REDRAW :
  1745. SCROLL_PAN_REDRAW;
  1746. } else {
  1747. if (reading_fast || (fast_copyarea && !fast_imageblit))
  1748. p->scrollmode = SCROLL_MOVE;
  1749. else
  1750. p->scrollmode = SCROLL_REDRAW;
  1751. }
  1752. }
  1753. static int fbcon_resize(struct vc_data *vc, unsigned int width,
  1754. unsigned int height)
  1755. {
  1756. struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
  1757. struct fbcon_ops *ops = info->fbcon_par;
  1758. struct display *p = &fb_display[vc->vc_num];
  1759. struct fb_var_screeninfo var = info->var;
  1760. int x_diff, y_diff, virt_w, virt_h, virt_fw, virt_fh;
  1761. virt_w = FBCON_SWAP(ops->rotate, width, height);
  1762. virt_h = FBCON_SWAP(ops->rotate, height, width);
  1763. virt_fw = FBCON_SWAP(ops->rotate, vc->vc_font.width,
  1764. vc->vc_font.height);
  1765. virt_fh = FBCON_SWAP(ops->rotate, vc->vc_font.height,
  1766. vc->vc_font.width);
  1767. var.xres = virt_w * virt_fw;
  1768. var.yres = virt_h * virt_fh;
  1769. x_diff = info->var.xres - var.xres;
  1770. y_diff = info->var.yres - var.yres;
  1771. if (x_diff < 0 || x_diff > virt_fw ||
  1772. y_diff < 0 || y_diff > virt_fh) {
  1773. struct fb_videomode *mode;
  1774. DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
  1775. mode = fb_find_best_mode(&var, &info->modelist);
  1776. if (mode == NULL)
  1777. return -EINVAL;
  1778. display_to_var(&var, p);
  1779. fb_videomode_to_var(&var, mode);
  1780. if (virt_w > var.xres/virt_fw || virt_h > var.yres/virt_fh)
  1781. return -EINVAL;
  1782. DPRINTK("resize now %ix%i\n", var.xres, var.yres);
  1783. if (CON_IS_VISIBLE(vc)) {
  1784. var.activate = FB_ACTIVATE_NOW |
  1785. FB_ACTIVATE_FORCE;
  1786. fb_set_var(info, &var);
  1787. }
  1788. var_to_display(p, &info->var, info);
  1789. ops->var = info->var;
  1790. }
  1791. updatescrollmode(p, info, vc);
  1792. return 0;
  1793. }
  1794. static int fbcon_switch(struct vc_data *vc)
  1795. {
  1796. struct fb_info *info, *old_info = NULL;
  1797. struct fbcon_ops *ops;
  1798. struct display *p = &fb_display[vc->vc_num];
  1799. struct fb_var_screeninfo var;
  1800. int i, prev_console, charcnt = 256;
  1801. info = registered_fb[con2fb_map[vc->vc_num]];
  1802. ops = info->fbcon_par;
  1803. if (softback_top) {
  1804. if (softback_lines)
  1805. fbcon_set_origin(vc);
  1806. softback_top = softback_curr = softback_in = softback_buf;
  1807. softback_lines = 0;
  1808. fbcon_update_softback(vc);
  1809. }
  1810. if (logo_shown >= 0) {
  1811. struct vc_data *conp2 = vc_cons[logo_shown].d;
  1812. if (conp2->vc_top == logo_lines
  1813. && conp2->vc_bottom == conp2->vc_rows)
  1814. conp2->vc_top = 0;
  1815. logo_shown = FBCON_LOGO_CANSHOW;
  1816. }
  1817. prev_console = ops->currcon;
  1818. if (prev_console != -1)
  1819. old_info = registered_fb[con2fb_map[prev_console]];
  1820. /*
  1821. * FIXME: If we have multiple fbdev's loaded, we need to
  1822. * update all info->currcon. Perhaps, we can place this
  1823. * in a centralized structure, but this might break some
  1824. * drivers.
  1825. *
  1826. * info->currcon = vc->vc_num;
  1827. */
  1828. for (i = 0; i < FB_MAX; i++) {
  1829. if (registered_fb[i] != NULL && registered_fb[i]->fbcon_par) {
  1830. struct fbcon_ops *o = registered_fb[i]->fbcon_par;
  1831. o->currcon = vc->vc_num;
  1832. }
  1833. }
  1834. memset(&var, 0, sizeof(struct fb_var_screeninfo));
  1835. display_to_var(&var, p);
  1836. var.activate = FB_ACTIVATE_NOW;
  1837. /*
  1838. * make sure we don't unnecessarily trip the memcmp()
  1839. * in fb_set_var()
  1840. */
  1841. info->var.activate = var.activate;
  1842. var.yoffset = info->var.yoffset;
  1843. var.xoffset = info->var.xoffset;
  1844. var.vmode = info->var.vmode;
  1845. fb_set_var(info, &var);
  1846. ops->var = info->var;
  1847. if (old_info != NULL && (old_info != info ||
  1848. info->flags & FBINFO_MISC_ALWAYS_SETPAR)) {
  1849. if (info->fbops->fb_set_par)
  1850. info->fbops->fb_set_par(info);
  1851. fbcon_del_cursor_timer(old_info);
  1852. fbcon_add_cursor_timer(info);
  1853. }
  1854. set_blitting_type(vc, info, p);
  1855. ops->cursor_reset = 1;
  1856. if (ops->rotate_font && ops->rotate_font(info, vc, p)) {
  1857. ops->rotate = FB_ROTATE_UR;
  1858. set_blitting_type(vc, info, p);
  1859. }
  1860. vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1);
  1861. vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
  1862. if (p->userfont)
  1863. charcnt = FNTCHARCNT(vc->vc_font.data);
  1864. if (charcnt > 256)
  1865. vc->vc_complement_mask <<= 1;
  1866. updatescrollmode(p, info, vc);
  1867. switch (p->scrollmode) {
  1868. case SCROLL_WRAP_MOVE:
  1869. scrollback_phys_max = p->vrows - vc->vc_rows;
  1870. break;
  1871. case SCROLL_PAN_MOVE:
  1872. case SCROLL_PAN_REDRAW:
  1873. scrollback_phys_max = p->vrows - 2 * vc->vc_rows;
  1874. if (scrollback_phys_max < 0)
  1875. scrollback_phys_max = 0;
  1876. break;
  1877. default:
  1878. scrollback_phys_max = 0;
  1879. break;
  1880. }
  1881. scrollback_max = 0;
  1882. scrollback_current = 0;
  1883. if (!fbcon_is_inactive(vc, info)) {
  1884. ops->var.xoffset = ops->var.yoffset = p->yscroll = 0;
  1885. ops->update_start(info);
  1886. }
  1887. fbcon_set_palette(vc, color_table);
  1888. fbcon_clear_margins(vc, 0);
  1889. if (logo_shown == FBCON_LOGO_DRAW) {
  1890. logo_shown = fg_console;
  1891. /* This is protected above by initmem_freed */
  1892. fb_show_logo(info, ops->rotate);
  1893. update_region(vc,
  1894. vc->vc_origin + vc->vc_size_row * vc->vc_top,
  1895. vc->vc_size_row * (vc->vc_bottom -
  1896. vc->vc_top) / 2);
  1897. return 0;
  1898. }
  1899. return 1;
  1900. }
  1901. static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info,
  1902. int blank)
  1903. {
  1904. if (blank) {
  1905. unsigned short charmask = vc->vc_hi_font_mask ?
  1906. 0x1ff : 0xff;
  1907. unsigned short oldc;
  1908. oldc = vc->vc_video_erase_char;
  1909. vc->vc_video_erase_char &= charmask;
  1910. fbcon_clear(vc, 0, 0, vc->vc_rows, vc->vc_cols);
  1911. vc->vc_video_erase_char = oldc;
  1912. }
  1913. }
  1914. static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)
  1915. {
  1916. struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
  1917. struct fbcon_ops *ops = info->fbcon_par;
  1918. if (mode_switch) {
  1919. struct fb_var_screeninfo var = info->var;
  1920. ops->graphics = 1;
  1921. if (!blank) {
  1922. if (info->fbops->fb_save_state)
  1923. info->fbops->fb_save_state(info);
  1924. var.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE;
  1925. fb_set_var(info, &var);
  1926. ops->graphics = 0;
  1927. ops->var = info->var;
  1928. } else if (info->fbops->fb_restore_state)
  1929. info->fbops->fb_restore_state(info);
  1930. }
  1931. if (!fbcon_is_inactive(vc, info)) {
  1932. if (ops->blank_state != blank) {
  1933. ops->blank_state = blank;
  1934. fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
  1935. ops->cursor_flash = (!blank);
  1936. if (fb_blank(info, blank))
  1937. fbcon_generic_blank(vc, info, blank);
  1938. }
  1939. if (!blank)
  1940. update_screen(vc);
  1941. }
  1942. if (!blank)
  1943. fbcon_add_cursor_timer(info);
  1944. else
  1945. fbcon_del_cursor_timer(info);
  1946. return 0;
  1947. }
  1948. static void fbcon_free_font(struct display *p)
  1949. {
  1950. if (p->userfont && p->fontdata && (--REFCOUNT(p->fontdata) == 0))
  1951. kfree(p->fontdata - FONT_EXTRA_WORDS * sizeof(int));
  1952. p->fontdata = NULL;
  1953. p->userfont = 0;
  1954. }
  1955. static int fbcon_get_font(struct vc_data *vc, struct console_font *font)
  1956. {
  1957. u8 *fontdata = vc->vc_font.data;
  1958. u8 *data = font->data;
  1959. int i, j;
  1960. font->width = vc->vc_font.width;
  1961. font->height = vc->vc_font.height;
  1962. font->charcount = vc->vc_hi_font_mask ? 512 : 256;
  1963. if (!font->data)
  1964. return 0;
  1965. if (font->width <= 8) {
  1966. j = vc->vc_font.height;
  1967. for (i = 0; i < font->charcount; i++) {
  1968. memcpy(data, fontdata, j);
  1969. memset(data + j, 0, 32 - j);
  1970. data += 32;
  1971. fontdata += j;
  1972. }
  1973. } else if (font->width <= 16) {
  1974. j = vc->vc_font.height * 2;
  1975. for (i = 0; i < font->charcount; i++) {
  1976. memcpy(data, fontdata, j);
  1977. memset(data + j, 0, 64 - j);
  1978. data += 64;
  1979. fontdata += j;
  1980. }
  1981. } else if (font->width <= 24) {
  1982. for (i = 0; i < font->charcount; i++) {
  1983. for (j = 0; j < vc->vc_font.height; j++) {
  1984. *data++ = fontdata[0];
  1985. *data++ = fontdata[1];
  1986. *data++ = fontdata[2];
  1987. fontdata += sizeof(u32);
  1988. }
  1989. memset(data, 0, 3 * (32 - j));
  1990. data += 3 * (32 - j);
  1991. }
  1992. } else {
  1993. j = vc->vc_font.height * 4;
  1994. for (i = 0; i < font->charcount; i++) {
  1995. memcpy(data, fontdata, j);
  1996. memset(data + j, 0, 128 - j);
  1997. data += 128;
  1998. fontdata += j;
  1999. }
  2000. }
  2001. return 0;
  2002. }
  2003. static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
  2004. const u8 * data, int userfont)
  2005. {
  2006. struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
  2007. struct fbcon_ops *ops = info->fbcon_par;
  2008. struct display *p = &fb_display[vc->vc_num];
  2009. int resize;
  2010. int cnt;
  2011. char *old_data = NULL;
  2012. if (CON_IS_VISIBLE(vc) && softback_lines)
  2013. fbcon_set_origin(vc);
  2014. resize = (w != vc->vc_font.width) || (h != vc->vc_font.height);
  2015. if (p->userfont)
  2016. old_data = vc->vc_font.data;
  2017. if (userfont)
  2018. cnt = FNTCHARCNT(data);
  2019. else
  2020. cnt = 256;
  2021. vc->vc_font.data = (void *)(p->fontdata = data);
  2022. if ((p->userfont = userfont))
  2023. REFCOUNT(data)++;
  2024. vc->vc_font.width = w;
  2025. vc->vc_font.height = h;
  2026. if (vc->vc_hi_font_mask && cnt == 256) {
  2027. vc->vc_hi_font_mask = 0;
  2028. if (vc->vc_can_do_color) {
  2029. vc->vc_complement_mask >>= 1;
  2030. vc->vc_s_complement_mask >>= 1;
  2031. }
  2032. /* ++Edmund: reorder the attribute bits */
  2033. if (vc->vc_can_do_color) {
  2034. unsigned short *cp =
  2035. (unsigned short *) vc->vc_origin;
  2036. int count = vc->vc_screenbuf_size / 2;
  2037. unsigned short c;
  2038. for (; count > 0; count--, cp++) {
  2039. c = scr_readw(cp);
  2040. scr_writew(((c & 0xfe00) >> 1) |
  2041. (c & 0xff), cp);
  2042. }
  2043. c = vc->vc_video_erase_char;
  2044. vc->vc_video_erase_char =
  2045. ((c & 0xfe00) >> 1) | (c & 0xff);
  2046. vc->vc_attr >>= 1;
  2047. }
  2048. } else if (!vc->vc_hi_font_mask && cnt == 512) {
  2049. vc->vc_hi_font_mask = 0x100;
  2050. if (vc->vc_can_do_color) {
  2051. vc->vc_complement_mask <<= 1;
  2052. vc->vc_s_complement_mask <<= 1;
  2053. }
  2054. /* ++Edmund: reorder the attribute bits */
  2055. {
  2056. unsigned short *cp =
  2057. (unsigned short *) vc->vc_origin;
  2058. int count = vc->vc_screenbuf_size / 2;
  2059. unsigned short c;
  2060. for (; count > 0; count--, cp++) {
  2061. unsigned short newc;
  2062. c = scr_readw(cp);
  2063. if (vc->vc_can_do_color)
  2064. newc =
  2065. ((c & 0xff00) << 1) | (c &
  2066. 0xff);
  2067. else
  2068. newc = c & ~0x100;
  2069. scr_writew(newc, cp);
  2070. }
  2071. c = vc->vc_video_erase_char;
  2072. if (vc->vc_can_do_color) {
  2073. vc->vc_video_erase_char =
  2074. ((c & 0xff00) << 1) | (c & 0xff);
  2075. vc->vc_attr <<= 1;
  2076. } else
  2077. vc->vc_video_erase_char = c & ~0x100;
  2078. }
  2079. }
  2080. if (resize) {
  2081. int cols, rows;
  2082. cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
  2083. rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
  2084. cols /= w;
  2085. rows /= h;
  2086. vc_resize(vc, cols, rows);
  2087. if (CON_IS_VISIBLE(vc) && softback_buf)
  2088. fbcon_update_softback(vc);
  2089. } else if (CON_IS_VISIBLE(vc)
  2090. && vc->vc_mode == KD_TEXT) {
  2091. fbcon_clear_margins(vc, 0);
  2092. update_screen(vc);
  2093. }
  2094. if (old_data && (--REFCOUNT(old_data) == 0))
  2095. kfree(old_data - FONT_EXTRA_WORDS * sizeof(int));
  2096. return 0;
  2097. }
  2098. static int fbcon_copy_font(struct vc_data *vc, int con)
  2099. {
  2100. struct display *od = &fb_display[con];
  2101. struct console_font *f = &vc->vc_font;
  2102. if (od->fontdata == f->data)
  2103. return 0; /* already the same font... */
  2104. return fbcon_do_set_font(vc, f->width, f->height, od->fontdata, od->userfont);
  2105. }
  2106. /*
  2107. * User asked to set font; we are guaranteed that
  2108. * a) width and height are in range 1..32
  2109. * b) charcount does not exceed 512
  2110. * but lets not assume that, since someone might someday want to use larger
  2111. * fonts. And charcount of 512 is small for unicode support.
  2112. *
  2113. * However, user space gives the font in 32 rows , regardless of
  2114. * actual font height. So a new API is needed if support for larger fonts
  2115. * is ever implemented.
  2116. */
  2117. static int fbcon_set_font(struct vc_data *vc, struct console_font *font, unsigned flags)
  2118. {
  2119. unsigned charcount = font->charcount;
  2120. int w = font->width;
  2121. int h = font->height;
  2122. int size;
  2123. int i, csum;
  2124. u8 *new_data, *data = font->data;
  2125. int pitch = (font->width+7) >> 3;
  2126. /* Is there a reason why fbconsole couldn't handle any charcount >256?
  2127. * If not this check should be changed to charcount < 256 */
  2128. if (charcount != 256 && charcount != 512)
  2129. return -EINVAL;
  2130. size = h * pitch * charcount;
  2131. new_data = kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size, GFP_USER);
  2132. if (!new_data)
  2133. return -ENOMEM;
  2134. new_data += FONT_EXTRA_WORDS * sizeof(int);
  2135. FNTSIZE(new_data) = size;
  2136. FNTCHARCNT(new_data) = charcount;
  2137. REFCOUNT(new_data) = 0; /* usage counter */
  2138. for (i=0; i< charcount; i++) {
  2139. memcpy(new_data + i*h*pitch, data + i*32*pitch, h*pitch);
  2140. }
  2141. /* Since linux has a nice crc32 function use it for counting font
  2142. * checksums. */
  2143. csum = crc32(0, new_data, size);
  2144. FNTSUM(new_data) = csum;
  2145. /* Check if the same font is on some other console already */
  2146. for (i = 0; i < MAX_NR_CONSOLES; i++) {
  2147. struct vc_data *tmp = vc_cons[i].d;
  2148. if (fb_display[i].userfont &&
  2149. fb_display[i].fontdata &&
  2150. FNTSUM(fb_display[i].fontdata) == csum &&
  2151. FNTSIZE(fb_display[i].fontdata) == size &&
  2152. tmp->vc_font.width == w &&
  2153. !memcmp(fb_display[i].fontdata, new_data, size)) {
  2154. kfree(new_data - FONT_EXTRA_WORDS * sizeof(int));
  2155. new_data = (u8 *)fb_display[i].fontdata;
  2156. break;
  2157. }
  2158. }
  2159. return fbcon_do_set_font(vc, font->width, font->height, new_data, 1);
  2160. }
  2161. static int fbcon_set_def_font(struct vc_data *vc, struct console_font *font, char *name)
  2162. {
  2163. struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
  2164. const struct font_desc *f;
  2165. if (!name)
  2166. f = get_default_font(info->var.xres, info->var.yres);
  2167. else if (!(f = find_font(name)))
  2168. return -ENOENT;
  2169. font->width = f->width;
  2170. font->height = f->height;
  2171. return fbcon_do_set_font(vc, f->width, f->height, f->data, 0);
  2172. }
  2173. static u16 palette_red[16];
  2174. static u16 palette_green[16];
  2175. static u16 palette_blue[16];
  2176. static struct fb_cmap palette_cmap = {
  2177. 0, 16, palette_red, palette_green, palette_blue, NULL
  2178. };
  2179. static int fbcon_set_palette(struct vc_data *vc, unsigned char *table)
  2180. {
  2181. struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
  2182. int i, j, k, depth;
  2183. u8 val;
  2184. if (fbcon_is_inactive(vc, info))
  2185. return -EINVAL;
  2186. if (!CON_IS_VISIBLE(vc))
  2187. return 0;
  2188. depth = fb_get_color_depth(&info->var, &info->fix);
  2189. if (depth > 3) {
  2190. for (i = j = 0; i < 16; i++) {
  2191. k = table[i];
  2192. val = vc->vc_palette[j++];
  2193. palette_red[k] = (val << 8) | val;
  2194. val = vc->vc_palette[j++];
  2195. palette_green[k] = (val << 8) | val;
  2196. val = vc->vc_palette[j++];
  2197. palette_blue[k] = (val << 8) | val;
  2198. }
  2199. palette_cmap.len = 16;
  2200. palette_cmap.start = 0;
  2201. /*
  2202. * If framebuffer is capable of less than 16 colors,
  2203. * use default palette of fbcon.
  2204. */
  2205. } else
  2206. fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap);
  2207. return fb_set_cmap(&palette_cmap, info);
  2208. }
  2209. static u16 *fbcon_screen_pos(struct vc_data *vc, int offset)
  2210. {
  2211. unsigned long p;
  2212. int line;
  2213. if (vc->vc_num != fg_console || !softback_lines)
  2214. return (u16 *) (vc->vc_origin + offset);
  2215. line = offset / vc->vc_size_row;
  2216. if (line >= softback_lines)
  2217. return (u16 *) (vc->vc_origin + offset -
  2218. softback_lines * vc->vc_size_row);
  2219. p = softback_curr + offset;
  2220. if (p >= softback_end)
  2221. p += softback_buf - softback_end;
  2222. return (u16 *) p;
  2223. }
  2224. static unsigned long fbcon_getxy(struct vc_data *vc, unsigned long pos,
  2225. int *px, int *py)
  2226. {
  2227. unsigned long ret;
  2228. int x, y;
  2229. if (pos >= vc->vc_origin && pos < vc->vc_scr_end) {
  2230. unsigned long offset = (pos - vc->vc_origin) / 2;
  2231. x = offset % vc->vc_cols;
  2232. y = offset / vc->vc_cols;
  2233. if (vc->vc_num == fg_console)
  2234. y += softback_lines;
  2235. ret = pos + (vc->vc_cols - x) * 2;
  2236. } else if (vc->vc_num == fg_console && softback_lines) {
  2237. unsigned long offset = pos - softback_curr;
  2238. if (pos < softback_curr)
  2239. offset += softback_end - softback_buf;
  2240. offset /= 2;
  2241. x = offset % vc->vc_cols;
  2242. y = offset / vc->vc_cols;
  2243. ret = pos + (vc->vc_cols - x) * 2;
  2244. if (ret == softback_end)
  2245. ret = softback_buf;
  2246. if (ret == softback_in)
  2247. ret = vc->vc_origin;
  2248. } else {
  2249. /* Should not happen */
  2250. x = y = 0;
  2251. ret = vc->vc_origin;
  2252. }
  2253. if (px)
  2254. *px = x;
  2255. if (py)
  2256. *py = y;
  2257. return ret;
  2258. }
  2259. /* As we might be inside of softback, we may work with non-contiguous buffer,
  2260. that's why we have to use a separate routine. */
  2261. static void fbcon_invert_region(struct vc_data *vc, u16 * p, int cnt)
  2262. {
  2263. while (cnt--) {
  2264. u16 a = scr_readw(p);
  2265. if (!vc->vc_can_do_color)
  2266. a ^= 0x0800;
  2267. else if (vc->vc_hi_font_mask == 0x100)
  2268. a = ((a) & 0x11ff) | (((a) & 0xe000) >> 4) |
  2269. (((a) & 0x0e00) << 4);
  2270. else
  2271. a = ((a) & 0x88ff) | (((a) & 0x7000) >> 4) |
  2272. (((a) & 0x0700) << 4);
  2273. scr_writew(a, p++);
  2274. if (p == (u16 *) softback_end)
  2275. p = (u16 *) softback_buf;
  2276. if (p == (u16 *) softback_in)
  2277. p = (u16 *) vc->vc_origin;
  2278. }
  2279. }
  2280. static int fbcon_scrolldelta(struct vc_data *vc, int lines)
  2281. {
  2282. struct fb_info *info = registered_fb[con2fb_map[fg_console]];
  2283. struct fbcon_ops *ops = info->fbcon_par;
  2284. struct display *p = &fb_display[fg_console];
  2285. int offset, limit, scrollback_old;
  2286. if (softback_top) {
  2287. if (vc->vc_num != fg_console)
  2288. return 0;
  2289. if (vc->vc_mode != KD_TEXT || !lines)
  2290. return 0;
  2291. if (logo_shown >= 0) {
  2292. struct vc_data *conp2 = vc_cons[logo_shown].d;
  2293. if (conp2->vc_top == logo_lines
  2294. && conp2->vc_bottom == conp2->vc_rows)
  2295. conp2->vc_top = 0;
  2296. if (logo_shown == vc->vc_num) {
  2297. unsigned long p, q;
  2298. int i;
  2299. p = softback_in;
  2300. q = vc->vc_origin +
  2301. logo_lines * vc->vc_size_row;
  2302. for (i = 0; i < logo_lines; i++) {
  2303. if (p == softback_top)
  2304. break;
  2305. if (p == softback_buf)
  2306. p = softback_end;
  2307. p -= vc->vc_size_row;
  2308. q -= vc->vc_size_row;
  2309. scr_memcpyw((u16 *) q, (u16 *) p,
  2310. vc->vc_size_row);
  2311. }
  2312. softback_in = p;
  2313. update_region(vc, vc->vc_origin,
  2314. logo_lines * vc->vc_cols);
  2315. }
  2316. logo_shown = FBCON_LOGO_CANSHOW;
  2317. }
  2318. fbcon_cursor(vc, CM_ERASE | CM_SOFTBACK);
  2319. fbcon_redraw_softback(vc, p, lines);
  2320. fbcon_cursor(vc, CM_DRAW | CM_SOFTBACK);
  2321. return 0;
  2322. }
  2323. if (!scrollback_phys_max)
  2324. return -ENOSYS;
  2325. scrollback_old = scrollback_current;
  2326. scrollback_current -= lines;
  2327. if (scrollback_current < 0)
  2328. scrollback_current = 0;
  2329. else if (scrollback_current > scrollback_max)
  2330. scrollback_current = scrollback_max;
  2331. if (scrollback_current == scrollback_old)
  2332. return 0;
  2333. if (fbcon_is_inactive(vc, info))
  2334. return 0;
  2335. fbcon_cursor(vc, CM_ERASE);
  2336. offset = p->yscroll - scrollback_current;
  2337. limit = p->vrows;
  2338. switch (p->scrollmode) {
  2339. case SCROLL_WRAP_MOVE:
  2340. info->var.vmode |= FB_VMODE_YWRAP;
  2341. break;
  2342. case SCROLL_PAN_MOVE:
  2343. case SCROLL_PAN_REDRAW:
  2344. limit -= vc->vc_rows;
  2345. info->var.vmode &= ~FB_VMODE_YWRAP;
  2346. break;
  2347. }
  2348. if (offset < 0)
  2349. offset += limit;
  2350. else if (offset >= limit)
  2351. offset -= limit;
  2352. ops->var.xoffset = 0;
  2353. ops->var.yoffset = offset * vc->vc_font.height;
  2354. ops->update_start(info);
  2355. if (!scrollback_current)
  2356. fbcon_cursor(vc, CM_DRAW);
  2357. return 0;
  2358. }
  2359. static int fbcon_set_origin(struct vc_data *vc)
  2360. {
  2361. if (softback_lines)
  2362. fbcon_scrolldelta(vc, softback_lines);
  2363. return 0;
  2364. }
  2365. static void fbcon_suspended(struct fb_info *info)
  2366. {
  2367. struct vc_data *vc = NULL;
  2368. struct fbcon_ops *ops = info->fbcon_par;
  2369. if (!ops || ops->currcon < 0)
  2370. return;
  2371. vc = vc_cons[ops->currcon].d;
  2372. /* Clear cursor, restore saved data */
  2373. fbcon_cursor(vc, CM_ERASE);
  2374. }
  2375. static void fbcon_resumed(struct fb_info *info)
  2376. {
  2377. struct vc_data *vc;
  2378. struct fbcon_ops *ops = info->fbcon_par;
  2379. if (!ops || ops->currcon < 0)
  2380. return;
  2381. vc = vc_cons[ops->currcon].d;
  2382. update_screen(vc);
  2383. }
  2384. static void fbcon_modechanged(struct fb_info *info)
  2385. {
  2386. struct fbcon_ops *ops = info->fbcon_par;
  2387. struct vc_data *vc;
  2388. struct display *p;
  2389. int rows, cols;
  2390. if (!ops || ops->currcon < 0)
  2391. return;
  2392. vc = vc_cons[ops->currcon].d;
  2393. if (vc->vc_mode != KD_TEXT ||
  2394. registered_fb[con2fb_map[ops->currcon]] != info)
  2395. return;
  2396. p = &fb_display[vc->vc_num];
  2397. set_blitting_type(vc, info, p);
  2398. if (CON_IS_VISIBLE(vc)) {
  2399. var_to_display(p, &info->var, info);
  2400. cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
  2401. rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
  2402. cols /= vc->vc_font.width;
  2403. rows /= vc->vc_font.height;
  2404. vc_resize(vc, cols, rows);
  2405. updatescrollmode(p, info, vc);
  2406. scrollback_max = 0;
  2407. scrollback_current = 0;
  2408. if (!fbcon_is_inactive(vc, info)) {
  2409. ops->var.xoffset = ops->var.yoffset = p->yscroll = 0;
  2410. ops->update_start(info);
  2411. }
  2412. fbcon_set_palette(vc, color_table);
  2413. update_screen(vc);
  2414. if (softback_buf)
  2415. fbcon_update_softback(vc);
  2416. }
  2417. }
  2418. static void fbcon_set_all_vcs(struct fb_info *info)
  2419. {
  2420. struct fbcon_ops *ops = info->fbcon_par;
  2421. struct vc_data *vc;
  2422. struct display *p;
  2423. int i, rows, cols;
  2424. if (!ops || ops->currcon < 0)
  2425. return;
  2426. for (i = 0; i < MAX_NR_CONSOLES; i++) {
  2427. vc = vc_cons[i].d;
  2428. if (!vc || vc->vc_mode != KD_TEXT ||
  2429. registered_fb[con2fb_map[i]] != info)
  2430. continue;
  2431. p = &fb_display[vc->vc_num];
  2432. set_blitting_type(vc, info, p);
  2433. var_to_display(p, &info->var, info);
  2434. cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
  2435. rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
  2436. cols /= vc->vc_font.width;
  2437. rows /= vc->vc_font.height;
  2438. vc_resize(vc, cols, rows);
  2439. if (CON_IS_VISIBLE(vc)) {
  2440. updatescrollmode(p, info, vc);
  2441. scrollback_max = 0;
  2442. scrollback_current = 0;
  2443. if (!fbcon_is_inactive(vc, info)) {
  2444. ops->var.xoffset = ops->var.yoffset =
  2445. p->yscroll = 0;
  2446. ops->update_start(info);
  2447. }
  2448. fbcon_set_palette(vc, color_table);
  2449. update_screen(vc);
  2450. if (softback_buf)
  2451. fbcon_update_softback(vc);
  2452. }
  2453. }
  2454. }
  2455. static int fbcon_mode_deleted(struct fb_info *info,
  2456. struct fb_videomode *mode)
  2457. {
  2458. struct fb_info *fb_info;
  2459. struct display *p;
  2460. int i, j, found = 0;
  2461. /* before deletion, ensure that mode is not in use */
  2462. for (i = first_fb_vc; i <= last_fb_vc; i++) {
  2463. j = con2fb_map[i];
  2464. if (j == -1)
  2465. continue;
  2466. fb_info = registered_fb[j];
  2467. if (fb_info != info)
  2468. continue;
  2469. p = &fb_display[i];
  2470. if (!p || !p->mode)
  2471. continue;
  2472. if (fb_mode_is_equal(p->mode, mode)) {
  2473. found = 1;
  2474. break;
  2475. }
  2476. }
  2477. return found;
  2478. }
  2479. static int fbcon_fb_registered(int idx)
  2480. {
  2481. int ret = 0, i;
  2482. if (info_idx == -1) {
  2483. for (i = 0; i < MAX_NR_CONSOLES; i++) {
  2484. if (con2fb_map_boot[i] == idx) {
  2485. info_idx = idx;
  2486. break;
  2487. }
  2488. }
  2489. if (info_idx != -1)
  2490. ret = fbcon_takeover(1);
  2491. } else {
  2492. for (i = 0; i < MAX_NR_CONSOLES; i++) {
  2493. if (con2fb_map_boot[i] == idx)
  2494. set_con2fb_map(i, idx, 0);
  2495. }
  2496. }
  2497. return ret;
  2498. }
  2499. static void fbcon_fb_blanked(struct fb_info *info, int blank)
  2500. {
  2501. struct fbcon_ops *ops = info->fbcon_par;
  2502. struct vc_data *vc;
  2503. if (!ops || ops->currcon < 0)
  2504. return;
  2505. vc = vc_cons[ops->currcon].d;
  2506. if (vc->vc_mode != KD_TEXT ||
  2507. registered_fb[con2fb_map[ops->currcon]] != info)
  2508. return;
  2509. if (CON_IS_VISIBLE(vc)) {
  2510. if (blank)
  2511. do_blank_screen(0);
  2512. else
  2513. do_unblank_screen(0);
  2514. }
  2515. ops->blank_state = blank;
  2516. }
  2517. static void fbcon_new_modelist(struct fb_info *info)
  2518. {
  2519. int i;
  2520. struct vc_data *vc;
  2521. struct fb_var_screeninfo var;
  2522. struct fb_videomode *mode;
  2523. for (i = 0; i < MAX_NR_CONSOLES; i++) {
  2524. if (registered_fb[con2fb_map[i]] != info)
  2525. continue;
  2526. if (!fb_display[i].mode)
  2527. continue;
  2528. vc = vc_cons[i].d;
  2529. display_to_var(&var, &fb_display[i]);
  2530. mode = fb_find_nearest_mode(fb_display[i].mode,
  2531. &info->modelist);
  2532. fb_videomode_to_var(&var, mode);
  2533. if (vc)
  2534. fbcon_set_disp(info, &var, vc);
  2535. else
  2536. fbcon_preset_disp(info, &var, i);
  2537. }
  2538. }
  2539. static int fbcon_event_notify(struct notifier_block *self,
  2540. unsigned long action, void *data)
  2541. {
  2542. struct fb_event *event = data;
  2543. struct fb_info *info = event->info;
  2544. struct fb_videomode *mode;
  2545. struct fb_con2fbmap *con2fb;
  2546. int ret = 0;
  2547. switch(action) {
  2548. case FB_EVENT_SUSPEND:
  2549. fbcon_suspended(info);
  2550. break;
  2551. case FB_EVENT_RESUME:
  2552. fbcon_resumed(info);
  2553. break;
  2554. case FB_EVENT_MODE_CHANGE:
  2555. fbcon_modechanged(info);
  2556. break;
  2557. case FB_EVENT_MODE_CHANGE_ALL:
  2558. fbcon_set_all_vcs(info);
  2559. break;
  2560. case FB_EVENT_MODE_DELETE:
  2561. mode = event->data;
  2562. ret = fbcon_mode_deleted(info, mode);
  2563. break;
  2564. case FB_EVENT_FB_REGISTERED:
  2565. ret = fbcon_fb_registered(info->node);
  2566. break;
  2567. case FB_EVENT_SET_CONSOLE_MAP:
  2568. con2fb = event->data;
  2569. ret = set_con2fb_map(con2fb->console - 1,
  2570. con2fb->framebuffer, 1);
  2571. break;
  2572. case FB_EVENT_GET_CONSOLE_MAP:
  2573. con2fb = event->data;
  2574. con2fb->framebuffer = con2fb_map[con2fb->console - 1];
  2575. break;
  2576. case FB_EVENT_BLANK:
  2577. fbcon_fb_blanked(info, *(int *)event->data);
  2578. break;
  2579. case FB_EVENT_NEW_MODELIST:
  2580. fbcon_new_modelist(info);
  2581. break;
  2582. case FB_EVENT_SET_CON_ROTATE:
  2583. fbcon_rotate(info, *(int *)event->data);
  2584. break;
  2585. case FB_EVENT_GET_CON_ROTATE:
  2586. ret = fbcon_get_rotate(info);
  2587. break;
  2588. case FB_EVENT_SET_CON_ROTATE_ALL:
  2589. fbcon_rotate_all(info, *(int *)event->data);
  2590. }
  2591. return ret;
  2592. }
  2593. /*
  2594. * The console `switch' structure for the frame buffer based console
  2595. */
  2596. static const struct consw fb_con = {
  2597. .owner = THIS_MODULE,
  2598. .con_startup = fbcon_startup,
  2599. .con_init = fbcon_init,
  2600. .con_deinit = fbcon_deinit,
  2601. .con_clear = fbcon_clear,
  2602. .con_putc = fbcon_putc,
  2603. .con_putcs = fbcon_putcs,
  2604. .con_cursor = fbcon_cursor,
  2605. .con_scroll = fbcon_scroll,
  2606. .con_bmove = fbcon_bmove,
  2607. .con_switch = fbcon_switch,
  2608. .con_blank = fbcon_blank,
  2609. .con_font_set = fbcon_set_font,
  2610. .con_font_get = fbcon_get_font,
  2611. .con_font_default = fbcon_set_def_font,
  2612. .con_font_copy = fbcon_copy_font,
  2613. .con_set_palette = fbcon_set_palette,
  2614. .con_scrolldelta = fbcon_scrolldelta,
  2615. .con_set_origin = fbcon_set_origin,
  2616. .con_invert_region = fbcon_invert_region,
  2617. .con_screen_pos = fbcon_screen_pos,
  2618. .con_getxy = fbcon_getxy,
  2619. .con_resize = fbcon_resize,
  2620. };
  2621. static struct notifier_block fbcon_event_notifier = {
  2622. .notifier_call = fbcon_event_notify,
  2623. };
  2624. static int __init fb_console_init(void)
  2625. {
  2626. int i;
  2627. acquire_console_sem();
  2628. fb_register_client(&fbcon_event_notifier);
  2629. release_console_sem();
  2630. for (i = 0; i < MAX_NR_CONSOLES; i++)
  2631. con2fb_map[i] = -1;
  2632. if (num_registered_fb) {
  2633. for (i = 0; i < FB_MAX; i++) {
  2634. if (registered_fb[i] != NULL) {
  2635. info_idx = i;
  2636. break;
  2637. }
  2638. }
  2639. fbcon_takeover(0);
  2640. }
  2641. return 0;
  2642. }
  2643. module_init(fb_console_init);
  2644. #ifdef MODULE
  2645. static void __exit fb_console_exit(void)
  2646. {
  2647. acquire_console_sem();
  2648. fb_unregister_client(&fbcon_event_notifier);
  2649. release_console_sem();
  2650. give_up_console(&fb_con);
  2651. }
  2652. module_exit(fb_console_exit);
  2653. #endif
  2654. MODULE_LICENSE("GPL");