Skip to content

Instantly share code, notes, and snippets.

@gbluma
Created November 5, 2013 22:02
Show Gist options
  • Save gbluma/7327127 to your computer and use it in GitHub Desktop.
Save gbluma/7327127 to your computer and use it in GitHub Desktop.
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
// application entry point
int main(int argc, char* argv[])
{
int fbfd = 0; // framebuffer filedescriptor
struct fb_var_screeninfo var_info;
// Open the framebuffer device file for reading and writing
fbfd = open("/dev/fb0", O_RDWR);
if (!fbfd) {
printf("Error: cannot open framebuffer device.\n");
return(1);
}
printf("The framebuffer device opened.\n");
// Get variable screen information
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &var_info)) {
printf("Error reading variable screen info.\n");
}
printf("Display info %dx%d, %d bpp\n",
var_info.xres, var_info.yres,
var_info.bits_per_pixel );
// close file
close(fbfd);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment