#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <unistd.h>

#include <pthread.h>

#include <signal.h>

#include <sys/types.h>

#include <sys/stat.h>

#include <fcntl.h>

#include <sys/ioctl.h>

#include <linux/fb.h>

#include <sys/mman.h>   //mmap

#include "hifb.h"

#include "sample_comm.h"

#define IMAGE_WIDTH 1920

#define IMAGE_HEIGHT 1080

#define IMAGE_SIZE (1920*1080*3)

#define IMAGE_NUM 14

#define IMAGE_PATH "./res/%d.bits"

 struct fb_bitfield       a16 = {15, 1, 0}, a32 = {24, 8, 0};

 struct fb_bitfield       r16 = {10, 5, 0}, r32 = {16, 8, 0};

 struct fb_bitfield       g16 = {5, 5, 0},  g32 = {8, 8, 0};

 struct fb_bitfield       b16 = {0, 5, 0},  b32 = {0, 8, 0};

 HIFB_ALPHA_S             stAlpha;

 HIFB_COLORKEY_S          stColorKey;

FILE                     *fp1,*fp2,*fp3;

   char  bmp_buf[1920*1080*3*4];

int main()

{

 int fd;

 int i;

 struct fb_fix_screeninfo fix;

 struct fb_var_screeninfo var;

unsigned char *pShowScreen;

 unsigned char *pHideScreen;

 HIFB_POINT_S stPoint = {0, 0};

 FILE *fp;

 VO_PUB_ATTR_S stPubAttr = {0};

 char image_name[128];

 /*0. open VO device 0 */

 /* …… initialize the attributes for stPubAttr */

 HI_MPI_VO_SetPubAttr(0, &stPubAttr);

 HI_MPI_VO_Enable(0);

 /*1. open Framebuffer device overlay 0*/

 fd = open("/dev/fb0", O_RDWR);

 if(fd < 0)

 {

 printf("open fb0 failed!\n");

 return -1;

 }

HI_BOOL  bShow = HI_FALSE;

/*2. set the screen original position*/

 if (ioctl(fd, FBIOPUT_SCREEN_ORIGIN_HIFB, &stPoint) < 0)

 {

 printf("set screen original show position failed!\n");

 return -1;

 }

/*3. get the variable screen info*/

 if (ioctl(fd, FBIOGET_VSCREENINFO, &var) < 0)

 {

 printf("Get variable screen info failed!\n");

 close(fd);

 return -1;

 }

 /*4. modify the variable screen info

 the screen size: IMAGE_WIDTH*IMAGE_HEIGHT

 the virtual screen size: IMAGE_WIDTH*(IMAGE_HEIGHT*2)

 the pixel format: ARGB1555

 */

    printf("%d,%d,%d,%d,%d,%d,%d\n", var.xres_virtual,var.yres_virtual,var.xres,var.yres,var.xoffset,var.yoffset,var.bits_per_pixel);

 var.xres = var.xres_virtual = IMAGE_WIDTH;

 var.yres = IMAGE_HEIGHT;

 var.yres_virtual = IMAGE_HEIGHT*2;

 var.bits_per_pixel = 32;

var.xoffset = 0;

 var.yoffset = 0;

var.red = r32;

 var.green = g32;

 var.blue = b32;

 var.transp = a32;

/*5. set the variable screeninfo*/

 if (ioctl(fd, FBIOPUT_VSCREENINFO, &var) < 0)

 {

 printf("Put variable screen info failed!\n");

 close(fd);

 return -1;

 }

  printf("%d,%d,%d,%d,%d,%d,%d\n", var.xres_virtual,var.yres_virtual,var.xres,var.yres,var.xoffset,var.yoffset,var.bits_per_pixel);

 /*6. get the fix screen info*/

 if (ioctl(fd, FBIOGET_FSCREENINFO, &fix) < 0)

 {

 printf("Get fix screen info failed!\n");

 close(fd);

 return -1;

 }

 /*7. map the physical video memory for user use*/

pShowScreen = mmap(NULL, fix.smem_len, PROT_READ|PROT_WRITE,MAP_SHARED, fd, 0);

 //pHideScreen = pShowScreen + (1920*1080*3;

 memset(pShowScreen, 0, 1920*1080*8);

   printf("fix.smem_len: %d\n", fix.smem_len);

 /*8. load the bitmaps from file to hide screen and set pan display the

 hide screen*/

unsigned int h,w,u32Height = 1080;

 unsigned int u32Width = 1920;

    bShow = HI_TRUE;

     if (ioctl(fd, FBIOPUT_SHOW_HIFB, &bShow) < 0)

     {

  printf("FBIOPUT_SHOW_HIFB failed!\n");

  close(fd);

  return -1;

       }

fp1 = fopen("1080P1.bmp", "rb");

if(fp1==NULL) printf("fp1 not open\n");

        fread(bmp_buf, 54, 1, fp1);

        fread(bmp_buf, u32Width*u32Height*3, 1, fp1);

        fclose(fp1);

fp2 = fopen("2.bmp", "rb");

if(fp2==NULL) printf("fp1 not open\n");

        fread(bmp_buf+u32Width*u32Height*3, 54, 1, fp2);

        fread(bmp_buf+u32Width*u32Height*3, u32Width*u32Height*3, 1, fp2);

        fclose(fp2);

fp3 = fopen("3.bmp", "rb");

if(fp3==NULL) printf("fp1 not open\n");

        fread(bmp_buf+u32Width*u32Height*6, 54, 1, fp3);

        fread(bmp_buf+u32Width*u32Height*6, u32Width*u32Height*3, 1, fp3);

        fclose(fp3);

        printf("ok open file\n");

int index=0;

for( index=0;index<100;index++)

{

 ////////////////////////////////////////////////////////////////////////////////////

  for(h=0;h<u32Height;h++)

     {

  for(w=0;w<u32Width;w++)

  {

            *(unsigned char *)(pShowScreen+(1-index%2)*u32Width*u32Height*4+h*u32Width*4+w*4+0) =  bmp_buf[(u32Height-1-h)*u32Width*3+w*3+0+(index%3)*u32Width*u32Height*3]; //b

            *(unsigned char *)(pShowScreen+(1-index%2)*u32Width*u32Height*4+h*u32Width*4+w*4+1) =  bmp_buf[(u32Height-1-h)*u32Width*3+w*3+1+(index%3)*u32Width*u32Height*3]; //g

            *(unsigned char *)(pShowScreen+(1-index%2)*u32Width*u32Height*4+h*u32Width*4+w*4+2) =  bmp_buf[(u32Height-1-h)*u32Width*3+w*3+2+(index%3)*u32Width*u32Height*3]; //r

            *(unsigned char *)(pShowScreen+(1-index%2)*u32Width*u32Height*4+h*u32Width*4+w*4+3) = 0xff; //a

  }

     }

////////////////////////////////////////////////////////////////////////////////////

  if(index%2==0)

  {

      var.yoffset = u32Height;

  }

  else

  {

      var.yoffset = 0;

  }

  if (ioctl(fd, FBIOPAN_DISPLAY, &var) < 0)

  {

   printf("FBIOPAN_DISPLAY failed!\n");

   close(fd);

   return -1;

  }

  sleep(3);

}

printf("Enter to quit!\n");

 getchar();

 /*9. close the devices*/

 close(fd);

 HI_MPI_VO_Disable(0);

 return 0;

}

