Linux LCD重要数据结构解析

Table of Contents

一、struct fb_info

1.1、struct fb_var_screeninfo

1.2、struct fb_fix_screeninfo

二、struct fb_videomode

三、 struct s3c_fb_platdata (填充platform_data)

3.1、struct s3c_fb_pd_win(窗口结构体)


一、struct fb_info

Fb.h linux-3.5\include\Linux
 

用法:

//驱动程序必须用这个结构体定义的成员,并且从平台设备数据中取出信息对该结构体进行填充

struct fb_info {
atomic_t count;
int node;
int flags;
struct mutex lock; /* Lock for open/release/ioctl funcs */
struct mutex mm_lock; /* Lock for fb_mmap and smem_* fields */
struct fb_var_screeninfo var; /* LCD 屏的可变参数 */
struct fb_fix_screeninfo fix; /* LCD 屏的可变参数*/

struct fb_monspecs monspecs; /* Current Monitor specs */
struct work_struct queue; /* Framebuffer event queue */
struct fb_pixmap pixmap; /* Image hardware mapper */
struct fb_pixmap sprite; /* 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;
/* Backlight level curve */
struct mutex bl_curve_mutex;
u8 bl_curve[FB_BACKLIGHT_LEVELS];
#endif
#ifdef CONFIG_FB_DEFERRED_IO
struct delayed_work deferred_work;
struct fb_deferred_io *fbdefio;
#endif
struct fb_ops *fbops; /* 真正操作 LCD 硬件寄存器的方法集合 */
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 */
#endif
char __iomem *screen_base; /* LCD 显存的虚拟址 */
unsigned long screen_size; /* Amount of ioremapped VRAM or 0 */
void *pseudo_palette; /* 指向 16 种颜色调试板,其实就是一块内存 */
#define FBINFO_STATE_RUNNING 0
#define FBINFO_STATE_SUSPENDED 1
u32 state; /* Hardware state i.e suspend */
void *fbcon_par; /* fbcon use-only private area */
/* From here on everything is device dependent */
void *par; /* 私有数据,驱动编程者可以用来存放自己的数据结构地址*/
/* we need the PCI or similar aperture base/size not
smem_start/size as smem_start may just be an object
allocated inside the aperture so may not actually overlap */
struct apertures_struct {
unsigned int count;
struct aperture {
resource_size_t base;
resource_size_t size;
} ranges[0];
} *apertures;
};

1.1、struct fb_var_screeninfo

struct fb_var_screeninfo {
__u32 xres; /* 可见屏幕一行有多少个像素点*/
__u32 yres; /* 可见屏幕一屏有多少行*/
__u32 xres_virtual; /* 虚拟屏幕一行有多少个像素点*/
__u32 yres_virtual; /* 虚拟屏幕一屏有多少行*/
__u32 xoffset; /*虚拟屏到实际屏的水平偏移量*/
__u32 yoffset; /*虚拟屏到实际屏的垂直偏移量*/

__u32 bits_per_pixel; /* LCD 屏工作时 BPP */
__u32 grayscale; /* 0 = 彩屏, 1 = 灰度,非彩屏,一般不使用了 */
struct fb_bitfield red; /*红色的长度和偏移信息, */
struct fb_bitfield green; /* 绿色的长度和偏移信息, */
struct fb_bitfield blue; /* 蓝色的长度和偏移信息, */
struct fb_bitfield transp; /* 透明度的长度和偏移信息,*/
__u32 nonstd; /* 0==0 表示标准像素格式,基本都是标准*/
//修改可变参数生效时刻,一般是马上生效,对应值是 0,宏名是 FB_ACTIVATE_NOW
__u32 activate; /* see FB_ACTIVATE_* :FB_ACTIVATE_NOW,FB_ACTIVATE_NXTOPEN */
//存放物理屏的物理尺寸,是外观尺寸,单位 mm ,可选的
__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)


以下是 LCD 屏的工作时序,对应的前面移植 LCD 传递下来的 struct fb_videomode 结构 */
__u32 pixclock; /* pixel clock in ps (pico seconds) */
__u32 left_margin; /* time from sync to picture HBPD*/
__u32 right_margin; /* time from picture to sync HFPD */
__u32 upper_margin; /* time from sync to picture VBPD*/
__u32 lower_margin; /* VFPB */
__u32 hsync_len; /* length of horizontal sync HSPW*/
__u32 vsync_len; /* length of vertical sync VSPW */

