• 【基于富瀚6630使用/dev/fb0显示设备和TDE模块渲染bmp图像】


    主要流程

    FY_MPI_VO_GetVideoLayerAttr(SAMPLE_VO_LAYER_VHD0, &stLayerAttr)获取视频层信息

    FY_MPI_SYS_MmzAlloc(&(g_stBackGround.u32PhyAddr), ((void**)&g_pu8BackGroundVir), “ui_bg”, NULL, BACKGROUNGD_WIDTHBACKGROUNGD_HEIGHTbyteDep)申请MMZ缓存

    ioctl(fd, FBIOPUT_SHOW_FYFB, &bShow)关闭显示

    ioctl(fd, FBIOPUT_COMPRESSION_FYFB, &bCompress)关闭图片压缩功能

    ioctl(fd, FBIOGET_VSCREENINFO, &var)获取屏幕信息

    ioctl(fd, FBIOPUT_VSCREENINFO, &var)设置屏幕属性

    ioctl(fd, FBIOGET_FSCREENINFO, &fix)获取屏幕起始帧缓冲内存物理地址

    ioctl(fd, FBIOPUT_SHOW_FYFB, &bShow)使能设备开启显示

    mmap(NULL, stFixInfo.smem_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)//内存映射

    ioctl(fd, FBIOPUT_ALPHA_FYFB, &stAlpha)//设置叠加层的不透明度

    FY_TDE2_Open()//打开TDE设备

    TDE_CreateSurfaceFromFile(pszBgNames[i++], &g_stBackGround, g_pu8BackGroundVir)//读取bmp图片数据

    TDE_DrawUiBySize//开始渲染bmp图片

    代码

    s32Ret = FY_MPI_VO_GetVideoLayerAttr(SAMPLE_VO_LAYER_VHD0, &stLayerAttr);
    if(s32Ret)
    {
        printf("failed to get vo layer(%d) info!\n", SAMPLE_VO_LAYER_VHD0);
        return FY_NULL;
    }
    
    fd = open("/dev/fb0", O_RDWR, 0);//鼠标的话用fb2
    if(fd < 0)
    {
        printf("open /dev/fb0 failed!\n");
        return FY_NULL;
    }
    bComSupport = FY_TRUE;
    prctl(PR_SET_NAME, "UI_HD");
    
    screanWidth = stLayerAttr.stImageSize.u32Width;
    screanHeight = stLayerAttr.stImageSize.u32Height;
    //在用户态申请 MMZ 内存。。
    if (FY_FAILURE == FY_MPI_SYS_MmzAlloc(&(g_stBackGround.u32PhyAddr), ((void**)&g_pu8BackGroundVir), "ui_bg", NULL, BACKGROUNGD_WIDTH*BACKGROUNGD_HEIGHT*byteDep))
    {
        printf("allocate memory 0 (%d bytes) failed\n", BACKGROUNGD_WIDTH*BACKGROUNGD_HEIGHT*byteDep);
        goto exitFb;
    }
    //把缓存置零清除一下数据
    memset(g_pu8BackGroundVir, 0x00, BACKGROUNGD_WIDTH*BACKGROUNGD_HEIGHT*byteDep);
    
    bShow = FY_FALSE;
    if (ioctl(fd, FBIOPUT_SHOW_FYFB, &bShow) < 0)
    {
    	SAMPLE_PRT("FBIOPUT_SHOW_FYFB failed!\n");
        goto exitMmz;
    }
    
    if(bComSupport){
        bCompress = FY_FALSE;
        if (ioctl(fd, FBIOPUT_COMPRESSION_FYFB, &bCompress) < 0)//是否启动图层压缩功能
        {
            printf(" FBIOPUT_COMPRESSION_FYFB failed!\n");
            goto exitMap;
        }
    }
    
    /* get the variable screen info */
    if (ioctl(fd, FBIOGET_VSCREENINFO, &stVarInfo) < 0)
    {
        printf("Get variable screen info failed!\n");
        goto exitMmz;
    }
    
    stVarInfo.xres_virtual	 	= ALIGN_UP(screanWidth, 8);//虚拟屏幕一行有多少个像素点
    stVarInfo.yres_virtual		= screanHeight;//虚拟屏幕一列有多少个像素点
    stVarInfo.xres      		= ALIGN_UP(screanWidth, 8);//定义屏幕一行有多少个像素点
    stVarInfo.yres      		= screanHeight;//定义屏幕一列有多少个像素点
    stVarInfo.activate  		= FB_ACTIVATE_NOW;
    stVarInfo.bits_per_pixel	= bitDep; //每个像素多少字节
    stVarInfo.xoffset = 0;
    stVarInfo.yoffset = 0;
    stVarInfo.red   = s_red;
    stVarInfo.green = s_gre;
    stVarInfo.blue  = s_blu;
    stVarInfo.transp = s_alp;
    
    if (ioctl(fd, FBIOPUT_VSCREENINFO, &stVarInfo) < 0)
    {
        printf("process frame buffer device error\n");
        goto exitMmz;
    }
    
    if (ioctl(fd, FBIOGET_FSCREENINFO, &stFixInfo) < 0)
    {
        printf("process frame buffer device error\n");
        goto exitMmz;
    }
    //获取fb缓冲内存的开始地址(物理地址)
    u32PhyAddr  = stFixInfo.smem_start;
    
    //用mmap映射出fb缓存的虚拟地址
    //smem_len----fb缓冲的长度
    pShowScreen   = mmap(NULL, stFixInfo.smem_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
    if (NULL == pShowScreen)
    {
        printf("mmap fb0 failed!\n");
        goto exitMmz;
    }
    memset(pShowScreen, 0x00, stFixInfo.smem_len);//清理fb缓存、因为物理地址不能直接操作需要mmap一下
    
    g_stScreen.enColorFmt = COLOR_FORMAT;//颜色的格式 这里是RGB1555
    g_stScreen.u32PhyAddr = u32PhyAddr;//fb缓冲内存的开始地址(物理地址)
    g_stScreen.u32Width = screanWidth;//位图宽度
    g_stScreen.u32Height = screanHeight;//位图高度
    g_stScreen.u32Stride = stFixInfo.line_length;//一行的字节长度
    g_stScreen.bAlphaMax255 = FY_TRUE;//不透明度
    g_stScreen.bAlphaExt1555 = FY_TRUE;//不透明度
    g_stScreen.u8Alpha0 = 0;//不透明度
    g_stScreen.u8Alpha1 = 255;//不透明度
    
    bShow = FY_TRUE;
    if (ioctl(fd, FBIOPUT_SHOW_FYFB, &bShow) < 0)
    {
        printf("FBIOPUT_SHOW_FYFB failed!\n");
        goto exitMap;
    }
    
    stAlpha.bAlphaChannel = FY_TRUE;
    stAlpha.bAlphaEnable = FY_TRUE;
    stAlpha.u8Alpha0 = 0;
    stAlpha.u8Alpha1 = 255;
    stAlpha.u8GlobalAlpha = 128;
    if (ioctl(fd, FBIOPUT_ALPHA_FYFB, &stAlpha) < 0)
    {
        printf("Put alpha info failed!\n");
        goto exitMap;
    }
    //打开 TDE 设备
    s32Ret = FY_TDE2_Open();
    if(s32Ret)
    {
        printf("Open tde failed!\n");
        ui_state = FY_FAILURE;
        goto exitMap;
    }
    
    if(ui_mode == 0){
        num_color = (FY_S32)((sizeof (pszBgNames) / sizeof (pszBgNames[0])));
    }else{
        num_color = 1;
        pszBgNames[0] = pColorNames;
        printf("UI open file named %s\n", pszBgNames[0]);
    }
    
    i = 0;
    
    TDE_CreateSurfaceFromFile(pszBgNames[i++], &g_stBackGround, g_pu8BackGroundVir);
    //设置g_stBackGround 图片的宽高还有1像素所占的字节
    //把图片数据读到g_pu8BackGroundVir MMZ虚拟地址上
    if(i > num_color - 1)
        i = 0;
    
    //g_stScreen有fb缓冲内存的开始地址(物理地址)
    //g_stBackGround有mmz的物理地址
    s32Ret = TDE_DrawUiBySize(fd, &g_stScreen, &g_stBackGround, 0, &stVarInfo);
    if(s32Ret)
        printf("draw globle UI failed!\n");
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144

    源码下载

    ~~~~~点这点这!!!

  • 相关阅读:
    Spring Boot集成Timefold Solver实现课程表编排
    java 根据身份证号码判断性别
    基于jsp+ssm的家庭理财系统
    java基础03
    [echarts] 两侧堆叠柱状图
    深度学习-矩阵计算
    最新版本 Stable Diffusion 开源AI绘画工具之部署篇
    微服务-微服务Nacos配置中心
    使用 Maven 构建 Java 项目
    【Rust笔记】从·类型转换·视角,浅谈Deref<Target = T>, AsRef<T> 等差异
  • 原文地址:https://blog.csdn.net/a812417530/article/details/126222078