Created
September 8, 2008 20:25
-
-
Save felipec/9528 to your computer and use it in GitHub Desktop.
framebuffer test
This file contains 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
#include <fcntl.h> | |
#include <sys/ioctl.h> | |
#include <linux/fb.h> | |
#include <sys/mman.h> | |
#include <stdio.h> | |
#include <stdint.h> | |
static struct fb_var_screeninfo sinfo; | |
static struct fb_fix_screeninfo fix_info; | |
int | |
main (void) | |
{ | |
int fd; | |
int err; | |
fd = open ("/dev/fb0", O_RDWR); | |
if (fd == -1) | |
{ | |
printf ("/dev/fb0\n"); | |
return 1; | |
} | |
if (ioctl (fd, FBIOGET_FSCREENINFO, &fix_info)) | |
{ | |
printf ("fix screen\n"); | |
goto leave; | |
} | |
if (ioctl (fd, FBIOGET_VSCREENINFO, &sinfo)) | |
{ | |
printf ("var screen\n"); | |
goto leave; | |
} | |
printf ("x=%d\n", sinfo.xres); | |
printf ("y=%d\n", sinfo.yres); | |
printf ("mem_len=%d\n", fix_info.smem_len); | |
{ | |
uint8_t *fbmem; | |
/* map the framebuffer */ | |
fbmem = mmap (NULL, fix_info.smem_len, PROT_WRITE, MAP_SHARED, fd, 0); | |
if (fbmem == MAP_FAILED) | |
{ | |
printf ("mmap\n"); | |
goto leave; | |
} | |
{ | |
unsigned int i; | |
for (i = 0; i < fix_info.smem_len / 4; i++) | |
((uint32_t*) fbmem)[i] = 0x80008000; | |
} | |
} | |
leave: | |
close (fd); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment