Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _LINUX_FB_H
0003 #define _LINUX_FB_H
0004 
0005 #include <linux/refcount.h>
0006 #include <linux/kgdb.h>
0007 #include <uapi/linux/fb.h>
0008 
0009 #define FBIO_CURSOR            _IOWR('F', 0x08, struct fb_cursor_user)
0010 
0011 #include <linux/fs.h>
0012 #include <linux/init.h>
0013 #include <linux/workqueue.h>
0014 #include <linux/notifier.h>
0015 #include <linux/list.h>
0016 #include <linux/backlight.h>
0017 #include <linux/slab.h>
0018 #include <asm/io.h>
0019 
0020 struct vm_area_struct;
0021 struct fb_info;
0022 struct device;
0023 struct file;
0024 struct videomode;
0025 struct device_node;
0026 
0027 /* Definitions below are used in the parsed monitor specs */
0028 #define FB_DPMS_ACTIVE_OFF  1
0029 #define FB_DPMS_SUSPEND     2
0030 #define FB_DPMS_STANDBY     4
0031 
0032 #define FB_DISP_DDI     1
0033 #define FB_DISP_ANA_700_300 2
0034 #define FB_DISP_ANA_714_286 4
0035 #define FB_DISP_ANA_1000_400    8
0036 #define FB_DISP_ANA_700_000 16
0037 
0038 #define FB_DISP_MONO        32
0039 #define FB_DISP_RGB     64
0040 #define FB_DISP_MULTI       128
0041 #define FB_DISP_UNKNOWN     256
0042 
0043 #define FB_SIGNAL_NONE      0
0044 #define FB_SIGNAL_BLANK_BLANK   1
0045 #define FB_SIGNAL_SEPARATE  2
0046 #define FB_SIGNAL_COMPOSITE 4
0047 #define FB_SIGNAL_SYNC_ON_GREEN 8
0048 #define FB_SIGNAL_SERRATION_ON  16
0049 
0050 #define FB_MISC_PRIM_COLOR  1
0051 #define FB_MISC_1ST_DETAIL  2   /* First Detailed Timing is preferred */
0052 #define FB_MISC_HDMI        4
0053 struct fb_chroma {
0054     __u32 redx; /* in fraction of 1024 */
0055     __u32 greenx;
0056     __u32 bluex;
0057     __u32 whitex;
0058     __u32 redy;
0059     __u32 greeny;
0060     __u32 bluey;
0061     __u32 whitey;
0062 };
0063 
0064 struct fb_monspecs {
0065     struct fb_chroma chroma;
0066     struct fb_videomode *modedb;    /* mode database */
0067     __u8  manufacturer[4];      /* Manufacturer */
0068     __u8  monitor[14];      /* Monitor String */
0069     __u8  serial_no[14];        /* Serial Number */
0070     __u8  ascii[14];        /* ? */
0071     __u32 modedb_len;       /* mode database length */
0072     __u32 model;            /* Monitor Model */
0073     __u32 serial;           /* Serial Number - Integer */
0074     __u32 year;         /* Year manufactured */
0075     __u32 week;         /* Week Manufactured */
0076     __u32 hfmin;            /* hfreq lower limit (Hz) */
0077     __u32 hfmax;            /* hfreq upper limit (Hz) */
0078     __u32 dclkmin;          /* pixelclock lower limit (Hz) */
0079     __u32 dclkmax;          /* pixelclock upper limit (Hz) */
0080     __u16 input;            /* display type - see FB_DISP_* */
0081     __u16 dpms;         /* DPMS support - see FB_DPMS_ */
0082     __u16 signal;           /* Signal Type - see FB_SIGNAL_* */
0083     __u16 vfmin;            /* vfreq lower limit (Hz) */
0084     __u16 vfmax;            /* vfreq upper limit (Hz) */
0085     __u16 gamma;            /* Gamma - in fractions of 100 */
0086     __u16 gtf   : 1;        /* supports GTF */
0087     __u16 misc;         /* Misc flags - see FB_MISC_* */
0088     __u8  version;          /* EDID version... */
0089     __u8  revision;         /* ...and revision */
0090     __u8  max_x;            /* Maximum horizontal size (cm) */
0091     __u8  max_y;            /* Maximum vertical size (cm) */
0092 };
0093 
0094 struct fb_cmap_user {
0095     __u32 start;            /* First entry  */
0096     __u32 len;          /* Number of entries */
0097     __u16 __user *red;      /* Red values   */
0098     __u16 __user *green;
0099     __u16 __user *blue;
0100     __u16 __user *transp;       /* transparency, can be NULL */
0101 };
0102 
0103 struct fb_image_user {
0104     __u32 dx;           /* Where to place image */
0105     __u32 dy;
0106     __u32 width;            /* Size of image */
0107     __u32 height;
0108     __u32 fg_color;         /* Only used when a mono bitmap */
0109     __u32 bg_color;
0110     __u8  depth;            /* Depth of the image */
0111     const char __user *data;    /* Pointer to image data */
0112     struct fb_cmap_user cmap;   /* color map info */
0113 };
0114 
0115 struct fb_cursor_user {
0116     __u16 set;          /* what to set */
0117     __u16 enable;           /* cursor on/off */
0118     __u16 rop;          /* bitop operation */
0119     const char __user *mask;    /* cursor mask bits */
0120     struct fbcurpos hot;        /* cursor hot spot */
0121     struct fb_image_user image; /* Cursor image */
0122 };
0123 
0124 /*
0125  * Register/unregister for framebuffer events
0126  */
0127 
0128 /*  The resolution of the passed in fb_info about to change */
0129 #define FB_EVENT_MODE_CHANGE        0x01
0130 
0131 #ifdef CONFIG_GUMSTIX_AM200EPD
0132 /* only used by mach-pxa/am200epd.c */
0133 #define FB_EVENT_FB_REGISTERED          0x05
0134 #define FB_EVENT_FB_UNREGISTERED        0x06
0135 #endif
0136 
0137 /*      A display blank is requested       */
0138 #define FB_EVENT_BLANK                  0x09
0139 
0140 struct fb_event {
0141     struct fb_info *info;
0142     void *data;
0143 };
0144 
0145 struct fb_blit_caps {
0146     u32 x;
0147     u32 y;
0148     u32 len;
0149     u32 flags;
0150 };
0151 
0152 #ifdef CONFIG_FB_NOTIFY
0153 extern int fb_register_client(struct notifier_block *nb);
0154 extern int fb_unregister_client(struct notifier_block *nb);
0155 extern int fb_notifier_call_chain(unsigned long val, void *v);
0156 #else
0157 static inline int fb_register_client(struct notifier_block *nb)
0158 {
0159     return 0;
0160 };
0161 
0162 static inline int fb_unregister_client(struct notifier_block *nb)
0163 {
0164     return 0;
0165 };
0166 
0167 static inline int fb_notifier_call_chain(unsigned long val, void *v)
0168 {
0169     return 0;
0170 };
0171 #endif
0172 
0173 /*
0174  * Pixmap structure definition
0175  *
0176  * The purpose of this structure is to translate data
0177  * from the hardware independent format of fbdev to what
0178  * format the hardware needs.
0179  */
0180 
0181 #define FB_PIXMAP_DEFAULT 1     /* used internally by fbcon */
0182 #define FB_PIXMAP_SYSTEM  2     /* memory is in system RAM  */
0183 #define FB_PIXMAP_IO      4     /* memory is iomapped       */
0184 #define FB_PIXMAP_SYNC    256   /* set if GPU can DMA       */
0185 
0186 struct fb_pixmap {
0187     u8  *addr;      /* pointer to memory            */
0188     u32 size;       /* size of buffer in bytes      */
0189     u32 offset;     /* current offset to buffer     */
0190     u32 buf_align;      /* byte alignment of each bitmap    */
0191     u32 scan_align;     /* alignment per scanline       */
0192     u32 access_align;   /* alignment per read/write (bits)  */
0193     u32 flags;      /* see FB_PIXMAP_*          */
0194     u32 blit_x;             /* supported bit block dimensions (1-32)*/
0195     u32 blit_y;             /* Format: blit_x = 1 << (width - 1)    */
0196                             /*         blit_y = 1 << (height - 1)   */
0197                             /* if 0, will be set to 0xffffffff (all)*/
0198     /* access methods */
0199     void (*writeio)(struct fb_info *info, void __iomem *dst, void *src, unsigned int size);
0200     void (*readio) (struct fb_info *info, void *dst, void __iomem *src, unsigned int size);
0201 };
0202 
0203 #ifdef CONFIG_FB_DEFERRED_IO
0204 struct fb_deferred_io_pageref {
0205     struct page *page;
0206     unsigned long offset;
0207     /* private */
0208     struct list_head list;
0209 };
0210 
0211 struct fb_deferred_io {
0212     /* delay between mkwrite and deferred handler */
0213     unsigned long delay;
0214     bool sort_pagereflist; /* sort pagelist by offset */
0215     struct mutex lock; /* mutex that protects the pageref list */
0216     struct list_head pagereflist; /* list of pagerefs for touched pages */
0217     /* callback */
0218     void (*first_io)(struct fb_info *info);
0219     void (*deferred_io)(struct fb_info *info, struct list_head *pagelist);
0220 };
0221 #endif
0222 
0223 /*
0224  * Frame buffer operations
0225  *
0226  * LOCKING NOTE: those functions must _ALL_ be called with the console
0227  * semaphore held, this is the only suitable locking mechanism we have
0228  * in 2.6. Some may be called at interrupt time at this point though.
0229  *
0230  * The exception to this is the debug related hooks.  Putting the fb
0231  * into a debug state (e.g. flipping to the kernel console) and restoring
0232  * it must be done in a lock-free manner, so low level drivers should
0233  * keep track of the initial console (if applicable) and may need to
0234  * perform direct, unlocked hardware writes in these hooks.
0235  */
0236 
0237 struct fb_ops {
0238     /* open/release and usage marking */
0239     struct module *owner;
0240     int (*fb_open)(struct fb_info *info, int user);
0241     int (*fb_release)(struct fb_info *info, int user);
0242 
0243     /* For framebuffers with strange non linear layouts or that do not
0244      * work with normal memory mapped access
0245      */
0246     ssize_t (*fb_read)(struct fb_info *info, char __user *buf,
0247                size_t count, loff_t *ppos);
0248     ssize_t (*fb_write)(struct fb_info *info, const char __user *buf,
0249                 size_t count, loff_t *ppos);
0250 
0251     /* checks var and eventually tweaks it to something supported,
0252      * DO NOT MODIFY PAR */
0253     int (*fb_check_var)(struct fb_var_screeninfo *var, struct fb_info *info);
0254 
0255     /* set the video mode according to info->var */
0256     int (*fb_set_par)(struct fb_info *info);
0257 
0258     /* set color register */
0259     int (*fb_setcolreg)(unsigned regno, unsigned red, unsigned green,
0260                 unsigned blue, unsigned transp, struct fb_info *info);
0261 
0262     /* set color registers in batch */
0263     int (*fb_setcmap)(struct fb_cmap *cmap, struct fb_info *info);
0264 
0265     /* blank display */
0266     int (*fb_blank)(int blank, struct fb_info *info);
0267 
0268     /* pan display */
0269     int (*fb_pan_display)(struct fb_var_screeninfo *var, struct fb_info *info);
0270 
0271     /* Draws a rectangle */
0272     void (*fb_fillrect) (struct fb_info *info, const struct fb_fillrect *rect);
0273     /* Copy data from area to another */
0274     void (*fb_copyarea) (struct fb_info *info, const struct fb_copyarea *region);
0275     /* Draws a image to the display */
0276     void (*fb_imageblit) (struct fb_info *info, const struct fb_image *image);
0277 
0278     /* Draws cursor */
0279     int (*fb_cursor) (struct fb_info *info, struct fb_cursor *cursor);
0280 
0281     /* wait for blit idle, optional */
0282     int (*fb_sync)(struct fb_info *info);
0283 
0284     /* perform fb specific ioctl (optional) */
0285     int (*fb_ioctl)(struct fb_info *info, unsigned int cmd,
0286             unsigned long arg);
0287 
0288     /* Handle 32bit compat ioctl (optional) */
0289     int (*fb_compat_ioctl)(struct fb_info *info, unsigned cmd,
0290             unsigned long arg);
0291 
0292     /* perform fb specific mmap */
0293     int (*fb_mmap)(struct fb_info *info, struct vm_area_struct *vma);
0294 
0295     /* get capability given var */
0296     void (*fb_get_caps)(struct fb_info *info, struct fb_blit_caps *caps,
0297                 struct fb_var_screeninfo *var);
0298 
0299     /* teardown any resources to do with this framebuffer */
0300     void (*fb_destroy)(struct fb_info *info);
0301 
0302     /* called at KDB enter and leave time to prepare the console */
0303     int (*fb_debug_enter)(struct fb_info *info);
0304     int (*fb_debug_leave)(struct fb_info *info);
0305 };
0306 
0307 #ifdef CONFIG_FB_TILEBLITTING
0308 #define FB_TILE_CURSOR_NONE        0
0309 #define FB_TILE_CURSOR_UNDERLINE   1
0310 #define FB_TILE_CURSOR_LOWER_THIRD 2
0311 #define FB_TILE_CURSOR_LOWER_HALF  3
0312 #define FB_TILE_CURSOR_TWO_THIRDS  4
0313 #define FB_TILE_CURSOR_BLOCK       5
0314 
0315 struct fb_tilemap {
0316     __u32 width;                /* width of each tile in pixels */
0317     __u32 height;               /* height of each tile in scanlines */
0318     __u32 depth;                /* color depth of each tile */
0319     __u32 length;               /* number of tiles in the map */
0320     const __u8 *data;           /* actual tile map: a bitmap array, packed
0321                        to the nearest byte */
0322 };
0323 
0324 struct fb_tilerect {
0325     __u32 sx;                   /* origin in the x-axis */
0326     __u32 sy;                   /* origin in the y-axis */
0327     __u32 width;                /* number of tiles in the x-axis */
0328     __u32 height;               /* number of tiles in the y-axis */
0329     __u32 index;                /* what tile to use: index to tile map */
0330     __u32 fg;                   /* foreground color */
0331     __u32 bg;                   /* background color */
0332     __u32 rop;                  /* raster operation */
0333 };
0334 
0335 struct fb_tilearea {
0336     __u32 sx;                   /* source origin in the x-axis */
0337     __u32 sy;                   /* source origin in the y-axis */
0338     __u32 dx;                   /* destination origin in the x-axis */
0339     __u32 dy;                   /* destination origin in the y-axis */
0340     __u32 width;                /* number of tiles in the x-axis */
0341     __u32 height;               /* number of tiles in the y-axis */
0342 };
0343 
0344 struct fb_tileblit {
0345     __u32 sx;                   /* origin in the x-axis */
0346     __u32 sy;                   /* origin in the y-axis */
0347     __u32 width;                /* number of tiles in the x-axis */
0348     __u32 height;               /* number of tiles in the y-axis */
0349     __u32 fg;                   /* foreground color */
0350     __u32 bg;                   /* background color */
0351     __u32 length;               /* number of tiles to draw */
0352     __u32 *indices;             /* array of indices to tile map */
0353 };
0354 
0355 struct fb_tilecursor {
0356     __u32 sx;                   /* cursor position in the x-axis */
0357     __u32 sy;                   /* cursor position in the y-axis */
0358     __u32 mode;                 /* 0 = erase, 1 = draw */
0359     __u32 shape;                /* see FB_TILE_CURSOR_* */
0360     __u32 fg;                   /* foreground color */
0361     __u32 bg;                   /* background color */
0362 };
0363 
0364 struct fb_tile_ops {
0365     /* set tile characteristics */
0366     void (*fb_settile)(struct fb_info *info, struct fb_tilemap *map);
0367 
0368     /* all dimensions from hereon are in terms of tiles */
0369 
0370     /* move a rectangular region of tiles from one area to another*/
0371     void (*fb_tilecopy)(struct fb_info *info, struct fb_tilearea *area);
0372     /* fill a rectangular region with a tile */
0373     void (*fb_tilefill)(struct fb_info *info, struct fb_tilerect *rect);
0374     /* copy an array of tiles */
0375     void (*fb_tileblit)(struct fb_info *info, struct fb_tileblit *blit);
0376     /* cursor */
0377     void (*fb_tilecursor)(struct fb_info *info,
0378                   struct fb_tilecursor *cursor);
0379     /* get maximum length of the tile map */
0380     int (*fb_get_tilemax)(struct fb_info *info);
0381 };
0382 #endif /* CONFIG_FB_TILEBLITTING */
0383 
0384 /* FBINFO_* = fb_info.flags bit flags */
0385 #define FBINFO_DEFAULT      0
0386 #define FBINFO_HWACCEL_DISABLED 0x0002
0387     /* When FBINFO_HWACCEL_DISABLED is set:
0388      *  Hardware acceleration is turned off.  Software implementations
0389      *  of required functions (copyarea(), fillrect(), and imageblit())
0390      *  takes over; acceleration engine should be in a quiescent state */
0391 
0392 /* hints */
0393 #define FBINFO_VIRTFB       0x0004 /* FB is System RAM, not device. */
0394 #define FBINFO_PARTIAL_PAN_OK   0x0040 /* otw use pan only for double-buffering */
0395 #define FBINFO_READS_FAST   0x0080 /* soft-copy faster than rendering */
0396 
0397 /* hardware supported ops */
0398 /*  semantics: when a bit is set, it indicates that the operation is
0399  *   accelerated by hardware.
0400  *  required functions will still work even if the bit is not set.
0401  *  optional functions may not even exist if the flag bit is not set.
0402  */
0403 #define FBINFO_HWACCEL_NONE     0x0000
0404 #define FBINFO_HWACCEL_COPYAREA     0x0100 /* required */
0405 #define FBINFO_HWACCEL_FILLRECT     0x0200 /* required */
0406 #define FBINFO_HWACCEL_IMAGEBLIT    0x0400 /* required */
0407 #define FBINFO_HWACCEL_ROTATE       0x0800 /* optional */
0408 #define FBINFO_HWACCEL_XPAN     0x1000 /* optional */
0409 #define FBINFO_HWACCEL_YPAN     0x2000 /* optional */
0410 #define FBINFO_HWACCEL_YWRAP        0x4000 /* optional */
0411 
0412 #define FBINFO_MISC_TILEBLITTING       0x20000 /* use tile blitting */
0413 
0414 /* A driver may set this flag to indicate that it does want a set_par to be
0415  * called every time when fbcon_switch is executed. The advantage is that with
0416  * this flag set you can really be sure that set_par is always called before
0417  * any of the functions dependent on the correct hardware state or altering
0418  * that state, even if you are using some broken X releases. The disadvantage
0419  * is that it introduces unwanted delays to every console switch if set_par
0420  * is slow. It is a good idea to try this flag in the drivers initialization
0421  * code whenever there is a bug report related to switching between X and the
0422  * framebuffer console.
0423  */
0424 #define FBINFO_MISC_ALWAYS_SETPAR   0x40000
0425 
0426 /* where the fb is a firmware driver, and can be replaced with a proper one */
0427 #define FBINFO_MISC_FIRMWARE        0x80000
0428 /*
0429  * Host and GPU endianness differ.
0430  */
0431 #define FBINFO_FOREIGN_ENDIAN   0x100000
0432 /*
0433  * Big endian math. This is the same flags as above, but with different
0434  * meaning, it is set by the fb subsystem depending FOREIGN_ENDIAN flag
0435  * and host endianness. Drivers should not use this flag.
0436  */
0437 #define FBINFO_BE_MATH  0x100000
0438 /*
0439  * Hide smem_start in the FBIOGET_FSCREENINFO IOCTL. This is used by modern DRM
0440  * drivers to stop userspace from trying to share buffers behind the kernel's
0441  * back. Instead dma-buf based buffer sharing should be used.
0442  */
0443 #define FBINFO_HIDE_SMEM_START  0x200000
0444 
0445 
0446 struct fb_info {
0447     refcount_t count;
0448     int node;
0449     int flags;
0450     /*
0451      * -1 by default, set to a FB_ROTATE_* value by the driver, if it knows
0452      * a lcd is not mounted upright and fbcon should rotate to compensate.
0453      */
0454     int fbcon_rotate_hint;
0455     struct mutex lock;      /* Lock for open/release/ioctl funcs */
0456     struct mutex mm_lock;       /* Lock for fb_mmap and smem_* fields */
0457     struct fb_var_screeninfo var;   /* Current var */
0458     struct fb_fix_screeninfo fix;   /* Current fix */
0459     struct fb_monspecs monspecs;    /* Current Monitor specs */
0460     struct fb_pixmap pixmap;    /* Image hardware mapper */
0461     struct fb_pixmap sprite;    /* Cursor hardware mapper */
0462     struct fb_cmap cmap;        /* Current cmap */
0463     struct list_head modelist;      /* mode list */
0464     struct fb_videomode *mode;  /* current mode */
0465 
0466 #if IS_ENABLED(CONFIG_FB_BACKLIGHT)
0467     /* assigned backlight device */
0468     /* set before framebuffer registration,
0469        remove after unregister */
0470     struct backlight_device *bl_dev;
0471 
0472     /* Backlight level curve */
0473     struct mutex bl_curve_mutex;
0474     u8 bl_curve[FB_BACKLIGHT_LEVELS];
0475 #endif
0476 #ifdef CONFIG_FB_DEFERRED_IO
0477     struct delayed_work deferred_work;
0478     unsigned long npagerefs;
0479     struct fb_deferred_io_pageref *pagerefs;
0480     struct fb_deferred_io *fbdefio;
0481 #endif
0482 
0483     const struct fb_ops *fbops;
0484     struct device *device;      /* This is the parent */
0485     struct device *dev;     /* This is this fb device */
0486     int class_flag;                    /* private sysfs flags */
0487 #ifdef CONFIG_FB_TILEBLITTING
0488     struct fb_tile_ops *tileops;    /* Tile Blitting */
0489 #endif
0490     union {
0491         char __iomem *screen_base;  /* Virtual address */
0492         char *screen_buffer;
0493     };
0494     unsigned long screen_size;  /* Amount of ioremapped VRAM or 0 */
0495     void *pseudo_palette;       /* Fake palette of 16 colors */
0496 #define FBINFO_STATE_RUNNING    0
0497 #define FBINFO_STATE_SUSPENDED  1
0498     u32 state;          /* Hardware state i.e suspend */
0499     void *fbcon_par;                /* fbcon use-only private area */
0500     /* From here on everything is device dependent */
0501     void *par;
0502     /* we need the PCI or similar aperture base/size not
0503        smem_start/size as smem_start may just be an object
0504        allocated inside the aperture so may not actually overlap */
0505     struct apertures_struct {
0506         unsigned int count;
0507         struct aperture {
0508             resource_size_t base;
0509             resource_size_t size;
0510         } ranges[0];
0511     } *apertures;
0512 
0513     bool skip_vt_switch; /* no VT switch on suspend/resume required */
0514 };
0515 
0516 static inline struct apertures_struct *alloc_apertures(unsigned int max_num) {
0517     struct apertures_struct *a;
0518 
0519     a = kzalloc(struct_size(a, ranges, max_num), GFP_KERNEL);
0520     if (!a)
0521         return NULL;
0522     a->count = max_num;
0523     return a;
0524 }
0525 
0526 #define FBINFO_FLAG_DEFAULT FBINFO_DEFAULT
0527 
0528 /* This will go away
0529  * fbset currently hacks in FB_ACCELF_TEXT into var.accel_flags
0530  * when it wants to turn the acceleration engine on.  This is
0531  * really a separate operation, and should be modified via sysfs.
0532  *  But for now, we leave it broken with the following define
0533  */
0534 #define STUPID_ACCELF_TEXT_SHIT
0535 
0536 // This will go away
0537 #if defined(__sparc__)
0538 
0539 /* We map all of our framebuffers such that big-endian accesses
0540  * are what we want, so the following is sufficient.
0541  */
0542 
0543 // This will go away
0544 #define fb_readb sbus_readb
0545 #define fb_readw sbus_readw
0546 #define fb_readl sbus_readl
0547 #define fb_readq sbus_readq
0548 #define fb_writeb sbus_writeb
0549 #define fb_writew sbus_writew
0550 #define fb_writel sbus_writel
0551 #define fb_writeq sbus_writeq
0552 #define fb_memset sbus_memset_io
0553 #define fb_memcpy_fromfb sbus_memcpy_fromio
0554 #define fb_memcpy_tofb sbus_memcpy_toio
0555 
0556 #elif defined(__i386__) || defined(__alpha__) || defined(__x86_64__) || \
0557     defined(__hppa__) || defined(__sh__) || defined(__powerpc__) || \
0558     defined(__arm__) || defined(__aarch64__)
0559 
0560 #define fb_readb __raw_readb
0561 #define fb_readw __raw_readw
0562 #define fb_readl __raw_readl
0563 #define fb_readq __raw_readq
0564 #define fb_writeb __raw_writeb
0565 #define fb_writew __raw_writew
0566 #define fb_writel __raw_writel
0567 #define fb_writeq __raw_writeq
0568 #define fb_memset memset_io
0569 #define fb_memcpy_fromfb memcpy_fromio
0570 #define fb_memcpy_tofb memcpy_toio
0571 
0572 #else
0573 
0574 #define fb_readb(addr) (*(volatile u8 *) (addr))
0575 #define fb_readw(addr) (*(volatile u16 *) (addr))
0576 #define fb_readl(addr) (*(volatile u32 *) (addr))
0577 #define fb_readq(addr) (*(volatile u64 *) (addr))
0578 #define fb_writeb(b,addr) (*(volatile u8 *) (addr) = (b))
0579 #define fb_writew(b,addr) (*(volatile u16 *) (addr) = (b))
0580 #define fb_writel(b,addr) (*(volatile u32 *) (addr) = (b))
0581 #define fb_writeq(b,addr) (*(volatile u64 *) (addr) = (b))
0582 #define fb_memset memset
0583 #define fb_memcpy_fromfb memcpy
0584 #define fb_memcpy_tofb memcpy
0585 
0586 #endif
0587 
0588 #define FB_LEFT_POS(p, bpp)          (fb_be_math(p) ? (32 - (bpp)) : 0)
0589 #define FB_SHIFT_HIGH(p, val, bits)  (fb_be_math(p) ? (val) >> (bits) : \
0590                               (val) << (bits))
0591 #define FB_SHIFT_LOW(p, val, bits)   (fb_be_math(p) ? (val) << (bits) : \
0592                               (val) >> (bits))
0593 
0594     /*
0595      *  `Generic' versions of the frame buffer device operations
0596      */
0597 
0598 extern int fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var);
0599 extern int fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var);
0600 extern int fb_blank(struct fb_info *info, int blank);
0601 extern void cfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect);
0602 extern void cfb_copyarea(struct fb_info *info, const struct fb_copyarea *area);
0603 extern void cfb_imageblit(struct fb_info *info, const struct fb_image *image);
0604 /*
0605  * Drawing operations where framebuffer is in system RAM
0606  */
0607 extern void sys_fillrect(struct fb_info *info, const struct fb_fillrect *rect);
0608 extern void sys_copyarea(struct fb_info *info, const struct fb_copyarea *area);
0609 extern void sys_imageblit(struct fb_info *info, const struct fb_image *image);
0610 extern ssize_t fb_sys_read(struct fb_info *info, char __user *buf,
0611                size_t count, loff_t *ppos);
0612 extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
0613                 size_t count, loff_t *ppos);
0614 
0615 /* drivers/video/fbmem.c */
0616 extern int register_framebuffer(struct fb_info *fb_info);
0617 extern void unregister_framebuffer(struct fb_info *fb_info);
0618 extern int remove_conflicting_pci_framebuffers(struct pci_dev *pdev,
0619                            const char *name);
0620 extern int remove_conflicting_framebuffers(struct apertures_struct *a,
0621                        const char *name, bool primary);
0622 extern int fb_prepare_logo(struct fb_info *fb_info, int rotate);
0623 extern int fb_show_logo(struct fb_info *fb_info, int rotate);
0624 extern char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size);
0625 extern void fb_pad_unaligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 idx,
0626                 u32 height, u32 shift_high, u32 shift_low, u32 mod);
0627 extern void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, u32 height);
0628 extern void fb_set_suspend(struct fb_info *info, int state);
0629 extern int fb_get_color_depth(struct fb_var_screeninfo *var,
0630                   struct fb_fix_screeninfo *fix);
0631 extern int fb_get_options(const char *name, char **option);
0632 extern int fb_new_modelist(struct fb_info *info);
0633 
0634 extern struct fb_info *registered_fb[FB_MAX];
0635 extern int num_registered_fb;
0636 extern bool fb_center_logo;
0637 extern int fb_logo_count;
0638 extern struct class *fb_class;
0639 
0640 #define for_each_registered_fb(i)       \
0641     for (i = 0; i < FB_MAX; i++)        \
0642         if (!registered_fb[i]) {} else
0643 
0644 static inline void lock_fb_info(struct fb_info *info)
0645 {
0646     mutex_lock(&info->lock);
0647 }
0648 
0649 static inline void unlock_fb_info(struct fb_info *info)
0650 {
0651     mutex_unlock(&info->lock);
0652 }
0653 
0654 static inline void __fb_pad_aligned_buffer(u8 *dst, u32 d_pitch,
0655                        u8 *src, u32 s_pitch, u32 height)
0656 {
0657     u32 i, j;
0658 
0659     d_pitch -= s_pitch;
0660 
0661     for (i = height; i--; ) {
0662         /* s_pitch is a few bytes at the most, memcpy is suboptimal */
0663         for (j = 0; j < s_pitch; j++)
0664             *dst++ = *src++;
0665         dst += d_pitch;
0666     }
0667 }
0668 
0669 /* drivers/video/fb_defio.c */
0670 int fb_deferred_io_mmap(struct fb_info *info, struct vm_area_struct *vma);
0671 extern int  fb_deferred_io_init(struct fb_info *info);
0672 extern void fb_deferred_io_open(struct fb_info *info,
0673                 struct inode *inode,
0674                 struct file *file);
0675 extern void fb_deferred_io_cleanup(struct fb_info *info);
0676 extern int fb_deferred_io_fsync(struct file *file, loff_t start,
0677                 loff_t end, int datasync);
0678 
0679 static inline bool fb_be_math(struct fb_info *info)
0680 {
0681 #ifdef CONFIG_FB_FOREIGN_ENDIAN
0682 #if defined(CONFIG_FB_BOTH_ENDIAN)
0683     return info->flags & FBINFO_BE_MATH;
0684 #elif defined(CONFIG_FB_BIG_ENDIAN)
0685     return true;
0686 #elif defined(CONFIG_FB_LITTLE_ENDIAN)
0687     return false;
0688 #endif /* CONFIG_FB_BOTH_ENDIAN */
0689 #else
0690 #ifdef __BIG_ENDIAN
0691     return true;
0692 #else
0693     return false;
0694 #endif /* __BIG_ENDIAN */
0695 #endif /* CONFIG_FB_FOREIGN_ENDIAN */
0696 }
0697 
0698 /* drivers/video/fbsysfs.c */
0699 extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev);
0700 extern void framebuffer_release(struct fb_info *info);
0701 extern int fb_init_device(struct fb_info *fb_info);
0702 extern void fb_cleanup_device(struct fb_info *head);
0703 extern void fb_bl_default_curve(struct fb_info *fb_info, u8 off, u8 min, u8 max);
0704 
0705 /* drivers/video/fbmon.c */
0706 #define FB_MAXTIMINGS       0
0707 #define FB_VSYNCTIMINGS     1
0708 #define FB_HSYNCTIMINGS     2
0709 #define FB_DCLKTIMINGS      3
0710 #define FB_IGNOREMON        0x100
0711 
0712 #define FB_MODE_IS_UNKNOWN  0
0713 #define FB_MODE_IS_DETAILED 1
0714 #define FB_MODE_IS_STANDARD 2
0715 #define FB_MODE_IS_VESA     4
0716 #define FB_MODE_IS_CALCULATED   8
0717 #define FB_MODE_IS_FIRST    16
0718 #define FB_MODE_IS_FROM_VAR     32
0719 
0720 extern int fbmon_dpms(const struct fb_info *fb_info);
0721 extern int fb_get_mode(int flags, u32 val, struct fb_var_screeninfo *var,
0722                struct fb_info *info);
0723 extern int fb_validate_mode(const struct fb_var_screeninfo *var,
0724                 struct fb_info *info);
0725 extern int fb_parse_edid(unsigned char *edid, struct fb_var_screeninfo *var);
0726 extern const unsigned char *fb_firmware_edid(struct device *device);
0727 extern void fb_edid_to_monspecs(unsigned char *edid,
0728                 struct fb_monspecs *specs);
0729 extern void fb_destroy_modedb(struct fb_videomode *modedb);
0730 extern int fb_find_mode_cvt(struct fb_videomode *mode, int margins, int rb);
0731 extern unsigned char *fb_ddc_read(struct i2c_adapter *adapter);
0732 
0733 extern int of_get_fb_videomode(struct device_node *np,
0734                    struct fb_videomode *fb,
0735                    int index);
0736 extern int fb_videomode_from_videomode(const struct videomode *vm,
0737                        struct fb_videomode *fbmode);
0738 
0739 /* drivers/video/modedb.c */
0740 #define VESA_MODEDB_SIZE 43
0741 #define DMT_SIZE 0x50
0742 
0743 extern void fb_var_to_videomode(struct fb_videomode *mode,
0744                 const struct fb_var_screeninfo *var);
0745 extern void fb_videomode_to_var(struct fb_var_screeninfo *var,
0746                 const struct fb_videomode *mode);
0747 extern int fb_mode_is_equal(const struct fb_videomode *mode1,
0748                 const struct fb_videomode *mode2);
0749 extern int fb_add_videomode(const struct fb_videomode *mode,
0750                 struct list_head *head);
0751 extern void fb_delete_videomode(const struct fb_videomode *mode,
0752                 struct list_head *head);
0753 extern const struct fb_videomode *fb_match_mode(const struct fb_var_screeninfo *var,
0754                         struct list_head *head);
0755 extern const struct fb_videomode *fb_find_best_mode(const struct fb_var_screeninfo *var,
0756                             struct list_head *head);
0757 extern const struct fb_videomode *fb_find_nearest_mode(const struct fb_videomode *mode,
0758                                struct list_head *head);
0759 extern void fb_destroy_modelist(struct list_head *head);
0760 extern void fb_videomode_to_modelist(const struct fb_videomode *modedb, int num,
0761                      struct list_head *head);
0762 extern const struct fb_videomode *fb_find_best_display(const struct fb_monspecs *specs,
0763                                struct list_head *head);
0764 
0765 /* drivers/video/fbcmap.c */
0766 extern int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp);
0767 extern int fb_alloc_cmap_gfp(struct fb_cmap *cmap, int len, int transp, gfp_t flags);
0768 extern void fb_dealloc_cmap(struct fb_cmap *cmap);
0769 extern int fb_copy_cmap(const struct fb_cmap *from, struct fb_cmap *to);
0770 extern int fb_cmap_to_user(const struct fb_cmap *from, struct fb_cmap_user *to);
0771 extern int fb_set_cmap(struct fb_cmap *cmap, struct fb_info *fb_info);
0772 extern int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *fb_info);
0773 extern const struct fb_cmap *fb_default_cmap(int len);
0774 extern void fb_invert_cmaps(void);
0775 
0776 struct fb_videomode {
0777     const char *name;   /* optional */
0778     u32 refresh;        /* optional */
0779     u32 xres;
0780     u32 yres;
0781     u32 pixclock;
0782     u32 left_margin;
0783     u32 right_margin;
0784     u32 upper_margin;
0785     u32 lower_margin;
0786     u32 hsync_len;
0787     u32 vsync_len;
0788     u32 sync;
0789     u32 vmode;
0790     u32 flag;
0791 };
0792 
0793 struct dmt_videomode {
0794     u32 dmt_id;
0795     u32 std_2byte_code;
0796     u32 cvt_3byte_code;
0797     const struct fb_videomode *mode;
0798 };
0799 
0800 extern const char *fb_mode_option;
0801 extern const struct fb_videomode vesa_modes[];
0802 extern const struct dmt_videomode dmt_modes[];
0803 
0804 struct fb_modelist {
0805     struct list_head list;
0806     struct fb_videomode mode;
0807 };
0808 
0809 extern int fb_find_mode(struct fb_var_screeninfo *var,
0810             struct fb_info *info, const char *mode_option,
0811             const struct fb_videomode *db,
0812             unsigned int dbsize,
0813             const struct fb_videomode *default_mode,
0814             unsigned int default_bpp);
0815 
0816 /* Convenience logging macros */
0817 #define fb_err(fb_info, fmt, ...)                   \
0818     pr_err("fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__)
0819 #define fb_notice(info, fmt, ...)                   \
0820     pr_notice("fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__)
0821 #define fb_warn(fb_info, fmt, ...)                  \
0822     pr_warn("fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__)
0823 #define fb_info(fb_info, fmt, ...)                  \
0824     pr_info("fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__)
0825 #define fb_dbg(fb_info, fmt, ...)                   \
0826     pr_debug("fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__)
0827 
0828 #endif /* _LINUX_FB_H */