- static int width; //LCD X 分辨率
- static int height; //LCD Y 分辨率
- static unsigned short *screen_base = NULL; //映射后的显存基地址
- int main(int argc, char *argv[])
- {
- struct fb_fix_screeninfo fb_fix;
- struct fb_var_screeninfo fb_var;
- unsigned int screen_size;
- int fd;
- /* 打开 framebuffer 设备 */
- if (0 > (fd = open("/dev/fb0", O_RDWR))) {
- perror("open error");
- exit(EXIT_FAILURE);
- }
- /* 获取参数信息 */
- ioctl(fd, FBIOGET_VSCREENINFO, &fb_var);
- ioctl(fd, FBIOGET_FSCREENINFO, &fb_fix);
- screen_size = fb_fix.line_length * fb_var.yres;
- printf("screen_size:%d\r\n",screen_size);
- width = fb_var.xres;
- height = fb_var.yres;
- /* 将显示缓冲区映射到进程地址空间 */
- screen_base = mmap(NULL, screen_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
- if (MAP_FAILED == (void *)screen_base) {
- perror("mmap error");
- close(fd);
- exit(EXIT_FAILURE);
- }
- memset(screen_base, 0xFF, screen_size);
- munmap(screen_base, screen_size); //取消映射
- close(fd); //关闭文件
- exit(EXIT_SUCCESS); //退出进
- }
复制代码
jefferyzhang 发表于 2022-9-6 11:25
都2202年了,现在OS都只支持drm框架了
欢迎光临 Toybrick (https://t.rock-chips.com/) | Powered by Discuz! X3.3 |