fbmem.c 32 KB

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