应用多元统计pdf:framebuffer应用程序编写
来源:百度文库 编辑:偶看新闻 时间:2024/05/09 05:41:00
1. 了解linux/fb.h中的关于framebuffer的结构体 fb_fix_screeninfo和fb_var_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 */
};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 */
};显存大小计算:xres * yres * bits_per_pixel/8 (BYTES)2.编程流程:(1) 打开设备 open("/dev/fb0",O_RDWR);(2) 获取framebuffer设备信息.ioctl(int fb,FBIOGET_FSCREENINFO,&finfo); ioctl函数是实现对设备的信息获取和设定,第一个参数为文件描述符,第二个参数为具体设备的参数,对于framebuffer,参数在linux/fb.h中定义的。 #define FBIOGET_VSCREENINFO 0x4600 //获取设备无关的数据信息fb_var_screeninfo
#define FBIOPUT_VSCREENINFO 0x4601 //设定设备无关的数据信息
#define FBIOGET_FSCREENINFO 0x4602 //获取设备无关的常值信息fb_fix_screeninfo
#define FBIOGETCMAP 0x4604 //获取设备无关颜色表信息
#define FBIOPUTCMAP 0x4605 //设定设备无关颜色表信息
#define FBIOPAN_DISPLAY 0x4606
#define FBIO_CURSOR _IOWR('F', 0x08, struct fb_cursor) 第三个参数是存放信息的结构体或者缓冲区(3)内存映射 mmap函数。头文件:sys/mman.h .常用用法:mmap(0,screensize,PROT_RD |PROT_WR,MAP_SHARED,int fb,0)返回映射的首地址。3。实例程序实现在lcd 上全屏写 blue 色#include
#include
#include
#include
#include
#include
{
int fbfd = 0;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
long int screensize = 0;
char *fbp = 0;
int x = 0, y = 0;
long int location = 0;
int sav=0;
/* open device*/
fbfd = open("/dev/fb0", O_RDWR);
if (!fbfd) {
printf("Error: cannot open framebuffer device.\n");
exit(1);
}
printf("The framebuffer device was opened successfully.\n"); /* Get fixed screen information */
if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) {
printf("Error reading fixed information.\n");
exit(2);
} /* Get variable screen information */
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) {
printf("Error reading variable information.\n");
exit(3);
}/* show these information*/
printf("vinfo.xres=%d\n",vinfo.xres);
printf("vinfo.yres=%d\n",vinfo.yres);
printf("vinfo.bits_per_bits=%d\n",vinfo.bits_per_pixel);
printf("vinfo.xoffset=%d\n",vinfo.xoffset);
printf("vinfo.yoffset=%d\n",vinfo.yoffset);
printf("finfo.line_length=%d\n",finfo.line_length);
/* Figure out the size of the screen in bytes */
screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
/* Map the device to memory */
fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0);
if ((int)fbp == -1) { printf("Error: failed to map framebuffer device to memory.\n"); exit(4);
}
printf("The framebuffer device was mapped to memory successfully.\n");memset(fbp,0,screensize);
/* Where we are going to put the pixel */
for(x=0;x
location = (x vinfo.xoffset) * (vinfo.bits_per_pixel/8)
(y vinfo.yoffset) * finfo.line_length; *(fbp location) = 0xff; /* blue */
*(fbp location 1) = 0x00;
}
munmap(fbp, screensize); /* release the memory */
close(fbfd);
return 0;
}这是最简单的直接写framebuffer 的程序,也是我在这一方面编程的起步。希望在以后的学习中能够和朋友们一起提高
c语言编写应用程序
编写一个应用程序
请编写一个数据库应用程序
怎样编写手机中的java应用程序
VC++是不是很少用于编写数据库应用程序
怎样用C语言编写WINDOWS应用程序
用c语言编写的应用程序
用哪种语言编写DOS环境下的应用程序好呢??
c# 编写的一般应用程序必须依赖.net环境吗?
在WINDOWS上编写简单的应用程序该学哪种语言?
编写应用程序,求10000以内的完全数
VC++是不是一般不用于编写数据库应用程序
找一个用c#编写的windows应用程序的记事本?
怎样用VC编写网络应用程序?(求源码)
如何在Authorware中调用C语言编写的应用程序?
如何用c#编写书店控制台的应用程序
怎么样编写用户登入,用C#WINDOW应用程序
Visual Studio 2005 能编写不依赖.NET的应用程序吗?
请使用VS.NET根据下列需求编写应用程序:
用java可以编写,类似于.exe文件的应用程序吗?
用java编写图形界面的应用程序时,怎样编写出能最小化到托盘的程序?
请大虾帮忙:制作一个单文档应用程序,编写字体应用程序。。。。
桌面应用程序是相对WEB应用程序而言的吗?编写这些程序通常用哪些语言
编写一个应用程序,接受用户输入的字符串,然后反序输出。用Java写。