|
发表于 2016-8-23 21:03:21
只看该作者
地板
你好,请问一下。我们想在板子上使用HDMI显示图片。但是他给的设备节点我们获取到的信息是数据需要16位送进去,#define FB_DEV_NAME "/dev/fb0"
int fbfd = 0;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
long int screensize = 0;
char *fbp = NULL;
char *pixel_basep = NULL;
char *csi_buffp = NULL;
char hight_char,low_char,pixel_char;
int i,j;
Lcd_Write::Lcd_Write()
{}
Lcd_Write::~Lcd_Write()
{}
int Lcd_Write::lcd_open(void)
{
fbfd = open(FB_DEV_NAME, O_RDWR);
printf("fbfd=%d.\n", fbfd);
if(fbfd < 0){
printf("open %s fail.\n", FB_DEV_NAME);
return -1;
}else{
printf("%s open.\n", FB_DEV_NAME);
}
/*获取屏幕固定信息*/
if(ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo) == -1){
printf("read fixed information fial.\n");
return -1;
}
/*获取屏幕可变信息*/
if(ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo) == -1){
printf("read variable information fail");
return -1;
}
printf("var_info.xres=%d.\n", vinfo.xres); //可见屏幕一行的像素点数
printf("var_info.yres=%d.\n", vinfo.yres); //可见屏幕一列的像素点数
printf("var_info.bits_per_pixel=%d.\n", vinfo.bits_per_pixel); //每个像素由多少位组成,即BPP
screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8; //将像素转换成字节数
printf("screensize=%u bits.\n", screensize);
fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0); //将设备映射到内存
printf("fbp=%X.\n", fbp);
if((int)fbfd == -1){
printf("map framebuffer device to memory fail.\n");
return -1;
}else{
printf("map framebuffer device to memory ok.\n");
}
memset(fbp, 0x0, screensize); //将屏幕显示全黑
return 0;
} |
|