导航

    全志在线开发者论坛

    • 注册
    • 登录
    • 搜索
    • 版块
    • 话题
    • 在线文档
    • 社区主页
    1. 主页
    2. peter_yyp
    P
    • 资料
    • 关注 0
    • 粉丝 0
    • 我的积分 68
    • 主题 0
    • 帖子 2
    • 最佳 0
    • 群组 0

    peter_yypLV 2

    @peter_yyp

    68
    积分
    0
    声望
    1
    资料浏览
    2
    帖子
    0
    粉丝
    0
    关注
    注册时间 最后登录

    peter_yyp 取消关注 关注

    peter_yyp 发布的最新帖子

    • 回复: T113奇怪的屏幕刷新问题

      @anruliu 以下是代码,请帮忙看一下,感谢大佬

      #include "stdio.h"
      #include "stdint.h"
      #include "string.h"
      #include <sys/mman.h>
      #include <sys/ioctl.h>
      #include <fcntl.h>
      #include "fbio.h"
      #include "linux/fb.h"
      #include <unistd.h>
      #include <sys/time.h>
      #include "stdio.h"
      
      #define FBDEV_PATH  "/dev/fb0"
      
      int fbfd = 0;
      struct fb_var_screeninfo vinfo;
      
      uint8_t * fbdev_init() {
        uint8_t * fbp = 0;
        struct fb_fix_screeninfo finfo;
        uint32_t screensize = 0;
      
        fbfd = open(FBDEV_PATH, O_RDWR);
        
        if(fbfd == -1) {
          perror("Error: cannot open framebuffer device");
          return fbp;
        }
      
        printf("The framebuffer device was opened successfully.\n");
      
        struct fbtype fb;
        unsigned line_length;
      
      
        // Get fixed screen information
        if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo) == -1) {
          perror("Error reading fixed information");
          return fbp;
        }
      
        // Get variable screen information
        if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo) == -1) {
          perror("Error reading variable information");
          return fbp;
        }
      
        // Figure out the size of the screen in bytes
        screensize =  finfo.smem_len; //finfo.line_length * vinfo.yres;    
      
        // Map the device to memory
        fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0);
      
        printf("%dx%d, %dbpp, size: %d; ptr: %08X\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel, screensize, fbp);
        
        if ((intptr_t)fbp == -1) {
          perror("Error: failed to map framebuffer device to memory");
          return fbp;
        }
        
        memset(fbp, 0x00, screensize);
       
        return fbp;
      }
      
      void fb_try_pan(uint32_t offset) {
        vinfo.xoffset = 0;
        vinfo.yoffset = offset;
        vinfo.activate = FB_ACTIVATE_VBL;
      
        int res = ioctl(fbfd, FBIOPAN_DISPLAY, &vinfo);
      
        if (res==-1) {
          printf("fb_try_pan res: %d\n", res);
          perror("fb_try_pan res:");
        }
      }
      
      int cur_fb=0;
      
      void fill_fb(uint32_t * fb, uint32_t pattern) {
        struct timeval tv;
        uint32_t fb_num=1;
      
        if (cur_fb==1) {  // Draw on inactive buf
          fb_num=0;
        }
      
        gettimeofday(&tv,NULL);
        long st = 1000000 * tv.tv_sec + tv.tv_usec;
      
        printf("Draw on buf %d. Current buf: %d\n", fb_num, cur_fb);
        
        for (uint32_t i=0; i<1024*600; i++) {
          fb[i+fb_num*1024*600]=pattern;
        }
      
        if (cur_fb==1) {  // Draw on inactive buf
          printf("Activate buf 0\n");
          fb_try_pan(600);
          fb_try_pan(0);
          cur_fb=0;
        }
          else
        {
          printf("Activate buf 1\n");
          fb_try_pan(0);
          fb_try_pan(600);
          cur_fb=1;
        } 
      
        gettimeofday(&tv,NULL);
        long end = 1000000 * tv.tv_sec + tv.tv_usec;
        long t=end-st;
      
        printf("time: %d, fps: %d\n", t, 1000000/t);
      
        usleep(1000000);
      }
      
      int main(void) {
        uint32_t * fb;
        printf("Hello my T133 board\n");
      
        fb=(uint32_t *)fbdev_init();
      
        if (fb==NULL) {
          return 0;
        }
      
        fb_try_pan(0);
       
        while (1) {
          printf("RED!!!\n");
          fill_fb(fb, 0x01FF0000);
          printf("GREEN!!!\n");
          fill_fb(fb, 0x0100FF00);
          printf("BLUE!!!\n");
          fill_fb(fb, 0x010000FF);
          printf("BLACK!!!\n");
          fill_fb(fb, 0x01000000);
          printf("WHITE!!!\n");
          fill_fb(fb, 0x01FFFFFF);
        }
      #endif
      }
       
      
      发布在 其它全志芯片讨论区
      P
      peter_yyp
    • 回复: T113奇怪的屏幕刷新问题

      @efancier

      和我在调试遇到的问题类似,跑R-G-B的时候切换的中间有花屏......

      发布在 其它全志芯片讨论区
      P
      peter_yyp