hi3531的hifb显示1080p60Hz的更多相关文章

  1. 在HI3531上移植和运行QT4.8.6

    在HI3531上移植和运行QT4.8.6 1.            前言: 近段有点时间,想把QT移植到HI3531上,在网上查找了很多资料,但都不是很全面,有些有问题也没有得到很好的体现. 2.  ...

  2. Hi3531 SDK v2.0.8.0 安装

    1.Hi3531 SDK包位置 在"Hi3531_V100R001***/01.software/board"目录下,您可以看到一个 Hi3531_SDK_Vx.x.x.x.tgz ...

  3. HI3531例子程序说明

    Hisilicon Hi35xx 样例程序使用说明 1. 样例程序文件结构说明    sample            # MPP 样例程序     |-- common       # hi35x ...

  4. hi3531 SDK已编译文件系统制作jffs2文件系统镜像并解决问题 .

    一, 安装SDK 1.Hi3531 SDK包位置 在"Hi3531_V100R001***/01.software/board"目录下,您可以看到一个 Hi3531_SDK_Vx. ...

  5. MiniGUI + Hi3531 笔记 .

    一.移动光驱安装Ubuntu 10.04 1.   重启系统按住Delete进入BIOS界面! 2.   退出/高级模式 --> 启动 --> 启动设备选择. 移动光驱正常被识别后这里应该 ...

  6. hi3531 SDK已编译文件系统制作jffs2文件系统镜像并解决这个问题 .

    一, 安装SDK 1.Hi3531 SDK包位置 在"Hi3531_V100R001***/01.software/board"文件夹下,您能够看到一个 Hi3531_SDK_Vx ...

  7. win10 环境 gitbash 显示中文乱码问题处理

    gitbash 是 windows 环境下非常好用的命令行终端,可以模拟一下linux下的命令如ls / mkdir 等等,如果使用过程中遇到中文显示不完整或乱码的情况,多半是因为编码问题导致的,修改 ...

  8. 关于textview显示特殊符号居中的问题

    话说这是2017年的第一篇博客,也是一篇技术博客.先从简单的一篇解决问题开始吧,千里之行,始于足下! ------------------------------------------------- ...

  9. IE的F12开发人员工具不显示问题

    按下F12之后,开发人员工具在桌面上看不到,但是任务栏里有显示.将鼠标放在任务栏的开发人员工具上,出现一片透明的区域,选中之后却出不来.将鼠标移动到开发人员工具的缩略图上,右键-最大化,工具就全屏出现 ...

