【海思篇】【Hi3516DV300】十二、海思framebuffer的qt移植

目的:

  1. 由于海思在fb上又封装了一层自己的hifb,所以为了能正常使用qt,需在调用前初始化和配置好hifb;这里我们将hifb配置代码封装在linuxfb_hi3516dv300.so的插件中;绝大部分海思芯片通用;
  2. 部分lcd/mipi显示时,视频颜色正常的,但是qt程序的颜色不正常;这是因为图形层默认CSC转换矩阵为VO_CSC_MATRIX_RGB_TO_BT601_TV, 当设置RGB数据输出接口(如LCD、MIPI_Tx)时,需要调用HI_MPI_VO_SetGraphicLayerCSC函数,选择VO_CSC_MATRIX_IDENTITY使输出数据保持为RGB类型。

环境:

  1. Hi3516DV300
  2. qt5.8.12

1 搭建qt的海思fb工程

基于前面的《qt移植》
创建工程步骤如下:

cd /opt/qt-everywhere-src-5.12.8/qtbase/src/plugins/platforms
cp linuxfb linuxfb_hi3516dv300 -rf
cd linuxfb_hi3516dv300 
vi linuxfb.pro #将第一句TARGET = qlinuxfb改为TARGET = qlinuxfb_hi3516dv300
../../../../bin/qmake
make
#最后生成libqlinuxfb_hi3516dv300.so表示qt工程搭建成功

2 工程添加海思依赖

vi linuxfb.pro

TARGET = qlinuxfb_hi3516dv300

DEFINES += QT_NO_FOREACH

QT += \
    core-private gui-private \
    service_support-private eventdispatcher_support-private \
    fontdatabase_support-private fb_support-private

qtHaveModule(input_support-private): \
    QT += input_support-private

SOURCES = main.cpp \
          qlinuxfbintegration.cpp \
          qlinuxfbscreen.cpp

HEADERS = qlinuxfbintegration.h \
          qlinuxfbscreen.h

qtHaveModule(kms_support-private) {
    QT += kms_support-private
    SOURCES += qlinuxfbdrmscreen.cpp
    HEADERS += qlinuxfbdrmscreen.h
}

# add by wei
INCLUDEPATH += /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/include
unix:LIBS += -Wl,--start-group     /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libsvpruntime.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libhi_cipher.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libupvqe.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libsns_imx307_2l.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libmpi.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/lib_hiawb_natura.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libsns_imx377.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/lib_hidrc.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libsns_imx458.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/lib_hiawb.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libsns_imx307.a \
        /opt/hisi/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libsns_mn34220.a \
        /opt/hisi/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/lib_hiae.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libdnvqe.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libnnie.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libhifisheyecalibrate.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libtde.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libVoiceEngine.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libsns_imx335.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libsecurec.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/lib_hildci.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libsns_os05a_2l.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libsns_imx327_2l.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libhdmi.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libmd.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libive.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libsns_imx327.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libsns_os05a.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/libisp.a \
        /opt/Hi3516CV500_SDK_V2.0.1.1/smp/a7_linux/mpp/lib/lib_hidehaze.a -lm -Wl,--end-group
# add by wei end

OTHER_FILES += linuxfb.json

PLUGIN_TYPE = platforms
PLUGIN_CLASS_NAME = QLinuxFbIntegrationPlugin
!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
load(qt_plugin)

调用qmake重新生成Makefile

…/…/…/…/bin/qmake

3 代码添加hifb配置

vi qlinuxfbscreen.cpp
注意:每个人显示的分辨率不同,需要自行修改SCREEN_WIDTH和SCREEN_HEIGHT
【海思篇】【Hi3516DV300】十二、海思framebuffer的qt移植_第1张图片在QLinuxFbScreen::initialize()中添加:
【海思篇】【Hi3516DV300】十二、海思framebuffer的qt移植_第2张图片【海思篇】【Hi3516DV300】十二、海思framebuffer的qt移植_第3张图片【海思篇】【Hi3516DV300】十二、海思framebuffer的qt移植_第4张图片【海思篇】【Hi3516DV300】十二、海思framebuffer的qt移植_第5张图片

4 编译和运行

  1. 编译
    make 后在qt-everywhere-src-5.12.8/qtbase/plugins/platforms/下生成libqlinuxfb_hi3516dv300.so
    拷贝到板子的qt库下plugins/platforms目录中
  2. 海思板配置qt运行环境
export QT_QPA_PLATFORM_PLUGIN_PATH=/sdcard/qt/plugins
export QT_QPA_FONTDIR=/sdcard/qt/fonts
export LD_LIBRARY_PATH=/sdcard/qt
export QT_QPA_PLATFORM=linuxfb:tty=/dev/fb0
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:size=320x240:offset=0x0:nographicsmodeswitch
  1. 运行qt demo
# 加载驱动
cd /komod
./load3516dv300 -i
# 运行海思
cd /app
./sample_vio
# 运行qt demo,此qt的样例,编译方法可参考qt移植章节
./collidingmice

5 源码传送门

linuxfb_hi3516dv300

你可能感兴趣的:(arm,qt,framebuffer)