fbmem.c 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975
  1. /*
  2. * linux/drivers/video/fbmem.c
  3. *
  4. * Copyright (C) 1994 Martin Schaller
  5. *
  6. * 2001 - Documented with DocBook
  7. * - Brad Douglas <brad@neruo.com>
  8. *
  9. * This file is subject to the terms and conditions of the GNU General Public
  10. * License. See the file COPYING in the main directory of this archive
  11. * for more details.
  12. */
  13. #include <linux/module.h>
  14. #include <linux/compat.h>
  15. #include <linux/types.h>
  16. #include <linux/errno.h>
  17. #include <linux/kernel.h>
  18. #include <linux/major.h>
  19. #include <linux/slab.h>
  20. #include <linux/mm.h>
  21. #include <linux/mman.h>
  22. #include <linux/vt.h>
  23. #include <linux/init.h>
  24. #include <linux/linux_logo.h>
  25. #include <linux/proc_fs.h>
  26. #include <linux/seq_file.h>
  27. #include <linux/console.h>
  28. #include <linux/kmod.h>
  29. #include <linux/err.h>
  30. #include <linux/device.h>
  31. #include <linux/efi.h>
  32. #include <linux/fb.h>
  33. #include <asm/fb.h>
  34. /*
  35. * Frame buffer device initialization and setup routines
  36. */
  37. #define FBPIXMAPSIZE (1024 * 8)
  38. static DEFINE_MUTEX(registration_lock);
  39. struct fb_info *registered_fb[FB_MAX] __read_mostly;
  40. int num_registered_fb __read_mostly;
  41. static struct fb_info *get_fb_info(unsigned int idx)
  42. {
  43. struct fb_info *fb_info;
  44. if (idx >= FB_MAX)
  45. return ERR_PTR(-ENODEV);
  46. mutex_lock(&registration_lock);
  47. fb_info = registered_fb[idx];
  48. if (fb_info)
  49. atomic_inc(&fb_info->count);
  50. mutex_unlock(&registration_lock);
  51. return fb_info;
  52. }
  53. static void put_fb_info(struct fb_info *fb_info)
  54. {
  55. if (!atomic_dec_and_test(&fb_info->count))
  56. return;
  57. if (fb_info->fbops->fb_destroy)
  58. fb_info->fbops->fb_destroy(fb_info);
  59. }
  60. int lock_fb_info(struct fb_info *info)
  61. {
  62. mutex_lock(&info->lock);
  63. if (!info->fbops) {
  64. mutex_unlock(&info->lock);
  65. return 0;
  66. }
  67. return 1;
  68. }
  69. EXPORT_SYMBOL(lock_fb_info);
  70. /*
  71. * Helpers
  72. */
  73. int fb_get_color_depth(struct fb_var_screeninfo *var,
  74. struct fb_fix_screeninfo *fix)
  75. {
  76. int depth = 0;
  77. if (fix->visual == FB_VISUAL_MONO01 ||
  78. fix->visual == FB_VISUAL_MONO10)
  79. depth = 1;
  80. else {
  81. if (var->green.length == var->blue.length &&
  82. var->green.length == var->red.length &&
  83. var->green.offset == var->blue.offset &&
  84. var->green.offset == var->red.offset)
  85. depth = var->green.length;
  86. else
  87. depth = var->green.length + var->red.length +
  88. var->blue.length;
  89. }
  90. return depth;
  91. }
  92. EXPORT_SYMBOL(fb_get_color_depth);
  93. /*
  94. * Data padding functions.
  95. */
  96. void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, u32 height)
  97. {
  98. __fb_pad_aligned_buffer(dst, d_pitch, src, s_pitch, height);
  99. }
  100. EXPORT_SYMBOL(fb_pad_aligned_buffer);
  101. void fb_pad_unaligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 idx, u32 height,
  102. u32 shift_high, u32 shift_low, u32 mod)
  103. {
  104. u8 mask = (u8) (0xfff << shift_high), tmp;
  105. int i, j;
  106. for (i = height; i--; ) {
  107. for (j = 0; j < idx; j++) {
  108. tmp = dst[j];
  109. tmp &= mask;
  110. tmp |= *src >> shift_low;
  111. dst[j] = tmp;
  112. tmp = *src << shift_high;
  113. dst[j+1] = tmp;
  114. src++;
  115. }
  116. tmp = dst[idx];
  117. tmp &= mask;
  118. tmp |= *src >> shift_low;
  119. dst[idx] = tmp;
  120. if (shift_high < mod) {
  121. tmp = *src << shift_high;
  122. dst[idx+1] = tmp;
  123. }
  124. src++;
  125. dst += d_pitch;
  126. }
  127. }
  128. EXPORT_SYMBOL(fb_pad_unaligned_buffer);
  129. /*
  130. * we need to lock this section since fb_cursor
  131. * may use fb_imageblit()
  132. */
  133. char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size)
  134. {
  135. u32 align = buf->buf_align - 1, offset;
  136. char *addr = buf->addr;
  137. /* If IO mapped, we need to sync before access, no sharing of
  138. * the pixmap is done
  139. */
  140. if (buf->flags & FB_PIXMAP_IO) {
  141. if (info->fbops->fb_sync && (buf->flags & FB_PIXMAP_SYNC))
  142. info->fbops->fb_sync(info);
  143. return addr;
  144. }
  145. /* See if we fit in the remaining pixmap space */
  146. offset = buf->offset + align;
  147. offset &= ~align;
  148. if (offset + size > buf->size) {
  149. /* We do not fit. In order to be able to re-use the buffer,
  150. * we must ensure no asynchronous DMA'ing or whatever operation
  151. * is in progress, we sync for that.
  152. */
  153. if (info->fbops->fb_sync && (buf->flags & FB_PIXMAP_SYNC))
  154. info->fbops->fb_sync(info);
  155. offset = 0;
  156. }
  157. buf->offset = offset + size;
  158. addr += offset;
  159. return addr;
  160. }
  161. #ifdef CONFIG_LOGO
  162. static inline unsigned safe_shift(unsigned d, int n)
  163. {
  164. return n < 0 ? d >> -n : d << n;
  165. }
  166. static void fb_set_logocmap(struct fb_info *info,
  167. const struct linux_logo *logo)
  168. {
  169. struct fb_cmap palette_cmap;
  170. u16 palette_green[16];
  171. u16 palette_blue[16];
  172. u16 palette_red[16];
  173. int i, j, n;
  174. const unsigned char *clut = logo->clut;
  175. palette_cmap.start = 0;
  176. palette_cmap.len = 16;
  177. palette_cmap.red = palette_red;
  178. palette_cmap.green = palette_green;
  179. palette_cmap.blue = palette_blue;
  180. palette_cmap.transp = NULL;
  181. for (i = 0; i < logo->clutsize; i += n) {
  182. n = logo->clutsize - i;
  183. /* palette_cmap provides space for only 16 colors at once */
  184. if (n > 16)
  185. n = 16;
  186. palette_cmap.start = 32 + i;
  187. palette_cmap.len = n;
  188. for (j = 0; j < n; ++j) {
  189. palette_cmap.red[j] = clut[0] << 8 | clut[0];
  190. palette_cmap.green[j] = clut[1] << 8 | clut[1];
  191. palette_cmap.blue[j] = clut[2] << 8 | clut[2];
  192. clut += 3;
  193. }
  194. fb_set_cmap(&palette_cmap, info);
  195. }
  196. }
  197. static void fb_set_logo_truepalette(struct fb_info *info,
  198. const struct linux_logo *logo,
  199. u32 *palette)
  200. {
  201. static const unsigned char mask[] = { 0,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff };
  202. unsigned char redmask, greenmask, bluemask;
  203. int redshift, greenshift, blueshift;
  204. int i;
  205. const unsigned char *clut = logo->clut;
  206. /*
  207. * We have to create a temporary palette since console palette is only
  208. * 16 colors long.
  209. */
  210. /* Bug: Doesn't obey msb_right ... (who needs that?) */
  211. redmask = mask[info->var.red.length < 8 ? info->var.red.length : 8];
  212. greenmask = mask[info->var.green.length < 8 ? info->var.green.length : 8];
  213. bluemask = mask[info->var.blue.length < 8 ? info->var.blue.length : 8];
  214. redshift = info->var.red.offset - (8 - info->var.red.length);
  215. greenshift = info->var.green.offset - (8 - info->var.green.length);
  216. blueshift = info->var.blue.offset - (8 - info->var.blue.length);
  217. for ( i = 0; i < logo->clutsize; i++) {
  218. palette[i+32] = (safe_shift((clut[0] & redmask), redshift) |
  219. safe_shift((clut[1] & greenmask), greenshift) |
  220. safe_shift((clut[2] & bluemask), blueshift));
  221. clut += 3;
  222. }
  223. }
  224. static void fb_set_logo_directpalette(struct fb_info *info,
  225. const struct linux_logo *logo,
  226. u32 *palette)
  227. {
  228. int redshift, greenshift, blueshift;
  229. int i;
  230. redshift = info->var.red.offset;
  231. greenshift = info->var.green.offset;
  232. blueshift = info->var.blue.offset;
  233. for (i = 32; i < 32 + logo->clutsize; i++)
  234. palette[i] = i << redshift | i << greenshift | i << blueshift;
  235. }
  236. static void fb_set_logo(struct fb_info *info,
  237. const struct linux_logo *logo, u8 *dst,
  238. int depth)
  239. {
  240. int i, j, k;
  241. const u8 *src = logo->data;
  242. u8 xor = (info->fix.visual == FB_VISUAL_MONO01) ? 0xff : 0;
  243. u8 fg = 1, d;
  244. switch (fb_get_color_depth(&info->var, &info->fix)) {
  245. case 1:
  246. fg = 1;
  247. break;
  248. case 2:
  249. fg = 3;
  250. break;
  251. default:
  252. fg = 7;
  253. break;
  254. }
  255. if (info->fix.visual == FB_VISUAL_MONO01 ||
  256. info->fix.visual == FB_VISUAL_MONO10)
  257. fg = ~((u8) (0xfff << info->var.green.length));
  258. switch (depth) {
  259. case 4:
  260. for (i = 0; i < logo->height; i++)
  261. for (j = 0; j < logo->width; src++) {
  262. *dst++ = *src >> 4;
  263. j++;
  264. if (j < logo->width) {
  265. *dst++ = *src & 0x0f;
  266. j++;
  267. }
  268. }
  269. break;
  270. case 1:
  271. for (i = 0; i < logo->height; i++) {
  272. for (j = 0; j < logo->width; src++) {
  273. d = *src ^ xor;
  274. for (k = 7; k >= 0; k--) {
  275. *dst++ = ((d >> k) & 1) ? fg : 0;
  276. j++;
  277. }
  278. }
  279. }
  280. break;
  281. }
  282. }
  283. /*
  284. * Three (3) kinds of logo maps exist. linux_logo_clut224 (>16 colors),
  285. * linux_logo_vga16 (16 colors) and linux_logo_mono (2 colors). Depending on
  286. * the visual format and color depth of the framebuffer, the DAC, the
  287. * pseudo_palette, and the logo data will be adjusted accordingly.
  288. *
  289. * Case 1 - linux_logo_clut224:
  290. * Color exceeds the number of console colors (16), thus we set the hardware DAC
  291. * using fb_set_cmap() appropriately. The "needs_cmapreset" flag will be set.
  292. *
  293. * For visuals that require color info from the pseudo_palette, we also construct
  294. * one for temporary use. The "needs_directpalette" or "needs_truepalette" flags
  295. * will be set.
  296. *
  297. * Case 2 - linux_logo_vga16:
  298. * The number of colors just matches the console colors, thus there is no need
  299. * to set the DAC or the pseudo_palette. However, the bitmap is packed, ie,
  300. * each byte contains color information for two pixels (upper and lower nibble).
  301. * To be consistent with fb_imageblit() usage, we therefore separate the two
  302. * nibbles into separate bytes. The "depth" flag will be set to 4.
  303. *
  304. * Case 3 - linux_logo_mono:
  305. * This is similar with Case 2. Each byte contains information for 8 pixels.
  306. * We isolate each bit and expand each into a byte. The "depth" flag will
  307. * be set to 1.
  308. */
  309. static struct logo_data {
  310. int depth;
  311. int needs_directpalette;
  312. int needs_truepalette;
  313. int needs_cmapreset;
  314. const struct linux_logo *logo;
  315. } fb_logo __read_mostly;
  316. static void fb_rotate_logo_ud(const u8 *in, u8 *out, u32 width, u32 height)
  317. {
  318. u32 size = width * height, i;
  319. out += size - 1;
  320. for (i = size; i--; )
  321. *out-- = *in++;
  322. }
  323. static void fb_rotate_logo_cw(const u8 *in, u8 *out, u32 width, u32 height)
  324. {
  325. int i, j, h = height - 1;
  326. for (i = 0; i < height; i++)
  327. for (j = 0; j < width; j++)
  328. out[height * j + h - i] = *in++;
  329. }
  330. static void fb_rotate_logo_ccw(const u8 *in, u8 *out, u32 width, u32 height)
  331. {
  332. int i, j, w = width - 1;
  333. for (i = 0; i < height; i++)
  334. for (j = 0; j < width; j++)
  335. out[height * (w - j) + i] = *in++;
  336. }
  337. static void fb_rotate_logo(struct fb_info *info, u8 *dst,
  338. struct fb_image *image, int rotate)
  339. {
  340. u32 tmp;
  341. if (rotate == FB_ROTATE_UD) {
  342. fb_rotate_logo_ud(image->data, dst, image->width,
  343. image->height);
  344. image->dx = info->var.xres - image->width - image->dx;
  345. image->dy = info->var.yres - image->height - image->dy;
  346. } else if (rotate == FB_ROTATE_CW) {
  347. fb_rotate_logo_cw(image->data, dst, image->width,
  348. image->height);
  349. tmp = image->width;
  350. image->width = image->height;
  351. image->height = tmp;
  352. tmp = image->dy;
  353. image->dy = image->dx;
  354. image->dx = info->var.xres - image->width - tmp;
  355. } else if (rotate == FB_ROTATE_CCW) {
  356. fb_rotate_logo_ccw(image->data, dst, image->width,
  357. image->height);
  358. tmp = image->width;
  359. image->width = image->height;
  360. image->height = tmp;
  361. tmp = image->dx;
  362. image->dx = image->dy;
  363. image->dy = info->var.yres - image->height - tmp;
  364. }
  365. image->data = dst;
  366. }
  367. static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
  368. int rotate, unsigned int num)
  369. {
  370. unsigned int x;
  371. if (rotate == FB_ROTATE_UR) {
  372. for (x = 0;
  373. x < num && image->dx + image->width <= info->var.xres;
  374. x++) {
  375. info->fbops->fb_imageblit(info, image);
  376. image->dx += image->width + 8;
  377. }
  378. } else if (rotate == FB_ROTATE_UD) {
  379. for (x = 0; x < num && image->dx >= 0; x++) {
  380. info->fbops->fb_imageblit(info, image);
  381. image->dx -= image->width + 8;
  382. }
  383. } else if (rotate == FB_ROTATE_CW) {
  384. for (x = 0;
  385. x < num && image->dy + image->height <= info->var.yres;
  386. x++) {
  387. info->fbops->fb_imageblit(info, image);
  388. image->dy += image->height + 8;
  389. }
  390. } else if (rotate == FB_ROTATE_CCW) {
  391. for (x = 0; x < num && image->dy >= 0; x++) {
  392. info->fbops->fb_imageblit(info, image);
  393. image->dy -= image->height + 8;
  394. }
  395. }
  396. }
  397. static int fb_show_logo_line(struct fb_info *info, int rotate,
  398. const struct linux_logo *logo, int y,
  399. unsigned int n)
  400. {
  401. u32 *palette = NULL, *saved_pseudo_palette = NULL;
  402. unsigned char *logo_new = NULL, *logo_rotate = NULL;
  403. struct fb_image image;
  404. /* Return if the frame buffer is not mapped or suspended */
  405. if (logo == NULL || info->state != FBINFO_STATE_RUNNING ||
  406. info->flags & FBINFO_MODULE)
  407. return 0;
  408. image.depth = 8;
  409. image.data = logo->data;
  410. if (fb_logo.needs_cmapreset)
  411. fb_set_logocmap(info, logo);
  412. if (fb_logo.needs_truepalette ||
  413. fb_logo.needs_directpalette) {
  414. palette = kmalloc(256 * 4, GFP_KERNEL);
  415. if (palette == NULL)
  416. return 0;
  417. if (fb_logo.needs_truepalette)
  418. fb_set_logo_truepalette(info, logo, palette);
  419. else
  420. fb_set_logo_directpalette(info, logo, palette);
  421. saved_pseudo_palette = info->pseudo_palette;
  422. info->pseudo_palette = palette;
  423. }
  424. if (fb_logo.depth <= 4) {
  425. logo_new = kmalloc(logo->width * logo->height, GFP_KERNEL);
  426. if (logo_new == NULL) {
  427. kfree(palette);
  428. if (saved_pseudo_palette)
  429. info->pseudo_palette = saved_pseudo_palette;
  430. return 0;
  431. }
  432. image.data = logo_new;
  433. fb_set_logo(info, logo, logo_new, fb_logo.depth);
  434. }
  435. image.dx = 0;
  436. image.dy = y;
  437. image.width = logo->width;
  438. image.height = logo->height;
  439. if (rotate) {
  440. logo_rotate = kmalloc(logo->width *
  441. logo->height, GFP_KERNEL);
  442. if (logo_rotate)
  443. fb_rotate_logo(info, logo_rotate, &image, rotate);
  444. }
  445. fb_do_show_logo(info, &image, rotate, n);
  446. kfree(palette);
  447. if (saved_pseudo_palette != NULL)
  448. info->pseudo_palette = saved_pseudo_palette;
  449. kfree(logo_new);
  450. kfree(logo_rotate);
  451. return logo->height;
  452. }
  453. #ifdef CONFIG_FB_LOGO_EXTRA
  454. #define FB_LOGO_EX_NUM_MAX 10
  455. static struct logo_data_extra {
  456. const struct linux_logo *logo;
  457. unsigned int n;
  458. } fb_logo_ex[FB_LOGO_EX_NUM_MAX];
  459. static unsigned int fb_logo_ex_num;
  460. void fb_append_extra_logo(const struct linux_logo *logo, unsigned int n)
  461. {
  462. if (!n || fb_logo_ex_num == FB_LOGO_EX_NUM_MAX)
  463. return;
  464. fb_logo_ex[fb_logo_ex_num].logo = logo;
  465. fb_logo_ex[fb_logo_ex_num].n = n;
  466. fb_logo_ex_num++;
  467. }
  468. static int fb_prepare_extra_logos(struct fb_info *info, unsigned int height,
  469. unsigned int yres)
  470. {
  471. unsigned int i;
  472. /* FIXME: logo_ex supports only truecolor fb. */
  473. if (info->fix.visual != FB_VISUAL_TRUECOLOR)
  474. fb_logo_ex_num = 0;
  475. for (i = 0; i < fb_logo_ex_num; i++) {
  476. if (fb_logo_ex[i].logo->type != fb_logo.logo->type) {
  477. fb_logo_ex[i].logo = NULL;
  478. continue;
  479. }
  480. height += fb_logo_ex[i].logo->height;
  481. if (height > yres) {
  482. height -= fb_logo_ex[i].logo->height;
  483. fb_logo_ex_num = i;
  484. break;
  485. }
  486. }
  487. return height;
  488. }
  489. static int fb_show_extra_logos(struct fb_info *info, int y, int rotate)
  490. {
  491. unsigned int i;
  492. for (i = 0; i < fb_logo_ex_num; i++)
  493. y += fb_show_logo_line(info, rotate,
  494. fb_logo_ex[i].logo, y, fb_logo_ex[i].n);
  495. return y;
  496. }
  497. #else /* !CONFIG_FB_LOGO_EXTRA */
  498. static inline int fb_prepare_extra_logos(struct fb_info *info,
  499. unsigned int height,
  500. unsigned int yres)
  501. {
  502. return height;
  503. }
  504. static inline int fb_show_extra_logos(struct fb_info *info, int y, int rotate)
  505. {
  506. return y;
  507. }
  508. #endif /* CONFIG_FB_LOGO_EXTRA */
  509. int fb_prepare_logo(struct fb_info *info, int rotate)
  510. {
  511. int depth = fb_get_color_depth(&info->var, &info->fix);
  512. unsigned int yres;
  513. memset(&fb_logo, 0, sizeof(struct logo_data));
  514. if (info->flags & FBINFO_MISC_TILEBLITTING ||
  515. info->flags & FBINFO_MODULE)
  516. return 0;
  517. if (info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
  518. depth = info->var.blue.length;
  519. if (info->var.red.length < depth)
  520. depth = info->var.red.length;
  521. if (info->var.green.length < depth)
  522. depth = info->var.green.length;
  523. }
  524. if (info->fix.visual == FB_VISUAL_STATIC_PSEUDOCOLOR && depth > 4) {
  525. /* assume console colormap */
  526. depth = 4;
  527. }
  528. /* Return if no suitable logo was found */
  529. fb_logo.logo = fb_find_logo(depth);
  530. if (!fb_logo.logo) {
  531. return 0;
  532. }
  533. if (rotate == FB_ROTATE_UR || rotate == FB_ROTATE_UD)
  534. yres = info->var.yres;
  535. else
  536. yres = info->var.xres;
  537. if (fb_logo.logo->height > yres) {
  538. fb_logo.logo = NULL;
  539. return 0;
  540. }
  541. /* What depth we asked for might be different from what we get */
  542. if (fb_logo.logo->type == LINUX_LOGO_CLUT224)
  543. fb_logo.depth = 8;
  544. else if (fb_logo.logo->type == LINUX_LOGO_VGA16)
  545. fb_logo.depth = 4;
  546. else
  547. fb_logo.depth = 1;
  548. if (fb_logo.depth > 4 && depth > 4) {
  549. switch (info->fix.visual) {
  550. case FB_VISUAL_TRUECOLOR:
  551. fb_logo.needs_truepalette = 1;
  552. break;
  553. case FB_VISUAL_DIRECTCOLOR:
  554. fb_logo.needs_directpalette = 1;
  555. fb_logo.needs_cmapreset = 1;
  556. break;
  557. case FB_VISUAL_PSEUDOCOLOR:
  558. fb_logo.needs_cmapreset = 1;
  559. break;
  560. }
  561. }
  562. return fb_prepare_extra_logos(info, fb_logo.logo->height, yres);
  563. }
  564. int fb_show_logo(struct fb_info *info, int rotate)
  565. {
  566. int y;
  567. y = fb_show_logo_line(info, rotate, fb_logo.logo, 0,
  568. num_online_cpus());
  569. y = fb_show_extra_logos(info, y, rotate);
  570. return y;
  571. }
  572. #else
  573. int fb_prepare_logo(struct fb_info *info, int rotate) { return 0; }
  574. int fb_show_logo(struct fb_info *info, int rotate) { return 0; }
  575. #endif /* CONFIG_LOGO */
  576. static void *fb_seq_start(struct seq_file *m, loff_t *pos)
  577. {
  578. mutex_lock(&registration_lock);
  579. return (*pos < FB_MAX) ? pos : NULL;
  580. }
  581. static void *fb_seq_next(struct seq_file *m, void *v, loff_t *pos)
  582. {
  583. (*pos)++;
  584. return (*pos < FB_MAX) ? pos : NULL;
  585. }
  586. static void fb_seq_stop(struct seq_file *m, void *v)
  587. {
  588. mutex_unlock(&registration_lock);
  589. }
  590. static int fb_seq_show(struct seq_file *m, void *v)
  591. {
  592. int i = *(loff_t *)v;
  593. struct fb_info *fi = registered_fb[i];
  594. if (fi)
  595. seq_printf(m, "%d %s\n", fi->node, fi->fix.id);
  596. return 0;
  597. }
  598. static const struct seq_operations proc_fb_seq_ops = {
  599. .start = fb_seq_start,
  600. .next = fb_seq_next,
  601. .stop = fb_seq_stop,
  602. .show = fb_seq_show,
  603. };
  604. static int proc_fb_open(struct inode *inode, struct file *file)
  605. {
  606. return seq_open(file, &proc_fb_seq_ops);
  607. }
  608. static const struct file_operations fb_proc_fops = {
  609. .owner = THIS_MODULE,
  610. .open = proc_fb_open,
  611. .read = seq_read,
  612. .llseek = seq_lseek,
  613. .release = seq_release,
  614. };
  615. /*
  616. * We hold a reference to the fb_info in file->private_data,
  617. * but if the current registered fb has changed, we don't
  618. * actually want to use it.
  619. *
  620. * So look up the fb_info using the inode minor number,
  621. * and just verify it against the reference we have.
  622. */
  623. static struct fb_info *file_fb_info(struct file *file)
  624. {
  625. struct inode *inode = file_inode(file);
  626. int fbidx = iminor(inode);
  627. struct fb_info *info = registered_fb[fbidx];
  628. if (info != file->private_data)
  629. info = NULL;
  630. return info;
  631. }
  632. static ssize_t
  633. fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
  634. {
  635. unsigned long p = *ppos;
  636. struct fb_info *info = file_fb_info(file);
  637. u8 *buffer, *dst;
  638. u8 __iomem *src;
  639. int c, cnt = 0, err = 0;
  640. unsigned long total_size;
  641. if (!info || ! info->screen_base)
  642. return -ENODEV;
  643. if (info->state != FBINFO_STATE_RUNNING)
  644. return -EPERM;
  645. if (info->fbops->fb_read)
  646. return info->fbops->fb_read(info, buf, count, ppos);
  647. total_size = info->screen_size;
  648. if (total_size == 0)
  649. total_size = info->fix.smem_len;
  650. if (p >= total_size)
  651. return 0;
  652. if (count >= total_size)
  653. count = total_size;
  654. if (count + p > total_size)
  655. count = total_size - p;
  656. buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count,
  657. GFP_KERNEL);
  658. if (!buffer)
  659. return -ENOMEM;
  660. src = (u8 __iomem *) (info->screen_base + p);
  661. if (info->fbops->fb_sync)
  662. info->fbops->fb_sync(info);
  663. while (count) {
  664. c = (count > PAGE_SIZE) ? PAGE_SIZE : count;
  665. dst = buffer;
  666. fb_memcpy_fromfb(dst, src, c);
  667. dst += c;
  668. src += c;
  669. if (copy_to_user(buf, buffer, c)) {
  670. err = -EFAULT;
  671. break;
  672. }
  673. *ppos += c;
  674. buf += c;
  675. cnt += c;
  676. count -= c;
  677. }
  678. kfree(buffer);
  679. return (err) ? err : cnt;
  680. }
  681. static ssize_t
  682. fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
  683. {
  684. unsigned long p = *ppos;
  685. struct fb_info *info = file_fb_info(file);
  686. u8 *buffer, *src;
  687. u8 __iomem *dst;
  688. int c, cnt = 0, err = 0;
  689. unsigned long total_size;
  690. if (!info || !info->screen_base)
  691. return -ENODEV;
  692. if (info->state != FBINFO_STATE_RUNNING)
  693. return -EPERM;
  694. if (info->fbops->fb_write)
  695. return info->fbops->fb_write(info, buf, count, ppos);
  696. total_size = info->screen_size;
  697. if (total_size == 0)
  698. total_size = info->fix.smem_len;
  699. if (p > total_size)
  700. return -EFBIG;
  701. if (count > total_size) {
  702. err = -EFBIG;
  703. count = total_size;
  704. }
  705. if (count + p > total_size) {
  706. if (!err)
  707. err = -ENOSPC;
  708. count = total_size - p;
  709. }
  710. buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count,
  711. GFP_KERNEL);
  712. if (!buffer)
  713. return -ENOMEM;
  714. dst = (u8 __iomem *) (info->screen_base + p);
  715. if (info->fbops->fb_sync)
  716. info->fbops->fb_sync(info);
  717. while (count) {
  718. c = (count > PAGE_SIZE) ? PAGE_SIZE : count;
  719. src = buffer;
  720. if (copy_from_user(src, buf, c)) {
  721. err = -EFAULT;
  722. break;
  723. }
  724. fb_memcpy_tofb(dst, src, c);
  725. dst += c;
  726. src += c;
  727. *ppos += c;
  728. buf += c;
  729. cnt += c;
  730. count -= c;
  731. }
  732. kfree(buffer);
  733. return (cnt) ? cnt : err;
  734. }
  735. int
  736. fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var)
  737. {
  738. struct fb_fix_screeninfo *fix = &info->fix;
  739. unsigned int yres = info->var.yres;
  740. int err = 0;
  741. if (var->yoffset > 0) {
  742. if (var->vmode & FB_VMODE_YWRAP) {
  743. if (!fix->ywrapstep || (var->yoffset % fix->ywrapstep))
  744. err = -EINVAL;
  745. else
  746. yres = 0;
  747. } else if (!fix->ypanstep || (var->yoffset % fix->ypanstep))
  748. err = -EINVAL;
  749. }
  750. if (var->xoffset > 0 && (!fix->xpanstep ||
  751. (var->xoffset % fix->xpanstep)))
  752. err = -EINVAL;
  753. if (err || !info->fbops->fb_pan_display ||
  754. var->yoffset > info->var.yres_virtual - yres ||
  755. var->xoffset > info->var.xres_virtual - info->var.xres)
  756. return -EINVAL;
  757. if ((err = info->fbops->fb_pan_display(var, info)))
  758. return err;
  759. info->var.xoffset = var->xoffset;
  760. info->var.yoffset = var->yoffset;
  761. if (var->vmode & FB_VMODE_YWRAP)
  762. info->var.vmode |= FB_VMODE_YWRAP;
  763. else
  764. info->var.vmode &= ~FB_VMODE_YWRAP;
  765. return 0;
  766. }
  767. static int fb_check_caps(struct fb_info *info, struct fb_var_screeninfo *var,
  768. u32 activate)
  769. {
  770. struct fb_event event;
  771. struct fb_blit_caps caps, fbcaps;
  772. int err = 0;
  773. memset(&caps, 0, sizeof(caps));
  774. memset(&fbcaps, 0, sizeof(fbcaps));
  775. caps.flags = (activate & FB_ACTIVATE_ALL) ? 1 : 0;
  776. event.info = info;
  777. event.data = &caps;
  778. fb_notifier_call_chain(FB_EVENT_GET_REQ, &event);
  779. info->fbops->fb_get_caps(info, &fbcaps, var);
  780. if (((fbcaps.x ^ caps.x) & caps.x) ||
  781. ((fbcaps.y ^ caps.y) & caps.y) ||
  782. (fbcaps.len < caps.len))
  783. err = -EINVAL;
  784. return err;
  785. }
  786. int
  787. fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
  788. {
  789. int flags = info->flags;
  790. int ret = 0;
  791. if (var->activate & FB_ACTIVATE_INV_MODE) {
  792. struct fb_videomode mode1, mode2;
  793. fb_var_to_videomode(&mode1, var);
  794. fb_var_to_videomode(&mode2, &info->var);
  795. /* make sure we don't delete the videomode of current var */
  796. ret = fb_mode_is_equal(&mode1, &mode2);
  797. if (!ret) {
  798. struct fb_event event;
  799. event.info = info;
  800. event.data = &mode1;
  801. ret = fb_notifier_call_chain(FB_EVENT_MODE_DELETE, &event);
  802. }
  803. if (!ret)
  804. fb_delete_videomode(&mode1, &info->modelist);
  805. ret = (ret) ? -EINVAL : 0;
  806. goto done;
  807. }
  808. if ((var->activate & FB_ACTIVATE_FORCE) ||
  809. memcmp(&info->var, var, sizeof(struct fb_var_screeninfo))) {
  810. u32 activate = var->activate;
  811. /* When using FOURCC mode, make sure the red, green, blue and
  812. * transp fields are set to 0.
  813. */
  814. if ((info->fix.capabilities & FB_CAP_FOURCC) &&
  815. var->grayscale > 1) {
  816. if (var->red.offset || var->green.offset ||
  817. var->blue.offset || var->transp.offset ||
  818. var->red.length || var->green.length ||
  819. var->blue.length || var->transp.length ||
  820. var->red.msb_right || var->green.msb_right ||
  821. var->blue.msb_right || var->transp.msb_right)
  822. return -EINVAL;
  823. }
  824. if (!info->fbops->fb_check_var) {
  825. *var = info->var;
  826. goto done;
  827. }
  828. ret = info->fbops->fb_check_var(var, info);
  829. if (ret)
  830. goto done;
  831. if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) {
  832. struct fb_var_screeninfo old_var;
  833. struct fb_videomode mode;
  834. if (info->fbops->fb_get_caps) {
  835. ret = fb_check_caps(info, var, activate);
  836. if (ret)
  837. goto done;
  838. }
  839. old_var = info->var;
  840. info->var = *var;
  841. if (info->fbops->fb_set_par) {
  842. ret = info->fbops->fb_set_par(info);
  843. if (ret) {
  844. info->var = old_var;
  845. printk(KERN_WARNING "detected "
  846. "fb_set_par error, "
  847. "error code: %d\n", ret);
  848. goto done;
  849. }
  850. }
  851. fb_pan_display(info, &info->var);
  852. fb_set_cmap(&info->cmap, info);
  853. fb_var_to_videomode(&mode, &info->var);
  854. if (info->modelist.prev && info->modelist.next &&
  855. !list_empty(&info->modelist))
  856. ret = fb_add_videomode(&mode, &info->modelist);
  857. if (!ret && (flags & FBINFO_MISC_USEREVENT)) {
  858. struct fb_event event;
  859. int evnt = (activate & FB_ACTIVATE_ALL) ?
  860. FB_EVENT_MODE_CHANGE_ALL :
  861. FB_EVENT_MODE_CHANGE;
  862. info->flags &= ~FBINFO_MISC_USEREVENT;
  863. event.info = info;
  864. event.data = &mode;
  865. fb_notifier_call_chain(evnt, &event);
  866. }
  867. }
  868. }
  869. done:
  870. return ret;
  871. }
  872. int
  873. fb_blank(struct fb_info *info, int blank)
  874. {
  875. struct fb_event event;
  876. int ret = -EINVAL, early_ret;
  877. if (blank > FB_BLANK_POWERDOWN)
  878. blank = FB_BLANK_POWERDOWN;
  879. event.info = info;
  880. event.data = &blank;
  881. early_ret = fb_notifier_call_chain(FB_EARLY_EVENT_BLANK, &event);
  882. if (info->fbops->fb_blank)
  883. ret = info->fbops->fb_blank(blank, info);
  884. if (!ret)
  885. fb_notifier_call_chain(FB_EVENT_BLANK, &event);
  886. else {
  887. /*
  888. * if fb_blank is failed then revert effects of
  889. * the early blank event.
  890. */
  891. if (!early_ret)
  892. fb_notifier_call_chain(FB_R_EARLY_EVENT_BLANK, &event);
  893. }
  894. return ret;
  895. }
  896. static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
  897. unsigned long arg)
  898. {
  899. struct fb_ops *fb;
  900. struct fb_var_screeninfo var;
  901. struct fb_fix_screeninfo fix;
  902. struct fb_con2fbmap con2fb;
  903. struct fb_cmap cmap_from;
  904. struct fb_cmap_user cmap;
  905. struct fb_event event;
  906. void __user *argp = (void __user *)arg;
  907. long ret = 0;
  908. switch (cmd) {
  909. case FBIOGET_VSCREENINFO:
  910. if (!lock_fb_info(info))
  911. return -ENODEV;
  912. var = info->var;
  913. unlock_fb_info(info);
  914. ret = copy_to_user(argp, &var, sizeof(var)) ? -EFAULT : 0;
  915. break;
  916. case FBIOPUT_VSCREENINFO:
  917. if (copy_from_user(&var, argp, sizeof(var)))
  918. return -EFAULT;
  919. if (!lock_fb_info(info))
  920. return -ENODEV;
  921. console_lock();
  922. info->flags |= FBINFO_MISC_USEREVENT;
  923. ret = fb_set_var(info, &var);
  924. info->flags &= ~FBINFO_MISC_USEREVENT;
  925. console_unlock();
  926. unlock_fb_info(info);
  927. if (!ret && copy_to_user(argp, &var, sizeof(var)))
  928. ret = -EFAULT;
  929. break;
  930. case FBIOGET_FSCREENINFO:
  931. if (!lock_fb_info(info))
  932. return -ENODEV;
  933. fix = info->fix;
  934. unlock_fb_info(info);
  935. ret = copy_to_user(argp, &fix, sizeof(fix)) ? -EFAULT : 0;
  936. break;
  937. case FBIOPUTCMAP:
  938. if (copy_from_user(&cmap, argp, sizeof(cmap)))
  939. return -EFAULT;
  940. ret = fb_set_user_cmap(&cmap, info);
  941. break;
  942. case FBIOGETCMAP:
  943. if (copy_from_user(&cmap, argp, sizeof(cmap)))
  944. return -EFAULT;
  945. if (!lock_fb_info(info))
  946. return -ENODEV;
  947. cmap_from = info->cmap;
  948. unlock_fb_info(info);
  949. ret = fb_cmap_to_user(&cmap_from, &cmap);
  950. break;
  951. case FBIOPAN_DISPLAY:
  952. if (copy_from_user(&var, argp, sizeof(var)))
  953. return -EFAULT;
  954. if (!lock_fb_info(info))
  955. return -ENODEV;
  956. console_lock();
  957. ret = fb_pan_display(info, &var);
  958. console_unlock();
  959. unlock_fb_info(info);
  960. if (ret == 0 && copy_to_user(argp, &var, sizeof(var)))
  961. return -EFAULT;
  962. break;
  963. case FBIO_CURSOR:
  964. ret = -EINVAL;
  965. break;
  966. case FBIOGET_CON2FBMAP:
  967. if (copy_from_user(&con2fb, argp, sizeof(con2fb)))
  968. return -EFAULT;
  969. if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
  970. return -EINVAL;
  971. con2fb.framebuffer = -1;
  972. event.data = &con2fb;
  973. if (!lock_fb_info(info))
  974. return -ENODEV;
  975. event.info = info;
  976. fb_notifier_call_chain(FB_EVENT_GET_CONSOLE_MAP, &event);
  977. unlock_fb_info(info);
  978. ret = copy_to_user(argp, &con2fb, sizeof(con2fb)) ? -EFAULT : 0;
  979. break;
  980. case FBIOPUT_CON2FBMAP:
  981. if (copy_from_user(&con2fb, argp, sizeof(con2fb)))
  982. return -EFAULT;
  983. if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
  984. return -EINVAL;
  985. if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
  986. return -EINVAL;
  987. if (!registered_fb[con2fb.framebuffer])
  988. request_module("fb%d", con2fb.framebuffer);
  989. if (!registered_fb[con2fb.framebuffer]) {
  990. ret = -EINVAL;
  991. break;
  992. }
  993. event.data = &con2fb;
  994. if (!lock_fb_info(info))
  995. return -ENODEV;
  996. console_lock();
  997. event.info = info;
  998. ret = fb_notifier_call_chain(FB_EVENT_SET_CONSOLE_MAP, &event);
  999. console_unlock();
  1000. unlock_fb_info(info);
  1001. break;
  1002. case FBIOBLANK:
  1003. if (!lock_fb_info(info))
  1004. return -ENODEV;
  1005. console_lock();
  1006. info->flags |= FBINFO_MISC_USEREVENT;
  1007. ret = fb_blank(info, arg);
  1008. info->flags &= ~FBINFO_MISC_USEREVENT;
  1009. console_unlock();
  1010. unlock_fb_info(info);
  1011. break;
  1012. default:
  1013. if (!lock_fb_info(info))
  1014. return -ENODEV;
  1015. fb = info->fbops;
  1016. if (fb->fb_ioctl)
  1017. ret = fb->fb_ioctl(info, cmd, arg);
  1018. else
  1019. ret = -ENOTTY;
  1020. unlock_fb_info(info);
  1021. }
  1022. return ret;
  1023. }
  1024. static long fb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  1025. {
  1026. struct fb_info *info = file_fb_info(file);
  1027. if (!info)
  1028. return -ENODEV;
  1029. return do_fb_ioctl(info, cmd, arg);
  1030. }
  1031. #ifdef CONFIG_COMPAT
  1032. struct fb_fix_screeninfo32 {
  1033. char id[16];
  1034. compat_caddr_t smem_start;
  1035. u32 smem_len;
  1036. u32 type;
  1037. u32 type_aux;
  1038. u32 visual;
  1039. u16 xpanstep;
  1040. u16 ypanstep;
  1041. u16 ywrapstep;
  1042. u32 line_length;
  1043. compat_caddr_t mmio_start;
  1044. u32 mmio_len;
  1045. u32 accel;
  1046. u16 reserved[3];
  1047. };
  1048. struct fb_cmap32 {
  1049. u32 start;
  1050. u32 len;
  1051. compat_caddr_t red;
  1052. compat_caddr_t green;
  1053. compat_caddr_t blue;
  1054. compat_caddr_t transp;
  1055. };
  1056. static int fb_getput_cmap(struct fb_info *info, unsigned int cmd,
  1057. unsigned long arg)
  1058. {
  1059. struct fb_cmap_user __user *cmap;
  1060. struct fb_cmap32 __user *cmap32;
  1061. __u32 data;
  1062. int err;
  1063. cmap = compat_alloc_user_space(sizeof(*cmap));
  1064. cmap32 = compat_ptr(arg);
  1065. if (copy_in_user(&cmap->start, &cmap32->start, 2 * sizeof(__u32)))
  1066. return -EFAULT;
  1067. if (get_user(data, &cmap32->red) ||
  1068. put_user(compat_ptr(data), &cmap->red) ||
  1069. get_user(data, &cmap32->green) ||
  1070. put_user(compat_ptr(data), &cmap->green) ||
  1071. get_user(data, &cmap32->blue) ||
  1072. put_user(compat_ptr(data), &cmap->blue) ||
  1073. get_user(data, &cmap32->transp) ||
  1074. put_user(compat_ptr(data), &cmap->transp))
  1075. return -EFAULT;
  1076. err = do_fb_ioctl(info, cmd, (unsigned long) cmap);
  1077. if (!err) {
  1078. if (copy_in_user(&cmap32->start,
  1079. &cmap->start,
  1080. 2 * sizeof(__u32)))
  1081. err = -EFAULT;
  1082. }
  1083. return err;
  1084. }
  1085. static int do_fscreeninfo_to_user(struct fb_fix_screeninfo *fix,
  1086. struct fb_fix_screeninfo32 __user *fix32)
  1087. {
  1088. __u32 data;
  1089. int err;
  1090. err = copy_to_user(&fix32->id, &fix->id, sizeof(fix32->id));
  1091. data = (__u32) (unsigned long) fix->smem_start;
  1092. err |= put_user(data, &fix32->smem_start);
  1093. err |= put_user(fix->smem_len, &fix32->smem_len);
  1094. err |= put_user(fix->type, &fix32->type);
  1095. err |= put_user(fix->type_aux, &fix32->type_aux);
  1096. err |= put_user(fix->visual, &fix32->visual);
  1097. err |= put_user(fix->xpanstep, &fix32->xpanstep);
  1098. err |= put_user(fix->ypanstep, &fix32->ypanstep);
  1099. err |= put_user(fix->ywrapstep, &fix32->ywrapstep);
  1100. err |= put_user(fix->line_length, &fix32->line_length);
  1101. data = (__u32) (unsigned long) fix->mmio_start;
  1102. err |= put_user(data, &fix32->mmio_start);
  1103. err |= put_user(fix->mmio_len, &fix32->mmio_len);
  1104. err |= put_user(fix->accel, &fix32->accel);
  1105. err |= copy_to_user(fix32->reserved, fix->reserved,
  1106. sizeof(fix->reserved));
  1107. return err;
  1108. }
  1109. static int fb_get_fscreeninfo(struct fb_info *info, unsigned int cmd,
  1110. unsigned long arg)
  1111. {
  1112. mm_segment_t old_fs;
  1113. struct fb_fix_screeninfo fix;
  1114. struct fb_fix_screeninfo32 __user *fix32;
  1115. int err;
  1116. fix32 = compat_ptr(arg);
  1117. old_fs = get_fs();
  1118. set_fs(KERNEL_DS);
  1119. err = do_fb_ioctl(info, cmd, (unsigned long) &fix);
  1120. set_fs(old_fs);
  1121. if (!err)
  1122. err = do_fscreeninfo_to_user(&fix, fix32);
  1123. return err;
  1124. }
  1125. static long fb_compat_ioctl(struct file *file, unsigned int cmd,
  1126. unsigned long arg)
  1127. {
  1128. struct fb_info *info = file_fb_info(file);
  1129. struct fb_ops *fb;
  1130. long ret = -ENOIOCTLCMD;
  1131. if (!info)
  1132. return -ENODEV;
  1133. fb = info->fbops;
  1134. switch(cmd) {
  1135. case FBIOGET_VSCREENINFO:
  1136. case FBIOPUT_VSCREENINFO:
  1137. case FBIOPAN_DISPLAY:
  1138. case FBIOGET_CON2FBMAP:
  1139. case FBIOPUT_CON2FBMAP:
  1140. arg = (unsigned long) compat_ptr(arg);
  1141. case FBIOBLANK:
  1142. ret = do_fb_ioctl(info, cmd, arg);
  1143. break;
  1144. case FBIOGET_FSCREENINFO:
  1145. ret = fb_get_fscreeninfo(info, cmd, arg);
  1146. break;
  1147. case FBIOGETCMAP:
  1148. case FBIOPUTCMAP:
  1149. ret = fb_getput_cmap(info, cmd, arg);
  1150. break;
  1151. default:
  1152. if (fb->fb_compat_ioctl)
  1153. ret = fb->fb_compat_ioctl(info, cmd, arg);
  1154. break;
  1155. }
  1156. return ret;
  1157. }
  1158. #endif
  1159. static int
  1160. fb_mmap(struct file *file, struct vm_area_struct * vma)
  1161. {
  1162. struct fb_info *info = file_fb_info(file);
  1163. struct fb_ops *fb;
  1164. unsigned long off;
  1165. unsigned long start;
  1166. u32 len;
  1167. if (!info)
  1168. return -ENODEV;
  1169. if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
  1170. return -EINVAL;
  1171. off = vma->vm_pgoff << PAGE_SHIFT;
  1172. fb = info->fbops;
  1173. if (!fb)
  1174. return -ENODEV;
  1175. mutex_lock(&info->mm_lock);
  1176. if (fb->fb_mmap) {
  1177. int res;
  1178. res = fb->fb_mmap(info, vma);
  1179. mutex_unlock(&info->mm_lock);
  1180. return res;
  1181. }
  1182. /* frame buffer memory */
  1183. start = info->fix.smem_start;
  1184. len = PAGE_ALIGN((start & ~PAGE_MASK) + info->fix.smem_len);
  1185. if (off >= len) {
  1186. /* memory mapped io */
  1187. off -= len;
  1188. if (info->var.accel_flags) {
  1189. mutex_unlock(&info->mm_lock);
  1190. return -EINVAL;
  1191. }
  1192. start = info->fix.mmio_start;
  1193. len = PAGE_ALIGN((start & ~PAGE_MASK) + info->fix.mmio_len);
  1194. }
  1195. mutex_unlock(&info->mm_lock);
  1196. start &= PAGE_MASK;
  1197. if ((vma->vm_end - vma->vm_start + off) > len)
  1198. return -EINVAL;
  1199. off += start;
  1200. vma->vm_pgoff = off >> PAGE_SHIFT;
  1201. /* VM_IO | VM_DONTEXPAND | VM_DONTDUMP are set by io_remap_pfn_range()*/
  1202. vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
  1203. fb_pgprotect(file, vma, off);
  1204. if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
  1205. vma->vm_end - vma->vm_start, vma->vm_page_prot))
  1206. return -EAGAIN;
  1207. return 0;
  1208. }
  1209. static int
  1210. fb_open(struct inode *inode, struct file *file)
  1211. __acquires(&info->lock)
  1212. __releases(&info->lock)
  1213. {
  1214. int fbidx = iminor(inode);
  1215. struct fb_info *info;
  1216. int res = 0;
  1217. info = get_fb_info(fbidx);
  1218. if (!info) {
  1219. request_module("fb%d", fbidx);
  1220. info = get_fb_info(fbidx);
  1221. if (!info)
  1222. return -ENODEV;
  1223. }
  1224. if (IS_ERR(info))
  1225. return PTR_ERR(info);
  1226. mutex_lock(&info->lock);
  1227. if (!try_module_get(info->fbops->owner)) {
  1228. res = -ENODEV;
  1229. goto out;
  1230. }
  1231. file->private_data = info;
  1232. if (info->fbops->fb_open) {
  1233. res = info->fbops->fb_open(info,1);
  1234. if (res)
  1235. module_put(info->fbops->owner);
  1236. }
  1237. #ifdef CONFIG_FB_DEFERRED_IO
  1238. if (info->fbdefio)
  1239. fb_deferred_io_open(info, inode, file);
  1240. #endif
  1241. out:
  1242. mutex_unlock(&info->lock);
  1243. if (res)
  1244. put_fb_info(info);
  1245. return res;
  1246. }
  1247. static int
  1248. fb_release(struct inode *inode, struct file *file)
  1249. __acquires(&info->lock)
  1250. __releases(&info->lock)
  1251. {
  1252. struct fb_info * const info = file->private_data;
  1253. mutex_lock(&info->lock);
  1254. if (info->fbops->fb_release)
  1255. info->fbops->fb_release(info,1);
  1256. module_put(info->fbops->owner);
  1257. mutex_unlock(&info->lock);
  1258. put_fb_info(info);
  1259. return 0;
  1260. }
  1261. static const struct file_operations fb_fops = {
  1262. .owner = THIS_MODULE,
  1263. .read = fb_read,
  1264. .write = fb_write,
  1265. .unlocked_ioctl = fb_ioctl,
  1266. #ifdef CONFIG_COMPAT
  1267. .compat_ioctl = fb_compat_ioctl,
  1268. #endif
  1269. .mmap = fb_mmap,
  1270. .open = fb_open,
  1271. .release = fb_release,
  1272. #ifdef HAVE_ARCH_FB_UNMAPPED_AREA
  1273. .get_unmapped_area = get_fb_unmapped_area,
  1274. #endif
  1275. #ifdef CONFIG_FB_DEFERRED_IO
  1276. .fsync = fb_deferred_io_fsync,
  1277. #endif
  1278. .llseek = default_llseek,
  1279. };
  1280. struct class *fb_class;
  1281. EXPORT_SYMBOL(fb_class);
  1282. static int fb_check_foreignness(struct fb_info *fi)
  1283. {
  1284. const bool foreign_endian = fi->flags & FBINFO_FOREIGN_ENDIAN;
  1285. fi->flags &= ~FBINFO_FOREIGN_ENDIAN;
  1286. #ifdef __BIG_ENDIAN
  1287. fi->flags |= foreign_endian ? 0 : FBINFO_BE_MATH;
  1288. #else
  1289. fi->flags |= foreign_endian ? FBINFO_BE_MATH : 0;
  1290. #endif /* __BIG_ENDIAN */
  1291. if (fi->flags & FBINFO_BE_MATH && !fb_be_math(fi)) {
  1292. pr_err("%s: enable CONFIG_FB_BIG_ENDIAN to "
  1293. "support this framebuffer\n", fi->fix.id);
  1294. return -ENOSYS;
  1295. } else if (!(fi->flags & FBINFO_BE_MATH) && fb_be_math(fi)) {
  1296. pr_err("%s: enable CONFIG_FB_LITTLE_ENDIAN to "
  1297. "support this framebuffer\n", fi->fix.id);
  1298. return -ENOSYS;
  1299. }
  1300. return 0;
  1301. }
  1302. static bool apertures_overlap(struct aperture *gen, struct aperture *hw)
  1303. {
  1304. /* is the generic aperture base the same as the HW one */
  1305. if (gen->base == hw->base)
  1306. return true;
  1307. /* is the generic aperture base inside the hw base->hw base+size */
  1308. if (gen->base > hw->base && gen->base < hw->base + hw->size)
  1309. return true;
  1310. return false;
  1311. }
  1312. static bool fb_do_apertures_overlap(struct apertures_struct *gena,
  1313. struct apertures_struct *hwa)
  1314. {
  1315. int i, j;
  1316. if (!hwa || !gena)
  1317. return false;
  1318. for (i = 0; i < hwa->count; ++i) {
  1319. struct aperture *h = &hwa->ranges[i];
  1320. for (j = 0; j < gena->count; ++j) {
  1321. struct aperture *g = &gena->ranges[j];
  1322. printk(KERN_DEBUG "checking generic (%llx %llx) vs hw (%llx %llx)\n",
  1323. (unsigned long long)g->base,
  1324. (unsigned long long)g->size,
  1325. (unsigned long long)h->base,
  1326. (unsigned long long)h->size);
  1327. if (apertures_overlap(g, h))
  1328. return true;
  1329. }
  1330. }
  1331. return false;
  1332. }
  1333. static int do_unregister_framebuffer(struct fb_info *fb_info);
  1334. #define VGA_FB_PHYS 0xA0000
  1335. static void do_remove_conflicting_framebuffers(struct apertures_struct *a,
  1336. const char *name, bool primary)
  1337. {
  1338. int i;
  1339. /* check all firmware fbs and kick off if the base addr overlaps */
  1340. for (i = 0 ; i < FB_MAX; i++) {
  1341. struct apertures_struct *gen_aper;
  1342. if (!registered_fb[i])
  1343. continue;
  1344. if (!(registered_fb[i]->flags & FBINFO_MISC_FIRMWARE))
  1345. continue;
  1346. gen_aper = registered_fb[i]->apertures;
  1347. if (fb_do_apertures_overlap(gen_aper, a) ||
  1348. (primary && gen_aper && gen_aper->count &&
  1349. gen_aper->ranges[0].base == VGA_FB_PHYS)) {
  1350. printk(KERN_INFO "fb: conflicting fb hw usage "
  1351. "%s vs %s - removing generic driver\n",
  1352. name, registered_fb[i]->fix.id);
  1353. do_unregister_framebuffer(registered_fb[i]);
  1354. }
  1355. }
  1356. }
  1357. static int do_register_framebuffer(struct fb_info *fb_info)
  1358. {
  1359. int i;
  1360. struct fb_event event;
  1361. struct fb_videomode mode;
  1362. if (fb_check_foreignness(fb_info))
  1363. return -ENOSYS;
  1364. do_remove_conflicting_framebuffers(fb_info->apertures, fb_info->fix.id,
  1365. fb_is_primary_device(fb_info));
  1366. if (num_registered_fb == FB_MAX)
  1367. return -ENXIO;
  1368. num_registered_fb++;
  1369. for (i = 0 ; i < FB_MAX; i++)
  1370. if (!registered_fb[i])
  1371. break;
  1372. fb_info->node = i;
  1373. atomic_set(&fb_info->count, 1);
  1374. mutex_init(&fb_info->lock);
  1375. mutex_init(&fb_info->mm_lock);
  1376. fb_info->dev = device_create(fb_class, fb_info->device,
  1377. MKDEV(FB_MAJOR, i), NULL, "fb%d", i);
  1378. if (IS_ERR(fb_info->dev)) {
  1379. /* Not fatal */
  1380. printk(KERN_WARNING "Unable to create device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->dev));
  1381. fb_info->dev = NULL;
  1382. } else
  1383. fb_init_device(fb_info);
  1384. if (fb_info->pixmap.addr == NULL) {
  1385. fb_info->pixmap.addr = kmalloc(FBPIXMAPSIZE, GFP_KERNEL);
  1386. if (fb_info->pixmap.addr) {
  1387. fb_info->pixmap.size = FBPIXMAPSIZE;
  1388. fb_info->pixmap.buf_align = 1;
  1389. fb_info->pixmap.scan_align = 1;
  1390. fb_info->pixmap.access_align = 32;
  1391. fb_info->pixmap.flags = FB_PIXMAP_DEFAULT;
  1392. }
  1393. }
  1394. fb_info->pixmap.offset = 0;
  1395. if (!fb_info->pixmap.blit_x)
  1396. fb_info->pixmap.blit_x = ~(u32)0;
  1397. if (!fb_info->pixmap.blit_y)
  1398. fb_info->pixmap.blit_y = ~(u32)0;
  1399. if (!fb_info->modelist.prev || !fb_info->modelist.next)
  1400. INIT_LIST_HEAD(&fb_info->modelist);
  1401. fb_var_to_videomode(&mode, &fb_info->var);
  1402. fb_add_videomode(&mode, &fb_info->modelist);
  1403. registered_fb[i] = fb_info;
  1404. event.info = fb_info;
  1405. if (!lock_fb_info(fb_info))
  1406. return -ENODEV;
  1407. console_lock();
  1408. fb_notifier_call_chain(FB_EVENT_FB_REGISTERED, &event);
  1409. console_unlock();
  1410. unlock_fb_info(fb_info);
  1411. return 0;
  1412. }
  1413. static int do_unregister_framebuffer(struct fb_info *fb_info)
  1414. {
  1415. struct fb_event event;
  1416. int i, ret = 0;
  1417. i = fb_info->node;
  1418. if (i < 0 || i >= FB_MAX || registered_fb[i] != fb_info)
  1419. return -EINVAL;
  1420. if (!lock_fb_info(fb_info))
  1421. return -ENODEV;
  1422. console_lock();
  1423. event.info = fb_info;
  1424. ret = fb_notifier_call_chain(FB_EVENT_FB_UNBIND, &event);
  1425. console_unlock();
  1426. unlock_fb_info(fb_info);
  1427. if (ret)
  1428. return -EINVAL;
  1429. unlink_framebuffer(fb_info);
  1430. if (fb_info->pixmap.addr &&
  1431. (fb_info->pixmap.flags & FB_PIXMAP_DEFAULT))
  1432. kfree(fb_info->pixmap.addr);
  1433. fb_destroy_modelist(&fb_info->modelist);
  1434. registered_fb[i] = NULL;
  1435. num_registered_fb--;
  1436. fb_cleanup_device(fb_info);
  1437. event.info = fb_info;
  1438. console_lock();
  1439. fb_notifier_call_chain(FB_EVENT_FB_UNREGISTERED, &event);
  1440. console_unlock();
  1441. /* this may free fb info */
  1442. put_fb_info(fb_info);
  1443. return 0;
  1444. }
  1445. int unlink_framebuffer(struct fb_info *fb_info)
  1446. {
  1447. int i;
  1448. i = fb_info->node;
  1449. if (i < 0 || i >= FB_MAX || registered_fb[i] != fb_info)
  1450. return -EINVAL;
  1451. if (fb_info->dev) {
  1452. device_destroy(fb_class, MKDEV(FB_MAJOR, i));
  1453. fb_info->dev = NULL;
  1454. }
  1455. return 0;
  1456. }
  1457. EXPORT_SYMBOL(unlink_framebuffer);
  1458. void remove_conflicting_framebuffers(struct apertures_struct *a,
  1459. const char *name, bool primary)
  1460. {
  1461. mutex_lock(&registration_lock);
  1462. do_remove_conflicting_framebuffers(a, name, primary);
  1463. mutex_unlock(&registration_lock);
  1464. }
  1465. EXPORT_SYMBOL(remove_conflicting_framebuffers);
  1466. /**
  1467. * register_framebuffer - registers a frame buffer device
  1468. * @fb_info: frame buffer info structure
  1469. *
  1470. * Registers a frame buffer device @fb_info.
  1471. *
  1472. * Returns negative errno on error, or zero for success.
  1473. *
  1474. */
  1475. int
  1476. register_framebuffer(struct fb_info *fb_info)
  1477. {
  1478. int ret;
  1479. mutex_lock(&registration_lock);
  1480. ret = do_register_framebuffer(fb_info);
  1481. mutex_unlock(&registration_lock);
  1482. return ret;
  1483. }
  1484. /**
  1485. * unregister_framebuffer - releases a frame buffer device
  1486. * @fb_info: frame buffer info structure
  1487. *
  1488. * Unregisters a frame buffer device @fb_info.
  1489. *
  1490. * Returns negative errno on error, or zero for success.
  1491. *
  1492. * This function will also notify the framebuffer console
  1493. * to release the driver.
  1494. *
  1495. * This is meant to be called within a driver's module_exit()
  1496. * function. If this is called outside module_exit(), ensure
  1497. * that the driver implements fb_open() and fb_release() to
  1498. * check that no processes are using the device.
  1499. */
  1500. int
  1501. unregister_framebuffer(struct fb_info *fb_info)
  1502. {
  1503. int ret;
  1504. mutex_lock(&registration_lock);
  1505. ret = do_unregister_framebuffer(fb_info);
  1506. mutex_unlock(&registration_lock);
  1507. return ret;
  1508. }
  1509. /**
  1510. * fb_set_suspend - low level driver signals suspend
  1511. * @info: framebuffer affected
  1512. * @state: 0 = resuming, !=0 = suspending
  1513. *
  1514. * This is meant to be used by low level drivers to
  1515. * signal suspend/resume to the core & clients.
  1516. * It must be called with the console semaphore held
  1517. */
  1518. void fb_set_suspend(struct fb_info *info, int state)
  1519. {
  1520. struct fb_event event;
  1521. event.info = info;
  1522. if (state) {
  1523. fb_notifier_call_chain(FB_EVENT_SUSPEND, &event);
  1524. info->state = FBINFO_STATE_SUSPENDED;
  1525. } else {
  1526. info->state = FBINFO_STATE_RUNNING;
  1527. fb_notifier_call_chain(FB_EVENT_RESUME, &event);
  1528. }
  1529. }
  1530. /**
  1531. * fbmem_init - init frame buffer subsystem
  1532. *
  1533. * Initialize the frame buffer subsystem.
  1534. *
  1535. * NOTE: This function is _only_ to be called by drivers/char/mem.c.
  1536. *
  1537. */
  1538. static int __init
  1539. fbmem_init(void)
  1540. {
  1541. proc_create("fb", 0, NULL, &fb_proc_fops);
  1542. if (register_chrdev(FB_MAJOR,"fb",&fb_fops))
  1543. printk("unable to get major %d for fb devs\n", FB_MAJOR);
  1544. fb_class = class_create(THIS_MODULE, "graphics");
  1545. if (IS_ERR(fb_class)) {
  1546. printk(KERN_WARNING "Unable to create fb class; errno = %ld\n", PTR_ERR(fb_class));
  1547. fb_class = NULL;
  1548. }
  1549. return 0;
  1550. }
  1551. #ifdef MODULE
  1552. module_init(fbmem_init);
  1553. static void __exit
  1554. fbmem_exit(void)
  1555. {
  1556. remove_proc_entry("fb", NULL);
  1557. class_destroy(fb_class);
  1558. unregister_chrdev(FB_MAJOR, "fb");
  1559. }
  1560. module_exit(fbmem_exit);
  1561. MODULE_LICENSE("GPL");
  1562. MODULE_DESCRIPTION("Framebuffer base");
  1563. #else
  1564. subsys_initcall(fbmem_init);
  1565. #endif
  1566. int fb_new_modelist(struct fb_info *info)
  1567. {
  1568. struct fb_event event;
  1569. struct fb_var_screeninfo var = info->var;
  1570. struct list_head *pos, *n;
  1571. struct fb_modelist *modelist;
  1572. struct fb_videomode *m, mode;
  1573. int err = 1;
  1574. list_for_each_safe(pos, n, &info->modelist) {
  1575. modelist = list_entry(pos, struct fb_modelist, list);
  1576. m = &modelist->mode;
  1577. fb_videomode_to_var(&var, m);
  1578. var.activate = FB_ACTIVATE_TEST;
  1579. err = fb_set_var(info, &var);
  1580. fb_var_to_videomode(&mode, &var);
  1581. if (err || !fb_mode_is_equal(m, &mode)) {
  1582. list_del(pos);
  1583. kfree(pos);
  1584. }
  1585. }
  1586. err = 1;
  1587. if (!list_empty(&info->modelist)) {
  1588. event.info = info;
  1589. err = fb_notifier_call_chain(FB_EVENT_NEW_MODELIST, &event);
  1590. }
  1591. return err;
  1592. }
  1593. static char *video_options[FB_MAX] __read_mostly;
  1594. static int ofonly __read_mostly;
  1595. /**
  1596. * fb_get_options - get kernel boot parameters
  1597. * @name: framebuffer name as it would appear in
  1598. * the boot parameter line
  1599. * (video=<name>:<options>)
  1600. * @option: the option will be stored here
  1601. *
  1602. * NOTE: Needed to maintain backwards compatibility
  1603. */
  1604. int fb_get_options(char *name, char **option)
  1605. {
  1606. char *opt, *options = NULL;
  1607. int retval = 0;
  1608. int name_len = strlen(name), i;
  1609. if (name_len && ofonly && strncmp(name, "offb", 4))
  1610. retval = 1;
  1611. if (name_len && !retval) {
  1612. for (i = 0; i < FB_MAX; i++) {
  1613. if (video_options[i] == NULL)
  1614. continue;
  1615. if (!video_options[i][0])
  1616. continue;
  1617. opt = video_options[i];
  1618. if (!strncmp(name, opt, name_len) &&
  1619. opt[name_len] == ':')
  1620. options = opt + name_len + 1;
  1621. }
  1622. }
  1623. if (options && !strncmp(options, "off", 3))
  1624. retval = 1;
  1625. if (option)
  1626. *option = options;
  1627. return retval;
  1628. }
  1629. #ifndef MODULE
  1630. /**
  1631. * video_setup - process command line options
  1632. * @options: string of options
  1633. *
  1634. * Process command line options for frame buffer subsystem.
  1635. *
  1636. * NOTE: This function is a __setup and __init function.
  1637. * It only stores the options. Drivers have to call
  1638. * fb_get_options() as necessary.
  1639. *
  1640. * Returns zero.
  1641. *
  1642. */
  1643. static int __init video_setup(char *options)
  1644. {
  1645. int i, global = 0;
  1646. if (!options || !*options)
  1647. global = 1;
  1648. if (!global && !strncmp(options, "ofonly", 6)) {
  1649. ofonly = 1;
  1650. global = 1;
  1651. }
  1652. if (!global && !strchr(options, ':')) {
  1653. fb_mode_option = options;
  1654. global = 1;
  1655. }
  1656. if (!global) {
  1657. for (i = 0; i < FB_MAX; i++) {
  1658. if (video_options[i] == NULL) {
  1659. video_options[i] = options;
  1660. break;
  1661. }
  1662. }
  1663. }
  1664. return 1;
  1665. }
  1666. __setup("video=", video_setup);
  1667. #endif
  1668. /*
  1669. * Visible symbols for modules
  1670. */
  1671. EXPORT_SYMBOL(register_framebuffer);
  1672. EXPORT_SYMBOL(unregister_framebuffer);
  1673. EXPORT_SYMBOL(num_registered_fb);
  1674. EXPORT_SYMBOL(registered_fb);
  1675. EXPORT_SYMBOL(fb_show_logo);
  1676. EXPORT_SYMBOL(fb_set_var);
  1677. EXPORT_SYMBOL(fb_blank);
  1678. EXPORT_SYMBOL(fb_pan_display);
  1679. EXPORT_SYMBOL(fb_get_buffer_offset);
  1680. EXPORT_SYMBOL(fb_set_suspend);
  1681. EXPORT_SYMBOL(fb_get_options);
  1682. MODULE_LICENSE("GPL");