随机推荐

  1. JAVA常用知识点及面试题总结

    1. String.StringBuffer.StringBuilder三者区别? (1)三者在执行速率上的比较: String<StringBuffer<StringBuilder 原因 ...

  2. 终于放弃Windows下丑陋的cmd

    微软万年不变的cmd命令行工具,简直其丑无比,交互性极差.但是作为开发者有时离不开.最近用了几款开源替代方案.发现几款不错的cmd替代者.例如Cmder.babun.ConsoleZ.win-bash ...

  3. BZOJ 1778: [Usaco2010 Hol]Dotp 驱逐猪猡 [高斯消元 概率DP]

    1778: [Usaco2010 Hol]Dotp 驱逐猪猡 题意:一个炸弹从1出发p/q的概率爆炸,否则等概率走向相邻的点.求在每个点爆炸的概率 高斯消元求不爆炸到达每个点的概率,然后在一个点爆炸就 ...

  4. BZOJ 2809: [Apio2012]dispatching [斜堆]

    题意:主席树做法见上一题 我曾发过誓再也不写左偏树(期末考试前一天下午5个小时没写出棘手的操作) 于是我来写斜堆啦 从叶子往根合并,维护斜堆就行了 题目连拓扑序都给你了... 说一下斜堆的操作: 合并 ...

  5. BZOJ 1176: [Balkan2007]Mokia [CDQ分治]

    题意: 有一个n * n的棋盘,每个格子内有一个数,初始的时候全部为0.现在要求维护两种操作: 1)Add:将格子(x, y)内的数加上A. 2)Query:询问矩阵(x0, y0, x1, y1)内 ...

  6. BZOJ 4566: [Haoi2016]找相同字符 [后缀自动机]

    4566: [Haoi2016]找相同字符 Time Limit: 20 Sec  Memory Limit: 256 MBSubmit: 275  Solved: 155[Submit][Statu ...

  7. python3图像识别库安装与使用

    pytesseract库的安装 因为用的win10,就直说windows上面的安装了.其实就是pip安装就完事了. $ pip install pytesseract 安装了这个还不算完,得安装Tes ...

  8. mybatis like条件添加%的方法

    使用 MySQL可以使用CONCAT函数.例: <if test="userName != null and userName != ''"> and user_nam ...

  9. C/C++语言简介之语言特点

    一.基本特性    1.高级语言:它是把高级语言的基本结构和语句与低级语言的实用性结合起来的工作单元.    2.结构式语言:结构式语言的显著特点是代码及数据的分隔化,即程序的各个部分除了必要的信息交 ...

  10. mysql那些事

    ---恢复内容开始--- 登录 mysql登录 -u+用户 -p 密码 显示数据库 show databases; 使用某个数据库 use xxx; 显示数据库表 show tables 显示表结构 ...