昨天做的一个极简单的framebuffer的例子,用来学习怎样操作fb设备。
这段代码是在picogl的vesafb backend部分的基础上简出来的,所以变量名还保留着。
流程如下:
1 打开framebuffer设备;
2 通过ioctl取得fixed screen information;
3 通过ioctl取得variable screen information;
4 通过mmap映射设备内存到进程空间;
5 写framebuffer;
6 终止。
#include
#include
#include
#include
#include
#include
struct fb_fix_screeninfo FixedInfo;
struct fb_var_screeninfo OrigVarInfo;
static int FrameBufferFD = -1;
void *FrameBuffer = ( void *) -1;
void openFBDEV( void ) {
/* open the framebuffer device */
FrameBufferFD = open( "/dev/fb0" , O_RDWR);
if (FrameBufferFD < 0) {
fprintf(stderr, "Error opening /dev/fb0/n" );
exit(1);
}

这篇博客介绍了一个简单的framebuffer操作示例,包括打开设备、获取屏幕信息、映射内存到进程空间以及直接写屏操作。通过示例代码展示了如何使用ioctl和mmap函数来与framebuffer设备交互,提供了理解Linux系统下framebuffer设备操作的基础。
最低0.47元/天 解锁文章
384

被折叠的 条评论
为什么被折叠?



