|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2011-3-25 15:05:54
|
显示全部楼层
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <string.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <linux/fb.h>
int main ()
{
int fp=0;
int fb_mem;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
fp = open ("/dev/fb0",O_RDWR);
if (fp < 0)
{
printf("Error : Can not open framebuffer device\n");
exit(1);
}
if (ioctl(fp,FBIOGET_FSCREENINFO,&finfo))
{
printf("Error reading fixed information\n");
exit(2);
}
if (ioctl(fp,FBIOGET_VSCREENINFO,&vinfo))
{
printf("Error reading variable information\n");
exit(3);
}
printf("The mem is :%d\n",finfo.smem_len);
printf("The line_length is :%d\n",finfo.line_length);
printf("The xpanstep is :%d\n",finfo.xpanstep);
printf("The xres is :%d\n",vinfo.xres);
printf("The yres is :%d\n",vinfo.yres);
printf("bits_per_pixel is :%d\n",vinfo.bits_per_pixel);
printf("The xresvirtual is :%d\n",vinfo.xres_virtual);
printf("The yresvirtual is :%d\n",vinfo.yres_virtual);
printf("The xoffset is :%d\n",vinfo.xoffset);
printf("The yoffset is :%d\n",vinfo.yoffset);
// printf("The height is :%d\n",vinfo.height);
// printf("The width is :%d\n",vinfo.width);
// printf("The hsync_len is :%d\n",vinfo.hsync_len);
// printf("The vsync_len is :%d\n",vinfo.vsync_len);
printf("\nCHANGE VIRTUAL\n");
vinfo.xres=320;
vinfo.yres=240;
vinfo.xres_virtual=640;
vinfo.yres_virtual=480;
vinfo.yoffset=20;
if (ioctl(fp,FBIOPUT_VSCREENINFO,&vinfo)==-1)
{
printf("Error setting variable information\n");
exit(3);
}
printf("\nREGET\n");
if (ioctl(fp,FBIOGET_VSCREENINFO,&vinfo))
{
printf("Error reading variable information\n");
exit(3);
}
printf("The xres is :%d\n",vinfo.xres);
printf("The yres is :%d\n",vinfo.yres);
printf("bits_per_pixel is :%d\n",vinfo.bits_per_pixel);
printf("The xresvirtual is :%d\n",vinfo.xres_virtual);
printf("The yresvirtual is :%d\n",vinfo.yres_virtual);
printf("The xoffset is :%d\n",vinfo.xoffset);
printf("The yoffset is :%d\n",vinfo.yoffset);
close (fp);
return 0;
} |
|