fb.h 28 KB

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