视频驱动程序概念整理
来源:互联网 发布:人工智能经济学 编辑:程序博客网 时间:2024/06/06 18:21
- 分析驱动之前,先说明下LCD有关概念:
1.1. LCD,即液晶显示器,有多种类型,比如STN,TFT,LTPS TFT,OLED等,各有优缺点。
1.2. Cpu或显卡发出的数据都是TTL信号,通常是LCD控制器发出,LCD本身接收的也是TTL信号,不管采用何种的信号传输,本质都是TTL信号。
1.3. LCD控制器输出的数据会将18 bit的数据分组,红绿蓝6 bit。
1.4. 一幅图像称为一帧,每帧多行组成,每行由多个像素组成,每个像素由若干位来表示,比如由8 bit表示一个像素,称为8Bpp。
1.5. 传输数据之前,需要设置一系列信号,比如VSYNC等,然后将帧缓存地址告诉LCD控制器,LCD控制器会自动发起DMA传输,并在上述设置好的信号下将数据传到VD[23:0]上。 - Linux 视频子系统:
2.1 帧缓冲(frame buffer)是Linux视频子系统的一个重要概念,帧缓冲进行了一般化的抽象并规定编程接口,帧缓冲允许App与图形硬件的变化无关。
2.2 子系统一些参数
为了方便理解,在ubuntu执行sudo fbset,会打印一下信息:
destop@ubuntu:~$ sudo fbsetmode "800x600" geometry 800 600 2048 1920 32 timings 0 0 0 0 0 0 0 rgba 8/16,8/8,8/0,0/0endmode
geometry(几何形状)后面表示分辨率,一个像素使用32 bit,
timings 第一个参数是一个像素的绘制速率,在带有LCD设备上执行会有相应数字出现。
fbset可以选择帧缓冲设备的设备性能。
注: 打印信息有会D: xxMHz,D为dotclock,表示视频硬件绘制像素的速率。
3. 帧缓冲API
3.1 帧缓冲核心层,向App层生成设备节点,供App操作设备。
3.2 帧缓冲核心层的数据结构主要存在include/linux/fb.h中,用户层的数据存在usr/include/linux/fb.h。
3.3 视频卡的基本属性,比如分辨率,每个像素占的bit等;数据结构如下:
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; /* resolution */ __u32 bits_per_pixel; /* guess what */ __u32 grayscale; /* != 0 Graylevels instead of colors */ struct fb_bitfield red; /* bitfield in fb mem if true color, */ struct fb_bitfield green; /* else only length is significant */ struct fb_bitfield blue; struct fb_bitfield transp; /* transparency */ __u32 nonstd; /* != 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) */ __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; __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 */};
3.4 视频卡的一些固定信息保存在fb_fix_screeninfo中,用户无权更改。
struct fb_fix_screeninfo { char id[16]; /* identification string eg "TT Builtin" */ unsigned long smem_start; /* Start of frame buffer mem */ /* (physical address) */ __u32 smem_len; /* Length of frame buffer mem */ __u32 type; /* see FB_TYPE_* */ __u32 type_aux; /* Interleave for interleaved Planes */ __u32 visual; /* see FB_VISUAL_* */ __u16 xpanstep; /* zero if no hardware panning */ __u16 ypanstep; /* zero if no hardware panning */ __u16 ywrapstep; /* zero if no hardware ywrap */ __u32 line_length; /* length of a line in bytes */ 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 reserved[3]; /* Reserved for future compatibility */};
3.5 fb_cmap 规定了颜色映射,将用户定义的颜色分配信息传给底层硬件,可以用这个结构体定义RGB的配比来获得不同颜色的分配。
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 */};
3.6 fb_info结构体
struct fb_info { int node; int flags; struct fb_var_screeninfo var; /* Current var */ struct fb_fix_screeninfo fix; /* Current fix */ 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; 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; /* Virtual address */ unsigned long screen_size; /* Amount of ioremapped VRAM or 0 */ void *pseudo_palette; /* Fake palette of 16 colors */ #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; };
fb_info是帧缓冲设备的核心数据结构,成员包括上文所述的数据结构,通过framebuffer_alloc()分配。
3.6 fb_ops结构体
fb_ops 包括了底层帧缓冲驱动程序提供的所有函数指针.
/* * 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);};
后续内容以后再补充。
阅读全文
0 0
- 视频驱动程序概念整理
- 视频驱动程序
- Linux设备驱动程序概念
- 视频 概念
- 概念整理
- 视频微端口驱动程序
- 1.设备驱动程序的概念
- 块设备驱动程序概念介绍
- 字符设备驱动程序----概念分析
- USB驱动程序之概念介绍
- 视频流概念
- 视频流概念
- 视频相关概念收集
- 视频监控相关概念
- 视频监控概念
- 视频的一些概念
- 视频流概念
- 视频相关概念
- 一张图看懂JavaScript中数组的迭代方法:forEach、map、filter、reduce、every、some
- 【云星数据---大数据集群部署系列006】:spark2.2部署方案
- MyBatis中对List<Object> 对象List的批处理插入操作
- [leetcode]455. Assign Cookies
- 面试会遇到的一些问题
- 视频驱动程序概念整理
- hbase架构原理之region、memstore、hfile、hlog、columm-family、colum、cell
- 安卓图片处理技术
- js复制文本内容到右键粘贴
- [51nod1824]染色游戏
- sqlserver中触发器
- 测试
- 消息队列-beanstalkd
- listen 函数