CalcProgrammer1

refresh.c for Note 3

Jul 18th, 2014
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <errno.h>
  5. #include <fcntl.h>
  6. #include <unistd.h>
  7. #include <getopt.h>
  8. #include <time.h>
  9.  
  10. #include <sys/time.h>
  11. #include <sys/resource.h>
  12. #include <sys/ioctl.h>
  13. #include <sys/stat.h>
  14. #include <sys/mman.h>
  15.  
  16. #include <linux/fb.h>
  17.  
  18. struct fb_info{
  19. int fd;
  20. void *ptr;
  21. struct fb_var_screeninfo var;
  22. struct fb_fix_screeninfo fix;
  23. };
  24.  
  25. void fb_getinfo(struct fb_info *fb_info){
  26. printf("fb res %dx%d virtual %dx%d, line_len %d\n",
  27. fb_info->var.xres, fb_info->var.yres,
  28. fb_info->var.xres_virtual, fb_info->var.yres_virtual,
  29. fb_info->fix.line_length);
  30. printf("dim %dmm x %dmm\n", fb_info->var.width, fb_info->var.height);
  31. printf("xoffset %d yoffset %d\n", fb_info->var.xoffset, fb_info->var.yoffset);
  32. }
  33. int fb_open(struct fb_info *fb_info){
  34.  
  35. int fd = open("/dev/graphics/fb0", O_RDWR);
  36.  
  37. if(fd < 0){
  38. printf("Failed to open fb\n");
  39. return 1;
  40. }
  41.  
  42. if(ioctl(fd, FBIOGET_VSCREENINFO, &(fb_info->var)) == -1)
  43. {
  44. printf("FBIOGET_VSCREENINFO failed");
  45. }
  46. if(ioctl(fd, FBIOGET_FSCREENINFO, &(fb_info->fix)) == -1)
  47. {
  48. printf("FBIOGET_FSCREENINFO failed");
  49. }
  50. fb_info->fd = fd;
  51. return 0;
  52. }
  53.  
  54.  
  55. void flip_buffer(struct fb_info *fb_info, int n){
  56. if( ioctl(fb_info->fd, FBIOPAN_DISPLAY, &fb_info->var) < 0 ){
  57. printf("Failed FBIOPAN_DISPLAY\n");
  58. }
  59. }
  60. int main(int argc, char *argv[]){
  61.  
  62. setpriority(PRIO_PROCESS, 0, -20);
  63.  
  64. struct fb_info fb_info;
  65. fb_open(&fb_info);
  66. fb_getinfo(&fb_info);
  67. while(1){
  68. flip_buffer(&fb_info,0);
  69. usleep(16666);
  70. }
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment