Created
February 15, 2023 07:15
-
-
Save dramforever/c2ec47fe2f0bb3da19e8403e08130f43 to your computer and use it in GitHub Desktop.
Playing around with /dev/fb0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _GNU_SOURCE | |
#include <fcntl.h> | |
#include <linux/fb.h> | |
#include <stddef.h> | |
#include <stdio.h> | |
#include <sys/ioctl.h> | |
#include <sys/mman.h> | |
int main() { | |
int fd = open("/dev/fb0", O_RDWR); | |
struct fb_fix_screeninfo fix_info; | |
struct fb_var_screeninfo var_info; | |
ioctl(fd, FBIOGET_FSCREENINFO, &fix_info); | |
ioctl(fd, FBIOGET_VSCREENINFO, &var_info); | |
printf("id = %s\n", fix_info.id); | |
printf("smem_start = 0x%lx\n", fix_info.smem_start); | |
printf("smem_len = 0x%lx\n", fix_info.smem_len); | |
printf("res %dx%d, virtual res %dx%d\n", var_info.xres, var_info.yres, var_info.xres_virtual, var_info.yres_virtual); | |
char *mem = mmap(NULL, fix_info.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, fix_info.smem_start); | |
while(1) | |
for (size_t i = 0; i < fix_info.smem_len; i ++) | |
mem[i] = i; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment