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