概述
unsigned char *fmem;
int FrameBufferFD;
FrameBufferFD = open("/dev/fb0", O_RDWR);
if (FrameBufferFD < 0)
{
fprintf(stderr, "Error opening /dev/fb0/n");
return (-1);
}
/* Get the fixed screen info */
if (ioctl(*FrameBufferFD, FBIOGET_FSCREENINFO, &FixedInfo))
{
fprintf(stderr, "error: ioctl(FBIOGET_FSCREENINFO) failed/n");
return (-1);
}
/* get the variable screen info */
if (ioctl(*FrameBufferFD, FBIOGET_VSCREENINFO, &OrigVarInfo))
{
fprintf(stderr, "error: ioctl(FBIOGET_VSCREENINFO) failed/n");
return (-1);
}
if (FixedInfo.visual != FB_VISUAL_TRUECOLOR && FixedInfo.visual != FB_VISUAL_DIRECTCOLOR)
{
fprintf(stderr, "non-TRUE/DIRECT-COLOR visuals (0x%x) not supported by this demo./n", FixedInfo.visual);
return (-1);
}
/*
* fbdev says the frame buffer is at offset zero, and the mmio region
* is immediately after.
*/
/* mmap the framebuffer into our address space */
fmem = mmap(0, /* start */
FixedInfo.smem_len, /* bytes */
PROT_READ | PROT_WRITE, /* prot */
MAP_SHARED, /* flags */
FrameBufferFD, /* fd */
0 /* offset */);
if (fmem == NULL)
{
fprintf(stderr, "error: unable to mmap framebuffer/n");
return(-1);
}
printf("fmem in %x/n",fmem);
return fmem;
最后
以上就是辛勤毛巾为你收集整理的Linux下framebuffer操作方法的全部内容,希望文章能够帮你解决Linux下framebuffer操作方法所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复