fb.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  1. #ifndef _LINUX_FB_H
  2. #define _LINUX_FB_H
  3. #include <linux/kgdb.h>
  4. #include <uapi/linux/fb.h>
  5. #define FBIO_CURSOR _IOWR('F', 0x08, struct fb_cursor_user)
  6. #include <linux/fs.h>
  7. #include <linux/init.h>
  8. #include <linux/workqueue.h>
  9. #include <linux/notifier.h>
  10. #include <linux/list.h>
  11. #include <linux/backlight.h>
  12. #include <linux/slab.h>
  13. #include <asm/io.h>
  14. struct vm_area_struct;
  15. struct fb_info;
  16. struct device;
  17. struct file;
  18. struct videomode;
  19. struct device_node;
  20. /* Definitions below are used in the parsed monitor specs */
  21. #define FB_DPMS_ACTIVE_OFF 1
  22. #define FB_DPMS_SUSPEND 2
  23. #define FB_DPMS_STANDBY 4
  24. #define FB_DISP_DDI 1
  25. #define FB_DISP_ANA_700_300 2
  26. #define FB_DISP_ANA_714_286 4
  27. #define FB_DISP_ANA_1000_400 8
  28. #define FB_DISP_ANA_700_000 16
  29. #define FB_DISP_MONO 32
  30. #define FB_DISP_RGB 64
  31. #define FB_DISP_MULTI 128
  32. #define FB_DISP_UNKNOWN 256
  33. #define FB_SIGNAL_NONE 0
  34. #define FB_SIGNAL_BLANK_BLANK 1
  35. #define FB_SIGNAL_SEPARATE 2
  36. #define FB_SIGNAL_COMPOSITE 4
  37. #define FB_SIGNAL_SYNC_ON_GREEN 8
  38. #define FB_SIGNAL_SERRATION_ON 16
  39. #define FB_MISC_PRIM_COLOR 1
  40. #define FB_MISC_1ST_DETAIL 2 /* First Detailed Timing is preferred */
  41. struct fb_chroma {
  42. __u32 redx; /* in fraction of 1024 */
  43. __u32 greenx;
  44. __u32 bluex;
  45. __u32 whitex;
  46. __u32 redy;
  47. __u32 greeny;
  48. __u32 bluey;
  49. __u32 whitey;
  50. };
  51. struct fb_monspecs {
  52. struct fb_chroma chroma;
  53. struct fb_videomode *modedb; /* mode database */
  54. __u8 manufacturer[4]; /* Manufacturer */
  55. __u8 monitor[14]; /* Monitor String */
  56. __u8 serial_no[14]; /* Serial Number */
  57. __u8 ascii[14]; /* ? */
  58. __u32 modedb_len; /* mode database length */
  59. __u32 model; /* Monitor Model */
  60. __u32 serial; /* Serial Number - Integer */
  61. __u32 year; /* Year manufactured */
  62. __u32 week; /* Week Manufactured */
  63. __u32 hfmin; /* hfreq lower limit (Hz) */
  64. __u32 hfmax; /* hfreq upper limit (Hz) */
  65. __u32 dclkmin; /* pixelclock lower limit (Hz) */
  66. __u32 dclkmax; /* pixelclock upper limit (Hz) */
  67. __u16 input; /* display type - see FB_DISP_* */
  68. __u16 dpms; /* DPMS support - see FB_DPMS_ */
  69. __u16 signal; /* Signal Type - see FB_SIGNAL_* */
  70. __u16 vfmin; /* vfreq lower limit (Hz) */
  71. __u16 vfmax; /* vfreq upper limit (Hz) */
  72. __u16 gamma; /* Gamma - in fractions of 100 */
  73. __u16 gtf : 1; /* supports GTF */
  74. __u16 misc; /* Misc flags - see FB_MISC_* */
  75. __u8 version; /* EDID version... */
  76. __u8 revision; /* ...and revision */
  77. __u8 max_x; /* Maximum horizontal size (cm) */
  78. __u8 max_y; /* Maximum vertical size (cm) */
  79. };
  80. struct fb_cmap_user {
  81. __u32 start; /* First entry */
  82. __u32 len; /* Number of entries */
  83. __u16 __user *red; /* Red values */
  84. __u16 __user *green;
  85. __u16 __user *blue;
  86. __u16 __user *transp; /* transparency, can be NULL */
  87. };
  88. struct fb_image_user {
  89. __u32 dx; /* Where to place image */
  90. __u32 dy;
  91. __u32 width; /* Size of image */
  92. __u32 height;
  93. __u32 fg_color; /* Only used when a mono bitmap */
  94. __u32 bg_color;
  95. __u8 depth; /* Depth of the image */
  96. const char __user *data; /* Pointer to image data */
  97. struct fb_cmap_user cmap; /* color map info */
  98. };
  99. struct fb_cursor_user {
  100. __u16 set; /* what to set */
  101. __u16 enable; /* cursor on/off */
  102. __u16 rop; /* bitop operation */
  103. const char __user *mask; /* cursor mask bits */
  104. struct fbcurpos hot; /* cursor hot spot */
  105. struct fb_image_user image; /* Cursor image */
  106. };
  107. /*
  108. * Register/unregister for framebuffer events
  109. */
  110. /* The resolution of the passed in fb_info about to change */
  111. #define FB_EVENT_MODE_CHANGE 0x01
  112. /* The display on this fb_info is beeing suspended, no access to the
  113. * framebuffer is allowed any more after that call returns
  114. */
  115. #define FB_EVENT_SUSPEND 0x02
  116. /* The display on this fb_info was resumed, you can restore the display
  117. * if you own it
  118. */
  119. #define FB_EVENT_RESUME 0x03
  120. /* An entry from the modelist was removed */
  121. #define FB_EVENT_MODE_DELETE 0x04
  122. /* A driver registered itself */
  123. #define FB_EVENT_FB_REGISTERED 0x05
  124. /* A driver unregistered itself */
  125. #define FB_EVENT_FB_UNREGISTERED 0x06
  126. /* CONSOLE-SPECIFIC: get console to framebuffer mapping */
  127. #define FB_EVENT_GET_CONSOLE_MAP 0x07
  128. /* CONSOLE-SPECIFIC: set console to framebuffer mapping */
  129. #define FB_EVENT_SET_CONSOLE_MAP 0x08
  130. /* A hardware display blank change occurred */
  131. #define FB_EVENT_BLANK 0x09
  132. /* Private modelist is to be replaced */
  133. #define FB_EVENT_NEW_MODELIST 0x0A
  134. /* The resolution of the passed in fb_info about to change and
  135. all vc's should be changed */
  136. #define FB_EVENT_MODE_CHANGE_ALL 0x0B
  137. /* A software display blank change occurred */
  138. #define FB_EVENT_CONBLANK 0x0C
  139. /* Get drawing requirements */
  140. #define FB_EVENT_GET_REQ 0x0D
  141. /* Unbind from the console if possible */
  142. #define FB_EVENT_FB_UNBIND 0x0E
  143. /* CONSOLE-SPECIFIC: remap all consoles to new fb - for vga switcheroo */
  144. #define FB_EVENT_REMAP_ALL_CONSOLE 0x0F
  145. /* A hardware display blank early change occured */
  146. #define FB_EARLY_EVENT_BLANK 0x10
  147. /* A hardware display blank revert early change occured */
  148. #define FB_R_EARLY_EVENT_BLANK 0x11
  149. struct fb_event {
  150. struct fb_info *info;
  151. void *data;
  152. };
  153. struct fb_blit_caps {
  154. u32 x;
  155. u32 y;
  156. u32 len;
  157. u32 flags;
  158. };
  159. extern int fb_register_client(struct notifier_block *nb);
  160. extern int fb_unregister_client(struct notifier_block *nb);
  161. extern int fb_notifier_call_chain(unsigned long val, void *v);
  162. /*
  163. * Pixmap structure definition
  164. *
  165. * The purpose of this structure is to translate data
  166. * from the hardware independent format of fbdev to what
  167. * format the hardware needs.
  168. */
  169. #define FB_PIXMAP_DEFAULT 1 /* used internally by fbcon */
  170. #define FB_PIXMAP_SYSTEM 2 /* memory is in system RAM */
  171. #define FB_PIXMAP_IO 4 /* memory is iomapped */
  172. #define FB_PIXMAP_SYNC 256 /* set if GPU can DMA */
  173. struct fb_pixmap {
  174. u8 *addr; /* pointer to memory */
  175. u32 size; /* size of buffer in bytes */
  176. u32 offset; /* current offset to buffer */
  177. u32 buf_align; /* byte alignment of each bitmap */
  178. u32 scan_align; /* alignment per scanline */
  179. u32 access_align; /* alignment per read/write (bits) */
  180. u32 flags; /* see FB_PIXMAP_* */
  181. u32 blit_x; /* supported bit block dimensions (1-32)*/
  182. u32 blit_y; /* Format: blit_x = 1 << (width - 1) */
  183. /* blit_y = 1 << (height - 1) */
  184. /* if 0, will be set to 0xffffffff (all)*/
  185. /* access methods */
  186. void (*writeio)(struct fb_info *info, void __iomem *dst, void *src, unsigned int size);
  187. void (*readio) (struct fb_info *info, void *dst, void __iomem *src, unsigned int size);
  188. };
  189. #ifdef CONFIG_FB_DEFERRED_IO
  190. struct fb_deferred_io {
  191. /* delay between mkwrite and deferred handler */
  192. unsigned long delay;
  193. struct mutex lock; /* mutex that protects the page list */
  194. struct list_head pagelist; /* list of touched pages */
  195. /* callback */
  196. void (*first_io)(struct fb_info *info);
  197. void (*deferred_io)(struct fb_info *info, struct list_head *pagelist);
  198. };
  199. #endif
  200. /*
  201. * Frame buffer operations
  202. *
  203. * LOCKING NOTE: those functions must _ALL_ be called with the console
  204. * semaphore held, this is the only suitable locking mechanism we have
  205. * in 2.6. Some may be called at interrupt time at this point though.
  206. *
  207. * The exception to this is the debug related hooks. Putting the fb
  208. * into a debug state (e.g. flipping to the kernel console) and restoring
  209. * it must be done in a lock-free manner, so low level drivers should
  210. * keep track of the initial console (if applicable) and may need to
  211. * perform direct, unlocked hardware writes in these hooks.
  212. */
  213. struct fb_ops {
  214. /* open/release and usage marking */
  215. struct module *owner;
  216. int (*fb_open)(struct fb_info *info, int user);
  217. int (*fb_release)(struct fb_info *info, int user);
  218. /* For framebuffers with strange non linear layouts or that do not
  219. * work with normal memory mapped access
  220. */
  221. ssize_t (*fb_read)(struct fb_info *info, char __user *buf,
  222. size_t count, loff_t *ppos);
  223. ssize_t (*fb_write)(struct fb_info *info, const char __user *buf,
  224. size_t count, loff_t *ppos);
  225. /* checks var and eventually tweaks it to something supported,
  226. * DO NOT MODIFY PAR */
  227. int (*fb_check_var)(struct fb_var_screeninfo *var, struct fb_info *info);
  228. /* set the video mode according to info->var */
  229. int (*fb_set_par)(struct fb_info *info);
  230. /* set color register */
  231. int (*fb_setcolreg)(unsigned regno, unsigned red, unsigned green,
  232. unsigned blue, unsigned transp, struct fb_info *info);
  233. /* set color registers in batch */
  234. int (*fb_setcmap)(struct fb_cmap *cmap, struct fb_info *info);
  235. /* blank display */
  236. int (*fb_blank)(int blank, struct fb_info *info);
  237. /* pan display */
  238. int (*fb_pan_display)(struct fb_var_screeninfo *var, struct fb_info *info);
  239. /* Draws a rectangle */
  240. void (*fb_fillrect) (struct fb_info *info, const struct fb_fillrect *rect);
  241. /* Copy data from area to another */
  242. void (*fb_copyarea) (struct fb_info *info, const struct fb_copyarea *region);
  243. /* Draws a image to the display */
  244. void (*fb_imageblit) (struct fb_info *info, const struct fb_image *image);
  245. /* Draws cursor */
  246. int (*fb_cursor) (struct fb_info *info, struct fb_cursor *cursor);
  247. /* Rotates the display */
  248. void (*fb_rotate)(struct fb_info *info, int angle);
  249. /* wait for blit idle, optional */
  250. int (*fb_sync)(struct fb_info *info);
  251. /* perform fb specific ioctl (optional) */
  252. int (*fb_ioctl)(struct fb_info *info, unsigned int cmd,
  253. unsigned long arg);
  254. /* Handle 32bit compat ioctl (optional) */
  255. int (*fb_compat_ioctl)(struct fb_info *info, unsigned cmd,
  256. unsigned long arg);
  257. /* perform fb specific mmap */
  258. int (*fb_mmap)(struct fb_info *info, struct vm_area_struct *vma);
  259. /* get capability given var */
  260. void (*fb_get_caps)(struct fb_info *info, struct fb_blit_caps *caps,
  261. struct fb_var_screeninfo *var);
  262. /* teardown any resources to do with this framebuffer */
  263. void (*fb_destroy)(struct fb_info *info);
  264. /* called at KDB enter and leave time to prepare the console */
  265. int (*fb_debug_enter)(struct fb_info *info);
  266. int (*fb_debug_leave)(struct fb_info *info);
  267. };
  268. #ifdef CONFIG_FB_TILEBLITTING
  269. #define FB_TILE_CURSOR_NONE 0
  270. #define FB_TILE_CURSOR_UNDERLINE 1
  271. #define FB_TILE_CURSOR_LOWER_THIRD 2
  272. #define FB_TILE_CURSOR_LOWER_HALF 3
  273. #define FB_TILE_CURSOR_TWO_THIRDS 4
  274. #define FB_TILE_CURSOR_BLOCK 5
  275. struct fb_tilemap {
  276. __u32 width; /* width of each tile in pixels */
  277. __u32 height; /* height of each tile in scanlines */
  278. __u32 depth; /* color depth of each tile */
  279. __u32 length; /* number of tiles in the map */
  280. const __u8 *data; /* actual tile map: a bitmap array, packed
  281. to the nearest byte */
  282. };
  283. struct fb_tilerect {
  284. __u32 sx; /* origin in the x-axis */
  285. __u32 sy; /* origin in the y-axis */
  286. __u32 width; /* number of tiles in the x-axis */
  287. __u32 height; /* number of tiles in the y-axis */
  288. __u32 index; /* what tile to use: index to tile map */
  289. __u32 fg; /* foreground color */
  290. __u32 bg; /* background color */
  291. __u32 rop; /* raster operation */
  292. };
  293. struct fb_tilearea {
  294. __u32 sx; /* source origin in the x-axis */
  295. __u32 sy; /* source origin in the y-axis */
  296. __u32 dx; /* destination origin in the x-axis */
  297. __u32 dy; /* destination origin in the y-axis */
  298. __u32 width; /* number of tiles in the x-axis */
  299. __u32 height; /* number of tiles in the y-axis */
  300. };
  301. struct fb_tileblit {
  302. __u32 sx; /* origin in the x-axis */
  303. __u32 sy; /* origin in the y-axis */
  304. __u32 width; /* number of tiles in the x-axis */
  305. __u32 height; /* number of tiles in the y-axis */
  306. __u32 fg; /* foreground color */
  307. __u32 bg; /* background color */
  308. __u32 length; /* number of tiles to draw */
  309. __u32 *indices; /* array of indices to tile map */
  310. };
  311. struct fb_tilecursor {
  312. __u32 sx; /* cursor position in the x-axis */
  313. __u32 sy; /* cursor position in the y-axis */
  314. __u32 mode; /* 0 = erase, 1 = draw */
  315. __u32 shape; /* see FB_TILE_CURSOR_* */
  316. __u32 fg; /* foreground color */
  317. __u32 bg; /* background color */
  318. };
  319. struct fb_tile_ops {
  320. /* set tile characteristics */
  321. void (*fb_settile)(struct fb_info *info, struct fb_tilemap *map);
  322. /* all dimensions from hereon are in terms of tiles */
  323. /* move a rectangular region of tiles from one area to another*/
  324. void (*fb_tilecopy)(struct fb_info *info, struct fb_tilearea *area);
  325. /* fill a rectangular region with a tile */
  326. void (*fb_tilefill)(struct fb_info *info, struct fb_tilerect *rect);
  327. /* copy an array of tiles */
  328. void (*fb_tileblit)(struct fb_info *info, struct fb_tileblit *blit);
  329. /* cursor */
  330. void (*fb_tilecursor)(struct fb_info *info,
  331. struct fb_tilecursor *cursor);
  332. /* get maximum length of the tile map */
  333. int (*fb_get_tilemax)(struct fb_info *info);
  334. };
  335. #endif /* CONFIG_FB_TILEBLITTING */
  336. /* FBINFO_* = fb_info.flags bit flags */
  337. #define FBINFO_MODULE 0x0001 /* Low-level driver is a module */
  338. #define FBINFO_HWACCEL_DISABLED 0x0002
  339. /* When FBINFO_HWACCEL_DISABLED is set:
  340. * Hardware acceleration is turned off. Software implementations
  341. * of required functions (copyarea(), fillrect(), and imageblit())
  342. * takes over; acceleration engine should be in a quiescent state */
  343. /* hints */
  344. #define FBINFO_VIRTFB 0x0004 /* FB is System RAM, not device. */
  345. #define FBINFO_PARTIAL_PAN_OK 0x0040 /* otw use pan only for double-buffering */
  346. #define FBINFO_READS_FAST 0x0080 /* soft-copy faster than rendering */
  347. /* hardware supported ops */
  348. /* semantics: when a bit is set, it indicates that the operation is
  349. * accelerated by hardware.
  350. * required functions will still work even if the bit is not set.
  351. * optional functions may not even exist if the flag bit is not set.
  352. */
  353. #define FBINFO_HWACCEL_NONE 0x0000
  354. #define FBINFO_HWACCEL_COPYAREA 0x0100 /* required */
  355. #define FBINFO_HWACCEL_FILLRECT 0x0200 /* required */
  356. #define FBINFO_HWACCEL_IMAGEBLIT 0x0400 /* required */
  357. #define FBINFO_HWACCEL_ROTATE 0x0800 /* optional */
  358. #define FBINFO_HWACCEL_XPAN 0x1000 /* optional */
  359. #define FBINFO_HWACCEL_YPAN 0x2000 /* optional */
  360. #define FBINFO_HWACCEL_YWRAP 0x4000 /* optional */
  361. #define FBINFO_MISC_USEREVENT 0x10000 /* event request
  362. from userspace */
  363. #define FBINFO_MISC_TILEBLITTING 0x20000 /* use tile blitting */
  364. /* A driver may set this flag to indicate that it does want a set_par to be
  365. * called every time when fbcon_switch is executed. The advantage is that with
  366. * this flag set you can really be sure that set_par is always called before
  367. * any of the functions dependent on the correct hardware state or altering
  368. * that state, even if you are using some broken X releases. The disadvantage
  369. * is that it introduces unwanted delays to every console switch if set_par
  370. * is slow. It is a good idea to try this flag in the drivers initialization
  371. * code whenever there is a bug report related to switching between X and the
  372. * framebuffer console.
  373. */
  374. #define FBINFO_MISC_ALWAYS_SETPAR 0x40000
  375. /* where the fb is a firmware driver, and can be replaced with a proper one */
  376. #define FBINFO_MISC_FIRMWARE 0x80000
  377. /*
  378. * Host and GPU endianness differ.
  379. */
  380. #define FBINFO_FOREIGN_ENDIAN 0x100000
  381. /*
  382. * Big endian math. This is the same flags as above, but with different
  383. * meaning, it is set by the fb subsystem depending FOREIGN_ENDIAN flag
  384. * and host endianness. Drivers should not use this flag.
  385. */
  386. #define FBINFO_BE_MATH 0x100000
  387. /* report to the VT layer that this fb driver can accept forced console
  388. output like oopses */
  389. #define FBINFO_CAN_FORCE_OUTPUT 0x200000
  390. struct fb_info {
  391. atomic_t count;
  392. int node;
  393. int flags;
  394. struct mutex lock; /* Lock for open/release/ioctl funcs */
  395. struct mutex mm_lock; /* Lock for fb_mmap and smem_* fields */
  396. struct fb_var_screeninfo var; /* Current var */
  397. struct fb_fix_screeninfo fix; /* Current fix */
  398. struct fb_monspecs monspecs; /* Current Monitor specs */
  399. struct work_struct queue; /* Framebuffer event queue */
  400. struct fb_pixmap pixmap; /* Image hardware mapper */
  401. struct fb_pixmap sprite; /* Cursor hardware mapper */
  402. struct fb_cmap cmap; /* Current cmap */
  403. struct list_head modelist; /* mode list */
  404. struct fb_videomode *mode; /* current mode */
  405. #ifdef CONFIG_FB_BACKLIGHT
  406. /* assigned backlight device */
  407. /* set before framebuffer registration,
  408. remove after unregister */
  409. struct backlight_device *bl_dev;
  410. /* Backlight level curve */
  411. struct mutex bl_curve_mutex;
  412. u8 bl_curve[FB_BACKLIGHT_LEVELS];
  413. #endif
  414. #ifdef CONFIG_FB_DEFERRED_IO
  415. struct delayed_work deferred_work;
  416. struct fb_deferred_io *fbdefio;
  417. #endif
  418. struct fb_ops *fbops;
  419. struct device *device; /* This is the parent */
  420. struct device *dev; /* This is this fb device */
  421. int class_flag; /* private sysfs flags */
  422. #ifdef CONFIG_FB_TILEBLITTING
  423. struct fb_tile_ops *tileops; /* Tile Blitting */
  424. #endif
  425. char __iomem *screen_base; /* Virtual address */
  426. unsigned long screen_size; /* Amount of ioremapped VRAM or 0 */
  427. void *pseudo_palette; /* Fake palette of 16 colors */
  428. #define FBINFO_STATE_RUNNING 0
  429. #define FBINFO_STATE_SUSPENDED 1
  430. u32 state; /* Hardware state i.e suspend */
  431. void *fbcon_par; /* fbcon use-only private area */
  432. /* From here on everything is device dependent */
  433. void *par;
  434. /* we need the PCI or similar aperture base/size not
  435. smem_start/size as smem_start may just be an object
  436. allocated inside the aperture so may not actually overlap */
  437. struct apertures_struct {
  438. unsigned int count;
  439. struct aperture {
  440. resource_size_t base;
  441. resource_size_t size;
  442. } ranges[0];
  443. } *apertures;
  444. bool skip_vt_switch; /* no VT switch on suspend/resume required */
  445. };
  446. static inline struct apertures_struct *alloc_apertures(unsigned int max_num) {
  447. struct apertures_struct *a = kzalloc(sizeof(struct apertures_struct)
  448. + max_num * sizeof(struct aperture), GFP_KERNEL);
  449. if (!a)
  450. return NULL;
  451. a->count = max_num;
  452. return a;
  453. }
  454. #ifdef MODULE
  455. #define FBINFO_DEFAULT FBINFO_MODULE
  456. #else
  457. #define FBINFO_DEFAULT 0
  458. #endif
  459. // This will go away
  460. #define FBINFO_FLAG_MODULE FBINFO_MODULE
  461. #define FBINFO_FLAG_DEFAULT FBINFO_DEFAULT
  462. /* This will go away
  463. * fbset currently hacks in FB_ACCELF_TEXT into var.accel_flags
  464. * when it wants to turn the acceleration engine on. This is
  465. * really a separate operation, and should be modified via sysfs.
  466. * But for now, we leave it broken with the following define
  467. */
  468. #define STUPID_ACCELF_TEXT_SHIT
  469. // This will go away
  470. #if defined(__sparc__)
  471. /* We map all of our framebuffers such that big-endian accesses
  472. * are what we want, so the following is sufficient.
  473. */
  474. // This will go away
  475. #define fb_readb sbus_readb
  476. #define fb_readw sbus_readw
  477. #define fb_readl sbus_readl
  478. #define fb_readq sbus_readq
  479. #define fb_writeb sbus_writeb
  480. #define fb_writew sbus_writew
  481. #define fb_writel sbus_writel
  482. #define fb_writeq sbus_writeq
  483. #define fb_memset sbus_memset_io
  484. #define fb_memcpy_fromfb sbus_memcpy_fromio
  485. #define fb_memcpy_tofb sbus_memcpy_toio
  486. #elif defined(__i386__) || defined(__alpha__) || defined(__x86_64__) || defined(__hppa__) || defined(__sh__) || defined(__powerpc__) || defined(__avr32__) || defined(__bfin__)
  487. #define fb_readb __raw_readb
  488. #define fb_readw __raw_readw
  489. #define fb_readl __raw_readl
  490. #define fb_readq __raw_readq
  491. #define fb_writeb __raw_writeb
  492. #define fb_writew __raw_writew
  493. #define fb_writel __raw_writel
  494. #define fb_writeq __raw_writeq
  495. #define fb_memset memset_io
  496. #define fb_memcpy_fromfb memcpy_fromio
  497. #define fb_memcpy_tofb memcpy_toio
  498. #else
  499. #define fb_readb(addr) (*(volatile u8 *) (addr))
  500. #define fb_readw(addr) (*(volatile u16 *) (addr))
  501. #define fb_readl(addr) (*(volatile u32 *) (addr))
  502. #define fb_readq(addr) (*(volatile u64 *) (addr))
  503. #define fb_writeb(b,addr) (*(volatile u8 *) (addr) = (b))
  504. #define fb_writew(b,addr) (*(volatile u16 *) (addr) = (b))
  505. #define fb_writel(b,addr) (*(volatile u32 *) (addr) = (b))
  506. #define fb_writeq(b,addr) (*(volatile u64 *) (addr) = (b))
  507. #define fb_memset memset
  508. #define fb_memcpy_fromfb memcpy
  509. #define fb_memcpy_tofb memcpy
  510. #endif
  511. #define FB_LEFT_POS(p, bpp) (fb_be_math(p) ? (32 - (bpp)) : 0)
  512. #define FB_SHIFT_HIGH(p, val, bits) (fb_be_math(p) ? (val) >> (bits) : \
  513. (val) << (bits))
  514. #define FB_SHIFT_LOW(p, val, bits) (fb_be_math(p) ? (val) << (bits) : \
  515. (val) >> (bits))
  516. /*
  517. * `Generic' versions of the frame buffer device operations
  518. */
  519. extern int fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var);
  520. extern int fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var);
  521. extern int fb_blank(struct fb_info *info, int blank);
  522. extern void cfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect);
  523. extern void cfb_copyarea(struct fb_info *info, const struct fb_copyarea *area);
  524. extern void cfb_imageblit(struct fb_info *info, const struct fb_image *image);
  525. /*
  526. * Drawing operations where framebuffer is in system RAM
  527. */
  528. extern void sys_fillrect(struct fb_info *info, const struct fb_fillrect *rect);
  529. extern void sys_copyarea(struct fb_info *info, const struct fb_copyarea *area);
  530. extern void sys_imageblit(struct fb_info *info, const struct fb_image *image);
  531. extern ssize_t fb_sys_read(struct fb_info *info, char __user *buf,
  532. size_t count, loff_t *ppos);
  533. extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
  534. size_t count, loff_t *ppos);
  535. /* drivers/video/fbmem.c */
  536. extern int register_framebuffer(struct fb_info *fb_info);
  537. extern int unregister_framebuffer(struct fb_info *fb_info);
  538. extern int unlink_framebuffer(struct fb_info *fb_info);
  539. extern void remove_conflicting_framebuffers(struct apertures_struct *a,
  540. const char *name, bool primary);
  541. extern int fb_prepare_logo(struct fb_info *fb_info, int rotate);
  542. extern int fb_show_logo(struct fb_info *fb_info, int rotate);
  543. extern char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size);
  544. extern void fb_pad_unaligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 idx,
  545. u32 height, u32 shift_high, u32 shift_low, u32 mod);
  546. extern void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, u32 height);
  547. extern void fb_set_suspend(struct fb_info *info, int state);
  548. extern int fb_get_color_depth(struct fb_var_screeninfo *var,
  549. struct fb_fix_screeninfo *fix);
  550. extern int fb_get_options(const char *name, char **option);
  551. extern int fb_new_modelist(struct fb_info *info);
  552. extern struct fb_info *registered_fb[FB_MAX];
  553. extern int num_registered_fb;
  554. extern struct class *fb_class;
  555. extern int lock_fb_info(struct fb_info *info);
  556. static inline void unlock_fb_info(struct fb_info *info)
  557. {
  558. mutex_unlock(&info->lock);
  559. }
  560. static inline void __fb_pad_aligned_buffer(u8 *dst, u32 d_pitch,
  561. u8 *src, u32 s_pitch, u32 height)
  562. {
  563. int i, j;
  564. d_pitch -= s_pitch;
  565. for (i = height; i--; ) {
  566. /* s_pitch is a few bytes at the most, memcpy is suboptimal */
  567. for (j = 0; j < s_pitch; j++)
  568. *dst++ = *src++;
  569. dst += d_pitch;
  570. }
  571. }
  572. /* drivers/video/fb_defio.c */
  573. extern void fb_deferred_io_init(struct fb_info *info);
  574. extern void fb_deferred_io_open(struct fb_info *info,
  575. struct inode *inode,
  576. struct file *file);
  577. extern void fb_deferred_io_cleanup(struct fb_info *info);
  578. extern int fb_deferred_io_fsync(struct file *file, loff_t start,
  579. loff_t end, int datasync);
  580. static inline bool fb_be_math(struct fb_info *info)
  581. {
  582. #ifdef CONFIG_FB_FOREIGN_ENDIAN
  583. #if defined(CONFIG_FB_BOTH_ENDIAN)
  584. return info->flags & FBINFO_BE_MATH;
  585. #elif defined(CONFIG_FB_BIG_ENDIAN)
  586. return true;
  587. #elif defined(CONFIG_FB_LITTLE_ENDIAN)
  588. return false;
  589. #endif /* CONFIG_FB_BOTH_ENDIAN */
  590. #else
  591. #ifdef __BIG_ENDIAN
  592. return true;
  593. #else
  594. return false;
  595. #endif /* __BIG_ENDIAN */
  596. #endif /* CONFIG_FB_FOREIGN_ENDIAN */
  597. }
  598. /* drivers/video/fbsysfs.c */
  599. extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev);
  600. extern void framebuffer_release(struct fb_info *info);
  601. extern int fb_init_device(struct fb_info *fb_info);
  602. extern void fb_cleanup_device(struct fb_info *head);
  603. extern void fb_bl_default_curve(struct fb_info *fb_info, u8 off, u8 min, u8 max);
  604. /* drivers/video/fbmon.c */
  605. #define FB_MAXTIMINGS 0
  606. #define FB_VSYNCTIMINGS 1
  607. #define FB_HSYNCTIMINGS 2
  608. #define FB_DCLKTIMINGS 3
  609. #define FB_IGNOREMON 0x100
  610. #define FB_MODE_IS_UNKNOWN 0
  611. #define FB_MODE_IS_DETAILED 1
  612. #define FB_MODE_IS_STANDARD 2
  613. #define FB_MODE_IS_VESA 4
  614. #define FB_MODE_IS_CALCULATED 8
  615. #define FB_MODE_IS_FIRST 16
  616. #define FB_MODE_IS_FROM_VAR 32
  617. extern int fbmon_dpms(const struct fb_info *fb_info);
  618. extern int fb_get_mode(int flags, u32 val, struct fb_var_screeninfo *var,
  619. struct fb_info *info);
  620. extern int fb_validate_mode(const struct fb_var_screeninfo *var,
  621. struct fb_info *info);
  622. extern int fb_parse_edid(unsigned char *edid, struct fb_var_screeninfo *var);
  623. extern const unsigned char *fb_firmware_edid(struct device *device);
  624. extern void fb_edid_to_monspecs(unsigned char *edid,
  625. struct fb_monspecs *specs);
  626. extern void fb_edid_add_monspecs(unsigned char *edid,
  627. struct fb_monspecs *specs);
  628. extern void fb_destroy_modedb(struct fb_videomode *modedb);
  629. extern int fb_find_mode_cvt(struct fb_videomode *mode, int margins, int rb);
  630. extern unsigned char *fb_ddc_read(struct i2c_adapter *adapter);
  631. extern int of_get_fb_videomode(struct device_node *np,
  632. struct fb_videomode *fb,
  633. int index);
  634. extern int fb_videomode_from_videomode(const struct videomode *vm,
  635. struct fb_videomode *fbmode);
  636. /* drivers/video/modedb.c */
  637. #define VESA_MODEDB_SIZE 34
  638. extern void fb_var_to_videomode(struct fb_videomode *mode,
  639. const struct fb_var_screeninfo *var);
  640. extern void fb_videomode_to_var(struct fb_var_screeninfo *var,
  641. const struct fb_videomode *mode);
  642. extern int fb_mode_is_equal(const struct fb_videomode *mode1,
  643. const struct fb_videomode *mode2);
  644. extern int fb_add_videomode(const struct fb_videomode *mode,
  645. struct list_head *head);
  646. extern void fb_delete_videomode(const struct fb_videomode *mode,
  647. struct list_head *head);
  648. extern const struct fb_videomode *fb_match_mode(const struct fb_var_screeninfo *var,
  649. struct list_head *head);
  650. extern const struct fb_videomode *fb_find_best_mode(const struct fb_var_screeninfo *var,
  651. struct list_head *head);
  652. extern const struct fb_videomode *fb_find_nearest_mode(const struct fb_videomode *mode,
  653. struct list_head *head);
  654. extern void fb_destroy_modelist(struct list_head *head);
  655. extern void fb_videomode_to_modelist(const struct fb_videomode *modedb, int num,
  656. struct list_head *head);
  657. extern const struct fb_videomode *fb_find_best_display(const struct fb_monspecs *specs,
  658. struct list_head *head);
  659. /* drivers/video/fbcmap.c */
  660. extern int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp);
  661. extern int fb_alloc_cmap_gfp(struct fb_cmap *cmap, int len, int transp, gfp_t flags);
  662. extern void fb_dealloc_cmap(struct fb_cmap *cmap);
  663. extern int fb_copy_cmap(const struct fb_cmap *from, struct fb_cmap *to);
  664. extern int fb_cmap_to_user(const struct fb_cmap *from, struct fb_cmap_user *to);
  665. extern int fb_set_cmap(struct fb_cmap *cmap, struct fb_info *fb_info);
  666. extern int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *fb_info);
  667. extern const struct fb_cmap *fb_default_cmap(int len);
  668. extern void fb_invert_cmaps(void);
  669. struct fb_videomode {
  670. const char *name; /* optional */
  671. u32 refresh; /* optional */
  672. u32 xres;
  673. u32 yres;
  674. u32 pixclock;
  675. u32 left_margin;
  676. u32 right_margin;
  677. u32 upper_margin;
  678. u32 lower_margin;
  679. u32 hsync_len;
  680. u32 vsync_len;
  681. u32 sync;
  682. u32 vmode;
  683. u32 flag;
  684. };
  685. extern const char *fb_mode_option;
  686. extern const struct fb_videomode vesa_modes[];
  687. extern const struct fb_videomode cea_modes[64];
  688. struct fb_modelist {
  689. struct list_head list;
  690. struct fb_videomode mode;
  691. };
  692. extern int fb_find_mode(struct fb_var_screeninfo *var,
  693. struct fb_info *info, const char *mode_option,
  694. const struct fb_videomode *db,
  695. unsigned int dbsize,
  696. const struct fb_videomode *default_mode,
  697. unsigned int default_bpp);
  698. #endif /* _LINUX_FB_H */