- include/linux/fb.h
- struct fb_info {
- int node; /* node成员域标示了特定的FrameBuffer,
- * 实际上也就是一个FrameBuffer设备的次设备号
- */
- int flags;
- struct fb_var_screeninfo var; /* LCD可变参数结构体 */
- struct fb_fix_screeninfo fix; /* LCD固定参数结构体 */
- struct fb_monspecs monspecs; /* LCD显示器标准 */
- struct work_struct queue; /* 帧缓冲事件队列 */
- struct fb_pixmap pixmap; /* 图像硬件mapper(Image hardware mapper) */
- struct fb_pixmap sprite; /* 光标硬件mapper(Cursor hardware mapper) */
- struct fb_cmap cmap; /* 当前颜色表(Current cmap) */
- struct list_head modelist; /* mode list */
- struct fb_videomode *mode; /* 当前的显示模式(current mode) */
- #ifdef CONFIG_FB_BACKLIGHT /* assigned backlight device */
- /* set before framebuffer registration,
- * remove after unregister
- */
- struct backlight_device *bl_dev; /* 对应的背光设备 */
- struct mutex bl_curve_mutex;
- u8 bl_curve[FB_BACKLIGHT_LEVELS]; /* 背光调整(Backlight level curve) */
- #endif
- #ifdef CONFIG_FB_DEFERRED_IO /* 延迟IO */
- struct delayed_work deferred_work;
- struct fb_deferred_io *fbdefio;
- #endif
- struct fb_ops *fbops; /* 对底层硬件操作的函数指针 */
- struct device *device; /* This is the parent */
- struct device *dev; /* This is this fb device */
- int class_flag; /* private sysfs flags */
- #ifdef CONFIG_FB_TILEBLITTING
- struct fb_tile_ops *tileops; /* Tile Blitting(blit -- Bit-Block Image Transfer) */
- #endif
- char __iomem *screen_base; /* 虚拟基地址(Virtual address) */
- unsigned long screen_size; /* LCD IO映射的虚拟内存大小(Amount of ioremapped VRAM or 0) */
- void *pseudo_palette; /* 伪16色颜色表(Fake palette of 16 colors) */
- #define FBINFO_STATE_RUNNING 0
- #define FBINFO_STATE_SUSPENDED 1
- u32 state; /* LCD硬件状态,如运行和挂起(Hardware state i.e suspend) */
- void *fbcon_par; /* fbcon use-only private area */
- /* From here on everything is device dependent */
- void *par;
- };/* struct fb_info */
- struct fb_var_screeninfo {
- __u32 xres; /* 可见屏幕一行的像素点数(visible resolution) */
- __u32 yres; /* 可见屏幕一列的像素点数 */
- __u32 xres_virtual; /* 虚拟屏幕一行的像素点数(virtual resolution) */
- __u32 yres_virtual; /* 虚拟屏幕一列的像素点数 */
- __u32 xoffset; /* 虚拟到可见屏幕之间的行偏移(offset from virtual to visible) */
- __u32 yoffset; /* 虚拟到可见屏幕之间的列偏移 */
- __u32 bits_per_pixel; /* 每个像素的位数即BPP */
- __u32 grayscale; /* 非0时,指的是灰度(!= 0 Graylevels instead of colors) */
- struct fb_bitfield red; /* bitfield in fb mem if true color,
- * else only length is significant
- */
- struct fb_bitfield green; /* fb缓存的G位域 */
- struct fb_bitfield blue; /* fb缓存的B位域 */
- struct fb_bitfield transp; /* 透明度(transparency )*/
- __u32 nonstd; /* 非0,非标准像素格式(!= 0 Non standard pixel format) */
- __u32 activate; /* see FB_ACTIVATE_* */
- __u32 height; /* 图像高度(height of picture in mm)*/
- __u32 width; /* 图像宽度(width of picture in mm)*/
- __u32 accel_flags; /* (OBSOLETE) see fb_info.flags */
- /* Timing: All values in pixclocks, except pixclock (of course) */
- /* 定时:除了pixclock本身外,其他的都以像素时钟为单位 */
- __u32 pixclock; /* 像素时钟,皮秒(pixel clock in ps (pico seconds)) */
- __u32 left_margin; /* 行切换,从同步到绘图之间的延迟(time from sync to picture)*/
- __u32 right_margin; /* 行切换,从绘图到同步之间的延迟(time from picture to sync)*/
- __u32 upper_margin; /* 帧切换,从同步到绘图之间的延迟(time from sync to picture)*/
- __u32 lower_margin; /* 帧切换,从绘图到同步之间的延迟(time from picture to sync)*/
- __u32 hsync_len; /* 水平同步的长度(length of horizontal sync)*/
- __u32 vsync_len; /* 垂直同步的长度(length of vertical sync)*/
- __u32 sync; /* see FB_SYNC_* */
- __u32 vmode; /* see FB_VMODE_* */
- __u32 rotate; /* angle we rotate counter clockwise */
- __u32 reserved[5]; /* 保留(Reserved for future compatibility)*/
- };/* struct fb_var_screeninfo */
- /* Interpretation of offset for color fields: All offsets are from the right,
- * inside a "pixel" value, which is exactly 'bits_per_pixel' wide (means: you
- * can use the offset as right argument to <<). A pixel afterwards is a bit
- * stream and is written to video memory as that unmodified. This implies
- * big-endian byte order if bits_per_pixel is greater than 8.
- */
- struct fb_bitfield {
- __u32 offset; /* beginning of bitfield */
- __u32 length; /* length of bitfield */
- __u32 msb_right; /* != 0 : Most significant bit is right */
- };
- struct fb_fix_screeninfo {
- char id[16]; /* 字符串形式的标示符(identification string eg "TT Builtin")*/
- unsigned long smem_start; /* fb缓存的起始位置(Start of frame buffer mem)*/
- /* (physical address) */
- __u32 smem_len; /* fb缓存的长度(Length of frame buffer mem)*/
- __u32 type; /* see FB_TYPE_* */
- __u32 type_aux; /* 分界(Interleave for interleaved Planes)*/
- __u32 visual; /* see FB_VISUAL_* */
- __u16 xpanstep; /* 如果没有硬件panning,就赋值为0(zero if no hardware panning)*/
- __u16 ypanstep; /* 如果没有硬件panning,就赋值为0(zero if no hardware panning)*/
- __u16 ywrapstep; /* 如果没有硬件ywrap,就赋值为0(zero if no hardware ywrap)*/
- __u32 line_length; /* 一行的字节数(length of a line in bytes)*/
- unsigned long mmio_start; /* 内存映射IO的起始位置(Start of Memory Mapped I/O)*/
- /* (physical address) */
- __u32 mmio_len; /* 内存映射IO的长度(Length of Memory Mapped I/O)*/
- __u32 accel; /* Indicate to driver which */
- /* specific chip/card we have */
- __u16 reserved[3]; /* Reserved for future compatibility */
- };/* struct fb_fix_screeninfo */
- struct fb_monspecs {
- struct fb_chroma chroma;
- struct fb_videomode *modedb; /* mode database */
- __u8 manufacturer[4]; /* Manufacturer */
- __u8 monitor[14]; /* Monitor String */
- __u8 serial_no[14]; /* Serial Number */
- __u8 ascii[14]; /* ? */
- __u32 modedb_len; /* mode database length */
- __u32 model; /* Monitor Model */
- __u32 serial; /* Serial Number - Integer */
- __u32 year; /* Year manufactured */
- __u32 week; /* Week Manufactured */
- __u32 hfmin; /* hfreq lower limit (Hz) */
- __u32 hfmax; /* hfreq upper limit (Hz) */
- __u32 dclkmin; /* pixelclock lower limit (Hz) */
- __u32 dclkmax; /* pixelclock upper limit (Hz) */
- __u16 input; /* display type - see FB_DISP_* */
- __u16 dpms; /* DPMS support - see FB_DPMS_ */
- __u16 signal; /* Signal Type - see FB_SIGNAL_* */
- __u16 vfmin; /* vfreq lower limit (Hz) */
- __u16 vfmax; /* vfreq upper limit (Hz) */
- __u16 gamma; /* Gamma - in fractions of 100 */
- __u16 gtf : 1; /* supports GTF */
- __u16 misc; /* Misc flags - see FB_MISC_* */
- __u8 version; /* EDID version... */
- __u8 revision; /* ...and revision */
- __u8 max_x; /* Maximum horizontal size (cm) */
- __u8 max_y; /* Maximum vertical size (cm) */
- };/* struct fb_monspecs */
- struct fb_pixmap {
- u8 *addr; /* pointer to memory */
- u32 size; /* size of buffer in bytes */
- u32 offset; /* current offset to buffer */
- u32 buf_align; /* byte alignment of each bitmap */
- u32 scan_align; /* alignment per scanline */
- u32 access_align; /* alignment per read/write (bits) */
- u32 flags; /* see FB_PIXMAP_* */
- u32 blit_x; /* supported bit block dimensions (1-32)*/
- u32 blit_y; /* Format: blit_x = 1 << (width - 1) */
- /* blit_y = 1 << (height - 1) */
- /* if 0, will be set to 0xffffffff (all)*/
- /* access methods */
- void (*writeio)(struct fb_info *info, void __iomem *dst, void *src, unsigned int size);
- void (*readio) (struct fb_info *info, void *dst, void __iomem *src, unsigned int size);
- };/* struct fb_pixmap */
- struct fb_cmap {
- __u32 start; /* First entry */
- __u32 len; /* Number of entries */
- __u16 *red; /* Red values */
- __u16 *green;
- __u16 *blue;
- __u16 *transp; /* transparency, can be NULL */
- };
- struct fb_videomode {
- const char *name; /* optional */
- u32 refresh; /* optional */
- u32 xres;
- u32 yres;
- u32 pixclock;
- u32 left_margin;
- u32 right_margin;
- u32 upper_margin;
- u32 lower_margin;
- u32 hsync_len;
- u32 vsync_len;
- u32 sync;
- u32 vmode;
- u32 flag;
- };
- struct backlight_device {
- /* Backlight properties */
- struct backlight_properties props;
- /* Serialise access to update_status method */
- struct mutex update_lock;
- /* This protects the 'ops' field. If 'ops' is NULL, the driver that
- registered this device has been unloaded, and if class_get_devdata()
- points to something in the body of that driver, it is also invalid. */
- struct mutex ops_lock;
- struct backlight_ops *ops;
- /* The framebuffer notifier block */
- struct notifier_block fb_notif;
- struct device dev;
- };
- struct mutex {
- /* 1: unlocked, 0: locked, negative: locked, possible waiters */
- atomic_t count;
- spinlock_t wait_lock;
- struct list_head wait_list;
- #ifdef CONFIG_DEBUG_MUTEXES
- struct thread_info *owner;
- const char *name;
- void *magic;
- #endif
- #ifdef CONFIG_DEBUG_LOCK_ALLOC
- struct lockdep_map dep_map;
- #endif
- };
- /*
- * Frame buffer operations
- *
- * LOCKING NOTE: those functions must _ALL_ be called with the console
- * semaphore held, this is the only suitable locking mechanism we have
- * in 2.6. Some may be called at interrupt time at this point though.
- */
- struct fb_ops {
- /* open/release and usage marking */
- struct module *owner;
- int (*fb_open)(struct fb_info *info, int user);
- int (*fb_release)(struct fb_info *info, int user);
- /* For framebuffers with strange non linear layouts(布局,结构) or that do not
- * work with normal memory mapped access
- */
- ssize_t (*fb_read)(struct fb_info *info, char __user *buf, size_t count, loff_t *ppos);
- ssize_t (*fb_write)(struct fb_info *info, const char __user *buf, size_t count, loff_t *ppos);
- /* checks var and eventually tweaks(调整) it to something supported,
- * DO NOT MODIFY PAR */
- int (*fb_check_var)(struct fb_var_screeninfo *var, struct fb_info *info);
- /* set the video mode according to info->var */
- int (*fb_set_par)(struct fb_info *info);
- /* set color register */
- int (*fb_setcolreg)(unsigned regno, unsigned red, unsigned green,
- unsigned blue, unsigned transp, struct fb_info *info);
- /* set color registers in batch(批量) */
- int (*fb_setcmap)(struct fb_cmap *cmap, struct fb_info *info);
- /* blank display */
- int (*fb_blank)(int blank, struct fb_info *info);
- /* pan display */
- int (*fb_pan_display)(struct fb_var_screeninfo *var, struct fb_info *info);
- /* Draws a rectangle */
- void (*fb_fillrect) (struct fb_info *info, const struct fb_fillrect *rect);
- /* Copy data from area to another */
- void (*fb_copyarea) (struct fb_info *info, const struct fb_copyarea *region);
- /* Draws a image to the display */
- void (*fb_imageblit) (struct fb_info *info, const struct fb_image *image);
- /* Draws cursor */
- int (*fb_cursor) (struct fb_info *info, struct fb_cursor *cursor);
- /* Rotates the display */
- void (*fb_rotate)(struct fb_info *info, int angle);
- /* wait for blit(位块传送) idle, optional */
- int (*fb_sync)(struct fb_info *info);
- /* perform fb specific ioctl (optional) */
- int (*fb_ioctl)(struct fb_info *info, unsigned int cmd,
- unsigned long arg);
- /* Handle 32bit compat(兼容) ioctl (optional) */
- int (*fb_compat_ioctl)(struct fb_info *info, unsigned cmd,
- unsigned long arg);
- /* perform fb specific mmap */
- int (*fb_mmap)(struct fb_info *info, struct vm_area_struct *vma);
- /* save current hardware state */
- void (*fb_save_state)(struct fb_info *info);
- /* restore saved state */
- void (*fb_restore_state)(struct fb_info *info);
- /* get capability given var */
- void (*fb_get_caps)(struct fb_info *info, struct fb_blit_caps *caps,
- struct fb_var_screeninfo *var);
- };/* struct fb_ops */
/***********************************************
***********************************************
***********************************************/
*transp = 0; //表示不支持透明度
fix->accel = FB_ACCEL_NONE; //表示显卡无硬件加速
var->xres = 400; 表示x 方向分辨率
var->yres = 234; //表示y 方向分辨率
//虚拟分辨率,不支持 pan,故和实际分辨率一致
var->xres_virtual = 400;
var->yres_virtual = 234;
//色深 16 位,5:6:5 结构
var->bits_per_pixel = 16;
//彩色,非灰度,bpp<8,grayscale=1
var->grayscale = 0;
//每行字节数,每行 400 象素,16 位色深,故 400*2
display.line_length = 400 * 2;
调用函数“fb_videomode_to_var(&var, &video_modes[0])”将屏幕显示参数转换为var结构变量的相关成员,