fb.h 29 KB

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