为了适应不同尺寸的pannel需要一个tool来动态实现修改framebuffer的参数
程序如下
#include <linux/fb.h>
#include <stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include <linux/ioctl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
struct fb_var_screeninfo vinfo;
typedef struct _RgbSetKind
{
int Hpixel;
int Vpixel;
int Hwd;
int Vwd;
int Hbp;
int Vbp;
int Hfp;
int Vfp;
int H_Level;
int V_Level;
int DE_Level;
int CLK_Level;
int Channel; // 0 : single , 1 : Dual
long pixel;
}RGB_SET_KIND;
void changeprame(int par,int val)
{
int value;
int p;
p=par;
value=val;
switch(p)
{
case 0:
printf("matt-x=%d\n",value);
vinfo.xres=value;
printf("matt-vinfo.xres=%d\n",vinfo.xres);
break;
}
}
void main(int argc, char * argv[])
{
int fd = 0;
int channel;
int x =0;
RGB_SET_KIND matt1={
1280,768,2,2,19,4,64,38,0,0,0,0,0,28017,
};
/* RGB_SET_KIND matt2={
800,480,8,2,8,5,16,43,0,0,0,0,0,37796,
};*/
RGB_SET_KIND matt2={
1280,720,70,10,200,10,100,10,0,0,0,0,0,13468,
};
printf("start ioctl \n");
// printf("matt-argc=%d\n",argc);
fd = open("/dev/fb0",O_RDWR);
if (fd < 0)
{
printf("matt-Open Dev Mem0 Error!\n");
}
sleep(5);
printf("matt-open success \n");
if (ioctl(fd,FBIOGET_VSCREENINFO,&vinfo))
{
printf("Error reading variable information/n");
exit(3);
}
printf("matt-var-pixclock=%ld \n",vinfo.pixclock);
printf("matt-matt2.pixel=%ld \n",matt2.pixel);
vinfo.xres=matt2.Hpixel;
vinfo.yres=matt2.Vpixel;
vinfo.pixclock=matt2.pixel;
vinfo.left_margin=matt2.Hbp;
vinfo.right_margin=matt2.Hfp;
vinfo.upper_margin=matt2.Vbp;
vinfo.lower_margin=matt2.Vfp;
vinfo.hsync_len=matt2.Hwd;
vinfo.vsync_len=matt2.Vwd;
vinfo.pixclock =matt2.pixel;
//vinfo.activate=128;
// channel=atoi(argv[1]);
// printf("matt-channel=%d\n",channel);
//x=atoi(argv[2]);
// printf("matt-vinfo.xres=%d\n",vinfo.xres);
//changeprame(prama,x);
if (ioctl(fd,FBIOPUT_VSCREENINFO,&vinfo))
{
printf("Error writeing variable information/n");
exit(3);
}
//选择channel
/*
if (ioctl(fd,0x2222,&channel))
{
printf("Error writeing variable information/n");
exit(3);
} */
close(fd);
done: exit(0);
}