fbmem.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339
  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/config.h>
  14. #include <linux/module.h>
  15. #include <linux/types.h>
  16. #include <linux/errno.h>
  17. #include <linux/sched.h>
  18. #include <linux/smp_lock.h>
  19. #include <linux/kernel.h>
  20. #include <linux/major.h>
  21. #include <linux/slab.h>
  22. #include <linux/mm.h>
  23. #include <linux/mman.h>
  24. #include <linux/tty.h>
  25. #include <linux/init.h>
  26. #include <linux/linux_logo.h>
  27. #include <linux/proc_fs.h>
  28. #include <linux/console.h>
  29. #ifdef CONFIG_KMOD
  30. #include <linux/kmod.h>
  31. #endif
  32. #include <linux/devfs_fs_kernel.h>
  33. #include <linux/err.h>
  34. #include <linux/kernel.h>
  35. #include <linux/device.h>
  36. #include <linux/efi.h>
  37. #if defined(__mc68000__) || defined(CONFIG_APUS)
  38. #include <asm/setup.h>
  39. #endif
  40. #include <asm/io.h>
  41. #include <asm/uaccess.h>
  42. #include <asm/page.h>
  43. #include <asm/pgtable.h>
  44. #include <linux/fb.h>
  45. /*
  46. * Frame buffer device initialization and setup routines
  47. */
  48. #define FBPIXMAPSIZE (1024 * 8)
  49. static struct notifier_block *fb_notifier_list;
  50. struct fb_info *registered_fb[FB_MAX];
  51. int num_registered_fb;
  52. /*
  53. * Helpers
  54. */
  55. int fb_get_color_depth(struct fb_var_screeninfo *var,
  56. struct fb_fix_screeninfo *fix)
  57. {
  58. int depth = 0;
  59. if (fix->visual == FB_VISUAL_MONO01 ||
  60. fix->visual == FB_VISUAL_MONO10)
  61. depth = 1;
  62. else {
  63. if (var->green.length == var->blue.length &&
  64. var->green.length == var->red.length &&
  65. var->green.offset == var->blue.offset &&
  66. var->green.offset == var->red.offset)
  67. depth = var->green.length;
  68. else
  69. depth = var->green.length + var->red.length +
  70. var->blue.length;
  71. }
  72. return depth;
  73. }
  74. EXPORT_SYMBOL(fb_get_color_depth);
  75. /*
  76. * Data padding functions.
  77. */
  78. void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, u32 height)
  79. {
  80. int i, j;
  81. for (i = height; i--; ) {
  82. /* s_pitch is a few bytes at the most, memcpy is suboptimal */
  83. for (j = 0; j < s_pitch; j++)
  84. dst[j] = src[j];
  85. src += s_pitch;
  86. dst += d_pitch;
  87. }
  88. }
  89. EXPORT_SYMBOL(fb_pad_aligned_buffer);
  90. void fb_pad_unaligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 idx, u32 height,
  91. u32 shift_high, u32 shift_low, u32 mod)
  92. {
  93. u8 mask = (u8) (0xfff << shift_high), tmp;
  94. int i, j;
  95. for (i = height; i--; ) {
  96. for (j = 0; j < idx; j++) {
  97. tmp = dst[j];
  98. tmp &= mask;
  99. tmp |= *src >> shift_low;
  100. dst[j] = tmp;
  101. tmp = *src << shift_high;
  102. dst[j+1] = tmp;
  103. src++;
  104. }
  105. tmp = dst[idx];
  106. tmp &= mask;
  107. tmp |= *src >> shift_low;
  108. dst[idx] = tmp;
  109. if (shift_high < mod) {
  110. tmp = *src << shift_high;
  111. dst[idx+1] = tmp;
  112. }
  113. src++;
  114. dst += d_pitch;
  115. }
  116. }
  117. EXPORT_SYMBOL(fb_pad_unaligned_buffer);
  118. /*
  119. * we need to lock this section since fb_cursor
  120. * may use fb_imageblit()
  121. */
  122. char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size)
  123. {
  124. u32 align = buf->buf_align - 1, offset;
  125. char *addr = buf->addr;
  126. /* If IO mapped, we need to sync before access, no sharing of
  127. * the pixmap is done
  128. */
  129. if (buf->flags & FB_PIXMAP_IO) {
  130. if (info->fbops->fb_sync && (buf->flags & FB_PIXMAP_SYNC))
  131. info->fbops->fb_sync(info);
  132. return addr;
  133. }
  134. /* See if we fit in the remaining pixmap space */
  135. offset = buf->offset + align;
  136. offset &= ~align;
  137. if (offset + size > buf->size) {
  138. /* We do not fit. In order to be able to re-use the buffer,
  139. * we must ensure no asynchronous DMA'ing or whatever operation
  140. * is in progress, we sync for that.
  141. */
  142. if (info->fbops->fb_sync && (buf->flags & FB_PIXMAP_SYNC))
  143. info->fbops->fb_sync(info);
  144. offset = 0;
  145. }
  146. buf->offset = offset + size;
  147. addr += offset;
  148. return addr;
  149. }
  150. #ifdef CONFIG_LOGO
  151. #include <linux/linux_logo.h>
  152. static inline unsigned safe_shift(unsigned d, int n)
  153. {
  154. return n < 0 ? d >> -n : d << n;
  155. }
  156. static void fb_set_logocmap(struct fb_info *info,
  157. const struct linux_logo *logo)
  158. {
  159. struct fb_cmap palette_cmap;
  160. u16 palette_green[16];
  161. u16 palette_blue[16];
  162. u16 palette_red[16];
  163. int i, j, n;
  164. const unsigned char *clut = logo->clut;
  165. palette_cmap.start = 0;
  166. palette_cmap.len = 16;
  167. palette_cmap.red = palette_red;
  168. palette_cmap.green = palette_green;
  169. palette_cmap.blue = palette_blue;
  170. palette_cmap.transp = NULL;
  171. for (i = 0; i < logo->clutsize; i += n) {
  172. n = logo->clutsize - i;
  173. /* palette_cmap provides space for only 16 colors at once */
  174. if (n > 16)
  175. n = 16;
  176. palette_cmap.start = 32 + i;
  177. palette_cmap.len = n;
  178. for (j = 0; j < n; ++j) {
  179. palette_cmap.red[j] = clut[0] << 8 | clut[0];
  180. palette_cmap.green[j] = clut[1] << 8 | clut[1];
  181. palette_cmap.blue[j] = clut[2] << 8 | clut[2];
  182. clut += 3;
  183. }
  184. fb_set_cmap(&palette_cmap, info);
  185. }
  186. }
  187. static void fb_set_logo_truepalette(struct fb_info *info,
  188. const struct linux_logo *logo,
  189. u32 *palette)
  190. {
  191. unsigned char mask[9] = { 0,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff };
  192. unsigned char redmask, greenmask, bluemask;
  193. int redshift, greenshift, blueshift;
  194. int i;
  195. const unsigned char *clut = logo->clut;
  196. /*
  197. * We have to create a temporary palette since console palette is only
  198. * 16 colors long.
  199. */
  200. /* Bug: Doesn't obey msb_right ... (who needs that?) */
  201. redmask = mask[info->var.red.length < 8 ? info->var.red.length : 8];
  202. greenmask = mask[info->var.green.length < 8 ? info->var.green.length : 8];
  203. bluemask = mask[info->var.blue.length < 8 ? info->var.blue.length : 8];
  204. redshift = info->var.red.offset - (8 - info->var.red.length);
  205. greenshift = info->var.green.offset - (8 - info->var.green.length);
  206. blueshift = info->var.blue.offset - (8 - info->var.blue.length);
  207. for ( i = 0; i < logo->clutsize; i++) {
  208. palette[i+32] = (safe_shift((clut[0] & redmask), redshift) |
  209. safe_shift((clut[1] & greenmask), greenshift) |
  210. safe_shift((clut[2] & bluemask), blueshift));
  211. clut += 3;
  212. }
  213. }
  214. static void fb_set_logo_directpalette(struct fb_info *info,
  215. const struct linux_logo *logo,
  216. u32 *palette)
  217. {
  218. int redshift, greenshift, blueshift;
  219. int i;
  220. redshift = info->var.red.offset;
  221. greenshift = info->var.green.offset;
  222. blueshift = info->var.blue.offset;
  223. for (i = 32; i < logo->clutsize; i++)
  224. palette[i] = i << redshift | i << greenshift | i << blueshift;
  225. }
  226. static void fb_set_logo(struct fb_info *info,
  227. const struct linux_logo *logo, u8 *dst,
  228. int depth)
  229. {
  230. int i, j, k;
  231. const u8 *src = logo->data;
  232. u8 xor = (info->fix.visual == FB_VISUAL_MONO01) ? 0xff : 0;
  233. u8 fg = 1, d;
  234. if (fb_get_color_depth(&info->var, &info->fix) == 3)
  235. fg = 7;
  236. if (info->fix.visual == FB_VISUAL_MONO01 ||
  237. info->fix.visual == FB_VISUAL_MONO10)
  238. fg = ~((u8) (0xfff << info->var.green.length));
  239. switch (depth) {
  240. case 4:
  241. for (i = 0; i < logo->height; i++)
  242. for (j = 0; j < logo->width; src++) {
  243. *dst++ = *src >> 4;
  244. j++;
  245. if (j < logo->width) {
  246. *dst++ = *src & 0x0f;
  247. j++;
  248. }
  249. }
  250. break;
  251. case 1:
  252. for (i = 0; i < logo->height; i++) {
  253. for (j = 0; j < logo->width; src++) {
  254. d = *src ^ xor;
  255. for (k = 7; k >= 0; k--) {
  256. *dst++ = ((d >> k) & 1) ? fg : 0;
  257. j++;
  258. }
  259. }
  260. }
  261. break;
  262. }
  263. }
  264. /*
  265. * Three (3) kinds of logo maps exist. linux_logo_clut224 (>16 colors),
  266. * linux_logo_vga16 (16 colors) and linux_logo_mono (2 colors). Depending on
  267. * the visual format and color depth of the framebuffer, the DAC, the
  268. * pseudo_palette, and the logo data will be adjusted accordingly.
  269. *
  270. * Case 1 - linux_logo_clut224:
  271. * Color exceeds the number of console colors (16), thus we set the hardware DAC
  272. * using fb_set_cmap() appropriately. The "needs_cmapreset" flag will be set.
  273. *
  274. * For visuals that require color info from the pseudo_palette, we also construct
  275. * one for temporary use. The "needs_directpalette" or "needs_truepalette" flags
  276. * will be set.
  277. *
  278. * Case 2 - linux_logo_vga16:
  279. * The number of colors just matches the console colors, thus there is no need
  280. * to set the DAC or the pseudo_palette. However, the bitmap is packed, ie,
  281. * each byte contains color information for two pixels (upper and lower nibble).
  282. * To be consistent with fb_imageblit() usage, we therefore separate the two
  283. * nibbles into separate bytes. The "depth" flag will be set to 4.
  284. *
  285. * Case 3 - linux_logo_mono:
  286. * This is similar with Case 2. Each byte contains information for 8 pixels.
  287. * We isolate each bit and expand each into a byte. The "depth" flag will
  288. * be set to 1.
  289. */
  290. static struct logo_data {
  291. int depth;
  292. int needs_directpalette;
  293. int needs_truepalette;
  294. int needs_cmapreset;
  295. const struct linux_logo *logo;
  296. } fb_logo;
  297. int fb_prepare_logo(struct fb_info *info)
  298. {
  299. int depth = fb_get_color_depth(&info->var, &info->fix);
  300. memset(&fb_logo, 0, sizeof(struct logo_data));
  301. if (info->flags & FBINFO_MISC_TILEBLITTING)
  302. return 0;
  303. if (info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
  304. depth = info->var.blue.length;
  305. if (info->var.red.length < depth)
  306. depth = info->var.red.length;
  307. if (info->var.green.length < depth)
  308. depth = info->var.green.length;
  309. }
  310. if (depth >= 8) {
  311. switch (info->fix.visual) {
  312. case FB_VISUAL_TRUECOLOR:
  313. fb_logo.needs_truepalette = 1;
  314. break;
  315. case FB_VISUAL_DIRECTCOLOR:
  316. fb_logo.needs_directpalette = 1;
  317. fb_logo.needs_cmapreset = 1;
  318. break;
  319. case FB_VISUAL_PSEUDOCOLOR:
  320. fb_logo.needs_cmapreset = 1;
  321. break;
  322. }
  323. }
  324. /* Return if no suitable logo was found */
  325. fb_logo.logo = fb_find_logo(depth);
  326. if (!fb_logo.logo || fb_logo.logo->height > info->var.yres) {
  327. fb_logo.logo = NULL;
  328. return 0;
  329. }
  330. /* What depth we asked for might be different from what we get */
  331. if (fb_logo.logo->type == LINUX_LOGO_CLUT224)
  332. fb_logo.depth = 8;
  333. else if (fb_logo.logo->type == LINUX_LOGO_VGA16)
  334. fb_logo.depth = 4;
  335. else
  336. fb_logo.depth = 1;
  337. return fb_logo.logo->height;
  338. }
  339. int fb_show_logo(struct fb_info *info)
  340. {
  341. u32 *palette = NULL, *saved_pseudo_palette = NULL;
  342. unsigned char *logo_new = NULL;
  343. struct fb_image image;
  344. int x;
  345. /* Return if the frame buffer is not mapped or suspended */
  346. if (fb_logo.logo == NULL || info->state != FBINFO_STATE_RUNNING)
  347. return 0;
  348. image.depth = 8;
  349. image.data = fb_logo.logo->data;
  350. if (fb_logo.needs_cmapreset)
  351. fb_set_logocmap(info, fb_logo.logo);
  352. if (fb_logo.needs_truepalette ||
  353. fb_logo.needs_directpalette) {
  354. palette = kmalloc(256 * 4, GFP_KERNEL);
  355. if (palette == NULL)
  356. return 0;
  357. if (fb_logo.needs_truepalette)
  358. fb_set_logo_truepalette(info, fb_logo.logo, palette);
  359. else
  360. fb_set_logo_directpalette(info, fb_logo.logo, palette);
  361. saved_pseudo_palette = info->pseudo_palette;
  362. info->pseudo_palette = palette;
  363. }
  364. if (fb_logo.depth <= 4) {
  365. logo_new = kmalloc(fb_logo.logo->width * fb_logo.logo->height,
  366. GFP_KERNEL);
  367. if (logo_new == NULL) {
  368. kfree(palette);
  369. if (saved_pseudo_palette)
  370. info->pseudo_palette = saved_pseudo_palette;
  371. return 0;
  372. }
  373. image.data = logo_new;
  374. fb_set_logo(info, fb_logo.logo, logo_new, fb_logo.depth);
  375. }
  376. image.width = fb_logo.logo->width;
  377. image.height = fb_logo.logo->height;
  378. image.dy = 0;
  379. for (x = 0; x < num_online_cpus() * (fb_logo.logo->width + 8) &&
  380. x <= info->var.xres-fb_logo.logo->width; x += (fb_logo.logo->width + 8)) {
  381. image.dx = x;
  382. info->fbops->fb_imageblit(info, &image);
  383. }
  384. kfree(palette);
  385. if (saved_pseudo_palette != NULL)
  386. info->pseudo_palette = saved_pseudo_palette;
  387. kfree(logo_new);
  388. return fb_logo.logo->height;
  389. }
  390. #else
  391. int fb_prepare_logo(struct fb_info *info) { return 0; }
  392. int fb_show_logo(struct fb_info *info) { return 0; }
  393. #endif /* CONFIG_LOGO */
  394. static int fbmem_read_proc(char *buf, char **start, off_t offset,
  395. int len, int *eof, void *private)
  396. {
  397. struct fb_info **fi;
  398. int clen;
  399. clen = 0;
  400. for (fi = registered_fb; fi < &registered_fb[FB_MAX] && len < 4000; fi++)
  401. if (*fi)
  402. clen += sprintf(buf + clen, "%d %s\n",
  403. (*fi)->node,
  404. (*fi)->fix.id);
  405. *start = buf + offset;
  406. if (clen > offset)
  407. clen -= offset;
  408. else
  409. clen = 0;
  410. return clen < len ? clen : len;
  411. }
  412. static ssize_t
  413. fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
  414. {
  415. unsigned long p = *ppos;
  416. struct inode *inode = file->f_dentry->d_inode;
  417. int fbidx = iminor(inode);
  418. struct fb_info *info = registered_fb[fbidx];
  419. u32 *buffer, *dst;
  420. u32 __iomem *src;
  421. int c, i, cnt = 0, err = 0;
  422. unsigned long total_size;
  423. if (!info || ! info->screen_base)
  424. return -ENODEV;
  425. if (info->state != FBINFO_STATE_RUNNING)
  426. return -EPERM;
  427. if (info->fbops->fb_read)
  428. return info->fbops->fb_read(file, buf, count, ppos);
  429. total_size = info->screen_size;
  430. if (total_size == 0)
  431. total_size = info->fix.smem_len;
  432. if (p >= total_size)
  433. return 0;
  434. if (count >= total_size)
  435. count = total_size;
  436. if (count + p > total_size)
  437. count = total_size - p;
  438. cnt = 0;
  439. buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count,
  440. GFP_KERNEL);
  441. if (!buffer)
  442. return -ENOMEM;
  443. src = (u32 __iomem *) (info->screen_base + p);
  444. if (info->fbops->fb_sync)
  445. info->fbops->fb_sync(info);
  446. while (count) {
  447. c = (count > PAGE_SIZE) ? PAGE_SIZE : count;
  448. dst = buffer;
  449. for (i = c >> 2; i--; )
  450. *dst++ = fb_readl(src++);
  451. if (c & 3) {
  452. u8 *dst8 = (u8 *) dst;
  453. u8 __iomem *src8 = (u8 __iomem *) src;
  454. for (i = c & 3; i--;)
  455. *dst8++ = fb_readb(src8++);
  456. src = (u32 __iomem *) src8;
  457. }
  458. if (copy_to_user(buf, buffer, c)) {
  459. err = -EFAULT;
  460. break;
  461. }
  462. *ppos += c;
  463. buf += c;
  464. cnt += c;
  465. count -= c;
  466. }
  467. kfree(buffer);
  468. return (err) ? err : cnt;
  469. }
  470. static ssize_t
  471. fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
  472. {
  473. unsigned long p = *ppos;
  474. struct inode *inode = file->f_dentry->d_inode;
  475. int fbidx = iminor(inode);
  476. struct fb_info *info = registered_fb[fbidx];
  477. u32 *buffer, *src;
  478. u32 __iomem *dst;
  479. int c, i, cnt = 0, err;
  480. unsigned long total_size;
  481. if (!info || !info->screen_base)
  482. return -ENODEV;
  483. if (info->state != FBINFO_STATE_RUNNING)
  484. return -EPERM;
  485. if (info->fbops->fb_write)
  486. return info->fbops->fb_write(file, buf, count, ppos);
  487. total_size = info->screen_size;
  488. if (total_size == 0)
  489. total_size = info->fix.smem_len;
  490. if (p > total_size)
  491. return -ENOSPC;
  492. if (count >= total_size)
  493. count = total_size;
  494. err = 0;
  495. if (count + p > total_size) {
  496. count = total_size - p;
  497. err = -ENOSPC;
  498. }
  499. cnt = 0;
  500. buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count,
  501. GFP_KERNEL);
  502. if (!buffer)
  503. return -ENOMEM;
  504. dst = (u32 __iomem *) (info->screen_base + p);
  505. if (info->fbops->fb_sync)
  506. info->fbops->fb_sync(info);
  507. while (count) {
  508. c = (count > PAGE_SIZE) ? PAGE_SIZE : count;
  509. src = buffer;
  510. if (copy_from_user(src, buf, c)) {
  511. err = -EFAULT;
  512. break;
  513. }
  514. for (i = c >> 2; i--; )
  515. fb_writel(*src++, dst++);
  516. if (c & 3) {
  517. u8 *src8 = (u8 *) src;
  518. u8 __iomem *dst8 = (u8 __iomem *) dst;
  519. for (i = c & 3; i--; )
  520. fb_writeb(*src8++, dst8++);
  521. dst = (u32 __iomem *) dst8;
  522. }
  523. *ppos += c;
  524. buf += c;
  525. cnt += c;
  526. count -= c;
  527. }
  528. kfree(buffer);
  529. return (err) ? err : cnt;
  530. }
  531. #ifdef CONFIG_KMOD
  532. static void try_to_load(int fb)
  533. {
  534. request_module("fb%d", fb);
  535. }
  536. #endif /* CONFIG_KMOD */
  537. int
  538. fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var)
  539. {
  540. int xoffset = var->xoffset;
  541. int yoffset = var->yoffset;
  542. int err;
  543. if (xoffset < 0 || yoffset < 0 || !info->fbops->fb_pan_display ||
  544. xoffset + info->var.xres > info->var.xres_virtual ||
  545. yoffset + info->var.yres > info->var.yres_virtual)
  546. return -EINVAL;
  547. if ((err = info->fbops->fb_pan_display(var, info)))
  548. return err;
  549. info->var.xoffset = var->xoffset;
  550. info->var.yoffset = var->yoffset;
  551. if (var->vmode & FB_VMODE_YWRAP)
  552. info->var.vmode |= FB_VMODE_YWRAP;
  553. else
  554. info->var.vmode &= ~FB_VMODE_YWRAP;
  555. return 0;
  556. }
  557. int
  558. fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
  559. {
  560. int err, flags = info->flags;
  561. if (var->activate & FB_ACTIVATE_INV_MODE) {
  562. struct fb_videomode mode1, mode2;
  563. int ret = 0;
  564. fb_var_to_videomode(&mode1, var);
  565. fb_var_to_videomode(&mode2, &info->var);
  566. /* make sure we don't delete the videomode of current var */
  567. ret = fb_mode_is_equal(&mode1, &mode2);
  568. if (!ret) {
  569. struct fb_event event;
  570. event.info = info;
  571. event.data = &mode1;
  572. ret = notifier_call_chain(&fb_notifier_list,
  573. FB_EVENT_MODE_DELETE, &event);
  574. }
  575. if (!ret)
  576. fb_delete_videomode(&mode1, &info->modelist);
  577. return ret;
  578. }
  579. if ((var->activate & FB_ACTIVATE_FORCE) ||
  580. memcmp(&info->var, var, sizeof(struct fb_var_screeninfo))) {
  581. if (!info->fbops->fb_check_var) {
  582. *var = info->var;
  583. return 0;
  584. }
  585. if ((err = info->fbops->fb_check_var(var, info)))
  586. return err;
  587. if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) {
  588. struct fb_videomode mode;
  589. int err = 0;
  590. info->var = *var;
  591. if (info->fbops->fb_set_par)
  592. info->fbops->fb_set_par(info);
  593. fb_pan_display(info, &info->var);
  594. fb_set_cmap(&info->cmap, info);
  595. fb_var_to_videomode(&mode, &info->var);
  596. if (info->modelist.prev && info->modelist.next &&
  597. !list_empty(&info->modelist))
  598. err = fb_add_videomode(&mode, &info->modelist);
  599. if (!err && (flags & FBINFO_MISC_USEREVENT)) {
  600. struct fb_event event;
  601. int evnt = (var->activate & FB_ACTIVATE_ALL) ?
  602. FB_EVENT_MODE_CHANGE_ALL :
  603. FB_EVENT_MODE_CHANGE;
  604. info->flags &= ~FBINFO_MISC_USEREVENT;
  605. event.info = info;
  606. notifier_call_chain(&fb_notifier_list, evnt,
  607. &event);
  608. }
  609. }
  610. }
  611. return 0;
  612. }
  613. int
  614. fb_blank(struct fb_info *info, int blank)
  615. {
  616. int ret = -EINVAL;
  617. if (blank > FB_BLANK_POWERDOWN)
  618. blank = FB_BLANK_POWERDOWN;
  619. if (info->fbops->fb_blank)
  620. ret = info->fbops->fb_blank(blank, info);
  621. if (!ret) {
  622. struct fb_event event;
  623. event.info = info;
  624. event.data = &blank;
  625. notifier_call_chain(&fb_notifier_list, FB_EVENT_BLANK, &event);
  626. }
  627. return ret;
  628. }
  629. static int
  630. fb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
  631. unsigned long arg)
  632. {
  633. int fbidx = iminor(inode);
  634. struct fb_info *info = registered_fb[fbidx];
  635. struct fb_ops *fb = info->fbops;
  636. struct fb_var_screeninfo var;
  637. struct fb_fix_screeninfo fix;
  638. struct fb_con2fbmap con2fb;
  639. struct fb_cmap_user cmap;
  640. struct fb_event event;
  641. void __user *argp = (void __user *)arg;
  642. int i;
  643. if (!fb)
  644. return -ENODEV;
  645. switch (cmd) {
  646. case FBIOGET_VSCREENINFO:
  647. return copy_to_user(argp, &info->var,
  648. sizeof(var)) ? -EFAULT : 0;
  649. case FBIOPUT_VSCREENINFO:
  650. if (copy_from_user(&var, argp, sizeof(var)))
  651. return -EFAULT;
  652. acquire_console_sem();
  653. info->flags |= FBINFO_MISC_USEREVENT;
  654. i = fb_set_var(info, &var);
  655. info->flags &= ~FBINFO_MISC_USEREVENT;
  656. release_console_sem();
  657. if (i) return i;
  658. if (copy_to_user(argp, &var, sizeof(var)))
  659. return -EFAULT;
  660. return 0;
  661. case FBIOGET_FSCREENINFO:
  662. return copy_to_user(argp, &info->fix,
  663. sizeof(fix)) ? -EFAULT : 0;
  664. case FBIOPUTCMAP:
  665. if (copy_from_user(&cmap, argp, sizeof(cmap)))
  666. return -EFAULT;
  667. return (fb_set_user_cmap(&cmap, info));
  668. case FBIOGETCMAP:
  669. if (copy_from_user(&cmap, argp, sizeof(cmap)))
  670. return -EFAULT;
  671. return fb_cmap_to_user(&info->cmap, &cmap);
  672. case FBIOPAN_DISPLAY:
  673. if (copy_from_user(&var, argp, sizeof(var)))
  674. return -EFAULT;
  675. acquire_console_sem();
  676. i = fb_pan_display(info, &var);
  677. release_console_sem();
  678. if (i)
  679. return i;
  680. if (copy_to_user(argp, &var, sizeof(var)))
  681. return -EFAULT;
  682. return 0;
  683. case FBIO_CURSOR:
  684. return -EINVAL;
  685. case FBIOGET_CON2FBMAP:
  686. if (copy_from_user(&con2fb, argp, sizeof(con2fb)))
  687. return -EFAULT;
  688. if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
  689. return -EINVAL;
  690. con2fb.framebuffer = -1;
  691. event.info = info;
  692. event.data = &con2fb;
  693. notifier_call_chain(&fb_notifier_list,
  694. FB_EVENT_GET_CONSOLE_MAP, &event);
  695. return copy_to_user(argp, &con2fb,
  696. sizeof(con2fb)) ? -EFAULT : 0;
  697. case FBIOPUT_CON2FBMAP:
  698. if (copy_from_user(&con2fb, argp, sizeof(con2fb)))
  699. return - EFAULT;
  700. if (con2fb.console < 0 || con2fb.console > MAX_NR_CONSOLES)
  701. return -EINVAL;
  702. if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
  703. return -EINVAL;
  704. #ifdef CONFIG_KMOD
  705. if (!registered_fb[con2fb.framebuffer])
  706. try_to_load(con2fb.framebuffer);
  707. #endif /* CONFIG_KMOD */
  708. if (!registered_fb[con2fb.framebuffer])
  709. return -EINVAL;
  710. event.info = info;
  711. event.data = &con2fb;
  712. return notifier_call_chain(&fb_notifier_list,
  713. FB_EVENT_SET_CONSOLE_MAP,
  714. &event);
  715. case FBIOBLANK:
  716. acquire_console_sem();
  717. info->flags |= FBINFO_MISC_USEREVENT;
  718. i = fb_blank(info, arg);
  719. info->flags &= ~FBINFO_MISC_USEREVENT;
  720. release_console_sem();
  721. return i;
  722. default:
  723. if (fb->fb_ioctl == NULL)
  724. return -EINVAL;
  725. return fb->fb_ioctl(inode, file, cmd, arg, info);
  726. }
  727. }
  728. #ifdef CONFIG_COMPAT
  729. static long
  730. fb_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  731. {
  732. int fbidx = iminor(file->f_dentry->d_inode);
  733. struct fb_info *info = registered_fb[fbidx];
  734. struct fb_ops *fb = info->fbops;
  735. long ret;
  736. if (fb->fb_compat_ioctl == NULL)
  737. return -ENOIOCTLCMD;
  738. lock_kernel();
  739. ret = fb->fb_compat_ioctl(file, cmd, arg, info);
  740. unlock_kernel();
  741. return ret;
  742. }
  743. #endif
  744. static int
  745. fb_mmap(struct file *file, struct vm_area_struct * vma)
  746. {
  747. int fbidx = iminor(file->f_dentry->d_inode);
  748. struct fb_info *info = registered_fb[fbidx];
  749. struct fb_ops *fb = info->fbops;
  750. unsigned long off;
  751. #if !defined(__sparc__) || defined(__sparc_v9__)
  752. unsigned long start;
  753. u32 len;
  754. #endif
  755. if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
  756. return -EINVAL;
  757. off = vma->vm_pgoff << PAGE_SHIFT;
  758. if (!fb)
  759. return -ENODEV;
  760. if (fb->fb_mmap) {
  761. int res;
  762. lock_kernel();
  763. res = fb->fb_mmap(info, file, vma);
  764. unlock_kernel();
  765. return res;
  766. }
  767. #if defined(__sparc__) && !defined(__sparc_v9__)
  768. /* Should never get here, all fb drivers should have their own
  769. mmap routines */
  770. return -EINVAL;
  771. #else
  772. /* !sparc32... */
  773. lock_kernel();
  774. /* frame buffer memory */
  775. start = info->fix.smem_start;
  776. len = PAGE_ALIGN((start & ~PAGE_MASK) + info->fix.smem_len);
  777. if (off >= len) {
  778. /* memory mapped io */
  779. off -= len;
  780. if (info->var.accel_flags) {
  781. unlock_kernel();
  782. return -EINVAL;
  783. }
  784. start = info->fix.mmio_start;
  785. len = PAGE_ALIGN((start & ~PAGE_MASK) + info->fix.mmio_len);
  786. }
  787. unlock_kernel();
  788. start &= PAGE_MASK;
  789. if ((vma->vm_end - vma->vm_start + off) > len)
  790. return -EINVAL;
  791. off += start;
  792. vma->vm_pgoff = off >> PAGE_SHIFT;
  793. /* This is an IO map - tell maydump to skip this VMA */
  794. vma->vm_flags |= VM_IO | VM_RESERVED;
  795. #if defined(__sparc_v9__)
  796. if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
  797. vma->vm_end - vma->vm_start, vma->vm_page_prot))
  798. return -EAGAIN;
  799. #else
  800. #if defined(__mc68000__)
  801. #if defined(CONFIG_SUN3)
  802. pgprot_val(vma->vm_page_prot) |= SUN3_PAGE_NOCACHE;
  803. #elif defined(CONFIG_MMU)
  804. if (CPU_IS_020_OR_030)
  805. pgprot_val(vma->vm_page_prot) |= _PAGE_NOCACHE030;
  806. if (CPU_IS_040_OR_060) {
  807. pgprot_val(vma->vm_page_prot) &= _CACHEMASK040;
  808. /* Use no-cache mode, serialized */
  809. pgprot_val(vma->vm_page_prot) |= _PAGE_NOCACHE_S;
  810. }
  811. #endif
  812. #elif defined(__powerpc__)
  813. vma->vm_page_prot = phys_mem_access_prot(file, off,
  814. vma->vm_end - vma->vm_start,
  815. vma->vm_page_prot);
  816. #elif defined(__alpha__)
  817. /* Caching is off in the I/O space quadrant by design. */
  818. #elif defined(__i386__) || defined(__x86_64__)
  819. if (boot_cpu_data.x86 > 3)
  820. pgprot_val(vma->vm_page_prot) |= _PAGE_PCD;
  821. #elif defined(__mips__)
  822. vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
  823. #elif defined(__hppa__)
  824. pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE;
  825. #elif defined(__arm__) || defined(__sh__) || defined(__m32r__)
  826. vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
  827. #elif defined(__ia64__)
  828. if (efi_range_is_wc(vma->vm_start, vma->vm_end - vma->vm_start))
  829. vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
  830. else
  831. vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
  832. #else
  833. #warning What do we have to do here??
  834. #endif
  835. if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
  836. vma->vm_end - vma->vm_start, vma->vm_page_prot))
  837. return -EAGAIN;
  838. #endif /* !__sparc_v9__ */
  839. return 0;
  840. #endif /* !sparc32 */
  841. }
  842. static int
  843. fb_open(struct inode *inode, struct file *file)
  844. {
  845. int fbidx = iminor(inode);
  846. struct fb_info *info;
  847. int res = 0;
  848. if (fbidx >= FB_MAX)
  849. return -ENODEV;
  850. #ifdef CONFIG_KMOD
  851. if (!(info = registered_fb[fbidx]))
  852. try_to_load(fbidx);
  853. #endif /* CONFIG_KMOD */
  854. if (!(info = registered_fb[fbidx]))
  855. return -ENODEV;
  856. if (!try_module_get(info->fbops->owner))
  857. return -ENODEV;
  858. if (info->fbops->fb_open) {
  859. res = info->fbops->fb_open(info,1);
  860. if (res)
  861. module_put(info->fbops->owner);
  862. }
  863. return res;
  864. }
  865. static int
  866. fb_release(struct inode *inode, struct file *file)
  867. {
  868. int fbidx = iminor(inode);
  869. struct fb_info *info;
  870. lock_kernel();
  871. info = registered_fb[fbidx];
  872. if (info->fbops->fb_release)
  873. info->fbops->fb_release(info,1);
  874. module_put(info->fbops->owner);
  875. unlock_kernel();
  876. return 0;
  877. }
  878. static struct file_operations fb_fops = {
  879. .owner = THIS_MODULE,
  880. .read = fb_read,
  881. .write = fb_write,
  882. .ioctl = fb_ioctl,
  883. #ifdef CONFIG_COMPAT
  884. .compat_ioctl = fb_compat_ioctl,
  885. #endif
  886. .mmap = fb_mmap,
  887. .open = fb_open,
  888. .release = fb_release,
  889. #ifdef HAVE_ARCH_FB_UNMAPPED_AREA
  890. .get_unmapped_area = get_fb_unmapped_area,
  891. #endif
  892. };
  893. static struct class *fb_class;
  894. /**
  895. * register_framebuffer - registers a frame buffer device
  896. * @fb_info: frame buffer info structure
  897. *
  898. * Registers a frame buffer device @fb_info.
  899. *
  900. * Returns negative errno on error, or zero for success.
  901. *
  902. */
  903. int
  904. register_framebuffer(struct fb_info *fb_info)
  905. {
  906. int i;
  907. struct fb_event event;
  908. if (num_registered_fb == FB_MAX)
  909. return -ENXIO;
  910. num_registered_fb++;
  911. for (i = 0 ; i < FB_MAX; i++)
  912. if (!registered_fb[i])
  913. break;
  914. fb_info->node = i;
  915. fb_info->class_device = class_device_create(fb_class, MKDEV(FB_MAJOR, i),
  916. fb_info->device, "fb%d", i);
  917. if (IS_ERR(fb_info->class_device)) {
  918. /* Not fatal */
  919. printk(KERN_WARNING "Unable to create class_device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->class_device));
  920. fb_info->class_device = NULL;
  921. } else
  922. fb_init_class_device(fb_info);
  923. if (fb_info->pixmap.addr == NULL) {
  924. fb_info->pixmap.addr = kmalloc(FBPIXMAPSIZE, GFP_KERNEL);
  925. if (fb_info->pixmap.addr) {
  926. fb_info->pixmap.size = FBPIXMAPSIZE;
  927. fb_info->pixmap.buf_align = 1;
  928. fb_info->pixmap.scan_align = 1;
  929. fb_info->pixmap.access_align = 32;
  930. fb_info->pixmap.flags = FB_PIXMAP_DEFAULT;
  931. }
  932. }
  933. fb_info->pixmap.offset = 0;
  934. if (!fb_info->modelist.prev ||
  935. !fb_info->modelist.next ||
  936. list_empty(&fb_info->modelist)) {
  937. struct fb_videomode mode;
  938. INIT_LIST_HEAD(&fb_info->modelist);
  939. fb_var_to_videomode(&mode, &fb_info->var);
  940. fb_add_videomode(&mode, &fb_info->modelist);
  941. }
  942. registered_fb[i] = fb_info;
  943. devfs_mk_cdev(MKDEV(FB_MAJOR, i),
  944. S_IFCHR | S_IRUGO | S_IWUGO, "fb/%d", i);
  945. event.info = fb_info;
  946. notifier_call_chain(&fb_notifier_list,
  947. FB_EVENT_FB_REGISTERED, &event);
  948. return 0;
  949. }
  950. /**
  951. * unregister_framebuffer - releases a frame buffer device
  952. * @fb_info: frame buffer info structure
  953. *
  954. * Unregisters a frame buffer device @fb_info.
  955. *
  956. * Returns negative errno on error, or zero for success.
  957. *
  958. */
  959. int
  960. unregister_framebuffer(struct fb_info *fb_info)
  961. {
  962. int i;
  963. i = fb_info->node;
  964. if (!registered_fb[i])
  965. return -EINVAL;
  966. devfs_remove("fb/%d", i);
  967. if (fb_info->pixmap.addr && (fb_info->pixmap.flags & FB_PIXMAP_DEFAULT))
  968. kfree(fb_info->pixmap.addr);
  969. fb_destroy_modelist(&fb_info->modelist);
  970. registered_fb[i]=NULL;
  971. num_registered_fb--;
  972. fb_cleanup_class_device(fb_info);
  973. class_device_destroy(fb_class, MKDEV(FB_MAJOR, i));
  974. return 0;
  975. }
  976. /**
  977. * fb_register_client - register a client notifier
  978. * @nb: notifier block to callback on events
  979. */
  980. int fb_register_client(struct notifier_block *nb)
  981. {
  982. return notifier_chain_register(&fb_notifier_list, nb);
  983. }
  984. /**
  985. * fb_unregister_client - unregister a client notifier
  986. * @nb: notifier block to callback on events
  987. */
  988. int fb_unregister_client(struct notifier_block *nb)
  989. {
  990. return notifier_chain_unregister(&fb_notifier_list, nb);
  991. }
  992. /**
  993. * fb_set_suspend - low level driver signals suspend
  994. * @info: framebuffer affected
  995. * @state: 0 = resuming, !=0 = suspending
  996. *
  997. * This is meant to be used by low level drivers to
  998. * signal suspend/resume to the core & clients.
  999. * It must be called with the console semaphore held
  1000. */
  1001. void fb_set_suspend(struct fb_info *info, int state)
  1002. {
  1003. struct fb_event event;
  1004. event.info = info;
  1005. if (state) {
  1006. notifier_call_chain(&fb_notifier_list, FB_EVENT_SUSPEND, &event);
  1007. info->state = FBINFO_STATE_SUSPENDED;
  1008. } else {
  1009. info->state = FBINFO_STATE_RUNNING;
  1010. notifier_call_chain(&fb_notifier_list, FB_EVENT_RESUME, &event);
  1011. }
  1012. }
  1013. /**
  1014. * fbmem_init - init frame buffer subsystem
  1015. *
  1016. * Initialize the frame buffer subsystem.
  1017. *
  1018. * NOTE: This function is _only_ to be called by drivers/char/mem.c.
  1019. *
  1020. */
  1021. static int __init
  1022. fbmem_init(void)
  1023. {
  1024. create_proc_read_entry("fb", 0, NULL, fbmem_read_proc, NULL);
  1025. devfs_mk_dir("fb");
  1026. if (register_chrdev(FB_MAJOR,"fb",&fb_fops))
  1027. printk("unable to get major %d for fb devs\n", FB_MAJOR);
  1028. fb_class = class_create(THIS_MODULE, "graphics");
  1029. if (IS_ERR(fb_class)) {
  1030. printk(KERN_WARNING "Unable to create fb class; errno = %ld\n", PTR_ERR(fb_class));
  1031. fb_class = NULL;
  1032. }
  1033. return 0;
  1034. }
  1035. #ifdef MODULE
  1036. module_init(fbmem_init);
  1037. static void __exit
  1038. fbmem_exit(void)
  1039. {
  1040. class_destroy(fb_class);
  1041. unregister_chrdev(FB_MAJOR, "fb");
  1042. }
  1043. module_exit(fbmem_exit);
  1044. MODULE_LICENSE("GPL");
  1045. MODULE_DESCRIPTION("Framebuffer base");
  1046. #else
  1047. subsys_initcall(fbmem_init);
  1048. #endif
  1049. int fb_new_modelist(struct fb_info *info)
  1050. {
  1051. struct fb_event event;
  1052. struct fb_var_screeninfo var = info->var;
  1053. struct list_head *pos, *n;
  1054. struct fb_modelist *modelist;
  1055. struct fb_videomode *m, mode;
  1056. int err = 1;
  1057. list_for_each_safe(pos, n, &info->modelist) {
  1058. modelist = list_entry(pos, struct fb_modelist, list);
  1059. m = &modelist->mode;
  1060. fb_videomode_to_var(&var, m);
  1061. var.activate = FB_ACTIVATE_TEST;
  1062. err = fb_set_var(info, &var);
  1063. fb_var_to_videomode(&mode, &var);
  1064. if (err || !fb_mode_is_equal(m, &mode)) {
  1065. list_del(pos);
  1066. kfree(pos);
  1067. }
  1068. }
  1069. err = 1;
  1070. if (!list_empty(&info->modelist)) {
  1071. event.info = info;
  1072. err = notifier_call_chain(&fb_notifier_list,
  1073. FB_EVENT_NEW_MODELIST,
  1074. &event);
  1075. }
  1076. return err;
  1077. }
  1078. static char *video_options[FB_MAX];
  1079. static int ofonly;
  1080. extern const char *global_mode_option;
  1081. /**
  1082. * fb_get_options - get kernel boot parameters
  1083. * @name: framebuffer name as it would appear in
  1084. * the boot parameter line
  1085. * (video=<name>:<options>)
  1086. * @option: the option will be stored here
  1087. *
  1088. * NOTE: Needed to maintain backwards compatibility
  1089. */
  1090. int fb_get_options(char *name, char **option)
  1091. {
  1092. char *opt, *options = NULL;
  1093. int opt_len, retval = 0;
  1094. int name_len = strlen(name), i;
  1095. if (name_len && ofonly && strncmp(name, "offb", 4))
  1096. retval = 1;
  1097. if (name_len && !retval) {
  1098. for (i = 0; i < FB_MAX; i++) {
  1099. if (video_options[i] == NULL)
  1100. continue;
  1101. opt_len = strlen(video_options[i]);
  1102. if (!opt_len)
  1103. continue;
  1104. opt = video_options[i];
  1105. if (!strncmp(name, opt, name_len) &&
  1106. opt[name_len] == ':')
  1107. options = opt + name_len + 1;
  1108. }
  1109. }
  1110. if (options && !strncmp(options, "off", 3))
  1111. retval = 1;
  1112. if (option)
  1113. *option = options;
  1114. return retval;
  1115. }
  1116. /**
  1117. * video_setup - process command line options
  1118. * @options: string of options
  1119. *
  1120. * Process command line options for frame buffer subsystem.
  1121. *
  1122. * NOTE: This function is a __setup and __init function.
  1123. * It only stores the options. Drivers have to call
  1124. * fb_get_options() as necessary.
  1125. *
  1126. * Returns zero.
  1127. *
  1128. */
  1129. static int __init video_setup(char *options)
  1130. {
  1131. int i, global = 0;
  1132. if (!options || !*options)
  1133. global = 1;
  1134. if (!global && !strncmp(options, "ofonly", 6)) {
  1135. ofonly = 1;
  1136. global = 1;
  1137. }
  1138. if (!global && !strstr(options, "fb:")) {
  1139. global_mode_option = options;
  1140. global = 1;
  1141. }
  1142. if (!global) {
  1143. for (i = 0; i < FB_MAX; i++) {
  1144. if (video_options[i] == NULL) {
  1145. video_options[i] = options;
  1146. break;
  1147. }
  1148. }
  1149. }
  1150. return 0;
  1151. }
  1152. __setup("video=", video_setup);
  1153. /*
  1154. * Visible symbols for modules
  1155. */
  1156. EXPORT_SYMBOL(register_framebuffer);
  1157. EXPORT_SYMBOL(unregister_framebuffer);
  1158. EXPORT_SYMBOL(num_registered_fb);
  1159. EXPORT_SYMBOL(registered_fb);
  1160. EXPORT_SYMBOL(fb_prepare_logo);
  1161. EXPORT_SYMBOL(fb_show_logo);
  1162. EXPORT_SYMBOL(fb_set_var);
  1163. EXPORT_SYMBOL(fb_blank);
  1164. EXPORT_SYMBOL(fb_pan_display);
  1165. EXPORT_SYMBOL(fb_get_buffer_offset);
  1166. EXPORT_SYMBOL(fb_set_suspend);
  1167. EXPORT_SYMBOL(fb_register_client);
  1168. EXPORT_SYMBOL(fb_unregister_client);
  1169. EXPORT_SYMBOL(fb_get_options);
  1170. EXPORT_SYMBOL(fb_new_modelist);
  1171. MODULE_LICENSE("GPL");