我敲写了一遍 程序,然后补充了 fb_fix_screeninfo 和 fb_var_screeninfo 结构体元素的内容测试
完整的代码:
framebuff-myself-press.rar 其中一部分的代码:
- ioctl(fdfd,FBIOGET_FSCREENINFO,&finfo); //获取 固定参数
-
-
printf("id %s\n",finfo.id); s3c2410fb
-
printf("smem_start %d\n",finfo.smem_start); //帧缓冲 内存开始地址,物理地址
-
printf("smem_len %d\n",finfo.smem_len); // 帧缓冲 内存 长度
-
printf("type %d\n",finfo.type);
-
printf("type_aux %d\n",finfo.type_aux);//平面交织交替
-
printf("visual %d\n",finfo.visual); //记录 色彩模式 2
-
printf("xpanstep %d\n",finfo.xpanstep);//如果没有硬件panning,赋0
-
printf("ypanstep %d\n",finfo.ypanstep);
-
printf("line_length %d\n",finfo.line_length); 640
-
printf("mmio_start %d\n",finfo.mmio_start);//内存映射IO开始地址 物理地址
-
printf("mmio_len %d\n",finfo.mmio_len);//内存映射IO 长度
-
printf("accel %d\n\n",finfo.accel);
-
-
-
ioctl(fdfd,FBIOGET_VSCREENINFO,&vinfo); //获取可变参数
-
-
printf("xres %d\n",vinfo.xres); //可见解析度 320
-
printf("yres %d\n",vinfo.yres); 240
-
printf("xres_virturl %d\n",vinfo.xres_virtual); //虚拟解析度 320
-
printf("yres_virtual %d\n",vinfo.yres_virtual); 240
-
printf("xoffset %d\n",vinfo.xoffset); //虚拟到可见的偏移 0
-
printf("yoffset %d\n",vinfo.yoffset); 0
-
printf("bits_per_pixel %d\n",vinfo.bits_per_pixel); //每像素位数 bpp 16
-
printf("grayscale %d\n",vinfo.grayscale);//非零时,指灰度
-
-
printf("fb_bitfield red.offset %d\n",vinfo.red.offset); 11 偏移11位
-
printf("fb_bitfield .length %d\n",vinfo.red.length); 5
-
printf("fb_bitfield .msb_right %d\n",vinfo.red.msb_right); 0
-
printf("fb_bitfield green.offset %d\n",vinfo.green.offset); 5 偏移5位
-
printf("fb_bitfield .length %d\n",vinfo.green.length); 6
-
printf("fb_bitfield .msb_right %d\n",vinfo.green.msb_right); 0
-
printf("fb_bitfield blue.offset %d\n",vinfo.blue.offset);
-
printf("fb_bitfield .length %d\n",vinfo.blue.length);
-
printf("fb_bitfield .msb_right %d\n",vinfo.blue.msb_right);
-
printf("fb_bitfield transp.offset %d\n",vinfo.transp.offset);
-
printf("fb_bitfield .length %d\n",vinfo.transp.length);
-
printf("fb_bitfield .msb_right %d\n",vinfo.transp.msb_right);
-
-
printf("nonstd %d\n",vinfo.nonstd); //!=0 非标准像素格式
-
printf("activate %d\n",vinfo.activate);
-
printf("height %d\n",vinfo.height); //高度/ 240
-
printf("widht %d\n",vinfo.width); 320
-
printf("accel_flags %d\n",vinfo.accel_flags); //看 fb_info.flags
-
-
//定时,除了 pixclock之外,其他的都以像素时钟为单位
-
printf("pixclock %d\n",vinfo.pixclock);//像素时钟,皮秒 80000
-
printf("left_margin %d\n",vinfo.left_margin);//行切换:从同步到绘图之间的延迟 28
-
printf("right_margin %d\n",vinfo.right_margin);//行切换:从绘图到同步之间的延迟 24
-
printf("upper_margin %d\n",vinfo.upper_margin);//帧切换:从同步到绘图之间的延迟 6
-
printf("lower_margin %d\n",vinfo.lower_margin);//帧切换:从绘图到同步之间的延迟 2
-
-
printf("hsync_len %d\n",vinfo.hsync_len); //hor 水平同步的长度 42
-
printf("vsync_len %d\n",vinfo.vsync_len); //vir 垂直同步的长度 12
-
-
printf("sync %d\n",vinfo.sync); //
-
printf("vmode %d\n",vinfo.vmode);
-
printf("rotate %d\n",vinfo.rotate);
测试结果
- [root@yuweixian yu]# ./framebuff-test
-
the framebuffer device was opended successfully.
-
id s3c2410fb
-
smem_start 864813056
-
smem_len 153600
-
type 0
-
type_aux 0
-
visual 2
-
xpanstep 0
-
ypanstep 0
-
line_length 640
-
mmio_start 0
-
mmio_len 0
-
accel 0
-
-
xres 320
-
yres 240
-
xres_virturl 320
-
yres_virtual 240
-
xoffset 0
-
yoffset 0
-
bits_per_pixel 16
-
grayscale 0
-
fb_bitfield red.offset 11
-
fb_bitfield .length 5
-
fb_bitfield .msb_right 0
-
fb_bitfield green.offset 5
-
fb_bitfield .length 6
-
fb_bitfield .msb_right 0
-
fb_bitfield blue.offset 0
-
fb_bitfield .length 5
-
fb_bitfield .msb_right 0
-
fb_bitfield transp.offset 0
-
fb_bitfield .length 0
-
fb_bitfield .msb_right 0
-
nonstd 0
-
activate 0
-
height 240
-
widht 320
-
accel_flags 0
-
pixclock 80000
-
left_margin 28
-
right_margin 24
-
upper_margin 6
-
lower_margin 2
-
hsync_len 42
-
vsync_len 12
-
sync 0
-
vmode 0
-
rotate 0
-
the framebuffer devices was mapped to memory successfully
-
bye the framebuffer
-
[root@yuweixian yu]#
分析 1.- printf("fb_bitfield red.offset %d\n",vinfo.red.offset); 11 偏移11位
-
printf("fb_bitfield .length %d\n",vinfo.red.length); 5
-
printf("fb_bitfield .msb_right %d\n",vinfo.red.msb_right); 0
-
printf("fb_bitfield green.offset %d\n",vinfo.green.offset); 5 偏移5位
这个对应 SC32440 中 RGB565 设置方式分析 2
- printf("smem_len %d\n",finfo.smem_len); 153600
printf("line_length %d\n",finfo.line_length); 640
printf("xres %d\n",vinfo.xres); 320
printf("yres %d\n",vinfo.yres); 240
printf("bits_per_pixel %d\n",vinfo.bits_per_pixel); 16- 1.smem_len=153600 是这个 /dev/fb0 d的大小,也就是内存大小
2. line_length =640 是屏幕上一行的点在内存中占有的空间,不是一行上的点数 320*2 因为是 16bpp 一个像素 占有2个字节大小,一行有320个点,所以line_length=640 字节大小 3. xres =320 yres=240 就是 x y 方向的分辨率,就是两个方向上的 像素点 个数4. bits_per_pixel=16bpp 每一个像素点 占用内存空间 2 字节 从上面知道了 分配的内存是 smem_len=153600字
节=150KB,屏幕每一行占用内存640字节,153600/640=240,
我们发现,240 就是屏幕的高度。
阅读(12677) | 评论(0) | 转发(1) |