fb.h 29 KB

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