__u32 sync; /* see FB_SYNC_* */
__u32 vmode; /* see FB_VMODE_* */
__u32 rotate; /* angle we rotate counter clockwise */
__u32 colorspace; /* colorspace for FOURCC-based modes */
__u32 reserved[4]; /* Reserved for future compatibility */
};

1.2、struct fb_fix_screeninfo

struct fb_fix_screeninfo {
char id[16]; /*lcd 标识名,随便*/
unsigned long smem_start; /*显存物理起始地址,注意,是物理址,不是虚拟地址*/
__u32 smem_len; /*显存的内存长度 */
__u32 type; /* see FB_TYPE_*, FB_TYPE_PACKED_PIXELS 表示像素类型,一般都标准像素格式 */
__u32 type_aux; /* Interleave for interleaved Planes */
__u32 visual; /* FB_VISUAL_TRUECOLOR,FB_VISUAL_PSEUDOCOLOR */
__u16 xpanstep; /* 如果没有硬件平移功能设置为 0 */
__u16 ypanstep; /*如果没有硬件平移功能设置为 0 */

__u16 ywrapstep; /* zero if no hardware ywrap */
__u32 line_length; /* 一行占用的内存字节数 */
unsigned long mmio_start; /* Start of Memory Mapped I/O, (physical address) */
__u32 mmio_len; /* Length of Memory Mapped I/O */
__u32 accel; /* Indicate to driver which specific chip/card we have */
__u16 capabilities; /* see FB_CAP_* */
__u16 reserved[2]; /* Reserved for future compatibility */
};

二、struct fb_videomode

定义文件: linux/fb.h

用法:

//struct fb_videomode 结构体定义的成员给平台驱动传递时间参数,便于LCD平台驱动程序设置时间相关的寄存器

struct fb_videomode {
const char *name; /* 名字,随便 */
u32 refresh; /* optional */
u32 xres; /* 物理屏的有水平方向的分辨率 */
u32 yres; /* 物理屏的有垂直方向的分辨率 */
u32 pixclock; /* LCD 屏的 VCLK 频率,单位是皮秒, 10^6/VCLK ,VCLK 单位 M */
u32 left_margin; /* 对于 lcd 屏的 HBPD */
u32 right_margin; /* 对于 lcd 屏的 HFPD */
u32 upper_margin; /* 对于 lcd 屏的 VBPD */
u32 lower_margin; /* 对于 lcd 屏的 VFPD */
u32 hsync_len; /* 对于 lcd 屏的水平同步脉冲信号宽度 HSPW*/
u32 vsync_len; /* 对于 lcd 屏的垂直同步脉冲信号宽度 VSPW*/
u32 sync; /* 表示同步脉冲信号极性 */
u32 vmode; /* 表示 LCD 屏的扫描方式*/
u32 flag;
};


sync 值内核有规定好对应的宏:
#define FB_SYNC_HOR_HIGH_ACT 1 /* horizontal sync high active */
#define FB_SYNC_VERT_HIGH_ACT 2 /* vertical sync high active */
flag 值内核有规定好对应的宏:
#define FB_VMODE_NONINTERLACED 0 /* non interlaced 非隔行扫描 */
#define FB_VMODE_INTERLACED 1 /* interlaced 隔行扫描*/
#define FB_VMODE_DOUBLE 2 /* double scan 双扫描*/
#define FB_VMODE_ODD_FLD_FIRST 4 /* interlaced: top line first */

三、 struct s3c_fb_platdata (填充platform_data)

用法:

//用s3c_fb_platdata结构体定义的成员用于填充platform_device->dev->platform_data成员,以便于lcd平台驱动取出平台数据

struct s3c_fb_platdata {
    void    (*setup_gpio)(void);

    struct s3c_fb_pd_win    *win[S3C_FB_MAX_WIN]; //tiny4412 LCD有5个窗口
    struct fb_videomode     *vtiming;

    u32             vidcon0;
    u32             vidcon1;
};

3.1、struct s3c_fb_pd_win(窗口结构体)

struct s3c_fb_pd_win {
    unsigned short        default_bpp;
    unsigned short        max_bpp;
    unsigned short        xres;
    unsigned short        yres;
    unsigned short        virtual_x;
    unsigned short        virtual_y;
    unsigned short        width;
    unsigned short        height;
};
 

发布了135 篇原创文章 · 获赞 112 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/shenlong1356/article/details/104427367
今日推荐