1 | /* SPDX-License-Identifier: GPL-2.0 */ |
---|---|
2 | #ifndef _LINUX_FB_H |
3 | #define _LINUX_FB_H |
4 | |
5 | #include <uapi/linux/fb.h> |
6 | |
7 | #define FBIO_CURSOR _IOWR('F', 0x08, struct fb_cursor_user) |
8 | |
9 | #include <linux/mutex.h> |
10 | #include <linux/printk.h> |
11 | #include <linux/refcount.h> |
12 | #include <linux/types.h> |
13 | #include <linux/workqueue.h> |
14 | |
15 | #include <asm/video.h> |
16 | |
17 | struct backlight_device; |
18 | struct device; |
19 | struct device_node; |
20 | struct fb_info; |
21 | struct file; |
22 | struct i2c_adapter; |
23 | struct inode; |
24 | struct lcd_device; |
25 | struct module; |
26 | struct notifier_block; |
27 | struct page; |
28 | struct videomode; |
29 | struct vm_area_struct; |
30 | |
31 | /* Definitions below are used in the parsed monitor specs */ |
32 | #define FB_DPMS_ACTIVE_OFF 1 |
33 | #define FB_DPMS_SUSPEND 2 |
34 | #define FB_DPMS_STANDBY 4 |
35 | |
36 | #define FB_DISP_DDI 1 |
37 | #define FB_DISP_ANA_700_300 2 |
38 | #define FB_DISP_ANA_714_286 4 |
39 | #define FB_DISP_ANA_1000_400 8 |
40 | #define FB_DISP_ANA_700_000 16 |
41 | |
42 | #define FB_DISP_MONO 32 |
43 | #define FB_DISP_RGB 64 |
44 | #define FB_DISP_MULTI 128 |
45 | #define FB_DISP_UNKNOWN 256 |
46 | |
47 | #define FB_SIGNAL_NONE 0 |
48 | #define FB_SIGNAL_BLANK_BLANK 1 |
49 | #define FB_SIGNAL_SEPARATE 2 |
50 | #define FB_SIGNAL_COMPOSITE 4 |
51 | #define FB_SIGNAL_SYNC_ON_GREEN 8 |
52 | #define FB_SIGNAL_SERRATION_ON 16 |
53 | |
54 | #define FB_MISC_PRIM_COLOR 1 |
55 | #define FB_MISC_1ST_DETAIL 2 /* First Detailed Timing is preferred */ |
56 | #define FB_MISC_HDMI 4 |
57 | struct fb_chroma { |
58 | __u32 redx; /* in fraction of 1024 */ |
59 | __u32 greenx; |
60 | __u32 bluex; |
61 | __u32 whitex; |
62 | __u32 redy; |
63 | __u32 greeny; |
64 | __u32 bluey; |
65 | __u32 whitey; |
66 | }; |
67 | |
68 | struct fb_monspecs { |
69 | struct fb_chroma chroma; |
70 | struct fb_videomode *modedb; /* mode database */ |
71 | __u8 manufacturer[4]; /* Manufacturer */ |
72 | __u8 monitor[14]; /* Monitor String */ |
73 | __u8 serial_no[14]; /* Serial Number */ |
74 | __u8 ascii[14]; /* ? */ |
75 | __u32 modedb_len; /* mode database length */ |
76 | __u32 model; /* Monitor Model */ |
77 | __u32 serial; /* Serial Number - Integer */ |
78 | __u32 year; /* Year manufactured */ |
79 | __u32 week; /* Week Manufactured */ |
80 | __u32 hfmin; /* hfreq lower limit (Hz) */ |
81 | __u32 hfmax; /* hfreq upper limit (Hz) */ |
82 | __u32 dclkmin; /* pixelclock lower limit (Hz) */ |
83 | __u32 dclkmax; /* pixelclock upper limit (Hz) */ |
84 | __u16 input; /* display type - see FB_DISP_* */ |
85 | __u16 dpms; /* DPMS support - see FB_DPMS_ */ |
86 | __u16 signal; /* Signal Type - see FB_SIGNAL_* */ |
87 | __u16 vfmin; /* vfreq lower limit (Hz) */ |
88 | __u16 vfmax; /* vfreq upper limit (Hz) */ |
89 | __u16 gamma; /* Gamma - in fractions of 100 */ |
90 | __u16 gtf : 1; /* supports GTF */ |
91 | __u16 misc; /* Misc flags - see FB_MISC_* */ |
92 | __u8 version; /* EDID version... */ |
93 | __u8 revision; /* ...and revision */ |
94 | __u8 max_x; /* Maximum horizontal size (cm) */ |
95 | __u8 max_y; /* Maximum vertical size (cm) */ |
96 | }; |
97 | |
98 | struct fb_cmap_user { |
99 | __u32 start; /* First entry */ |
100 | __u32 len; /* Number of entries */ |
101 | __u16 __user *red; /* Red values */ |
102 | __u16 __user *green; |
103 | __u16 __user *blue; |
104 | __u16 __user *transp; /* transparency, can be NULL */ |
105 | }; |
106 | |
107 | struct fb_image_user { |
108 | __u32 dx; /* Where to place image */ |
109 | __u32 dy; |
110 | __u32 width; /* Size of image */ |
111 | __u32 height; |
112 | __u32 fg_color; /* Only used when a mono bitmap */ |
113 | __u32 bg_color; |
114 | __u8 depth; /* Depth of the image */ |
115 | const char __user *data; /* Pointer to image data */ |
116 | struct fb_cmap_user cmap; /* color map info */ |
117 | }; |
118 | |
119 | struct fb_cursor_user { |
120 | __u16 set; /* what to set */ |
121 | __u16 enable; /* cursor on/off */ |
122 | __u16 rop; /* bitop operation */ |
123 | const char __user *mask; /* cursor mask bits */ |
124 | struct fbcurpos hot; /* cursor hot spot */ |
125 | struct fb_image_user image; /* Cursor image */ |
126 | }; |
127 | |
128 | /* |
129 | * Register/unregister for framebuffer events |
130 | */ |
131 | |
132 | #ifdef CONFIG_GUMSTIX_AM200EPD |
133 | /* only used by mach-pxa/am200epd.c */ |
134 | #define FB_EVENT_FB_REGISTERED 0x05 |
135 | #define FB_EVENT_FB_UNREGISTERED 0x06 |
136 | #endif |
137 | |
138 | struct fb_event { |
139 | struct fb_info *info; |
140 | void *data; |
141 | }; |
142 | |
143 | /* Enough for the VT console needs, see its max_font_width/height */ |
144 | #define FB_MAX_BLIT_WIDTH 64 |
145 | #define FB_MAX_BLIT_HEIGHT 128 |
146 | |
147 | struct fb_blit_caps { |
148 | DECLARE_BITMAP(x, FB_MAX_BLIT_WIDTH); |
149 | DECLARE_BITMAP(y, FB_MAX_BLIT_HEIGHT); |
150 | u32 len; |
151 | u32 flags; |
152 | }; |
153 | |
154 | #ifdef CONFIG_FB_NOTIFY |
155 | extern int fb_register_client(struct notifier_block *nb); |
156 | extern int fb_unregister_client(struct notifier_block *nb); |
157 | extern int fb_notifier_call_chain(unsigned long val, void *v); |
158 | #else |
159 | static inline int fb_register_client(struct notifier_block *nb) |
160 | { |
161 | return 0; |
162 | }; |
163 | |
164 | static inline int fb_unregister_client(struct notifier_block *nb) |
165 | { |
166 | return 0; |
167 | }; |
168 | |
169 | static inline int fb_notifier_call_chain(unsigned long val, void *v) |
170 | { |
171 | return 0; |
172 | }; |
173 | #endif |
174 | |
175 | /* |
176 | * Pixmap structure definition |
177 | * |
178 | * The purpose of this structure is to translate data |
179 | * from the hardware independent format of fbdev to what |
180 | * format the hardware needs. |
181 | */ |
182 | |
183 | #define FB_PIXMAP_DEFAULT 1 /* used internally by fbcon */ |
184 | #define FB_PIXMAP_SYSTEM 2 /* memory is in system RAM */ |
185 | #define FB_PIXMAP_IO 4 /* memory is iomapped */ |
186 | #define FB_PIXMAP_SYNC 256 /* set if GPU can DMA */ |
187 | |
188 | struct fb_pixmap { |
189 | u8 *addr; /* pointer to memory */ |
190 | u32 size; /* size of buffer in bytes */ |
191 | u32 offset; /* current offset to buffer */ |
192 | u32 buf_align; /* byte alignment of each bitmap */ |
193 | u32 scan_align; /* alignment per scanline */ |
194 | u32 access_align; /* alignment per read/write (bits) */ |
195 | u32 flags; /* see FB_PIXMAP_* */ |
196 | /* supported bit block dimensions */ |
197 | /* Format: test_bit(width - 1, blit_x) */ |
198 | /* test_bit(height - 1, blit_y) */ |
199 | /* if zero, will be set to full (all) */ |
200 | DECLARE_BITMAP(blit_x, FB_MAX_BLIT_WIDTH); |
201 | DECLARE_BITMAP(blit_y, FB_MAX_BLIT_HEIGHT); |
202 | /* access methods */ |
203 | void (*writeio)(struct fb_info *info, void __iomem *dst, void *src, unsigned int size); |
204 | void (*readio) (struct fb_info *info, void *dst, void __iomem *src, unsigned int size); |
205 | }; |
206 | |
207 | #ifdef CONFIG_FB_DEFERRED_IO |
208 | struct fb_deferred_io_pageref { |
209 | struct page *page; |
210 | unsigned long offset; |
211 | /* private */ |
212 | struct list_head list; |
213 | }; |
214 | |
215 | struct fb_deferred_io { |
216 | /* delay between mkwrite and deferred handler */ |
217 | unsigned long delay; |
218 | bool sort_pagereflist; /* sort pagelist by offset */ |
219 | int open_count; /* number of opened files; protected by fb_info lock */ |
220 | struct mutex lock; /* mutex that protects the pageref list */ |
221 | struct list_head pagereflist; /* list of pagerefs for touched pages */ |
222 | struct address_space *mapping; /* page cache object for fb device */ |
223 | /* callback */ |
224 | struct page *(*get_page)(struct fb_info *info, unsigned long offset); |
225 | void (*deferred_io)(struct fb_info *info, struct list_head *pagelist); |
226 | }; |
227 | #endif |
228 | |
229 | /* |
230 | * Frame buffer operations |
231 | * |
232 | * LOCKING NOTE: those functions must _ALL_ be called with the console |
233 | * semaphore held, this is the only suitable locking mechanism we have |
234 | * in 2.6. Some may be called at interrupt time at this point though. |
235 | * |
236 | * The exception to this is the debug related hooks. Putting the fb |
237 | * into a debug state (e.g. flipping to the kernel console) and restoring |
238 | * it must be done in a lock-free manner, so low level drivers should |
239 | * keep track of the initial console (if applicable) and may need to |
240 | * perform direct, unlocked hardware writes in these hooks. |
241 | */ |
242 | |
243 | struct fb_ops { |
244 | /* open/release and usage marking */ |
245 | struct module *owner; |
246 | int (*fb_open)(struct fb_info *info, int user); |
247 | int (*fb_release)(struct fb_info *info, int user); |
248 | |
249 | /* For framebuffers with strange non linear layouts or that do not |
250 | * work with normal memory mapped access |
251 | */ |
252 | ssize_t (*fb_read)(struct fb_info *info, char __user *buf, |
253 | size_t count, loff_t *ppos); |
254 | ssize_t (*fb_write)(struct fb_info *info, const char __user *buf, |
255 | size_t count, loff_t *ppos); |
256 | |
257 | /* checks var and eventually tweaks it to something supported, |
258 | * DO NOT MODIFY PAR */ |
259 | int (*fb_check_var)(struct fb_var_screeninfo *var, struct fb_info *info); |
260 | |
261 | /* set the video mode according to info->var */ |
262 | int (*fb_set_par)(struct fb_info *info); |
263 | |
264 | /* set color register */ |
265 | int (*fb_setcolreg)(unsigned regno, unsigned red, unsigned green, |
266 | unsigned blue, unsigned transp, struct fb_info *info); |
267 | |
268 | /* set color registers in batch */ |
269 | int (*fb_setcmap)(struct fb_cmap *cmap, struct fb_info *info); |
270 | |
271 | /* blank display */ |
272 | int (*fb_blank)(int blank, struct fb_info *info); |
273 | |
274 | /* pan display */ |
275 | int (*fb_pan_display)(struct fb_var_screeninfo *var, struct fb_info *info); |
276 | |
277 | /* Draws a rectangle */ |
278 | void (*fb_fillrect) (struct fb_info *info, const struct fb_fillrect *rect); |
279 | /* Copy data from area to another */ |
280 | void (*fb_copyarea) (struct fb_info *info, const struct fb_copyarea *region); |
281 | /* Draws a image to the display */ |
282 | void (*fb_imageblit) (struct fb_info *info, const struct fb_image *image); |
283 | |
284 | /* Draws cursor */ |
285 | int (*fb_cursor) (struct fb_info *info, struct fb_cursor *cursor); |
286 | |
287 | /* wait for blit idle, optional */ |
288 | int (*fb_sync)(struct fb_info *info); |
289 | |
290 | /* perform fb specific ioctl (optional) */ |
291 | int (*fb_ioctl)(struct fb_info *info, unsigned int cmd, |
292 | unsigned long arg); |
293 | |
294 | /* Handle 32bit compat ioctl (optional) */ |
295 | int (*fb_compat_ioctl)(struct fb_info *info, unsigned cmd, |
296 | unsigned long arg); |
297 | |
298 | /* perform fb specific mmap */ |
299 | int (*fb_mmap)(struct fb_info *info, struct vm_area_struct *vma); |
300 | |
301 | /* get capability given var */ |
302 | void (*fb_get_caps)(struct fb_info *info, struct fb_blit_caps *caps, |
303 | struct fb_var_screeninfo *var); |
304 | |
305 | /* teardown any resources to do with this framebuffer */ |
306 | void (*fb_destroy)(struct fb_info *info); |
307 | |
308 | /* called at KDB enter and leave time to prepare the console */ |
309 | int (*fb_debug_enter)(struct fb_info *info); |
310 | int (*fb_debug_leave)(struct fb_info *info); |
311 | }; |
312 | |
313 | #ifdef CONFIG_FB_TILEBLITTING |
314 | #define FB_TILE_CURSOR_NONE 0 |
315 | #define FB_TILE_CURSOR_UNDERLINE 1 |
316 | #define FB_TILE_CURSOR_LOWER_THIRD 2 |
317 | #define FB_TILE_CURSOR_LOWER_HALF 3 |
318 | #define FB_TILE_CURSOR_TWO_THIRDS 4 |
319 | #define FB_TILE_CURSOR_BLOCK 5 |
320 | |
321 | struct fb_tilemap { |
322 | __u32 width; /* width of each tile in pixels */ |
323 | __u32 height; /* height of each tile in scanlines */ |
324 | __u32 depth; /* color depth of each tile */ |
325 | __u32 length; /* number of tiles in the map */ |
326 | const __u8 *data; /* actual tile map: a bitmap array, packed |
327 | to the nearest byte */ |
328 | }; |
329 | |
330 | struct fb_tilerect { |
331 | __u32 sx; /* origin in the x-axis */ |
332 | __u32 sy; /* origin in the y-axis */ |
333 | __u32 width; /* number of tiles in the x-axis */ |
334 | __u32 height; /* number of tiles in the y-axis */ |
335 | __u32 index; /* what tile to use: index to tile map */ |
336 | __u32 fg; /* foreground color */ |
337 | __u32 bg; /* background color */ |
338 | __u32 rop; /* raster operation */ |
339 | }; |
340 | |
341 | struct fb_tilearea { |
342 | __u32 sx; /* source origin in the x-axis */ |
343 | __u32 sy; /* source origin in the y-axis */ |
344 | __u32 dx; /* destination origin in the x-axis */ |
345 | __u32 dy; /* destination origin in the y-axis */ |
346 | __u32 width; /* number of tiles in the x-axis */ |
347 | __u32 height; /* number of tiles in the y-axis */ |
348 | }; |
349 | |
350 | struct fb_tileblit { |
351 | __u32 sx; /* origin in the x-axis */ |
352 | __u32 sy; /* origin in the y-axis */ |
353 | __u32 width; /* number of tiles in the x-axis */ |
354 | __u32 height; /* number of tiles in the y-axis */ |
355 | __u32 fg; /* foreground color */ |
356 | __u32 bg; /* background color */ |
357 | __u32 length; /* number of tiles to draw */ |
358 | __u32 *indices; /* array of indices to tile map */ |
359 | }; |
360 | |
361 | struct fb_tilecursor { |
362 | __u32 sx; /* cursor position in the x-axis */ |
363 | __u32 sy; /* cursor position in the y-axis */ |
364 | __u32 mode; /* 0 = erase, 1 = draw */ |
365 | __u32 shape; /* see FB_TILE_CURSOR_* */ |
366 | __u32 fg; /* foreground color */ |
367 | __u32 bg; /* background color */ |
368 | }; |
369 | |
370 | struct fb_tile_ops { |
371 | /* set tile characteristics */ |
372 | void (*fb_settile)(struct fb_info *info, struct fb_tilemap *map); |
373 | |
374 | /* all dimensions from hereon are in terms of tiles */ |
375 | |
376 | /* move a rectangular region of tiles from one area to another*/ |
377 | void (*fb_tilecopy)(struct fb_info *info, struct fb_tilearea *area); |
378 | /* fill a rectangular region with a tile */ |
379 | void (*fb_tilefill)(struct fb_info *info, struct fb_tilerect *rect); |
380 | /* copy an array of tiles */ |
381 | void (*fb_tileblit)(struct fb_info *info, struct fb_tileblit *blit); |
382 | /* cursor */ |
383 | void (*fb_tilecursor)(struct fb_info *info, |
384 | struct fb_tilecursor *cursor); |
385 | /* get maximum length of the tile map */ |
386 | int (*fb_get_tilemax)(struct fb_info *info); |
387 | }; |
388 | #endif /* CONFIG_FB_TILEBLITTING */ |
389 | |
390 | /* FBINFO_* = fb_info.flags bit flags */ |
391 | #define FBINFO_HWACCEL_DISABLED 0x0002 |
392 | /* When FBINFO_HWACCEL_DISABLED is set: |
393 | * Hardware acceleration is turned off. Software implementations |
394 | * of required functions (copyarea(), fillrect(), and imageblit()) |
395 | * takes over; acceleration engine should be in a quiescent state */ |
396 | |
397 | /* hints */ |
398 | #define FBINFO_VIRTFB 0x0004 /* FB is System RAM, not device. */ |
399 | #define FBINFO_PARTIAL_PAN_OK 0x0040 /* otw use pan only for double-buffering */ |
400 | #define FBINFO_READS_FAST 0x0080 /* soft-copy faster than rendering */ |
401 | |
402 | /* hardware supported ops */ |
403 | /* semantics: when a bit is set, it indicates that the operation is |
404 | * accelerated by hardware. |
405 | * required functions will still work even if the bit is not set. |
406 | * optional functions may not even exist if the flag bit is not set. |
407 | */ |
408 | #define FBINFO_HWACCEL_NONE 0x0000 |
409 | #define FBINFO_HWACCEL_COPYAREA 0x0100 /* required */ |
410 | #define FBINFO_HWACCEL_FILLRECT 0x0200 /* required */ |
411 | #define FBINFO_HWACCEL_IMAGEBLIT 0x0400 /* required */ |
412 | #define FBINFO_HWACCEL_ROTATE 0x0800 /* optional */ |
413 | #define FBINFO_HWACCEL_XPAN 0x1000 /* optional */ |
414 | #define FBINFO_HWACCEL_YPAN 0x2000 /* optional */ |
415 | #define FBINFO_HWACCEL_YWRAP 0x4000 /* optional */ |
416 | |
417 | #define FBINFO_MISC_TILEBLITTING 0x20000 /* use tile blitting */ |
418 | |
419 | /* A driver may set this flag to indicate that it does want a set_par to be |
420 | * called every time when fbcon_switch is executed. The advantage is that with |
421 | * this flag set you can really be sure that set_par is always called before |
422 | * any of the functions dependent on the correct hardware state or altering |
423 | * that state, even if you are using some broken X releases. The disadvantage |
424 | * is that it introduces unwanted delays to every console switch if set_par |
425 | * is slow. It is a good idea to try this flag in the drivers initialization |
426 | * code whenever there is a bug report related to switching between X and the |
427 | * framebuffer console. |
428 | */ |
429 | #define FBINFO_MISC_ALWAYS_SETPAR 0x40000 |
430 | |
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 | /* |
442 | * Hide smem_start in the FBIOGET_FSCREENINFO IOCTL. This is used by modern DRM |
443 | * drivers to stop userspace from trying to share buffers behind the kernel's |
444 | * back. Instead dma-buf based buffer sharing should be used. |
445 | */ |
446 | #define FBINFO_HIDE_SMEM_START 0x200000 |
447 | |
448 | |
449 | struct fb_info { |
450 | refcount_t count; |
451 | int node; |
452 | int flags; |
453 | /* |
454 | * -1 by default, set to a FB_ROTATE_* value by the driver, if it knows |
455 | * a lcd is not mounted upright and fbcon should rotate to compensate. |
456 | */ |
457 | int fbcon_rotate_hint; |
458 | struct mutex lock; /* Lock for open/release/ioctl funcs */ |
459 | struct mutex mm_lock; /* Lock for fb_mmap and smem_* fields */ |
460 | struct fb_var_screeninfo var; /* Current var */ |
461 | struct fb_fix_screeninfo fix; /* Current fix */ |
462 | struct fb_monspecs monspecs; /* Current Monitor specs */ |
463 | struct fb_pixmap pixmap; /* Image hardware mapper */ |
464 | struct fb_pixmap sprite; /* Cursor hardware mapper */ |
465 | struct fb_cmap cmap; /* Current cmap */ |
466 | struct list_head modelist; /* mode list */ |
467 | struct fb_videomode *mode; /* current mode */ |
468 | |
469 | int blank; /* current blanking; see FB_BLANK_ constants */ |
470 | |
471 | #if IS_ENABLED(CONFIG_FB_BACKLIGHT) |
472 | /* assigned backlight device */ |
473 | /* set before framebuffer registration, |
474 | remove after unregister */ |
475 | struct backlight_device *bl_dev; |
476 | |
477 | /* Backlight level curve */ |
478 | struct mutex bl_curve_mutex; |
479 | u8 bl_curve[FB_BACKLIGHT_LEVELS]; |
480 | #endif |
481 | |
482 | /* |
483 | * Assigned LCD device; set before framebuffer |
484 | * registration, remove after unregister |
485 | */ |
486 | struct lcd_device *lcd_dev; |
487 | |
488 | #ifdef CONFIG_FB_DEFERRED_IO |
489 | struct delayed_work deferred_work; |
490 | unsigned long npagerefs; |
491 | struct fb_deferred_io_pageref *pagerefs; |
492 | struct fb_deferred_io *fbdefio; |
493 | #endif |
494 | |
495 | const struct fb_ops *fbops; |
496 | struct device *device; /* This is the parent */ |
497 | #if defined(CONFIG_FB_DEVICE) |
498 | struct device *dev; /* This is this fb device */ |
499 | #endif |
500 | int class_flag; /* private sysfs flags */ |
501 | #ifdef CONFIG_FB_TILEBLITTING |
502 | struct fb_tile_ops *tileops; /* Tile Blitting */ |
503 | #endif |
504 | union { |
505 | char __iomem *screen_base; /* Virtual address */ |
506 | char *screen_buffer; |
507 | }; |
508 | unsigned long screen_size; /* Amount of ioremapped VRAM or 0 */ |
509 | void *pseudo_palette; /* Fake palette of 16 colors */ |
510 | #define FBINFO_STATE_RUNNING 0 |
511 | #define FBINFO_STATE_SUSPENDED 1 |
512 | u32 state; /* Hardware state i.e suspend */ |
513 | void *fbcon_par; /* fbcon use-only private area */ |
514 | /* From here on everything is device dependent */ |
515 | void *par; |
516 | |
517 | bool skip_vt_switch; /* no VT switch on suspend/resume required */ |
518 | bool skip_panic; /* Do not write to the fb after a panic */ |
519 | }; |
520 | |
521 | /* This will go away |
522 | * fbset currently hacks in FB_ACCELF_TEXT into var.accel_flags |
523 | * when it wants to turn the acceleration engine on. This is |
524 | * really a separate operation, and should be modified via sysfs. |
525 | * But for now, we leave it broken with the following define |
526 | */ |
527 | #define STUPID_ACCELF_TEXT_SHIT |
528 | |
529 | #define FB_LEFT_POS(p, bpp) (fb_be_math(p) ? (32 - (bpp)) : 0) |
530 | #define FB_SHIFT_HIGH(p, val, bits) (fb_be_math(p) ? (val) >> (bits) : \ |
531 | (val) << (bits)) |
532 | #define FB_SHIFT_LOW(p, val, bits) (fb_be_math(p) ? (val) << (bits) : \ |
533 | (val) >> (bits)) |
534 | |
535 | /* |
536 | * `Generic' versions of the frame buffer device operations |
537 | */ |
538 | |
539 | extern int fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var); |
540 | extern int fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var); |
541 | extern int fb_blank(struct fb_info *info, int blank); |
542 | |
543 | /* |
544 | * Helpers for framebuffers in I/O memory |
545 | */ |
546 | |
547 | extern void cfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect); |
548 | extern void cfb_copyarea(struct fb_info *info, const struct fb_copyarea *area); |
549 | extern void cfb_imageblit(struct fb_info *info, const struct fb_image *image); |
550 | extern ssize_t fb_io_read(struct fb_info *info, char __user *buf, |
551 | size_t count, loff_t *ppos); |
552 | extern ssize_t fb_io_write(struct fb_info *info, const char __user *buf, |
553 | size_t count, loff_t *ppos); |
554 | int fb_io_mmap(struct fb_info *info, struct vm_area_struct *vma); |
555 | |
556 | #define __FB_DEFAULT_IOMEM_OPS_RDWR \ |
557 | .fb_read = fb_io_read, \ |
558 | .fb_write = fb_io_write |
559 | |
560 | #define __FB_DEFAULT_IOMEM_OPS_DRAW \ |
561 | .fb_fillrect = cfb_fillrect, \ |
562 | .fb_copyarea = cfb_copyarea, \ |
563 | .fb_imageblit = cfb_imageblit |
564 | |
565 | #define __FB_DEFAULT_IOMEM_OPS_MMAP \ |
566 | .fb_mmap = fb_io_mmap |
567 | |
568 | #define FB_DEFAULT_IOMEM_OPS \ |
569 | __FB_DEFAULT_IOMEM_OPS_RDWR, \ |
570 | __FB_DEFAULT_IOMEM_OPS_DRAW, \ |
571 | __FB_DEFAULT_IOMEM_OPS_MMAP |
572 | |
573 | /* |
574 | * Helpers for framebuffers in system memory |
575 | */ |
576 | |
577 | extern void sys_fillrect(struct fb_info *info, const struct fb_fillrect *rect); |
578 | extern void sys_copyarea(struct fb_info *info, const struct fb_copyarea *area); |
579 | extern void sys_imageblit(struct fb_info *info, const struct fb_image *image); |
580 | extern ssize_t fb_sys_read(struct fb_info *info, char __user *buf, |
581 | size_t count, loff_t *ppos); |
582 | extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf, |
583 | size_t count, loff_t *ppos); |
584 | |
585 | #define __FB_DEFAULT_SYSMEM_OPS_RDWR \ |
586 | .fb_read = fb_sys_read, \ |
587 | .fb_write = fb_sys_write |
588 | |
589 | #define __FB_DEFAULT_SYSMEM_OPS_DRAW \ |
590 | .fb_fillrect = sys_fillrect, \ |
591 | .fb_copyarea = sys_copyarea, \ |
592 | .fb_imageblit = sys_imageblit |
593 | |
594 | /* |
595 | * Helpers for framebuffers in DMA-able memory |
596 | */ |
597 | |
598 | #define __FB_DEFAULT_DMAMEM_OPS_RDWR \ |
599 | .fb_read = fb_sys_read, \ |
600 | .fb_write = fb_sys_write |
601 | |
602 | #define __FB_DEFAULT_DMAMEM_OPS_DRAW \ |
603 | .fb_fillrect = sys_fillrect, \ |
604 | .fb_copyarea = sys_copyarea, \ |
605 | .fb_imageblit = sys_imageblit |
606 | |
607 | /* fbmem.c */ |
608 | extern int register_framebuffer(struct fb_info *fb_info); |
609 | extern void unregister_framebuffer(struct fb_info *fb_info); |
610 | extern int devm_register_framebuffer(struct device *dev, struct fb_info *fb_info); |
611 | extern char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size); |
612 | extern void fb_pad_unaligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 idx, |
613 | u32 height, u32 shift_high, u32 shift_low, u32 mod); |
614 | extern void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, u32 height); |
615 | extern void fb_set_suspend(struct fb_info *info, int state); |
616 | extern int fb_get_color_depth(struct fb_var_screeninfo *var, |
617 | struct fb_fix_screeninfo *fix); |
618 | extern int fb_get_options(const char *name, char **option); |
619 | extern int fb_new_modelist(struct fb_info *info); |
620 | |
621 | static inline void lock_fb_info(struct fb_info *info) |
622 | { |
623 | mutex_lock(&info->lock); |
624 | } |
625 | |
626 | static inline void unlock_fb_info(struct fb_info *info) |
627 | { |
628 | mutex_unlock(lock: &info->lock); |
629 | } |
630 | |
631 | static inline void __fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, |
632 | u8 *src, u32 s_pitch, u32 height) |
633 | { |
634 | u32 i, j; |
635 | |
636 | d_pitch -= s_pitch; |
637 | |
638 | for (i = height; i--; ) { |
639 | /* s_pitch is a few bytes at the most, memcpy is suboptimal */ |
640 | for (j = 0; j < s_pitch; j++) |
641 | *dst++ = *src++; |
642 | dst += d_pitch; |
643 | } |
644 | } |
645 | |
646 | /* fb_defio.c */ |
647 | int fb_deferred_io_mmap(struct fb_info *info, struct vm_area_struct *vma); |
648 | extern int fb_deferred_io_init(struct fb_info *info); |
649 | extern void fb_deferred_io_open(struct fb_info *info, |
650 | struct inode *inode, |
651 | struct file *file); |
652 | extern void fb_deferred_io_release(struct fb_info *info); |
653 | extern void fb_deferred_io_cleanup(struct fb_info *info); |
654 | extern int fb_deferred_io_fsync(struct file *file, loff_t start, |
655 | loff_t end, int datasync); |
656 | |
657 | /* |
658 | * Generate callbacks for deferred I/O |
659 | */ |
660 | |
661 | #define __FB_GEN_DEFAULT_DEFERRED_OPS_RDWR(__prefix, __damage_range, __mode) \ |
662 | static ssize_t __prefix ## _defio_read(struct fb_info *info, char __user *buf, \ |
663 | size_t count, loff_t *ppos) \ |
664 | { \ |
665 | return fb_ ## __mode ## _read(info, buf, count, ppos); \ |
666 | } \ |
667 | static ssize_t __prefix ## _defio_write(struct fb_info *info, const char __user *buf, \ |
668 | size_t count, loff_t *ppos) \ |
669 | { \ |
670 | unsigned long offset = *ppos; \ |
671 | ssize_t ret = fb_ ## __mode ## _write(info, buf, count, ppos); \ |
672 | if (ret > 0) \ |
673 | __damage_range(info, offset, ret); \ |
674 | return ret; \ |
675 | } |
676 | |
677 | #define __FB_GEN_DEFAULT_DEFERRED_OPS_DRAW(__prefix, __damage_area, __mode) \ |
678 | static void __prefix ## _defio_fillrect(struct fb_info *info, \ |
679 | const struct fb_fillrect *rect) \ |
680 | { \ |
681 | __mode ## _fillrect(info, rect); \ |
682 | __damage_area(info, rect->dx, rect->dy, rect->width, rect->height); \ |
683 | } \ |
684 | static void __prefix ## _defio_copyarea(struct fb_info *info, \ |
685 | const struct fb_copyarea *area) \ |
686 | { \ |
687 | __mode ## _copyarea(info, area); \ |
688 | __damage_area(info, area->dx, area->dy, area->width, area->height); \ |
689 | } \ |
690 | static void __prefix ## _defio_imageblit(struct fb_info *info, \ |
691 | const struct fb_image *image) \ |
692 | { \ |
693 | __mode ## _imageblit(info, image); \ |
694 | __damage_area(info, image->dx, image->dy, image->width, image->height); \ |
695 | } |
696 | |
697 | #define FB_GEN_DEFAULT_DEFERRED_IOMEM_OPS(__prefix, __damage_range, __damage_area) \ |
698 | __FB_GEN_DEFAULT_DEFERRED_OPS_RDWR(__prefix, __damage_range, io) \ |
699 | __FB_GEN_DEFAULT_DEFERRED_OPS_DRAW(__prefix, __damage_area, cfb) |
700 | |
701 | #define FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(__prefix, __damage_range, __damage_area) \ |
702 | __FB_GEN_DEFAULT_DEFERRED_OPS_RDWR(__prefix, __damage_range, sys) \ |
703 | __FB_GEN_DEFAULT_DEFERRED_OPS_DRAW(__prefix, __damage_area, sys) |
704 | |
705 | #define FB_GEN_DEFAULT_DEFERRED_DMAMEM_OPS(__prefix, __damage_range, __damage_area) \ |
706 | __FB_GEN_DEFAULT_DEFERRED_OPS_RDWR(__prefix, __damage_range, sys) \ |
707 | __FB_GEN_DEFAULT_DEFERRED_OPS_DRAW(__prefix, __damage_area, sys) |
708 | |
709 | /* |
710 | * Initializes struct fb_ops for deferred I/O. |
711 | */ |
712 | |
713 | #define __FB_DEFAULT_DEFERRED_OPS_RDWR(__prefix) \ |
714 | .fb_read = __prefix ## _defio_read, \ |
715 | .fb_write = __prefix ## _defio_write |
716 | |
717 | #define __FB_DEFAULT_DEFERRED_OPS_DRAW(__prefix) \ |
718 | .fb_fillrect = __prefix ## _defio_fillrect, \ |
719 | .fb_copyarea = __prefix ## _defio_copyarea, \ |
720 | .fb_imageblit = __prefix ## _defio_imageblit |
721 | |
722 | #define __FB_DEFAULT_DEFERRED_OPS_MMAP(__prefix) \ |
723 | .fb_mmap = fb_deferred_io_mmap |
724 | |
725 | #define FB_DEFAULT_DEFERRED_OPS(__prefix) \ |
726 | __FB_DEFAULT_DEFERRED_OPS_RDWR(__prefix), \ |
727 | __FB_DEFAULT_DEFERRED_OPS_DRAW(__prefix), \ |
728 | __FB_DEFAULT_DEFERRED_OPS_MMAP(__prefix) |
729 | |
730 | static inline bool fb_be_math(struct fb_info *info) |
731 | { |
732 | #ifdef CONFIG_FB_FOREIGN_ENDIAN |
733 | #if defined(CONFIG_FB_BOTH_ENDIAN) |
734 | return info->flags & FBINFO_BE_MATH; |
735 | #elif defined(CONFIG_FB_BIG_ENDIAN) |
736 | return true; |
737 | #elif defined(CONFIG_FB_LITTLE_ENDIAN) |
738 | return false; |
739 | #endif /* CONFIG_FB_BOTH_ENDIAN */ |
740 | #else |
741 | #ifdef __BIG_ENDIAN |
742 | return true; |
743 | #else |
744 | return false; |
745 | #endif /* __BIG_ENDIAN */ |
746 | #endif /* CONFIG_FB_FOREIGN_ENDIAN */ |
747 | } |
748 | |
749 | extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev); |
750 | extern void framebuffer_release(struct fb_info *info); |
751 | extern void fb_bl_default_curve(struct fb_info *fb_info, u8 off, u8 min, u8 max); |
752 | |
753 | #if IS_ENABLED(CONFIG_FB_BACKLIGHT) |
754 | struct backlight_device *fb_bl_device(struct fb_info *info); |
755 | void fb_bl_notify_blank(struct fb_info *info, int old_blank); |
756 | #else |
757 | static inline struct backlight_device *fb_bl_device(struct fb_info *info) |
758 | { |
759 | return NULL; |
760 | } |
761 | |
762 | static inline void fb_bl_notify_blank(struct fb_info *info, int old_blank) |
763 | { } |
764 | #endif |
765 | |
766 | static inline struct lcd_device *fb_lcd_device(struct fb_info *info) |
767 | { |
768 | return info->lcd_dev; |
769 | } |
770 | |
771 | /* fbmon.c */ |
772 | #define FB_MAXTIMINGS 0 |
773 | #define FB_VSYNCTIMINGS 1 |
774 | #define FB_HSYNCTIMINGS 2 |
775 | #define FB_DCLKTIMINGS 3 |
776 | #define FB_IGNOREMON 0x100 |
777 | |
778 | #define FB_MODE_IS_UNKNOWN 0 |
779 | #define FB_MODE_IS_DETAILED 1 |
780 | #define FB_MODE_IS_STANDARD 2 |
781 | #define FB_MODE_IS_VESA 4 |
782 | #define FB_MODE_IS_CALCULATED 8 |
783 | #define FB_MODE_IS_FIRST 16 |
784 | #define FB_MODE_IS_FROM_VAR 32 |
785 | |
786 | extern int fbmon_dpms(const struct fb_info *fb_info); |
787 | extern int fb_get_mode(int flags, u32 val, struct fb_var_screeninfo *var, |
788 | struct fb_info *info); |
789 | extern int fb_validate_mode(const struct fb_var_screeninfo *var, |
790 | struct fb_info *info); |
791 | extern int fb_parse_edid(unsigned char *edid, struct fb_var_screeninfo *var); |
792 | extern const unsigned char *fb_firmware_edid(struct device *device); |
793 | extern void fb_edid_to_monspecs(unsigned char *edid, |
794 | struct fb_monspecs *specs); |
795 | extern void fb_destroy_modedb(struct fb_videomode *modedb); |
796 | extern int fb_find_mode_cvt(struct fb_videomode *mode, int margins, int rb); |
797 | extern unsigned char *fb_ddc_read(struct i2c_adapter *adapter); |
798 | |
799 | extern int of_get_fb_videomode(struct device_node *np, |
800 | struct fb_videomode *fb, |
801 | int index); |
802 | extern int fb_videomode_from_videomode(const struct videomode *vm, |
803 | struct fb_videomode *fbmode); |
804 | |
805 | /* modedb.c */ |
806 | #define VESA_MODEDB_SIZE 43 |
807 | #define DMT_SIZE 0x50 |
808 | |
809 | extern void fb_var_to_videomode(struct fb_videomode *mode, |
810 | const struct fb_var_screeninfo *var); |
811 | extern void fb_videomode_to_var(struct fb_var_screeninfo *var, |
812 | const struct fb_videomode *mode); |
813 | extern int fb_mode_is_equal(const struct fb_videomode *mode1, |
814 | const struct fb_videomode *mode2); |
815 | extern int fb_add_videomode(const struct fb_videomode *mode, |
816 | struct list_head *head); |
817 | extern void fb_delete_videomode(const struct fb_videomode *mode, |
818 | struct list_head *head); |
819 | extern const struct fb_videomode *fb_match_mode(const struct fb_var_screeninfo *var, |
820 | struct list_head *head); |
821 | extern const struct fb_videomode *fb_find_best_mode(const struct fb_var_screeninfo *var, |
822 | struct list_head *head); |
823 | extern const struct fb_videomode *fb_find_nearest_mode(const struct fb_videomode *mode, |
824 | struct list_head *head); |
825 | extern void fb_destroy_modelist(struct list_head *head); |
826 | extern void fb_videomode_to_modelist(const struct fb_videomode *modedb, int num, |
827 | struct list_head *head); |
828 | extern const struct fb_videomode *fb_find_best_display(const struct fb_monspecs *specs, |
829 | struct list_head *head); |
830 | |
831 | /* fbcmap.c */ |
832 | extern int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp); |
833 | extern int fb_alloc_cmap_gfp(struct fb_cmap *cmap, int len, int transp, gfp_t flags); |
834 | extern void fb_dealloc_cmap(struct fb_cmap *cmap); |
835 | extern int fb_copy_cmap(const struct fb_cmap *from, struct fb_cmap *to); |
836 | extern int fb_cmap_to_user(const struct fb_cmap *from, struct fb_cmap_user *to); |
837 | extern int fb_set_cmap(struct fb_cmap *cmap, struct fb_info *fb_info); |
838 | extern int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *fb_info); |
839 | extern const struct fb_cmap *fb_default_cmap(int len); |
840 | extern void fb_invert_cmaps(void); |
841 | |
842 | struct fb_videomode { |
843 | const char *name; /* optional */ |
844 | u32 refresh; /* optional */ |
845 | u32 xres; |
846 | u32 yres; |
847 | u32 pixclock; |
848 | u32 left_margin; |
849 | u32 right_margin; |
850 | u32 upper_margin; |
851 | u32 lower_margin; |
852 | u32 hsync_len; |
853 | u32 vsync_len; |
854 | u32 sync; |
855 | u32 vmode; |
856 | u32 flag; |
857 | }; |
858 | |
859 | struct dmt_videomode { |
860 | u32 dmt_id; |
861 | u32 std_2byte_code; |
862 | u32 cvt_3byte_code; |
863 | const struct fb_videomode *mode; |
864 | }; |
865 | |
866 | extern const struct fb_videomode vesa_modes[]; |
867 | extern const struct dmt_videomode dmt_modes[]; |
868 | |
869 | struct fb_modelist { |
870 | struct list_head list; |
871 | struct fb_videomode mode; |
872 | }; |
873 | |
874 | extern int fb_find_mode(struct fb_var_screeninfo *var, |
875 | struct fb_info *info, const char *mode_option, |
876 | const struct fb_videomode *db, |
877 | unsigned int dbsize, |
878 | const struct fb_videomode *default_mode, |
879 | unsigned int default_bpp); |
880 | |
881 | bool fb_modesetting_disabled(const char *drvname); |
882 | |
883 | /* |
884 | * Convenience logging macros |
885 | */ |
886 | |
887 | #define fb_err(fb_info, fmt, ...) \ |
888 | pr_err("fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__) |
889 | #define fb_notice(info, fmt, ...) \ |
890 | pr_notice("fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__) |
891 | #define fb_warn(fb_info, fmt, ...) \ |
892 | pr_warn("fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__) |
893 | #define fb_info(fb_info, fmt, ...) \ |
894 | pr_info("fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__) |
895 | #define fb_dbg(fb_info, fmt, ...) \ |
896 | pr_debug("fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__) |
897 | |
898 | #define fb_warn_once(fb_info, fmt, ...) \ |
899 | pr_warn_once("fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__) |
900 | |
901 | #define fb_WARN_ONCE(fb_info, condition, fmt, ...) \ |
902 | WARN_ONCE(condition, "fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__) |
903 | #define fb_WARN_ON_ONCE(fb_info, x) \ |
904 | fb_WARN_ONCE(fb_info, (x), "%s", "fb_WARN_ON_ONCE(" __stringify(x) ")") |
905 | |
906 | #endif /* _LINUX_FB_H */ |
907 |
Definitions
- fb_chroma
- fb_monspecs
- fb_cmap_user
- fb_image_user
- fb_cursor_user
- fb_event
- fb_blit_caps
- fb_pixmap
- fb_deferred_io_pageref
- fb_deferred_io
- fb_ops
- fb_tilemap
- fb_tilerect
- fb_tilearea
- fb_tileblit
- fb_tilecursor
- fb_tile_ops
- fb_info
- lock_fb_info
- unlock_fb_info
- __fb_pad_aligned_buffer
- fb_be_math
- fb_lcd_device
- fb_videomode
- dmt_videomode
Improve your Profiling and Debugging skills
Find out more