daily pastebin goal
63%
SHARE
TWEET

Framebuffer-yresvirtual

a guest Jun 8th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdint.h>
  3. #include <sys/ioctl.h>
  4. #include <sys/mman.h>
  5. #include <unistd.h>
  6. #include <fcntl.h>
  7. #include "frameutils.h"
  8.  
  9. int mainloop(FrameBuffer *fb) {
  10.     int active = 1;
  11.     while(active) {
  12.         active = 0;
  13.     }
  14.     return 0;
  15. }
  16.  
  17. int main() {
  18.     FrameBuffer fb; //Framebuffer properties
  19.    
  20.     fb.fd = open("/dev/fb0", O_RDWR); //Framebuffer device
  21.    
  22.     ioctl(fb.fd, FBIOGET_VSCREENINFO, &fb.vinfo); //Get variable screen info
  23.     fb.vinfo.grayscale = 0;
  24.     fb.vinfo.bits_per_pixel = 32;
  25.     fb.vinfo.yres_virtual = fb.vinfo.yres * 2;
  26.    
  27.     if(ioctl(fb.fd, FBIOPUT_VSCREENINFO, &fb.vinfo) == -1) { //Set variable screen info
  28.         perror("App ioctl FBIOPUT_VSCREENINFO");
  29.         return -1;
  30.     }
  31.  
  32.     ioctl(fb.fd, FBIOGET_VSCREENINFO, &fb.vinfo); //Get variable screen info
  33.    
  34.     ioctl(fb.fd, FBIOGET_FSCREENINFO, &fb.finfo);
  35.        
  36.     long screensize = fb.vinfo.yres_virtual * fb.finfo.line_length; //Size needed for allocation.
  37.  
  38.     fb.fbp = mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fb.fd, (off_t)0); //Map fb to memory.
  39.  
  40.     fill_box(10, 10, 500, 500, &fb, pixel_color(0xff, 0xff, 0x00, &fb));
  41.  
  42.     printf("Allocated: %d MB (%d bytes).\nReal resolution: %ix%i.\nVirtual resolution: %ix%i.\n", screensize / 1000000, screensize, fb.vinfo.xres, fb.vinfo.yres, fb.vinfo.xres_virtual, fb.vinfo.yres_virtual);
  43.  
  44.     close(fb.fd);
  45.  
  46.     return 0;
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top