定义当显卡的当前状态;fb_info结构仅在内核中可见,在这个结构中有一个fb_ops指针, 指向驱动设备工作所需的函数集。
- struct fb_info {
- char modename[40]; /* default video mode */
- kdev_t node;
- int flags;
- int open; /* Has this been open already ? */
- #define FBINFO_FLAG_MODULE 1 /* Low-level driver is a module */
- struct fb_var_screeninfo var; /* Current var */
- struct fb_fix_screeninfo fix; /* Current fix */
- struct fb_monspecs monspecs; /* Current Monitor specs */
- struct fb_cmap cmap; /* Current cmap */
- struct fb_ops *fbops;
- char *screen_base; /* Virtual address */
- struct display *disp; /* initial display variable */
- struct vc_data *display_fg; /* Console visible on this display */
- char fontname[40]; /* default font name */
- devfs_handle_t devfs_handle; /* Devfs handle for new name */
- devfs_handle_t devfs_lhandle; /* Devfs handle for compat. symlink */
- int (*changevar)(int); /* tell console var has changed */
- int (*switch_con)(int, struct fb_info*);
- /* tell fb to switch consoles */
- int (*updatevar)(int, struct fb_info*);
- /* tell fb to update the vars */
- void (*blank)(int, struct fb_info*); /* tell fb to (un)blank the screen */
- /* arg = 0: unblank */
- /* arg > 0: VESA level (arg-1) */
- void *pseudo_palette; /* Fake palette of 16 colors and
- the cursor's color for non
- palette mode */
- /* From here on everything is device dependent */
- void *par;
- };
5) struct fb_ops
用户应用可以使用ioctl()系统调用来操作设备,这个结构就是用一支持ioctl()的这些操作的。
- 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);
- /* get non settable parameters */
- int (*fb_get_fix)(struct fb_fix_screeninfo *fix, int con,
- struct fb_info *info);
- /* get settable parameters */
- int (*fb_get_var)(struct fb_var_screeninfo *var, int con,
- struct fb_info *info);
- /* set settable parameters */
- int (*fb_set_var)(struct fb_var_screeninfo *var, int con,
- struct fb_info *info);
- /* get colormap */
- int (*fb_get_cmap)(struct fb_cmap *cmap, int kspc, int con,
- struct fb_info *info);
- /* set colormap */
- int (*fb_set_cmap)(struct fb_cmap *cmap, int kspc, int con,
- struct fb_info *info);
- /* pan display (optional) */
- int (*fb_pan_display)(struct fb_var_screeninfo *var, int con,
- struct fb_info *info);
- /* perform fb specific ioctl (optional) */
- int (*fb_ioctl)(struct inode *inode, struct file *file, unsigned int cmd,
- unsigned long arg, int con, struct fb_info *info);
- /* perform fb specific mmap */
- int (*fb_mmap)(struct fb_info *info, struct file *file, struct
- vm_area_struct *vma);
- /* switch to/from raster image mode */
- int (*fb_rasterimg)(struct fb_info *info, int start);
- };
6) structure map
struct fb_info_gen | struct fb_info | fb_var_screeninfo
| | fb_fix_screeninfo
| | fb_cmap
| | modename[40]
| | fb_ops ---|--->ops on var
| | ... | fb_open
| | | fb_release
| | | fb_ioctl
| | | fb_mmap
| struct fbgen_hwswitch -|-> detect
| | encode_fix
| | encode_var
| | decode_fix
| | decode_var
| | get_var
| | set_var
| | getcolreg
| | setcolreg
| | pan_display
| | blank
| | set_disp
[编排有点困难,第一行的第一条竖线和下面的第一列竖线对齐,第一行的第二条竖线和下面的第二列竖���对齐就可以了]
这个结构 fbgen_hwswitch抽象了硬件的操作.虽然它不是必需的,但有时候很有用.
