CalcProgrammer1

refresh.c with MSMFB_DISPLAY_COMMIT ioctl

Jul 18th, 2014
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 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. #include "msm_mdp.h"
  19.  
  20. struct fb_info{
  21. int fd;
  22. void *ptr;
  23. struct fb_var_screeninfo var;
  24. struct fb_fix_screeninfo fix;
  25. };
  26.  
  27. void fb_getinfo(struct fb_info *fb_info){
  28. printf("fb res %dx%d virtual %dx%d, line_len %d\n",
  29. fb_info->var.xres, fb_info->var.yres,
  30. fb_info->var.xres_virtual, fb_info->var.yres_virtual,
  31. fb_info->fix.line_length);
  32. printf("dim %dmm x %dmm\n", fb_info->var.width, fb_info->var.height);
  33. printf("xoffset %d yoffset %d\n", fb_info->var.xoffset, fb_info->var.yoffset);
  34. }
  35. int fb_open(struct fb_info *fb_info){
  36.  
  37. int fd = open("/dev/fb0", O_RDWR);
  38.  
  39. if(fd < 0){
  40. printf("Failed to open fb\n");
  41. return 1;
  42. }
  43.  
  44. if(ioctl(fd, FBIOGET_VSCREENINFO, &(fb_info->var)) == -1)
  45. {
  46. printf("FBIOGET_VSCREENINFO failed");
  47. }
  48. if(ioctl(fd, FBIOGET_FSCREENINFO, &(fb_info->fix)) == -1)
  49. {
  50. printf("FBIOGET_FSCREENINFO failed");
  51. }
  52. fb_info->fd = fd;
  53. return 0;
  54. }
  55.  
  56.  
  57. void flip_buffer(struct fb_info *fb_info, int n){
  58. if( ioctl(fb_info->fd, FBIOPAN_DISPLAY, &fb_info->var) < 0 ){
  59. printf("Failed FBIOPAN_DISPLAY\n");
  60. }
  61. }
  62.  
  63. void display_commit(struct fb_info *fb_info)
  64. {
  65. struct mdp_display_commit commit_info;
  66. memset(&commit_info, 0, sizeof(struct mdp_display_commit));
  67. commit_info.flags = MDP_DISPLAY_COMMIT_OVERLAY;
  68. if(ioctl(fb_info->fd, MSMFB_DISPLAY_COMMIT, &commit_info) == -1)
  69. {
  70. printf("failed MSMFB_DISPLAY_COMMIT");
  71. }
  72. }
  73.  
  74. int main(int argc, char *argv[]){
  75.  
  76. setpriority(PRIO_PROCESS, 0, -20);
  77.  
  78. struct fb_info fb_info;
  79. fb_open(&fb_info);
  80. fb_getinfo(&fb_info);
  81. while(1){
  82. //flip_buffer(&fb_info,0);
  83. display_commit(&fb_info);
  84. usleep(06666);
  85. }
  86. return 0;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment