Skip to content

MI VIF API


REVISION HISTORY

Revision No.
Description
Date
3.0
  • Initial release
  • 12/04/2020
    3.1
  • Added Muffin flow char
  • 07/16/2021
    3.2
  • Added procfs introduction
  • 08/25/2021
    3.3
  • Updated MI_VIF_GroupIdMask_e E_MI_VIF_GROUPMASK_ID up to 7
  • Updated char flow note info
  • 12/22/2021
    3.4
  • Added Mochi information
  • 02/17/2022
    3.5
  • Added Maruko information
  • 03/21/2022
    3.6
  • Updated Pipe count of all chips in Section 1.2; Added Pipe description in Section 1.3
  • Added Field type parameters in Section 3.12
  • Updated cat information description in Section 5.1; Updated echo command in Section 5.2
  • 07/08/2022
    3.7
  • Added Opera flow chart and information section 1.2.5
  • Added the CompressMode parameter supported by Opera in section 2.9
  • Added DCG HDR type in section 3.6,
  • Updated cat information description in section 5.1; Updated echo command in Section 5.2
  • 10/27/2022
    3.8
  • Added COMP and COMPVS HDR type in section 3.6
  • 01/11/2023
    3.9
  • Added Souffle flow chart and information in section 1.2.6
  • Added the CompressMode parameter supported by Souffle in section 2.9; Added section 2.16, specify function MI_VIF_CustFunction
  • Added eHDRFusionTpye/u8HDRExposureMask/stMetaDataAttr specification in section 3.10; Added section 3.19 to specify HDR fusion type; Added section 3.20 to specify HDR exposure type; Added 3.21 and 3.22 to specify Metadata enum and structure; Added section 3.23 to specify VIF customer command ID; Added section 3.24 to specify Putdata structure
  • 03/14/2023
    3.10
  • Updated cat debug information in Section 5.1
  • Added Section 6 MODPARAM INTRODUCTION
  • 04/17/2023
    3.11
  • Added "SET IR STATUS" customer command description in section 3.23
  • 06/28/2023
    3.12
  • Added Iford information
  • 12/22/2023
    3.13
  • Added group attributes
  • 02/19/2024
    3.14
  • Added new structure description about AOV function
  • 06/07/2024
    3.15
  • Added bDevEnableFrameStartPts in sections 6.1 and 6.2
  • 04/03/2025
    3.16
  • Restructure the documentation according to the standard template
  • 04/24/2025
    3.17
  • Back to mainline,Added new structure description about AiIsp function, Added api and sample code for aov,Add 5.3. cat debug_hal
  • 05/13/2025
    3.18
  • Supplement the field descriptions of the modparam.json configuration document related to multi-sensor VIF
  • 08/18/2025

    1. OVERVIEW


    1.1. MODULE DESCRIPTION

    MI_VIF is a device driver used for binding and enabling video input channels. It abstracts the differences in protocols and hardware among various video input devices, allowing upper-layer applications to operate without needing to consider specific sensor types. With simple configuration based on requirements, users can easily set up a pipeline for receiving video stream

    KEYWORD:

    • sensor pad

      sensor hardware interface location

    • VIF Group

      The VIF IP's internal hardware architecture is responsible for processing video streams from the corresponding sensor pad

    • VIF Device

      Channels within the VIF Group enable the transmission of video streams through different channels

    • Linear mode

      Single VIF Device mode

    • HDR mode

      To support HDR from the sensor, which contains both long and short exposure data, this configuration will occupy two or more VIF Devices.

    • realtime

      VIF directly connects with downstream hardware

    • framemode

      VIF data is first buffered in DRAM before being transferred to downstream modules


    1.2. BASIC ARCHITECTURE

    The MI_VIF module is primarily designed to receive video streams from front-end sensors. The VIF hardware contains multiple VIF groups, each maintaining a fixed correspondence with specific sensor pads (as shown in Figure 1-1).The VIF group's sensor interface types are hardware-configured, mandating specific pad/group assignments for particular standards (BT656/BT1120, etc.). Each group integrates multiple internal devices for concurrent multi-channel signal reception from the sensor.

    The VIF module routes incoming data through configurable output ports to different destinations based on application scenarios. In Frame Mode, it supports transferring both Bayer and YUV422 format data to system memory. When bound to the ISP in real-time mode, it exclusively processes Bayer format data, while real-time binding with the SCL only permits YUV422 data transmission.

    Figure 1‑1 VIF Architecture

    Figure 1-2 illustrates the application development approach using the MI_VIF API

    Figure 1-2 MI_VIF Usage Methodology


    1.3. FUNCTIONAL DESCRIPTION

    MI_VIF supports the following features:

    1. Receiving sensor output of different interface types

    2. Controlling the output video frame rate

    3. Cropping the output image

    4. FBC (Frame Buffer Compression) compression of data

    5. CRC (Cyclic Redundancy Check) verification of data

    6. Outputting fixed-pattern images


    1.4. APPLICATION SCENARIOS

    MI_VIF currently supports the following deployment environments, all of which allow development using the MI_VIF API:

    1. Pure Linux environment

    2. Pure RTOS environment

    3. Dual-OS environment


    1.5. CHIP DIFFERENCES

    The MI_VIF API maintains consistent behavior across different chips, primary hardware differences between chips include: number of underlying VIF groups and devices, and supported sensor interface types.

    please refernece #### 1.5.7. Iford


    1.5.1. Tiramisu

    Tiramisu hardware quantity and layout are shown in the figure below.

    Supported Interfaces Associated Sensor Pad
    BT656 0, 2
    MIPI 0, 1, 2, 3

    Tiramisu has two output ports with the following respective functions:

    PortId Input Pixel Format Output Pixel Format Crop scaling Output Mode
    0 Native sensor format 1. Native sensor format
    2. YUV422→12-bit Bayer conversion
    Not supported Not supported 1. DRAM output.
    2. Any device supports realtime output to MI_ISP, but only one can be used at a time.
    3. Any device supports yuv422 realtime output to MI_SCL, but only one can be used at a time.
    1 YUV422 only 12-bit Bayer only Supported Only scaling down is supported. When the height is scaled down, the maximum width is 960. DRAM output only

    1.5.2. Muffin

    Muffin hardware quantity and layout are shown in the figure below.

    Supported Interfaces Associated Sensor Pad
    BT656 0, 1, 2, 3, 4, 5, 6, 7
    BT1120 0, 1, 4, 5
    MIPI 0, 1, 2, 3, 4, 5, 6, 7
    LVDS 0, 2, 4, 6

    Muffin has one output port with the following function:

    PortId Input Pixel Format Output Pixel Format Crop scaling Output Mode
    0 Native sensor format 1. Native sensor format
    2. YUV422→12-bit Bayer conversion
    Not supported Not supported 1. DRAM output.
    2. Device0-15 support realtime output to MI_ISP Dev0, but only one can be used at a time; Device16-31 support realtime output to MI_ISP Dev1, but only one can be used at a time.
    3. Device0-15 support YUV422 realtime output to MI_SCL Dev, but only one can be used at a time. Device16-31 support YUV422 realtime output to MI_SCL Dev6, but only one can be used at a time.

    1.5.3. Mochi

    Mochi hardware quantity and layout are shown in the figure below.

    Supported Interfaces Associated Sensor Pad
    BT656 0, 1, 2, 3
    BT1120 0, 1

    Mochi has one output port with the following function:

    PortId Input Pixel Format Output Pixel Format Crop scaling Output Mode
    0 YUV422 only YUV422 only Not supported Not supported 1. Dram output.
    2. Any device supports yuv realtime output to MI_SCL Dev0, but only one can be used at a time.

    1.5.4. Maruko

    Maruko hardware quantity and layout are shown in the figure below.

    Supported Interfaces Associated Sensor Pad
    BT656 1
    MIPI 0, 2

    Maruko has one output port with the following function:

    PortId Input Pixel Format Output Pixel Format Crop scaling Output Mode
    0 Native sensor format Native sensor format Not supported Not supported 1. Dram output.
    2. Any device supports realtime output to MI_ISP Dev0, but only one can be used at a time.
    3. Any device supports yuv422 realtime output to MI_SCL Dev2, but only one can be used at a time.

    1.5.5. Opera

    Opera hardware quantity and layout are shown in the figure below.

    Supported Interfaces Associated Sensor Pad
    BT656 0, 1
    BT1120 0
    MIPI 0, 1, 2, 3

    Opera has one output port with the following function:

    PortId Input Pixel Format Output Pixel Format Crop scaling Output Mode
    0 Native sensor format Native sensor format Not supported Not supported 1. Dram output.
    2. Any device supports realtime output to MI_ISP Dev0, but only one can be used at a time.
    3. Any device supports yuv422 realtime output to MI_SCL Dev2, but only one can be used at a time.

    1.5.6. Souffle

    Souffle hardware quantity and layout are shown in the figure below.

    Supported Interfaces Associated Sensor Pad
    BT656 0, 1
    BT1120 0
    MIPI 0, 1, 2, 3

    Souffle has one output port with the following function:

    PortId Input Pixel Format Output Pixel Format Crop scaling Output Mode
    0 Native sensor format Native sensor format Not supported Not supported 1. Dram output.
    2. Any device supports realtime output to MI_ISP Dev0, but only one can be used at a time.
    3. Any device supports yuv422 realtime output to MI_SCL Dev2, but only one can be used at a time.

    1.5.7. Iford

    Iford hardware quantity and layout are shown in the figure below.

    Supported Interfaces Associated Sensor Pad
    MIPI 0, 2

    Iford has one output port with the following function:

    PortId Input Pixel Format Output Pixel Format Crop scaling Output Mode
    0 Native sensor format Native sensor format Supported Not supported 1. Dram output.
    2. Any device supports realtime output to MI_ISP Dev0, but only one can be used at a time.
    3. YUV422 format real-time output to MI_SCL Dev2 is not supported.

    1.5.8. pCupid

    pCupid hardware quantity and layout are shown in the figure below.

    Supported Interfaces Associated Sensor Pad
    BT656 0
    parallel 0
    MIPI 0, 2

    pCupid has one output port with the following function:

    PortId Input Pixel Format Output Pixel Format Crop scaling Output Mode
    0 Native sensor format Native sensor format Supported Not supported 1. Dram output.
    2. Any device supports realtime output to MI_ISP Dev0, but only one can be used at a time.

    1.5.9. Jaguar1

    Jaguar1 hardware quantity and layout are shown in the figure below.

    Supported Interfaces Associated Sensor Pad
    BT656 0, 1
    BT1120 0
    MIPI 0, 1, 2, 3

    Jaguar1 has one output port with the following function:

    PortId Input Pixel Format Output Pixel Format Crop scaling Output Mode
    0 Native sensor format Native sensor format Not supported Not supported 1. Dram output.
    2. Any device supports realtime output to MI_ISP Dev0, but only one can be used at a time.
    3. Any device supports yuv422 realtime output to MI_SCL Dev2, but only one can be used at a time.

    1.6. WORKING PRINCIPLE

    The VIF can be divided into frame mode and realtime bind based on its binding relationship with the downstream module. For these two modes, users can choose according to the memory and bandwidth requirements in their actual usage scenarios. Compared to realtime mode, frame mode has higher memory and bandwidth demands. Therefore, it is recommended to use VIF realtime mode under conditions of limited memory and bandwidth.

    1.6.1 FRAME MODE

    When the VIF is bound to the downstream module in frame mode, each device's output port in the VIF first writes data to the corresponding location in DRAM. The downstream module (typically the ISP) then reads from the designated memory address.

    vif-isp frame mode

    1.6.2 REALTIME

    The VIF also supports direct hardware-connected data transmission to downstream modules, implemented in two modes: VIF-ISP realtime binding and VIF-SCL realtime binding.

    1.6.2.1 VIF-ISP REALTIME

    In VIF-ISP realtime binding under linear mode (non-HDR mode), VIF data bypasses DRAM and is sent directly to the ISP for internal processing. However, in HDR mode, the long-exposure data path still goes through DRAM. This working mode only supports Bayer format image transmission.

    vif-isp realtime mode

    1.6.2.2 VIF-SCL REALTIME

    In VIF-SCL realtime binding mode, the VIF bypasses the ISP module completely without performing any image signal processing, transmitting data directly to the SCL module. This operating mode only supports YUV format image transmission.

    vif-scl realtime mode

    1.7. DEVELOPMENT WORKFLOW

    1.7.1 COMPILATION CONFIGURATION

    1. enter alkaid project root directory, make menuconfig

    2. press Enter to choose Sdk Config sub-options

    3. press Enter to choose Interface Compile Config sub-options

    4. Press the spacebar to select the VIF submodule and recompile the project.

      Upon successful compilation, mi_vif.ko will be generated at sdk/interface/src/vif. Header file mi_vif.h and mi_vif_datatype.h will be release to project/release. In pure linux environment they are automatically packaged into system images by default. While in dualos environment, they are excluded from default image packaging (requires manual compilation and installation)


    1.7.2 API CALL FLOW

    MI_VIF API Calling Sequence

    The MI_VIF interface invocation follows these steps:

    1. Configure VIF Group parameters (interface type, operation mode, etc.) and create the specified VIF group

    2. Set VIF Device parameters (window size, pixel format, etc.)

    3. Enable the target VIF Device

    4. Configure VIF OutputPort parameters (window size, pixel format, compression mode, etc.)

    5. Enable the target VIF OutputPort

    6. Disable the VIF OutputPort

    7. Disable the VIF Device

    8. Destroy the VIF Group

    9. Terminate the application


    1.8. SAMPLE CODE

    This example demonstrates the development workflow based on the MI_VIF API.

    #include <stdio.h>
    #include "mi_sys.h"
    #include "mi_vif.h"
    #include "mi_sensor.h"
    #include "mi_vif_datatype.h"
    #include <string.h>
    
    int main(int argc, char **argv)
    {
        MI_SNR_PADID eSnrPadId = 0;
        MI_VIF_GROUP GroupId = 0;
        MI_S32 s32Ret = 0;
        MI_VIF_DEV vifDev =0;
        MI_VIF_PORT vifPort = 0;
    
        MI_SYS_ChnPort_t stChnPort;
        MI_VIF_GroupAttr_t stGroupAttr;
        MI_VIF_DevAttr_t stVifDevAttr;
        MI_VIF_OutputPortAttr_t stVifPortInfo;
    
        memset(&stGroupAttr, 0x0, sizeof(MI_VIF_GroupAttr_t));
        stGroupAttr.eIntfMode = E_MI_VIF_MODE_MIPI;
    
        memset(&stVifDevAttr, 0x0, sizeof(MI_VIF_DevAttr_t));
        stVifDevAttr.stInputRect.u16X = 0;
        stVifDevAttr.stInputRect.u16Y = 0;
        stVifDevAttr.stInputRect.u16Width = 1920;
        stVifDevAttr.stInputRect.u16Height = 1080;
        stVifDevAttr.eInputPixel = (MI_SYS_PixelFormat_e)47;
    
        memset(&stVifPortInfo, 0, sizeof(MI_VIF_OutputPortAttr_t));
         stVifPortInfo.stCapRect.u16X = 0;
        stVifPortInfo.stCapRect.u16Y = 0;
        stVifPortInfo.stCapRect.u16Width =  1920;
        stVifPortInfo.stCapRect.u16Height = 1080;
        stVifPortInfo.stDestSize.u16Width = 1920;
        stVifPortInfo.stDestSize.u16Height = 1080;
        stVifPortInfo.ePixFormat = (MI_SYS_PixelFormat_e)47;
    
        memset(&stChnPort, 0x0, sizeof(MI_SYS_ChnPort_t));
        stChnPort.eModId=E_MI_MODULE_ID_VIF;
        stChnPort.u32DevId=vifDev;
        stChnPort.u32ChnId=0;
        stChnPort.u32PortId=vifPort;
    
        MI_SYS_Init(0);
    
        s32Ret = MI_SNR_Enable(eSnrPadId);
        if(s32Ret != MI_SUCCESS)
        {
            printf("enable sensor:%d failed\n", eSnrPadId);
            goto EXIT;
        }
    
        s32Ret = MI_VIF_CreateDevGroup(GroupId, &stGroupAttr);
        if(s32Ret != MI_SUCCESS)
        {
            printf("create group id:%d failed\n", GroupId);
            goto EXIT;
        }
        s32Ret = MI_VIF_SetDevAttr(vifDev, &stVifDevAttr);
        if(s32Ret != MI_SUCCESS)
        {
            printf("set vif dev:%d failed\n",vifDev);
            goto EXIT;
        }
    
        s32Ret = MI_VIF_EnableDev(vifDev);
        if(s32Ret != MI_SUCCESS)
        {
            printf("enable vif dev:%d failed\n",vifDev);
            goto EXIT;
        }
    
        s32Ret = MI_VIF_SetOutputPortAttr(vifDev, vifPort, &stVifPortInfo);
        if(s32Ret != MI_SUCCESS)
        {
            printf("set vif dev:%d port:%d failed\n",vifDev,vifPort);
            goto EXIT;
        }
    
        s32Ret = MI_VIF_EnableOutputPort(vifDev, vifPort);
        if(s32Ret != MI_SUCCESS)
        {
            printf("enable vif dev:%d port:%d  failed\n",vifDev,vifPort);
            goto EXIT;
        }
    
        s32Ret = MI_SYS_SetChnOutputPortDepth(0, &stChnPort, 1, 4);
        if(s32Ret != MI_SUCCESS)
        {
            printf("set vif port depth failed\n");
            goto EXIT;
        }
    
        s32Ret = MI_VIF_DisableOutputPort(vifDev, vifPort);
        if(s32Ret != MI_SUCCESS)
        {
            printf("disable vif dev:%d port:%d failed\n",vifDev,vifPort);
            goto EXIT;
        }
    
        s32Ret = MI_VIF_DisableDev(vifDev);
        if(s32Ret != MI_SUCCESS)
        {
            printf("disable vif dev:%d failed\n",vifDev);
            goto EXIT;
        }
        s32Ret = MI_VIF_DestroyDevGroup(GroupId);
        if(s32Ret != MI_SUCCESS)
        {
            printf("destroy vif group:%d failed\n",GroupId);
            goto EXIT;
        }
    
        s32Ret = MI_SNR_Disable(eSnrPadId);
        if(s32Ret != MI_SUCCESS)
        {
            printf("enable sensor:%d failed\n", eSnrPadId);
            goto EXIT;
        }
        MI_SYS_Exit(0);
    EXIT:
        return s32Ret;
    }
    

    2. API REFERENCE


    This function module provides the following API:

    API Name Function
    MI_VIF_CreateDevGroup Create a Group corresponding to Device
    MI_VIF_DestroyDevGroup Destroy Group
    MI_VIF_SetDevGroupAttr Set Group attributes
    MI_VIF_GetDevGroupAttr Get Group attributes
    MI_VIF_SetDevAttr Set device attribute
    MI_VIF_GetDevAttr Get device attribute
    MI_VIF_EnableDev Enable device
    MI_VIF_DisableDev Disable device
    MI_VIF_GetDevStatus Get device status
    MI_VIF_SetOutputPortAttr Set output port attribute
    MI_VIF_GetOutputPortAttr Get output port attribute
    MI_VIF_EnableOutputPort Enable output port
    MI_VIF_DisableOutputPort Disable output port
    MI_VIF_Query Query VIF channel port interrupt counts, average frame rate, etc.
    MI_VIF_CallBackTask_Register Register callback interface with VIF
    MI_VIF_CallBackTask_UnRegister Unregister callback interface with VIF
    MI_VIF_CustFunction Provide Vif customer function

    2.1. MI_VIF_CreateDevGroup

    • Description

      Create a Group corresponding to Device

    • Syntax

      MI_S32 MI_VIF_CreateDevGroup(MI_VIF_GROUP GroupId, MI_VIF_GroupAttr_t *pstGroupAttr)
      
    • Parameters

      Parameter Name Description Input/Output
      GroupId Group ID Input
      pstGroupAttr Group attributes, static attributes. Input
    • Return Value

      • MI_SUCCESS(0): Successful

      • Non-zero: Failed, see error code for details

    • Dependence

      • Header: mi_vif_datatype.h, mi_vif.h

      • Library: libmi_vif.a

    • Note

      • When MI VIF and back-end module have both real-time and FrameMode connections, such as ISP Bayer Realitme, SCL Dev2 YUV Realitme, and other Devs have Frame mode connections, priority should be given to create DevGroup with real-time connection and bind back-end module.

      • Before Creating DevGroup, make sure that the sensor flows out successfully. That is, if you use our Mi sensor, you need to ensure MI_SNR_Enable. If you use your user sensor, you need to ensure that the user's own sensor has been initialized.

      • Ifackel supports obtaining 3A statistics from the VIF side. If the VIF is connected to the ISP in FrameMode, when Create DevGroup, you need to assign a fixed value (E_MI_VIF_METADATA_AE_STAT | E_MI_VIF_METADATA_AF_STAT) to the variable stMetaDataAttr.u32MetaDataTypeMask on the VIF side to enable the VIF 3A statistics module. In Realtime, you need to assign 0 to the variable stMetaDataAttr.u32MetaDataTypeMask to disable the VIF 3A statistics module.

      • Ifackel Chip supports AI ISP function, to enable the AI ISP function, the variable stGroupAttr.stAiIspAttr.stVifAiBnrAttr.eAiSourceType and stGroupAttr.stAiIspAttr.stVifAiHdrAttr.bAiHdrEn should be set relavant value.

      • If AI and no-AI scene switching is expected in the usage scenario, it is recommended that when initializing the VIF, you first configure AI enablement, that is, configure variables stGroupAttr.stAiIspAttr.stVifAiBnrAttr, such as settings ai bnr source type to linear mode or hdr fusion or hdr long-expo. The purpose of configuring AI enablement first is to handle AI and no_AI scenes during the outflow process. When switching, you can dynamically switch the AI configuration on the VIF side without destroying or re-initializing the VIF. On the contrary, if you initialize the VIF according to the no-AI configuration and switch to the AI scene during the outflow process, you need to destroy and re-initialize the VIF.

      • Group Id Device Id
        0 Device0~3
        1 Device4~7
        2 Device8~11
        3 Device12~15
        4 Device16~19
        5 Device20~23
        6 Device24~27
        7 Device28~31
    • Example

      #define ST_MAX_VIF_DEV_PERGROUP (4)
      #define ST_MAX_VIF_OUTPORT_NUM (2)
      

      MI_VIF initialization process:

      MI_S32 ST_VifModuleInit(MI_VIF_GROUP groupId)
      {
          MI_VIF_DEV vifDev =0;
          MI_VIF_PORT vifPort = 0;
          MI_SNR_PADID SnrPadId = 0;
          MI_U32 u32PlaneId = 0;
          MI_U16 vifDevIdPerGroup=0;
      
          MI_SNR_PADInfo_t  stPad0Info;
          MI_SNR_PlaneInfo_t stSnrPlane0Info;
          memset(&stPad0Info, 0x0, sizeof(MI_SNR_PADInfo_t));
          memset(&stSnrPlane0Info, 0x0, sizeof(MI_SNR_PlaneInfo_t));
      
          MI_VIF_GroupAttr_t stGroupAttr;
          memset(&stGroupAttr, 0x0, sizeof(MI_VIF_GroupAttr_t));
      
          STCHECKRESULT(MI_SNR_GetPadInfo(SnrPadId, &stPad0Info));
          STCHECKRESULT(MI_SNR_GetPlaneInfo(SnrPadId, u32PlaneId, &stSnrPlane0Info));
      
          stGroupAttr.eIntfMode = E_MI_VIF_MODE_MIPI;
          stGroupAttr.eWorkMode = E_MI_VIF_WORK_MODE_1MULTIPLEX;
          stGroupAttr.eHDRType = E_MI_VIF_HDR_TYPE_OFF;
          if(stGroupAttr.eIntfMode == E_MI_VIF_MODE_BT656)
              stGroupAttr.eClkEdge = (MI_VIF_ClkEdge_e)stPad0Info.unIntfAttr.stBt656Attr.eClkEdge;
          else
              stGroupAttr.eClkEdge = E_MI_VIF_CLK_EDGE_DOUBLE;
      
          stGroupAttr.stMetaDataAttr.u32MetaDataTypeMask       = E_MI_VIF_METADATA_AE_STAT | E_MI_VIF_METADATA_AF_STAT;
          stGroupAttr.stAiIspAttr.stVifAiBnrAttr.eAiSourceType = E_MI_VIF_AI_BNR_SOURCE_TYPE_LINEAR;
          stGroupAttr.stAiIspAttr.stVifAiHdrAttr.bAiHdrEn      = FALSE;
      
          STCHECKRESULT(MI_VIF_CreateDevGroup(groupId, &stGroupAttr));
      
          for(vifDevIdPerGroup=0; vifDevIdPerGroup< ST_MAX_VIF_DEV_PERGROUP; vifDevIdPerGroup++)
          {
              MI_VIF_DevAttr_t stVifDevAttr;
              memset(&stVifDevAttr, 0x0, sizeof(MI_VIF_DevAttr_t));
      
              vifDev = groupId*ST_MAX_VIF_DEV_PERGROUP+vifDevIdPerGroup;
              stVifDevAttr.stInputRect.u16X = stSnrPlane0Info.stCapRect.u16X;
              stVifDevAttr.stInputRect.u16Y = stSnrPlane0Info.stCapRect.u16Y;
              stVifDevAttr.stInputRect.u16Width = stSnrPlane0Info.stCapRect.u16Width;
              stVifDevAttr.stInputRect.u16Height = stSnrPlane0Info.stCapRect.u16Height;
              if(stSnrPlane0Info.eBayerId = E_MI_SYS_PIXEL_BAYERID_MAX)
              {
                  stVifDevAttr.eInputPixel = stSnrPlane0Info.ePixel;
              }
              else
                  stVifDevAttr.eInputPixel = (MI_SYS_PixelFormat_e)RGB_BAYER_PIXEL(stSnrPlane0Info.ePixPrecision, stSnrPlane0Info.eBayerId);
      
              printf("setchnportattr (%d,%d,%d,%d) \n", stVifDevAttr.stInputRect.u16X, stVifDevAttr.stInputRect.u16Y, stVifDevAttr.stInputRect.u16Width, stVifDevAttr.stInputRect.u16Height);
              STCHECKRESULT(MI_VIF_SetDevAttr(vifDev, &stVifDevAttr));
              STCHECKRESULT(MI_VIF_EnableDev(vifDev));
      
              for(vifPort=0; vifPort< ST_MAX_VIF_OUTPORT_NUM; vifPort++)
              {
                  MI_VIF_OutputPortAttr_t stVifPortInfo;
                  memset(&stVifPortInfo, 0, sizeof(MI_VIF_OutputPortAttr_t));
      
                  stVifPortInfo.stCapRect.u16X = stSnrPlane0Info.stCapRect.u16X;
                  stVifPortInfo.stCapRect.u16Y = stSnrPlane0Info.stCapRect.u16Y;
                  stVifPortInfo.stCapRect.u16Width =  stSnrPlane0Info.stCapRect.u16Width;
                  stVifPortInfo.stCapRect.u16Height = stSnrPlane0Info.stCapRect.u16Height;
                  stVifPortInfo.stDestSize.u16Width = stSnrPlane0Info.stCapRect.u16Width;
                  stVifPortInfo.stDestSize.u16Height = stSnrPlane0Info.stCapRect.u16Height;
                  printf("sensor bayerid %d, bit mode %d \n", stSnrPlane0Info.eBayerId, stSnrPlane0Info.ePixPrecision);
                  if(stSnrPlane0Info.eBayerId = E_MI_SYS_PIXEL_BAYERID_MAX)
                  {
                      stVifPortInfo.ePixFormat = stSnrPlane0Info.ePixel;
                  }
                  else
                      stVifPortInfo.ePixFormat = (MI_SYS_PixelFormat_e)RGB_BAYER_PIXEL(stSnrPlane0Info.ePixPrecision, stSnrPlane0Info.eBayerId);
                  stVifPortInfo.eFrameRate = E_MI_VIF_FRAMERATE_FULL;
      
                  STCHECKRESULT(MI_VIF_SetOutputPortAttr(vifDev, vifPort, &stVifPortInfo));
                  STCHECKRESULT(MI_VIF_EnableOutputPort(vifDev, vifPort));
              }
          }
          return MI_SUCCESS;
      }
      

      MI_VIF deinitialization process:

      MI_S32 ST_VifModuleUnInit(MI_VIF_GROUP groupId)
      {
          MI_VIF_DEV vifDev = 0;
          MI_VIF_PORT vifPort=0;
          MI_U16 vifDevIdPerGroup=0;
          for(vifDevIdPerGroup=0; vifDevIdPerGroup< ST_MAX_VIF_DEV_PERGROUP; vifDevIdPerGroup++)
          {
              vifDev = groupId*ST_MAX_VIF_DEV_PERGROUP+vifDevIdPerGroup;
      
              for(vifPort=0; vifPort< ST_MAX_VIF_OUTPORT_NUM; vifPort++)
              {
                  STCHECKRESULT(MI_VIF_DisableOutputPort(vifDev, vifPort));
              }
              STCHECKRESULT(MI_VIF_DisableDev(vifDev));
          }
      
          STCHECKRESULT(MI_VIF_DestroyDevGroup(groupId));
      
          return MI_SUCCESS;
      }
      
    • Related APIs

      MI_VIF_DestroyDevGroup


    2.2. MI_VIF_DestroyDevGroup

    • Description

      Destroy the group corresponding to the device.

    • Syntax

      MI_S32 MI_VIF_DestroyDevGroup(MI_VIF_GROUP GroupId)
      
    • Parameters

      Parameter Name Description Input/Output
      GroupId Group ID Input
    • Return Value

      • MI_SUCCESS(0): Successful

      • Non-zero: Failed, see error code for details

    • Dependence

      • Header: mi_vif_datatype.h, mi_vif.h

      • Library: libmi_vif.a

    • Note

      At first, use MI_VIF_DisableOutputPort to disable all the output ports on device, the use MI_VIF_DisableDev to disable all the devices on group.

    • Example

      See the example of MI_VIF_CreateDevGroup.

    • Related APIs

      MI_VIF_CreateDevGroup


    2.3. MI_VIF_SetDevGroupAttr

    • Description

      Set Group attributes.

    • Syntax

      MI_S32 MI_VIF_SetDevGroupAttr(MI_VIF_GROUP GroupId, MI_VIF_GroupAttr_t *pstGroupAttr)
      
    • Parameters

      Parameter Name Description Input/Output
      GroupId Group ID Input
      pstGroupAttr Group attributes Output
    • Return Value

      • MI_SUCCESS(0): Successful

      • Non-zero: Failed, see error code for details

    • Dependence

      • Header: mi_vif_datatype.h, mi_vif.h

      • Library: libmi_vif.a

    • Related APIs

      MI_VIF_GroupAttr_t

      MI_VIF_CreateDevGroup


    2.4. MI_VIF_GetDevGroupAttr

    • Description

      Get Group attributes.

    • Syntax

      MI_S32 MI_VIF_GetDevGroupAttr(MI_VIF_GROUP GroupId, MI_VIF_GroupAttr_t *pstGroupAttr)
      
    • Parameters

      Parameter Name Description Input/Output
      GroupId Group ID Input
      pstGroupAttr Group attributes Output
    • Return Value

      • MI_SUCCESS(0): Successful

      • Non-zero: Failed, see error code for details

    • Dependence

      • Header: mi_vif_datatype.h, mi_vif.h

      • Library: libmi_vif.a

    • Related APIs

      MI_VIF_CreateDevGroup


    2.5. MI_VIF_SetDevAttr

    • Description

      Set VIF device attributes.

    • Syntax

      MI_S32 MI_VIF_SetDevAttr(MI_VIF_DEV DevId, MI_VIF_DevAttr_t *pstDevAttr)
      
    • Parameters

      Parameter Name Description Input/Output
      DevId VIF device ID Input
      pstDevAttr VIF device attribute pointer, static attribute. Input
    • Return Value

      • MI_SUCCESS(0): Successful

      • Non-zero: Failed, see error code for details

    • Dependence

      • Header: mi_vif_datatype.h, mi_vif.h

      • Library: libmi_vif.a

    • Note

      • Make sure that the VIF device is disabled before calling. If the VIF device is enabled, you can use MI_VIF_DisableDev to disable it.

      • pstDevAttr is mainly used to configure the video input format of the specified VIF device.

      • eInputPixel only supports YUV422_YUYV/YVYU/UYVY/VYUY and bayer formats, please refer to CHIP DIFFERENCES for details, and set according to chip specifications.

    • Example

      See the example of MI_VIF_CreateDevGroup.

    • Related APIs

      MI_VIF_GetDevAttr


    2.6. MI_VIF_GetDevAttr

    • Description

      Get VIF device attribute.

    • Syntax

      MI_S32 MI_VIF_GetDevAttr(MI_VIF_DEV DevId, MI_VIF_DevAttr_t *pstDevAttr)
      
    • Parameters

      Parameter Name Description Input/Output
      DevId VIF device ID Input
      pstDevAttr VIF device attribute pointer. Output
    • Return Value

      • MI_SUCCESS(0): Successful

      • Non-zero: Failed, see error code for details

    • Dependence

      • Header: mi_vif_datatype.h, mi_vif.h

      • Library: libmi_vif.a

    • Related APIs

      MI_VIF_SetDevAttr


    2.7. MI_VIF_EnableDev

    • Description

      Enable VIF device.

    • Syntax

      MI_S32 MI_VIF_EnableDev(MI_VIF_DEV DevId);
      
    • Parameters

      Parameter Name Description Input/Output
      DevId VIF device ID Input
    • Return Value

      • MI_SUCCESS(0): Successful

      • Non-zero: Failed, see error code for details

    • Dependence

      • Header: mi_vif_datatype.h, mi_vif.h

      • Library: libmi_vif.a

    • Note

      • Enable must be after device attribute have be configured, or fail will be returned

      • Calling again is available, fail will not be returned.

    • Example

      Please refer to MI_VIF_SetDevAttr.

    • Related APIs

      MI_VIF_DisableDev


    2.8. MI_VIF_DisableDev

    • Description

      Disable VIF device.

    • Syntax

      MI_S32 MI_VIF_DisableDev(MI_VIF_DEV DevId);
      
    • Parameters

      Parameter Name Description Input/Output
      DevId VIF device ID Input
    • Return Value

      • MI_SUCCESS(0): Successful

      • Non-zero: Failed, see error code for details

    • Dependence

      • Header: mi_vif_datatype.h, mi_vif.h

      • Library: libmi_vif.a

    • Note

      • Disable all the output ports on device before disable the VIF device.

      • Calling again is available, fail will not be returned.

    • Example

      See the example of MI_VIF_CreateDevGroup

    • Related APIs

      MI_VIF_EnableDev


    2.9. MI_VIF_GetDevStatus

    • Description

      Get device status.

    • Syntax

      MI_S32 MI_VIF_GetDevStatus(MI_VIF_DEV DevId, MI_VIF_DevStatus_t *pstVifDevStatus)
      
    • Parameters

      Parameter Description Input/Output
      DevId VIF device ID Input
      pstVifDevStatus Device status Output
    • Return Value

      • MI_SUCCESS(0): Successful

      • Non-zero: Failed, see error code for details

    • Dependence

      • Header: mi_vif_datatype.h, mi_vif.h

      • Library: libmi_vif.a


    2.10. MI_VIF_SetOutputPortAttr

    • Description

      Set VIF channel Output port attributes.·

    • Syntax

      MI_S32 MI_VIF_SetOutputPortAttr(MI_VIF_DEV DevId, MI_VIF_PORT PortId, MI_VIF_OutputPortAttr_t *pstAttr);
      
    • Parameters

      Parameter Name Description Input/Output
      DevId VIF device ID Input
      PortId Port ID Input
      pstAttr VIF device port attribute pointer Input
    • Return Value

      • MI_SUCCESS(0): Successful

      • Non-zero: Failed, see error code for details

    • Dependence

      • Header: mi_vif_datatype.h, mi_vif.h

      • Library: libmi_vif.a

    • Note

      • MI_VIF_SetOutputPortAttr is used for setting port attribute in default, such as CapSize, DestSize, FrameRate, ect.

      • Port 0 does not support crop and scaling, so cap and dest size must be equal to input size in MI_VIF_SetDevAttr.

      • The input of port1 only supports YUV format, so only YUVsensor can use port1, which supports crop and scaling down, and the output only supports 12bit bayer format.

      • When Port1 height is scaling down, the maximum output width is 960.

      • Tiramisu/Muffin/Mochi/Opera series chips: eFrameRate setting is not supported.

      • Tiramisu/Muffin/Opera/Souffle series chips: port0 supports output 12-bit Bayer format, which can be sent to MI_ISP for 3DNR.

      • Mochi series chip: supports output YUV422 format, which can be sent to MI_ISP for 3DNR.

        Chip Compress support pixel Support compress mode Note
        Tiramisu Bayer 10/12bit E_MI_SYS_COMPRESS_MODE_TO_8BIT None
        Muffin Bayer 10/12bit E_MI_SYS_COMPRESS_MODE_TO_8BIT None
        Mochi YUV422 UYVY E_MI_SYS_COMPRESS_MODE_TO_6BIT
        E_MI_SYS_COMPRESS_MODE_SFBC0
        DI mode does not support SFBC0 compress mode.
        Maruko Bayer 10/12bit E_MI_SYS_COMPRESS_MODE_TO_8BIT None
        Opera Bayer 10/12bit E_MI_SYS_COMPRESS_MODE_TO_8BIT None
        Souffle Bayer 10/12bit E_MI_SYS_COMPRESS_MODE_TO_8BIT None
        Iford Bayer 10/12bit E_MI_SYS_COMPRESS_MODE_TO_8BIT None
    • Example

      See the example of MI_VIF_CreateDevGroup.

    • Related APIs

      MI_VIF_GetOutputPortAttr


    2.11. MI_VIF_GetOutputPortAttr

    • Description

      Get VIF channel Output port attributes.

    • Syntax

      MI_S32 MI_VIF_GetOutputPortAttr(MI_VIF_DEV DevId, MI_VIF_PORT PortId, MI_VIF_OutputPortAttr_t *pstAttr)
      
    • Parameters

      Parameter Name Description Input/Output
      DevId VIF device ID Input
      PortId Port ID Input
      pstAttr VIF device port attribute pointer Output
    • Return Value

      • MI_SUCCESS(0): Successful

      • Non-zero: Failed, see error code for details

    • Dependence

      • Header: mi_vif_datatype.h, mi_vif.h

      • Library: libmi_vif.a

    • Related APIs

      MI_VIF_SetOutputPortAttr


    2.12. MI_VIF_EnableOutputPort

    • Description

      Enable VIF Output port.

    • Syntax

      MI_S32 MI_VIF_EnableOutputPort(MI_VIF_DEV DevId, MI_VIF_PORT PortId)
      
    • Parameters

      Parameter Name Description Input/Output
      DevId VIF device ID Input
      PortId Port ID Input
    • Return Value

      • MI_SUCCESS(0): Successful

      • Non-zero: Failed, see error code for details

    • Dependence

      • Header: mi_vif_datatype.h, mi_vif.h

      • Library: libmi_vif.a

    • Note

      • The channel attributes must be set first, and the VIF device bound channel must be enabled.

      • The VIF channel can be enabled repeatedly without returning failure.

    • Example

      See the example of MI_VIF_SetDevAttr.

    • Related APIs

      MI_VIF_DisableOutputPort


    2.13. MI_VIF_DisableOutputPort

    • Description

      Disable VIF Output port.

    • Syntax

      MI_S32 MI_VIF_DisableOutputPort(MI_VIF_DEV DevId, MI_VIF_PORT PortId)
      
    • Parameters

      Parameter Name Description Input/Output
      DevId VIF device ID Input
      PortId Port ID Input
    • Return Value

      • MI_SUCCESS(0): Successful

      • Non-zero: Failed, see error code for details

    • Dependence

      • Header: mi_vif_datatype.h, mi_vif.h

      • Library: libmi_vif.a

    • Note

      • The VIF channel port stops collecting video input data after being disabled. And if the backend has been bound, the backend will no longer receive video images.

      • The VIF channel can be disabled repeatedly without returning failure.

    • Example

      See the example of MI_VIF_CreateDevGroup.

    • Related APIs

      MI_VIF_EnableOutputPort


    2.14. MI_VIF_Query

    • Description

      Query VIF channel port interrupt counts, average frame rate, etc.

    • Syntax

      MI_S32 MI_VIF_Query(MI_VIF_DEV DevId, MI_VIF_PORT PortId, MI_VIF_DevPortStat_t *pstStat)
      
    • Parameters

      Parameter Name Description Input/Output
      DevId VIF device ID Input
      PortId Port ID Input
      pstStat Channel information structure pointer. Output
    • Return Value

      • MI_SUCCESS(0): Successful

      • Non-zero: Failed, see error code for details

    • Dependence

      • Header: mi_vif_datatype.h, mi_vif.h

      • Library: libmi_vif.a

    • Note

      • This API can be used to query interrupt counts, channel enable/disable status, interrupt loss counts, VB fail counts, height/width of image

      • Frame rate got via this API is average frame rate over 1 second, VIF could calculate average frame rate every second, the precision of this value is not exact

      • User could query interrupt loss counts via this API. If this loss counts increase at all time, it meant VIF is abnormal.

      • This interface is only supported by chips after Tiramisu.


    2.15. MI_VIF_CallBackTask_Register

    • Description

      Register callback interface with VIF

    • Syntax

      MI_S32 MI_VIF_CallBackTask_Register(MI_VIF_DEV DevId, MI_VIF_CallBackParam_t *pstCallBackParam);
      
    • Parameters

      Parameter Name Description Input/Output
      DevId VIF device ID Input
      pstCallBackParam Arguments Input
    • Return Value

      • MI_SUCCESS(0): Successful

      • Non-zero: Failed, see error code for details

    • Dependence

      • Header: mi_vif_datatype.h, mi_vif.h

      • Library: libmi_vif.a

    • Note

    • Example

      MI_S32 _mi_vif_framestart1(MI_U64 u64Data)
      {
          DBG_ERR("DATA %llu \n", u64Data);
          return 0;
      }
      MI_S32 _mi_vif_framestart2(MI_U64 u64Data)
      {
          DBG_ERR("DATA %llu \n", u64Data);
          return 0;
      }
      
      static MS_S32 _mi_vif_testRegVifCallback(void)
      {
          MI_VIF_CallBackParam_t stCallBackParam1;
          MI_VIF_CallBackParam_t stCallBackParam2;
          MI_VIF_DEV u32DevId = 0;
          memset(&stCallBackParam1, 0x0, sizeof(MI_VIF_CallBackParam_t));
          memset(&stCallBackParam2, 0x0, sizeof(MI_VIF_CallBackParam_t));
          stCallBackParam1.eCallBackMode = E_MI_VIF_CALLBACK_ISR;
          stCallBackParam1.eIrqType = E_MI_VIF_IRQ_FRAMESTART;
          stCallBackParam1.pfnCallBackFunc = _mi_vif_framestart1;
          stCallBackParam1.u64Data = 11;
          MI_VIF_CallBackTask_Register(u32DevId,&stCallBackParam1);
          stCallBackParam2.eCallBackMode = E_MI_VIF_CALLBACK_ISR;
          stCallBackParam2.eIrqType = E_MI_VIF_IRQ_FRAMESTART;
          stCallBackParam2.pfnCallBackFunc = _mi_vif_framestart2;
          stCallBackParam2.u64Data = 22;
          MI_VIF_CallBackTask_Register(u32DevId,&stCallBackParam2);
          return 0;
      }
      static MS_S32 _mi_vif_testUnRegVifCallback(void)
      {
          MI_VIF_CallBackParam_t stCallBackParam1;
          MI_VIF_CallBackParam_t stCallBackParam2;
      
          MI_VIF_DEV u32DevId = 0;
          memset(&stCallBackParam1, 0x0, sizeof(MI_VIF_CallBackParam_t));
          memset(&stCallBackParam1, 0x0, sizeof(MI_VIF_CallBackParam_t));
          stCallBackParam1.eCallBackMode = E_MI_VIF_CALLBACK_ISR;
          stCallBackParam1.eIrqType = E_MI_VIF_IRQ_FRAMESTART;
          stCallBackParam1.pfnCallBackFunc = _mi_vif_framestart1;
          stCallBackParam1.u64Data = 33;
          MI_VIF_CallBackTask_UnRegister(u32DevId,&stCallBackParam1);
          stCallBackParam2.eCallBackMode = E_MI_VIF_CALLBACK_ISR;
          stCallBackParam2.eIrqType = E_MI_VIF_IRQ_FRAMESTART;
          stCallBackParam2.pfnCallBackFunc = _mi_vif_framestart2;
          stCallBackParam2.u64Data = 44;
          MI_VIF_CallBackTask_UnRegister(u32DevId,&stCallBackParam2);
          return 0;
      }
      
    • Related topic

      MI_VIF_CallBackTask_UnRegister


    2.16. MI_VIF_CallBackTask_UnRegister

    • Description

      Unregister callback interface with VIF

    • Syntax

      MI_S32 MI_VIF_CallBackTask_UnRegister(MI_VIF_DEV DevId, MI_VIF_CallBackParam_t *pstCallBackParam);
      
    • Parameters

      Parameter Name Description Input/Output
      DevId VIF device ID Input
      pstCallBackParam Arguments Input
    • Return Value

      • MI_SUCCESS(0): Successful

      • Non-zero: Failed, see error code for details

    • Dependence

      • Header: mi_vif_datatype.h, mi_vif.h

      • Library: libmi_vif.a

    • Note

    • Currently, this interface only supports kernel mode calls

    • This interface must be called in pair with MI_VIF_CallBackTask_Register

    • Example

      Refer to MI_VIF_CallBackTask_Register example.

    • Related topic

      MI_VIF_CallBackTask_Register


    2.17. MI_VIF_CustFunction

    • Description

      Provide Vif customer function.

    • Syntax

      MI_S32 MI_VIF_CustFunction(MI_VIF_DEV DevId, MI_VIF_CustCmd_e eCmdId, MI_U32 u32DataSize, void *pCustData);
      
    • Parameters

      Parameter Name Description Input/Output
      DevId VIF device ID Input
      eCmdId Customer Command ID Input
      u32DataSize Customer Data Size Input
      pCustData Customer Data Address Input
    • Return Value

      • MI_SUCCESS(0): Successful

      • Non-zero: Failed, see error code for details

    • Dependence

      • Header: mi_vif_datatype.h, mi_vif.h

      • Library: libmi_vif.a


    3. VIF DATA TYPE


    VIF module relative data type definition:

    Data type description
    MI_VIF_GROUP Define device group ID
    MI_VIF_IntfMode_e Define interface mode of video Input device
    MI_VIF_WorkMode_e Define working mode of video Input device
    MI_VIF_FrameRate_e Define relation between Output fps and Input fps
    MI_VIF_ClkEdge_e Define clock edge received from video Input device
    MI_VIF_HDRType_e Define HDR type of video Input device
    MI_VIF_MclkSource_e Set Senor clock drive
    MI_VIF_GroupIdMask_e Device group mask
    MI_VIF_SNRPad_e Define SensorPad Id
    MI_VIF_GroupAttr_t Define Group attributes
    MI_VIF_DevAttr_t Define attribute of video Input device.
    MI_VIF_OutputPortAttr_t Define VIF output port attributes
    MI_VIF_DevPortStat_t Define VIF output port information structure
    MI_VIF_DevStatus_t Define VIF device current status
    MI_VIF_CALLBK_FUNC Define callback function type
    MI_VIF_CallBackMode_e Define callback mode
    MI_VIF_IrqType_e Define hardware interrupt type
    MI_VIF_CallBackParam_t Define callback parameters
    MI_VIF_HDRFusionType_e Define HDR fusion type
    MI_VIF_HDRExposureType_e Define HDR exposure type
    MI_VIF_MetaDataType_e Define VIF extra function type
    MI_VIF_MetaDataAttr_t Define VIF extra function structure
    MI_VIF_CustCmd_e Define VIF customer command id
    MI_VIF_PutDataAttr_t Define VIF input data structure
    MI_VIF_FrameEndInfo_t Define the structure that VIF uses as input in FrameEnd Callback
    MI_VIF_SleepModeParams_t Define the parameter structure for VIF to control the Sensor to enter and exit Sleep Mode
    MI_VIF_ShutterGainParams_t Define the parameter structure for VIF to control AE of Sensor
    MI_VIF_ForceFrameParams_t Define the setting parameters of VIF to force the sensor to exit sleep mode
    MI_VIF_AiIspAttr_t Define AiIsp attribute configuration
    MI_VIF_AiBnrAttr_t Define AiBnr case attribute configuration
    MI_VIF_AiHdrAttr_t Define AiHdr case attribute configuration
    MI_VIF_AiBnrSourceType_e Define AI BNR source type

    3.1. MI_VIF_GROUP

    • Description

      Define device group ID.

    • Definition

      typedef MI_U32 MI_VIF_GROUP;
      
    • Related Type

      MI_VIF_CreateDevGroup


    3.2. MI_VIF_IntfMode_e

    • Description

      Define interface mode of video Input device

    • Definition

      typedef enum
      
      {
      
          E_MI_VIF_MODE_BT656 = 0,
      
          E_MI_VIF_MODE_DIGITAL_CAMERA,
      
          E_MI_VIF_MODE_BT1120_STANDARD,
      
          E_MI_VIF_MODE_BT1120_INTERLEAVED,
      
          E_MI_VIF_MODE_MIPI,
      
          E_MI_VIF_MODE_LVDS,
      
          E_MI_VIF_MODE_NUM
      
      } MI_VIF_IntfMode_e;
      
    • Member

      Member name Description
      E_MI_VIF_MODE_BT656 Input data protocol is standard BT.656, port data Input mode is compound mode of brightness and color, quantity mode is single
      E_MI_VIF_MODE_DIGITAL_CAMERA Input data protocol is Digital camera 6, port data Input mode is compound mode of brightness and color, quantity mode is single
      E_MI_VIF_MODE_BT1120_STANDARD Input data protocol is standard BT.1120(BT.656+ double quantity), port data Input mode is division mode of brightness and color, quantity mode is double
      E_MI_VIF_MODE_BT1120_INTERLEAVED Input data protocol is BT.1120 interleave mode, port data Input mode is division mode of brightness and color, quantity mode is double
      E_MI_VIF_MODE_MIPI Input data protocol is MIPI
      E_MI_VIF_MODE_LVDS Input data protocol is LVDS
    • Note

      The current interface mode can be obtained from eintfmode in MI_SNR_GetPadInfo.

    • Related Type

      MI_VIF_GroupAttr_t


    3.3. MI_VIF_WorkMode_e

    • Description

      Define working mode of video Input device

    • Definition

      typedef enum
      
      {
      
          /* BT656 multiple ch mode */
      
          E_MI_VIF_WORK_MODE_1MULTIPLEX,
      
          E_MI_VIF_WORK_MODE_2MULTIPLEX,
      
          E_MI_VIF_WORK_MODE_4MULTIPLEX,
      
          E_MI_VIF_WORK_MODE_MAX
      
      } MI_VIF_WorkMode_e;
      
    • member

      Member name Description
      E_MI_VIF_WORK_MODE_1MULTIPLEX 1 way compound working mode.
      E_MI_VIF_WORK_MODE_2MULTIPLEX 2 way compound working mode.
      E_MI_VIF_WORK_MODE_4MULTIPLEX 4 way compound working mode.
    • Note

      For example, E_MI_VIF_WORK_MODE_4MULTIPLEX means that there are 4 mixed video signals in the Sensor Pad corresponding to the Group, if the number of mixed signals in the SensorPad does not match the compound working mode of the Group, it will cause abnormal signals collected by the Group.

    • Related Type

      MI_VIF_GroupAttr_t


    3.4. MI_VIF_FrameRate_e

    • Description

      Define relation between Output fps and Input fps.

    • Definition

      typedef enum
      
      {
      
          E_MI_VIF_FRAMERATE_FULL = 0,
      
          E_MI_VIF_FRAMERATE_HALF,
      
          E_MI_VIF_FRAMERATE_QUARTR,
      
          E_MI_VIF_FRAMERATE_OCTANT,
      
          E_MI_VIF_FRAMERATE_THREE_QUARTERS,
      
          E_MI_VIF_FRAMERATE_NUM,
      
      } MI_VIF_FrameRate_e;
      
    • member

      Member name Description
      E_MI_VIF_FRAMERATE_FULL Source over target is 1:1 Output.
      E_MI_VIF_FRAMERATE_HALF Source over target is 2:1 Output.
      E_MI_VIF_FRAMERATE_QUARTER Source over target is 4:1 Output.
      E_MI_VIF_FRAMERATE_OCTANT Source over target is 8:1 Output.
      E_MI_VIF_FRAMERATE_THREE_QUARTERS Source over target is 4:3 Output.
    • Note

      This function is reserved. Control frame rate output can be set by MI_SYS_BindChnPort2.

    • Related Type

      MI_VIF_OutputPortAttr_t


    3.5. MI_VIF_ClkEdge_e

    • Description

      Define clock edge received from video Input device

    • Definition

      typedef enum
      
      {
      
          E_MI_VIF_CLK_EDGE_SINGLE_UP = 0,
      
          E_MI_VIF_CLK_EDGE_SINGLE_DOWN,
      
          E_MI_VIF_CLK_EDGE_DOUBLE,
      
          E_MI_VIF_CLK_EDGE_NUM
      
      } MI_VIF_ClkEdge_e;
      
    • member

      Member name Description
      E_MI_VIF_CLK_EDGE_SINGLE_UP Clock single edge mode, sampling in up edge
      E_MI_VIF_CLK_EDGE_SINGLE_DOWN lock single edge mode, sampling in down edge
      E_MI_VIF_CLK_EDGE_DOUBLE VIF do sampling in double edge for double edge data
    • Related Type

      MI_VIF_GroupAttr_t


    3.6. MI_VIF_HDRType_e

    • Description

      Define HDR type of video Input device

    • Definition

      typedef enum
      
      {
      
          E_MI_VIF_HDR_TYPE_OFF,
      
          E_MI_VIF_HDR_TYPE_VC, //virtual channel mode HDR,vc0-long, vc1-short
      
          E_MI_VIF_HDR_TYPE_DOL,
      
          E_MI_VIF_HDR_TYPE_COMP, //compressed HDR mode
      
          E_MI_VIF_HDR_TYPE_LI, //Line interlace HDR
      
          E_MI_VIF_HDR_TYPE_COMPVS,
      
          E_MI_VIF_HDR_TYPE_DCG, //Dual conversion gain HDR
      
          E_MI_VIF_HDR_TYPE_MAX
      
      } MI_VIF_HDRType_e;
      
    • member

      Member name Description
      E_MI_VIF_HDR_TYPE_OFF HDR off
      E_MI_VIF_HDR_TYPE_VC virtual channel mode HDR,vc0-long, vc1-short
      E_MI_VIF_HDR_TYPE_DOL Digital Overlap High Dynamic Range
      E_MI_VIF_HDR_TYPE_COMP Long and Short exposure are merged by sesnor, and isp controls the gain vaule of two frames
      E_MI_VIF_HDR_TYPE_LI Line interlace HDR
      E_MI_VIF_HDR_TYPE_COMPVS compressed HDR + Very short
      E_MI_VIF_HDR_TYPE_DCG Dual conversion gain HDR
    • Note

      • HDR type is related to the sensor. You can obtain the HDR type supported by the current sensor through ehdrmode of MI_SNR_GetPadInfo.

      • The realization of HDR function requires MI_VIF and MI_VPE modules to set the same HDR type.

      • DCG HDR type and COMPVS HDR type are temporarily not supported.

      • Opera series chip support COMP HDR type.

    • Related Type

      MI_VIF_GroupAttr_t


    3.7. MI_VIF_MclkSource_e

    • Description

      Set Senor clock drive.

    • Definition

      typedef enum
      
      {
      
          E_MI_VIF_MCLK_12MHZ,
      
          E_MI_VIF_MCLK_18MHZ,
      
          E_MI_VIF_MCLK_27MHZ,
      
          E_MI_VIF_MCLK_36MHZ,
      
          E_MI_VIF_MCLK_54MHZ,
      
          E_MI_VIF_MCLK_108MHZ,
      
          E_MI_VIF_MCLK_MAX
      
      }MI_VIF_MclkSource_e;
      
    • Member

      Member name Description
      E_MI_VIF_MCLK_12MHZ 12M clk type
      E_MI_VIF_MCLK_18MHZ 18M clk type
      E_MI_VIF_MCLK_27MHZ 27M clk type
      E_MI_VIF_MCLK_36MHZ 36M clk type
      E_MI_VIF_MCLK_54MHZ 54M clk type
      E_MI_VIF_MCLK_108MHZ 108M clk type
    • Note

      • Set mclk from the sensor driver first.

      • If there is no sensor driver and the main control chip is needed to output mclk, then this parameter can be used.

    • Related Type

      MI_VIF_GroupAttr_t


    3.8. MI_VIF_GroupIdMask_e

    • Description

      Device group mask.

    • Definition

      typedef enum
      {
          E_MI_VIF_GROUPMASK_ID0  = 0x0001,
          E_MI_VIF_GROUPMASK_ID1  = 0x0002,
          E_MI_VIF_GROUPMASK_ID2  = 0x0004,
          E_MI_VIF_GROUPMASK_ID3  = 0x0008,
          E_MI_VIF_GROUPMASK_ID4  = 0x0010,
          E_MI_VIF_GROUPMASK_ID5  = 0x0020,
          E_MI_VIF_GROUPMASK_ID6  = 0x0040,
          E_MI_VIF_GROUPMASK_ID7  = 0x0080,
          E_MI_VIF_GROUPMASK_ID_MAX = 0xffff
      } MI_VIF_GroupIdMask_e;
      
    • Note

      In a multi-sensor splicing scene, two sensor images need to be output simultaneously, so you need to create a group, and put the two group id masks together to achieve this.

    • Related Type

      MI_VIF_GroupAttr_t


    3.9. MI_VIF_SNRPad_e

    • Description

      Define SensorPad Id.

    • Definition

      typedef enum
      {
          E_MI_VIF_SNRPAD_ID_0 = 0,
          E_MI_VIF_SNRPAD_ID_1 = 1,
          E_MI_VIF_SNRPAD_ID_2 = 2,
          E_MI_VIF_SNRPAD_ID_3 = 3,
          E_MI_VIF_SNRPAD_ID_4 = 4,
          E_MI_VIF_SNRPAD_ID_5 = 5,
          E_MI_VIF_SNRPAD_ID_6 = 6,
          E_MI_VIF_SNRPAD_ID_7 = 7,
          E_MI_VIF_SNRPAD_ID_MAX,
          E_MI_VIF_SNRPAD_ID_NA = 0xFF,
      }MI_VIF_SNRPad_e;
      
    • Member

      Member name Description
      E_MI_VIF_SNRPAD_ID_0 Corresponding hardware device Sensor0
      E_MI_VIF_SNRPAD_ID_1 Corresponding hardware device Sensor1
      E_MI_VIF_SNRPAD_ID_2 Corresponding hardware device Sensor2
      E_MI_VIF_SNRPAD_ID_3 Corresponding hardware device Sensor3
      E_MI_VIF_SNRPAD_ID_4 Corresponding hardware device Sensor4
      E_MI_VIF_SNRPAD_ID_5 Corresponding hardware device Sensor5
      E_MI_VIF_SNRPAD_ID_6 Corresponding hardware device Sensor6
      E_MI_VIF_SNRPAD_ID_7 Corresponding hardware device Sensor7
      E_MI_VIF_SNRPAD_ID_MAX Exceed the maximum Sensor Num
      E_MI_VIF_SNRPAD_ID_NA Invalid sensor id
    • Note

      • In default, VIF Group0 corresponding to Sensor0, Group2 corresponding to Sensor1, Group6 corresponding to Sensor5.

      • Tiramisu/ Mochi has 4 pad(0-3), Muffin has 8 pad(0-7). See CHIP DIFFERENCES for details.

    • Related Type

      MI_VIF_GroupAttr_t

      MI_VIF_DevStatus_t


    3.10. MI_VIF_GroupAttr_t

    • Description

      Define Group attributes.

    • Definition

      typedef struct MI_VIF_GroupAttr_s
      
      {
      
          MI_VIF_IntfMode_e       eIntfMode;
      
          MI_VIF_WorkMode_e       eWorkMode;
      
          MI_VIF_HDRType_e        eHDRType;
      
          MI_VIF_HDRFusionType_e  eHDRFusionTpye;
      
          MI_U8                   u8HDRExposureMask;
      
          MI_VIF_ClkEdge_e        eClkEdge; //BT656
      
          MI_VIF_MclkSource_e     eMclk;
      
          MI_SYS_FrameScanMode_e  eScanMode;
      
          MI_U32                  u32GroupStitchMask;  //multi vif dev bitmask by MI_VIF_GroupIdMask_e
      
          MI_VIF_MetaDataAttr_t   stMetaDataAttr;
      
          MI_VIF_AiIspAttr_t      stAiIspAttr;
      
      } MI_VIF_GroupAttr_t;
      
    • Member

      Member name Description
      eIntfMode Interface mode
      eWorkMode Working mode
      eHDRType HDR type
      eHDRFusionTpye HDR fusion type
      u8HDRExposureMask HDR exposure type bitmask, composed of MI_VIF_HDRExposureType_e bitmask.
      eClkEdge Clock edge mode (rising edge sampling, falling edge sampling, double edge sampling).
      eMclk Type of clock output to sensor
      eScanMode Frame scan mode (sequential, interlace Scanning)
      u32GroupStitchMask Multiple GroupId stitched output, composed of MI_VIF_GroupIdMask_e bitmask.
      stMetaDataAttr Extra function switch and attributes (include PDAF/Header not compress/STA).
      stAiIspAttr AiIsp attribute configuration.
    • Note

      Tiramisu, Muffin: eScanMode only support E_MI_SYS_FRAME_SCAN_MODE_PROGRESSIVE.

      u8HDRExposureMask : useless in 2Frame HDR, MI vif will set to LS(long/short) exposure inside. In 3Frame HDR, mask have 4 combinations, likes LMS(long/medium/short)/LM/LS/MS, only supported in Souffle.

    • Related Type

      MI_VIF_CreateDevGroup

      MI_VIF_DestroyDevGroup

      MI_VIF_SetDevGroupAttr

      MI_VIF_GetDevGroupAttr


    3.11. MI_VIF_DevAttr_t

    • Description

      Define attribute of video Input device.

    • Definition

      typedef struct MI_VIF_DevAttr_s
      
      {
      
          MI_SYS_PixelFormat_e eInputPixel;
      
          MI_SYS_DataPrecision_e eDataPrecision;
      
          MI_SYS_WindowRect_t stInputRect;
      
          MI_SYS_FieldType_e eField;
      
          MI_BOOL bEnH2T1PMode;
      
          } MI_VIF_DevAttr_t;
      
    • member

      Member name Description
      eInputPixel Input pixel format
      eDataPrecision Input pixel bit width
      stInputRect Collect the input range
      eField Frame field selection is only used in interlaced mode. It is recommended to select the bottom field when capturing a single field. In sequential mode, it must be set to E_MI_SYS_FIELDTYPE_NONE.
      Value: 0 No Field / 1 Top Field / 2 Bottom Field / 3 Both Fields
      bEnH2T1PMode Enable the function of reducing the collection by half in the horizontal direction.
    • Note

      • In bayer format, the pixel format setting is as following:

        stVifDevAttr.eInputPixel =(MI_SYS_PixelFormat_e)RGB_BAYER_PIXEL(stSnrPlane0Info.ePixPrecision, stSnrPlane0Info.eBayerId);

      • The eDataPrecision param is only used when DVP interface runs YUV sensor. For example, when inputting 8 bit YUV, please set eDataPrecision to E_MI_SYS_DATA_PRECISION_8BPP, which will notify VIF that the number of data pins is 8.

      • When the input format is YUV, the bEnH2T1Pmode can be used, otherwise return an error.

    • Related Type

      MI_VIF_SetDevAttr

      MI_VIF_GetDevAttr


    3.12. MI_VIF_OutputPortAttr_t

    • Description

      Define VIF output port attributes.

    • Definition

      typedef struct MI_VIF_OutputPortAttr_s
      {
          MI_SYS_WindowRect_t     stCapRect;
          MI_SYS_WindowSize_t     stDestSize;
          MI_SYS_PixelFormat_e    ePixFormat;
          MI_VIF_FrameRate_e      eFrameRate;
          MI_SYS_CompressMode_e   eCompressMode;
      } MI_VIF_OutputPortAttr_t;
      
    • member

      sub ports only support stDestSize, enDstFrameRate, other attributes will be ignored.

      Member name Description
      stCapRect coordinates and width and height of capturing region(based on original device image).
      stDestSize Destination image size. Must to be configured, the size cannot over outside ADC Input image, or VIF hardware may be abnormal.
      ePixFormat Pixel storage format support, can support YUV422 packet/bayer.
      eFrameRate The ratio between the target frame rate and the input frame rate. If frame rate control is not performed, this value is set to 0. It can output in proportions of 1:1, 2:1, 4:1, 8:1, 4:3, etc. This function is reserved. Control frame rate output can be set by MI_SYS_BindChnPort2.
      eCompressMode Picture compression mode, only use when vif bind isp by framemode, for saving buffer. Default 0, no compression.
      Muffin can use E_MI_SYS_COMPRESS_MODE_TO_8BIT, for FBC.
      Mochi can use E_MI_SYS_COMPRESS_MODE_TO_6BIT (for YUV FBC) or E_MI_SYS_COMPRESS_MODE_SFBC0 (SFBC).
    • Related Type

      MI_VIF_SetOutputPortAttr

      MI_VIF_GetOutputPortAttr


    3.13. MI_VIF_DevPortStat_t

    • Description

      Define VIF channel information structure.

    • Definition

      typedef struct MI_VIF_DevPortStat_s
      
      {
      
          MI_BOOL bEnable;
      
          MI_U32 u32IntCnt;
      
          MI_U32 u32FrameRate;
      
          MI_U32 u32LostInt;
      
          MI_U32 u32VbFail;
      
          MI_U32 u32PicWidth;
      
          MI_U32 u32PicHeight;
      
      } MI_VIF_DevPortStat_t;
      
    • member

      Member name Description
      bEnable Channel enable.
      u32IntCnt Interrupt count.
      u32FrameRate Average fps every 1s, the precision is not perfect.
      u32LostInt Interrupt loss count.
      u32VbFail VB fail count.
      u32PicWidth Picture width.
      u32PicHeight Picture height.
    • Note

      • Interrupt count can be used to detect no interrupt

      • Fps is average fps every 1s, VIF calculate average fps every 1s, the precision is not perfect.

      • If interrupt loss count increased all the time, it meant VIF is abnormal

    • Related Type

      MI_VIF_Query


    3.14. MI_VIF_DevStatus_t

    • Description

      Define VIF device current status.

    • Definition

      typedef struct MI_VIF_VIFDevStatus_s
      
      {
      
          MI_VIF_GROUP GroupId;
      
          MI_BOOL bGroupCreated;
      
          MI_U32 bDevEn;
      
          MI_VIF_SNRPad_e eSensorPadID;
      
          MI_U32 u32PlaneID;
      
      } MI_VIF_DevStatus_t;
      
    • Member

      Member Name Description
      GroupId Device Group number
      bGroupCreated Group current Create status
      bDevEn VIF Dev current enable status
      eSensorPadID VIF Dev bound SensorPad
      u32PlaneID VIF Dev bound PlaneId
    • Related data types and interfaces

      MI_VIF_GetDevStatus


    3.15. MI_VIF_CALLBK_FUNC

    • Description

      Define callback function type

    • Definition

      typedef MI_S32 (*MI_VIF_CALLBK_FUNC)(MI_U64 u64Data);
      
    • Related data types and interfaces

      MI_VIF_CallBackParam_t


    3.16. MI_VIF_CallBackMode_e

    • Description

      Define callback mode.

    • Definition

      typedef enum
      
      {
      
          E_MI_VIF_CALLBACK_ISR,
      
          E_MI_VIF_CALLBACK_MAX,
      
      } MI_VIF_CallBackMode_e;
      
    • Member

      Member Name Description
      E_MI_VIF_CALLBACK_ISR Hardware interrupt mode callback
      E_MI_VIF_CALLBACK_MAX Callback mode Max
    • Related data types and interfaces

      MI_VIF_CallBackParam_t


    3.17. MI_VIF_IrqType_e

    • Description

      Define hardware interrupt type

    • Definition

      typedef enum
      
      {
      
          E_MI_VIF_IRQ_FRAMESTART, //frame start irq
      
          E_MI_VIF_IRQ_FRAMEEND, //frame end irq
      
          E_MI_VIF_IRQ_LINEHIT, //frame line hit irq
      
          E_MI_VIF_IRQ_MAX,
      
      } MI_VIF_IrqType_e;
      
    • Member

      Member Name Description
      E_MI_VIF_IRQ_FRAMESTART VIF frame start interrupt type
      E_MI_VIF_IRQ_FRAMEEND VIF frame done interrupt type
      E_MI_VIF_IRQ_LINEHIT VIF frame line count hit type
    • Note

      • E_MI_VIF_IRQ_FRAMESTART: Signal of the first pixel in each frame

      • E_MI_VPE_IRQ_ISPFRAMEDONE: Signal of the last pixel in each frame

      • E_MI_VIF_IRQ_LINEHIT:Signal of the set line coming in each frame

    • Related data types and interfaces

      MI_VIF_CallBackParam_t


    3.18. MI_VIF_CallBackParam_t

    • Description

      Define callback parameters.

    • Definition

      typedef struct MI_VIF_CallBackParam_s
      
      {
      
          MI_VIF_CallBackMode_e eCallBackMode;
      
          MI_VIF_IrqType_e eIrqType;
      
          MI_VIF_CALLBK_FUNC pfnCallBackFunc;
      
          MI_U64 u64Data;
      
      } MI_VIF_CallBackParam_t;
      
    • Member

      Member Name Description
      eCallBackMode Call back mode
      eIrqType Hardware interrupt type
      pfnCallBackFunc Callback function
      u64Data Callback function parameters
    • Related data types and interfaces

      MI_VIF_CallBackTask_Register

      MI_VIF_CallBackTask_UnRegister


    3.19. MI_VIF_HDRFusionType_e

    • Description

      Define HDR fusion type.

    • Definition

      typedef enum
      {
          E_MI_VIF_HDR_FUSION_TYPE_NONE,
          E_MI_VIF_HDR_FUSION_TYPE_2T1,
          E_MI_VIF_HDR_FUSION_TYPE_3T1,
          E_MI_VIF_HDR_FUSION_TYPE_MAX
      } MI_VIF_HDRFusionType_e;
      
    • Member

      Member Name Description
      E_MI_VIF_HDR_FUSION_TYPE_NONE Not represent any fusion type
      E_MI_VIF_HDR_FUSION_TYPE_2T1 2Frame HDR mode
      E_MI_VIF_HDR_FUSION_TYPE_3T1 3Frame HDR mode
      E_MI_VIF_HDR_FUSION_TYPE_MAX HDR fusion mode Enum Max value
    • Note

      • E_MI_VIF_HDR_FUSION_TYPE_2T1: 2Frame HDR with long/short exposure, internal default value even not set this fusion type when open HDR.

      • E_MI_VIF_HDR_FUSION_TYPE_3T1: 3Frame HDR, for long/medium/short exposure, only supported in Souffle.

    • Related data types and interfaces

      MI_VIF_GroupAttr_t

      MI_VIF_CreateDevGroup


    3.20. MI_VIF_HDRExposureType_e

    • Description

      Define HDR exposure type.

    • Definition

      typedef enum
      {
          E_MI_VIF_HDR_EXPOSURE_TYPE_NONE,
          E_MI_VIF_HDR_EXPOSURE_TYPE_SHORT   = 0x01,
          E_MI_VIF_HDR_EXPOSURE_TYPE_MEDIUM  = 0x02,
          E_MI_VIF_HDR_EXPOSURE_TYPE_LONG    = 0x04,
          E_MI_VIF_HDR_EXPOSURE_TYPE_MAX
      } MI_VIF_HDRExposureType_e;
      
    • Member

      Member Name Description
      E_MI_VIF_HDR_EXPOSURE_TYPE_NONE Not represent any HDR exposure
      E_MI_VIF_HDR_EXPOSURE_TYPE_SHORT HDR Short exposure
      E_MI_VIF_HDR_EXPOSURE_TYPE_MEDIUM HDR Medium exposure
      E_MI_VIF_HDR_EXPOSURE_TYPE_LONG HDR Long exposure
      E_MI_VIF_HDR_EXPOSURE_TYPE_MAX HDR exposure Enum Max Value
    • Note

      • In 2Frame HDR, MI VIF will force to 0x1+0x4(short/long) exposure inside.

      • E_MI_VIF_HDR_EXPOSURE_TYPE_MEDIUM: only support in Souffle.

    • Related data types and interfaces

      MI_VIF_GroupAttr_t

      MI_VIF_CreateDevGroup


    3.21. MI_VIF_MetaDataType_e

    • Description

      Define VIF extra function type.

    • Definition

      typedef enum
      {
          E_MI_VIF_METADATA_NONE,
          E_MI_VIF_METADATA_PDAF       = 0x01,
          E_MI_VIF_METADATA_HEADER     = 0x02,
          E_MI_VIF_METADATA_AE_STAT    = 0x04,
          E_MI_VIF_METADATA_AWB_STAT   = 0x08,
          E_MI_VIF_METADATA_AF_STAT    = 0x10,
          E_MI_VIF_METADATA_HISTO_STAT = 0x20,
          E_MI_VIF_METADATA_MAX
      } MI_VIF_MetaDataType_e;
      
    • Member

      Member Name Description
      E_MI_VIF_METADATA_NONE Not represent any function
      E_MI_VIF_METADATA_PDAF PDAF function
      E_MI_VIF_METADATA_HEADER Header not compress function
      E_MI_VIF_METADATA_AE_STAT STA function AE statistics
      E_MI_VIF_METADATA_AWB_STAT STA function AWB statistics
      E_MI_VIF_METADATA_AF_STAT STA function AF statistics
      E_MI_VIF_METADATA_HISTO_STAT STA function HISTO statistics
      E_MI_VIF_METADATA_MAX Metadata enum Max value
    • Related data types and interfaces

      MI_VIF_MetaDataAttr_t


    3.22. MI_VIF_MetaDataAttr_t

    • Description

      Define VIF extra function structure.

    • Definition

      typedef struct MI_VIF_MetaDataAttr_s
      {
          MI_U32              u32MetaDataTypeMask;
          MI_SYS_WindowRect_t stCropRect; // For header usage only
      } MI_VIF_MetaDataAttr_t;
      
    • Member

      Member Name Description
      u32MetaDataTypeMask Extra function onoff Mask value
      stCropRect Crop window of Header not compress function
    • Related data types and interfaces

      MI_VIF_GroupAttr_t

      MI_VIF_CreateDevGroup


    3.23. MI_VIF_CustCmd_e

    • Description

      Define VIF customer command id.

    • Definition

      typedef enum
      {
          E_MI_VIF_CUSTCMD_PUTNUCDATA,
          E_MI_VIF_CUSTCMD_SETIRSTATUS,
          E_MI_VIF_CUSTCMD_FRAMEEND_NOTIFY,
          E_MI_VIF_CUSTCMD_SLEEPPARAM_SET,
          E_MI_VIF_CUSTCMD_SHUTTER_GAIN_SET,
          E_MI_VIF_CUSTCMD_FORCEFRAMEPARAM_SET,
          E_MI_VIF_CUSTCMD_MAX
      } MI_VIF_CustCmd_e;
      
    • Member

      Member Name Description Data Type
      E_MI_VIF_CUSTCMD_PUTNUCDATA Customized command for VIF to set NUC buffer MI_VIF_PutDataAttr_t
      E_MI_VIF_CUSTCMD_SETIRSTATUS Customized command for VIF to set IR status MI_U8
      E_MI_VIF_CUSTCMD_FRAMEEND_NOTIFY Customized command for VIF to set function pointer of FrameEnd Callback void*
      E_MI_VIF_CUSTCMD_SLEEPPARAM_SET Customized command for VIF to set the parameters of controlling the Sensor to enter sleep mode MI_VIF_SleepModeParams_t
      E_MI_VIF_CUSTCMD_SHUTTER_GAIN_SET Customized command for VIF to set the parameters of controlling sensor exposure MI_VIF_ShutterGainParams_t
      E_MI_VIF_CUSTCMD_FORCEFRAMEPARAM_SET force sensor exit sleep mode immediately MI_VIF_ForceFrameParams_t
      E_MI_VIF_CUSTCMD_MAX Max value of customized command NA
    • Note

      • E_MI_VIF_CUSTCMD_PUTNUCDATA: This command only use when Input is Thermal Sensor, customer will process NUC correction algorithm by AD data get from Thermal Sensor, then put NUC data into VIF by this command, and VIF will transfer this NUC data to Thermal Sensor.
      • E_MI_VIF_CUSTCMD_SETIRSTATUS: This command is for Windows Hello function, customer will set IR status(ON:1 OFF:0) to VIF by this cmd, then VIF will put this IR flag into buffer info, so customer can get IR status when they get output buffer.
      • E_MI_VIF_CUSTCMD_FRAMEEND_NOTIFY: In the AOV scene, it is used to register the the callback function of Frame End. VIF will call the registered function in the Frame End interrupt.
      • E_MI_VIF_CUSTCMD_SLEEPPARAM_SET: In the AOV scene, it is used to set the parameters of controlling the number of frames that the Sensor needs to stream out before entering the Sleep mode through VIF.
      • E_MI_VIF_CUSTCMD_SHUTTER_GAIN_SET: In AOV scene, it is used to set the shutter and gain values of the sensor through VIF.
      • E_MI_VIF_CUSTCMD_FORCEFRAMEPARAM_SET: Before using this command , you need to call E_MI_VIF_CUSTCMD_SLEEPPARAM_SET to set variable bSleepEnable to true.
    • Related data types and interfaces

      MI_VIF_CustFunction


    3.24. MI_VIF_PutDataAttr_t

    • Description

      Define VIF input data structure.

    • Definition

      typedef struct MI_VIF_PutDataAttr_s
      {
          MI_U32 u32Stride;
          MI_U32 u32Buffsize;
          MI_PHY phyAddr;
      } MI_VIF_PutDataAttr_t;
      
    • Member

      Member Name Description
      u32Stride Input data byte count of one line
      u32Buffsize Input data buffer size
      phyAddr Input data buffer address
    • Related data types and interfaces

      MI_VIF_CustFunction


    3.25. MI_VIF_FrameEndInfo_t

    • Description

      FrameEnd interrupt in the FrameEnd Callback registered by Cusfuntion will pass this structure as an input parameter.

    • Definition

      typedef struct MI_VIF_FrameEndInfo_s
      {
          MI_BOOL bDoneFlag;
          MI_U32  u32FrameCnt;
          MI_VIF_DEV vifDevId;
      } MI_VIF_FrameEndInfo_t;
      
    • Member

      Member Name Description
      bDoneFlag Flag to determine if it is the last Frame
      u32FrameCnt FrameEnd count value
      vifDevId vif device id of frame done
    • Related data types and interfaces

      MI_VIF_CustFunction

    • Usage and sample code

      The usage of this command is shown in the figure

      1. Declare the address of the function pointer in the user app
      2. In the user driver, bind the frameDone_Callback function in the driver to the address passed in step 1 through ioctl.
      3. Call MI_VIF_CustFunction in the user app.
      4. Inside the VIF, the function bound in the user driver will be automatically called when the frame is done

      Here is a simple example code for using the command:

      //user driver
      static int Misc_Control_FrameDone_CallBack(MI_VIF_FrameEndInfo_t *pstVifFrameEndInfo)
      {
          printk("Here to get updated info from vif when frameDone\n");
          printk("vifDevId: %d doneFlag:%d frameCnt:%d\n", pstVifFrameEndInfo->vifDevId,
              pstVifFrameEndInfo->bDoneFlag, pstVifFrameEndInfo->u32FrameCnt);
      }
      
      static long misc_control_dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
      {
          int ret = 0;
          switch (cmd)
          {
              case IOCTL_MISC_CONTROL_INIT:
              {
                  unsigned long fun_ptr_addr = 0;
                  if (copy_from_user(&fun_ptr_addr, (int __user *)arg, sizeof(fun_ptr_addr)))
                  {
                      return -EFAULT;
                  }
                  //bind user app callback func addr with specific func in user driver
      
                  fun_ptr_addr = Misc_Control_FrameDone_CallBack;
      
                  if (copy_to_user((int __user *)arg, &stCallback_Param, sizeof(Misc_Callback_Param_t)))
                  {
                      return -EFAULT;
                  }
      
                  else
                  {
                      return -EFAULT;
                  }
              }
          }
          return 0;
      }
      
      //user app
      void main()
      {
          unsigned long fun_ptr_addr ;
          ioctl(dev_fd, IOCTL_MISC_CONTROL_INIT, &fun_ptr_addr);
          MI_VIF_CustFunction(vifDevId, (MI_VIF_CustCmd_e)E_MI_VIF_CUSTCMD_FRAMEEND_NOTIFY, sizeof(unsigned long),
                                  &callback_param.fun_ptr_addr);
      }
      

      For more details and usage, please refer to sdk/verify/sample_code/internal/aov/light_misc_control_api.h


    3.26. MI_VIF_SleepModeParams_t

    • Description

      Define the parameter structure for VIF to control the Sensor to enter and exit Sleep Mode.

    • Definition

      typedef struct MI_VIF_SleepModeParams_s
      {
          MI_BOOL bSleepEnable;
          MI_U32  u32FrameCntBeforeSleep;
      } MI_VIF_SleepModeParams_t;
      
    • Member

      Member Name Description
      bSleepEnable Whether to enable VIF to control the Sensor to enter Sleep mode
      u32FrameCntBeforeSleep Frame count for VIF to control the Sensor to enter Sleep mode
    • Related data types and interfaces

      MI_VIF_CustFunction

    • Usage and sample code

      void *aov_thread(void* args)
      {
          MI_VIF_SleepModeParams_t stSleepParam;
      
          while(!bExit)
          {
              if(status == wakeup)
                  stSleepParam.bSleepEnable = TRUE;
                  stSleepParam.u32FrameCntBeforeSleep = 1;
                  MI_VIF_CustFunction(u32VifDevId, E_MI_VIF_CUSTCMD_SLEEPPARAM_SET, sizeof(MI_VIF_SleepModeParams_t), &stSleepParam);
      
                  //wait frame done
                  ......
      
                  //enter suspend
                  system("echo mem >/sys/power/state");
      
          }
      
          // Disable sleep mode
          stSleepParam.bSleepEnable = FALSE;
          MI_VIF_CustFunction(u32VifDevId, E_MI_VIF_CUSTCMD_SLEEPPARAM_SET, sizeof(ST_Common_SNRSleepParam_t), &stSleepParam);
      }
      
      int main()
      {
          pthread_t pthread;
      
          //init and run the pipeline
          pipeline_init_and_run();
      
          pthread_create(&pthread, NULL, aov_thread, NULL);
          pthread_join(&pthread, NULL);
      
      }
      

      For more details and usage, please refer to sdk/verify/sample_code/source/iford/aov/aov_demo/st_sample_aov.c


    3.27. MI_VIF_ShutterGainParams_t

    • Description

      Define the parameter structure for VIF to control AE of Sensor.

    • Definition

      typedef struct MI_VIF_ShutterGainParams_s
      {
          MI_U32 u32ShutterTimeUs;
          MI_U32 u32AeGain;
      } MI_VIF_ShutterGainParams_t;
      
    • Member

      Member Name Description
      u32ShutterTimeUs Set the Shutter value of Sensor, unit: us
      u32AeGain Set the Gain value of Sensor, unit: 1024
    • Related data types and interfaces

      MI_VIF_CustFunction - Usage and sample code

      MI_VIF_ShutterGainParams_t stSnrParam;
      MI_U32 u32Gain = 1;
      stSnrParam.u32ShutterTimeUs = 1000;
      stSnrParam.u32AeGain        = u32Gain x 1024;
      MI_VIF_CustFunction(0, E_MI_VIF_CUSTCMD_SHUTTER_GAIN_SET, sizeof(MI_VIF_ShutterGainParams_t), &stSnrParam);
      

      For more details and usage, please refer to sdk/verify/sample_code/internal/aov/st_common_aov.c


    3.28. MI_VIF_ForceFrameParams_t

    • Description

      Define the setting parameters of VIF to force the sensor to exit sleep mode

    • Definition

      typedef struct MI_VIF_ForceFrameParams_s
      {
          MI_U32  u32ForceFrameCnt;
          MI_U32  u32DropCnt;
      } MI_VIF_ForceFrameParams_t;
      
    • Member

      Member Name Description
      u32ForceFrameCnt frame counts before sensor entering sleep mode
      u32DropCnt frame counts dropped by VIF
    • Usage and sample code

      void Do_fastAe()
      {
          // configure sensor to enable sleep mode & consecutive frames cnt (to 2)
          MI_VIF_SleepModeParams_t stVifSleepParam;
          stVifSleepParam.bSleepEnable           = TRUE;
          stVifSleepParam.u32FrameCntBeforeSleep = 2;
          MI_VIF_CustFunction(u32VifDevId, E_MI_VIF_CUSTCMD_SLEEPPARAM_SET, sizeof(MI_VIF_SleepModeParams_t),
                              &stVifSleepParam);
      
          // wait sensor enter sleep mode
          // config to small pic (switch on fast ae)
          ......
      
          MI_VIF_ForceFrameParams_t stVifSleepDisableParam;
          stVifSleepDisableParam.u32ForceFrameCnt = 4;
          stVifSleepDisableParam.u32DropCnt       = 3;
          MI_VIF_CustFunction(u32VifDevId, E_MI_VIF_CUSTCMD_FORCEFRAMEPARAM_SET, sizeof(MI_VIF_ForceFrameParams_t),
                              &stVifSleepDisableParam);
      
          //wait sensor stream out done
          //configure sensor to enable sleep mode & consecutive frames cnt (to 1)
          ......
      
      }
      

      For more details and usage, please refer to sdk/verify/sample_code/internal/fast_ae/fast_ae.c


    3.29. MI_VIF_AiIspAttr_t

    • Description

      Define AiIsp attribute configuration

    • Definition

      typedef struct MI_VIF_AiIspAttr_s {
          MI_VIF_AiBnrAttr_t stVifAiBnrAttr;
          MI_VIF_AiHdrAttr_t stVifAiHdrAttr;
      } MI_VIF_AiIspAttr_t;
      
    • Member

      Member Name Description
      stVifAiBnrAttr Define AiBnr case attribute configuration
      stVifAiHdrAttr Define AiHdr case attribute configuration
    • Related data types and interfaces

      MI_VIF_GroupAttr_t


    3.30. MI_VIF_AiBnrAttr_t

    • Description

      Define AiBnr case attribute configuration

    • Definition

      typedef struct MI_VIF_AiBnrAttr_s {
          MI_VIF_AiBnrSourceType_e eAiSourceType;
      } MI_VIF_AiBnrAttr_t;
      
    • Member

      Member Name Description
      eAiSourceType Define AI BNR source type
    • Related data types and interfaces

      MI_VIF_AiIspAttr_t


    3.31. MI_VIF_AiHdrAttr_t

    • Description

      Define AiHdr case attribute configuration

    • Definition

      typedef struct MI_VIF_AiHdrAttr_s {
          MI_BOOL bAiHdrEn;
      } MI_VIF_AiHdrAttr_t;
      
    • Member

      Member Name Description
      bAiHdrEn Enable or disable aihdr function
    • Related data types and interfaces

      MI_VIF_AiIspAttr_t


    3.32. MI_VIF_AiBnrSourceType_e

    • Description

      Define AI BNR source type

    • Definition

      typedef enum
      {
          E_MI_VIF_AI_BNR_SOURCE_TYPE_NONE,
          E_MI_VIF_AI_BNR_SOURCE_TYPE_LINEAR,
          E_MI_VIF_AI_BNR_SOURCE_TYPE_HDR_FUSION,
          E_MI_VIF_AI_BNR_SOURCE_TYPE_HDR_LONG,
          E_MI_VIF_AI_BNR_SOURCE_TYPE_MAX
      } MI_VIF_AiBnrSourceType_e;
      
    • Member

      Member Name Description
      E_MI_VIF_AI_BNR_SOURCE_TYPE_LINEAR Do AI for linear mode case
      E_MI_VIF_AI_BNR_SOURCE_TYPE_HDR_FUSION Do AI work after ISP HDR fusion
      E_MI_VIF_AI_BNR_SOURCE_TYPE_HDR_LONG Do AI work for long exposure frame
    • Related data types and interfaces

      MI_VIF_AiBnrAttr_t


    4. VIF ERROR CODE


    VIF API error code is defined in following table:

    Error code Macro definition Description
    0xA0062001 MI_ERR_VIF_INVALID_DEVID Video Input device ID invalid
    0xA0062002 MI_ERR_VIF_INVALID_CHNID Video Input channel ID invalid
    0xA0062003 MI_ERR_VIF_INVALID_PARA Video Input parameter invalid
    0xA0062006 MI_ERR_VIF_INVALID_NULL_PTR Null pointer invalid
    0xA0062007 MI_ERR_VIF_FAILED_NOTCONFIG Video device or channel attribute is not configured
    0xA0062008 MI_ERR_VIF_NOT_SUPPORT Operation is not supported
    0xA0062009 MI_ERR_VIF_NOT_PERM Operation is not permitted
    0xA006200C MI_ERR_VIF_NOMEM Memory allocation fail
    0xA006200E MI_ERR_VIF_BUF_EMPTY Buffer empty
    0xA006200F MI_ERR_VIF_BUF_FULL Buffer full
    0xA0062010 MI_ERR_VIF_SYS_NOTREADY Video Input system is not ready
    0xA0062012 MI_ERR_VIF_BUSY Video Input system is busy
    0xA0062080 MI_ERR_VIF_INVALID_PORTID Video Input port ID invalid
    0xA0062081 MI_ERR_VIF_FAILED_DEVNOTENABLE Video Input device is not enable
    0xA0062082 MI_ERR_VIF_FAILED_DEVNOTDISABLE Video Input device is not disable
    0xA0062083 MI_ERR_VIF_FAILED_PORTNOTENABLE Video Input channel is not enable
    0xA0062084 MI_ERR_VIF_FAILED_PORTNOTDISABLE Video Input channel is not disable
    0xA0062085 MI_ERR_VIF_CFG_TIMEOUT Video configure timeout
    0xA0062086 MI_ERR_VIF_NORM_UNMATCH Video norm of ADC and VIU unmatched
    0xA0062087 MI_ERR_VIF_INVALID_WAYID Video way ID invalid
    0xA0062088 MI_ERR_VIF_INVALID_PHYCHNID Video physical channel ID invalid
    0xA0062089 MI_ERR_VIF_FAILED_NOTBIND Video channel is not bound
    0xA006208A MI_ERR_VIF_FAILED_BINDED Video channel is bound

    5. PROCFS INTRODUCTION


    5.1. cat

    • Debug Information

      #cat /proc/mi_modules/mi_vif/mi_vif0
      
      ----------------------------------dump Group Attr--------------------------------------------------
      groupId  Intf       Work  Clkedge   Hdr  HdrFusion  ExposureMask    NUC  MetaDataType       MetaCrop
      0  MIPI 1MULTIPLEX        2   OFF       NONE             0    0             0(0,0,   0,   0)
      
      ----------------------------------dump Dev Attr--------------------------------------------------
      Dev  FsCnt  ActiveTime         incrop       infmt  capsel    rstcnt  NucRdmaDone
      0    745        32ms(0,0,3840,2160)    RG_10BPP       0( 0, 0, 0)            0
      Dev  AsyncCnt  EnqCnt  BarCnt  CheckCnt  DequCnt  DropCnt  NucEnqCnt  Mask
      0      1438     709     708      2130      706        0          0     0
      
      -------------------------------------dump pipe attr-----------------------------------------------
      PipeId  PortId  DevId  Hdn           crop       Dest  Pixel  wkmode  Compress
      12       0      0    0(0,0,3840,2160)(3840x2160)     45       1         0
      
      -------------------------------------dump outport attr-----------------------------------------------
      Dev  Port  wFsNum  wLCNum  wDoneNum  Dvcnt  Oscnt  LostFrame
      0     0     711       0       706      0      0          3
      
      Dev  Port       Cap_size  Dest_size       Fmt  Rate  CRC  Atom       MetaInfo  OutCount  Addr0Cnt  FailCount  EnqFailCount  Fps
      0     0(0,0,3840,2160)(3840,2160)  RG_10BPP     0    0     2  c0000000005a3       706         1          1             0    30.04
      
      Dev  Port   Recv_size    Out_size SubOut_size  FifoDepth  WInactive
      0     0 (3856,2180) ( 300,2160) (   0,   0)          1          0
      
    • Debug Information Analysis

      Record the current VIF usage status and Group/ Dev/ pipe/ outport attributes, you can get this information dynamically, which is convenient for debugging and testing.

    • Parameter Description

      Parameter Description
      Group Attr GroupId Group ID
      input input ID
      Intf Protocol for entering data, please refer toMI_VIF_IntfMode_e
      Work Work mode, please refer toMI_VIF_WorkMode_e
      Clkedge Clock edge trigger mode, please refer toMI_VIF_ClkEdge_e
      Hdr Hdr type, please refer to MI_VIF_HDRType_e
      HdrFusion Hdr fusion type, please refer to MI_VIF_HDRFusionType_e
      ExposureMask Hdr exposure bitmask, please refer to MI_VIF_HDRExposureType_e
      NUC if using NUC Sensor, use NUC flow
      MetaDataType vif extra function using status bitmask, please refer to MI_VIF_MetaDataType_e
      MetaDataCrop Crop window of Header not compress function, please refer to MI_VIF_MetaDataAttr_t
      Dev Attr Dev Dev ID
      FsCnt Interrupt count of Frame start
      chn channel ID, actually used device id
      FsCnt Interrupt count of Frame start
      FsInt Interval between two Frame start(unit:us)
      Active timing of active data transmission
      FdCnt Interrupt count of Frame done
      incrop Input Corp Size, please refer toMI_VIF_DevAttr_t stInputRect
      infmt Input pixel format, please refer toMI_VIF_DevAttr_t eInputPixel
      capsel Field type, please refer toMI_VIF_DevAttr_t Field
      rstcnt Reset count, corresponding to (Fifo, Wdma, Fifo_Wdma)
      NucRdmaDone Nuc rdma done count
      AsyncCnt/EnqCnt/ BarCnt/CheckCnt/ DequCnt MI internal Callback interface execution times
      DropCnt Drop frame count
      NucEnqCnt nuc buffer count queued by app to mi vif, also buffer count which queue to nuc rdma
      channel Attr Dev Dev ID
      PipeId Pipe id
      Port Port ID
      Chn >channel ID, actually used device id
      Output Output ID, VIF internal pipe ID
      Hdn H2T1PMode enable, please refer toMI_VIF_DevAttr_t bEnH2T1PMode
      crop output crop size (Height will divide 2 in DI Mode)
      Dest output size (Height will divide 2 in DI Mode)
      Pixel Mhal output Pixel, transferred by MI pixel
      wkmode Pipe work mode, 0: Realtime,1: FrameMode
      Compress Please refer to MI_VIF_OutputPortAttr_t eCompressMode
      OutPort Attr Dev Device id
      Port Port id
      Output Output ID, VIF internal pipe ID
      FsNum Count of Wdma Frame start Interrupt
      FsInt Interval of Wdma Frame start Interrupt(unit:us)
      LCNum Count of Wdma Line Count hit
      DoneNum Count of Wdma Done
      DvCnt Count of Wdma Double vsync
      OsCnt Count of Wdma Oversize
      LostFrame Lost count of Wdma Frame start Interrupt
      TaskId Current Wdma used fifo customer id
      BufAddr Current Wdma used buffer addr
      Cap_size Port Crop Size, please refer to MI_VIF_OutputPortAttr_t stCapRect
      Dest_size Output size, please refer to MI_VIF_OutputPortAttr_t stDestSize
      Fmt Output pixel format, please refer toMI_VIF_OutputPortAttr_t ePixFormat
      Rate Frame rate type, please refer toMI_VIF_OutputPortAttr_t eFrameRate
      CRC CRC on/off status
      Atom The number of buffers held by driver
      MetaInfo Frame id
      OutCount Output frame count, only done frame, not include drop frame
      Addr0Cnt Frame address 0 count, means skip frame count
      FailCount Failed to get outputbuffer count
      EnqFailCount Count which failed to queue buffer to wdma
      Fps Frame per second
      Recv_size Vif hardware received size
      Out_size Port0 wdma size setting
      SubOut_size Port1 wdma size setting
      FifoDepth Buffer count in wdma fifo
      WdmaInactive Wdma is active or not, 0: active, 1: inactive


    5.2. echo

    Echo help can view available commands:

    # echo help >/proc/mi_modules/mi_vif/mi_vif0
    
         dump           [devid portid /path cnt DumpDrop];
    
         initatom       [devid InitAtom];
    
         erasebuffer    [devid portid bEraseBuffer];
    
         devmask        [devid bMask];
    
         enport         [devid portid bEn];
    
         cfgport        [devid portid crop(x,y,width,height) dest(width,height) pixel];
    
         resethw        [devid eResetType(0:FIFO 1:wdma 2:AFIFO_WDMA_GROUP 3:FIFO_WDMA_DEV)];
    
         fpsth      [devid portid FpsTh FpsFloatTh];
    
         ptsth      [devid portid ptsmax ptsmin];
    
         fifofull   [devid cnt];
    
         crc        [devid enable];
    
         patgen     [grouid w h fps fmt chn fieldEn hdren En];
    
         datagen        [grouid En];
    
         forcedeque     [devid portid curwrite validcnt wdmainactive], curwrite !=0, will use validcnt/wdmainactive param;
    
         debuglv        [devid level] buffer debug(0x1), check_loop(0x2), check_isr(0x4), check_flow(0x8), check_latency(0x80);
    
         changebuf      [devid portid changecnt (bdump, mode) ];once(0), once_vfs_pps(1), constant(2), constant_vfs_pps(3)
    
    Function
    Dump frame to the specified path.
    Command echo dump [devid portid path cnt dumpdrop] > /proc/mi_modules/mi_vif/mi_vif0
    Parameter
    Description
    devid: device id
    portid: port id
    path: Dumped path
    cnt: optional, frame count need to be dumped, default 1
    dumpdrop: optional, only dump frame need to be dropped, default FALSE
    Example echo dump 0 0 /tmp > /proc/mi_modules/mi_vif/mi_vif0
    echo dump 0 0 /tmp 2 1 > /proc/mi_modules/mi_vif/mi_vif0
    Function
    Set the number of vif atoms.
    Command echo initatom [devid portid InitAtom] > /proc/mi_modules/mi_vif/mi_vif0
    Parameter
    Description
    devid: device id
    portid: port id
    InitAtom: The maximum number of buffers held by the Driver
    Example echo initatom 0 0 2 > /proc/mi_modules/mi_vif/mi_vif0
    Function
    Erase vif buffer
    Command echo erasebuffer [devid portid bEraseBuffer] > /proc/mi_modules/mi_vif/mi_vif0
    Parameter
    Description
    devid: device id
    portid: port id
    EraseBuffer: Enable to erase buffer
    Example echo erasebuffer 0 0 1 > /proc/mi_modules/mi_vif/mi_vif0
    Function
    Set Dev Mask
    Command echo devmask [devid bMask] > /proc/mi_modules/mi_vif/mi_vif0
    Parameter
    Description
    devid: device id
    bmask: Enable mask
    Example echo devmask 0 1 > /proc/mi_modules/mi_vif/mi_vif0
    Function
    Enable output port
    Command echo enport [devid portid bEn] > /proc/mi_modules/mi_vif/mi_vif0
    Parameter
    Description
    devid: device id
    portid: port id
    bEn: enable
    Example echo enport 0 0 1 > /proc/mi_modules/mi_vif/mi_vif0
    Function
    Set output port attribute
    Command echo cfgport [devid portid crop(x,y,width,height) dest(width,height) pixel compress] > /proc/mi_modules/mi_vif/mi_vif0
    Parameter
    Description
    devid: device id
    portid: port id
    crop(x,y,width,height): output port crop position
    dest(width,height): output size
    Pixel: output port pixel format
    compress: compress mode
    Example echo cfgport 0 0 0 0 1280 720 1280 720 14 5 > /proc/mi_modules/mi_vif/mi_vif0
    Function
    Reset vif
    Command echo resethw [devid eResetType] > /proc/mi_modules/mi_vif/mi_vif0
    Parameter
    Description
    devid: device id
    eResetType: reset position. 0:FIFO; 1:wdma; 2:AFIFO_WDMA_GROUP; 3:FIFO_WDMA_DEV
    Example echo resethw 0 3 > /proc/mi_modules/mi_vif/mi_vif0
    Function
    Set fps threshold. When fps less than threshold, warning will be reported.
    Command echo fpsth [devid portid FpsTh FpsFloatTh] > /proc/mi_modules/mi_vif/mi_vif0
    Parameter
    Description
    devid: device id
    portid: port id
    FpsTh: fps integer threshold
    FpsFloatTh: fps decimal threshold
    Example echo enport 0 0 29 98 > /proc/mi_modules/mi_vif/mi_vif0
    Function
    Set pts interval threshold. When pts is not in the range of threshold, warning will be reported.
    Command echo ptsth [devid portid ptsmin ptsmax] > /proc/mi_modules/mi_vif/mi_vif0
    Parameter
    Description
    devid: device id
    portid: port id
    ptsmin: pts interval min threshold(us)
    ptsmax: pts interval max threshold(us)
    Example echo ptsth 0 0 25000 40000 > /proc/mi_modules/mi_vif/mi_vif0
    Function
    Trigger fifo full reset flow
    Command echo fifofull [devid bNeedReset] > /proc/mi_modules/mi_vif/mi_vif0
    Parameter
    Description
    devid: device id
    bNeedReset: set 1 to trigger fifo full reset flow
    Example echo fifofull 0 1 > /proc/mi_modules/mi_vif/mi_vif0
    Function
    Enable CRC check
    Command echo crc [devid portid enable] > /proc/mi_modules/mi_vif/mi_vif0
    Parameter
    Description
    devid: device id
    portid: port id
    enable: set 1 to enable CRC
    Example echo crc 0 0 1 > /proc/mi_modules/mi_vif/mi_vif0
    Function
    Set MI VIF debug level
    Command echo debuglv [devid debuglevel] > /proc/mi_modules/mi_vif/mi_vif0
    Parameter
    Description
    devid: device id
    debuglevel: MI VIF debug level, default 0, off
    0x0001 Mhal_Buff_Dbg
    0x0002 CHECK_LOOP
    0x0004 CHECK_ISR
    0x0008 CHECK_FLOW
    0x0080 CHECK_LATENCY
    Example echo debuglv 0 3 > /proc/mi_modules/mi_vif/mi_vif0
    Function
    Enable VIF pattern gen
    Command echo patgen [group width height fps pixel multi bFieldEn bHdrEn Enable] > /proc/mi_modules/mi_vif/mi_vif0
    Parameter
    Description
    Group: group ID
    Width: pattern width
    Height: pattern height
    Fps: output frame per second
    Pixel: pattern pixel format
    Multi: can be set to 1chn/2chn/4chn, the same as BT656 multichn concept
    bFieldEn: enable DI mode
    Enable: enable pattern
    Example echo patgen 0 1280 720 25 14 4 0 1 1 > /proc/mi_modules/mi_vif/mi_vif0
    Function
    Enable VIF data gen
    Command echo datagen [group Enable] > /proc/mi_modules/mi_vif/mi_vif0
    Parameter
    Description
    group: group ID
    Enable: enable data gen
    Example echo datagen 0 1 > /proc/mi_modules/mi_vif/mi_vif0
    Function
    Force deque vif buffer, used for debugging when the buffer is stuck in vif.
    Command echo forcedeque [devid portid CurrentWriteAddr ValidCnt WdmaInactive] > /proc/mi_modules/mi_vif/mi_vif0
    Parameter
    Description
    devid: device id
    Portid: port id
    CurrentWriteAddr: address which WMDA is writing
    ValidCnt: buffer count which stay in WDMA FIFO
    WdmaInactive: wdma status, 0: active, 1: inactive
    Example echo forcedeque 0 0 0 0 1 > /proc/mi_modules/mi_vif/mi_vif0
    Function
    Change VIF output buffer randomly
    Command echo changebuf [devid portid cnt bdump mode] > /proc/mi_modules/mi_vif/mi_vif0
    Parameter
    Description
    devid: device id
    portid: port id
    Cnt: buffer count which need to be changed
    bdump: optional, dump change buffer or not, default FALSE not dump
    Mode: optional, different mode to change buffer, default mode 0
    0: Only change buffer by the count which user set
    1: For SFBC0 compress, only change count which user set, but change position within SFBC0 PPS header
    2: Change every output buffer, and not refer to parameter “cnt”
    3: Change every output buffer, change position include 50% SFBC0 PPS and 50% Non-PPS, and not refer to parameter “cnt”
    Example echo changebuf 0 0 3 > /proc/mi_modules/mi_vif/mi_vif0
    echo changebuf 0 0 3 1 2 > /proc/mi_modules/mi_vif/mi_vif0

    5.3. cat debug_hal

    5.3.1. vif_ints

    • Debug Information

      #cat /proc/mi_modules/mi_vif/debug_hal/vif0/vif_ints
      
      == VIF3 INTS @:218128070 ==
      == VIF CH-0 ==
      CH State:                       : WORKING
      Interval(us)                    : 33336
      FramePeriod(us)                 : 33334
      VREF_FALLING                    : 3737 @:218108268
      LINE_CNT_0                      : 3736 @:218106814
      LINE_CNT_1                      : 3737 @:218108269
      TOTAL_PIX_CNT                   : 3736 @:218106939
      
      == VIF WDMA-0(0) p0 aff0 ==
      WDMA State:                     : WORKING
      FrameStart                      : 0 @:0
      LINE_CNT                        : 0 @:0
      FrameDone                       : 0 @:0
      
      == VIF FIFO-0 ==
      Aff State:                      : WORKING
      AFF Count:                      : 0 @:0
      
      == VIF FIFO-1 ==
      Aff State:                      : READY
      AFF Count:                      : 0 @:0
      
      == VIF FIFO-2 ==
      Aff State:                      : READY
      AFF Count:                      : 0 @:0
      
      == VIF FIFO-3 ==
      Aff State:                      : READY
      AFF Count:                      : 0 @:0
      
    • Debug Information Analysis

      Record the frame cycle, current state of VIF Channel/Wdma/Aff, and related interrupt count.

    • Parameter Description

      Parameter Description
      VIF CH CH State CH current state
      Interval(ns) Frame interval time
      VREF_FALLING VSYNC interrupt count and display the timestamp of the most recent interrupt
      LINE_CNT_0 Total line count hit 0 interrupt count and display the timestamp of the most recent interrupt
      LINE_CNT_1 Total line count hit 1 interrupt count and display the timestamp of the most recent interrupt
      TOTAL_PIX_CNT Total pixel count hit interrupt count and display the timestamp of the most recent interrupt
      VIF WDMA WDMA State Wdma current state
      FrameStart Frame start interrupt count and display the timestamp of the most recent interrupt
      LINE_CNT Line count hit interrupt count and display the timestamp of the most recent interrupt
      FrameDone Frame done interrupt count and display the timestamp of the most recent interrupt
      VIF FIFO Aff State Afifo current state
      AFF Count Fifo full interrupt count and display the timestamp of the most recent interrupt

    5.3.2. vif_info

    • Debug Information

      /  # cat /proc/mi_modules/mi_vif/debug_hal/vif0/vif_info
      == VIF0 INFO @:10772957883 ==
      == VIF CH=0 ==
      CH State:: WORKING
      [vg:0 link:FRAME_WDMA]--[chn:0]--[afifo:0]--[pipe:0(0)]--[wdma:0(0)]--[end]
      CH_EN: 1
      SRC: MIPI0
      INPUT_FMT: RGB
      PIX_FMT: 10 bits
      CROP_EN: 1
      CROP_START_X: 0 - 3839
      CROP_START_Y: 0 - 2159
      PIXEL_CNT: 3840
      LINE_CNT: 2160
      TOTAL_PIXEL_CNT: 3864
      TOTAL_LINE_CNT: 2192
      
    • Debug Information Analysis

      Record the basic VIF settings obtained from the register.

    • Parameter Description

      Parameter Description
      CH State CH current state
      vg Group ID
      link Link mode:
      E_VIF_LINK_PATH_TYPE_FRAME_WDMA
      E_VIF_LINK_PATH_TYPE_REAL_ISP
      E_VIF_LINK_PATH_TYPE_REAL_SCL
      CH_EN Enable the current VIF channel ID
      SRC VIF source selection
      INPUT_FMT Data format
      PIX_FMT Output bitwidth
      CROP_EN Enable to crop
      CROP_START_X Read cropped horizontal data
      CROP_START_Y Read cropped vertical data
      PIXEL_CNT Cropped pixel count of VIF
      LINE_CNT Cropped line count of VIF
      TOTAL_PIXEL_CNT Total pixel count of VIF
      TOTAL_LINE_CNT Total line count of VIF

    6. MODPARAM INTRODUCTION


    6.1. json file sample

    {
        "E_MI_MODULE_ID_SYS" :
        {
            "cmdQBufSize" : 400
        },
        "E_MI_MODULE_ID_VIF" :
        {
            "u32threadPriority" : 98,
            "u32DevDebugLevel":  [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
            "bDevEnableFrameStartPts" : [false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],
            "u32PatGen" : [0,0,0,0,0,0,0,0,0],
            "vif_clk" : 288000000,
            "u8MulSnrRtVifGroupCnt" : 3,
            "u8MulSnrRtVifGroupPhyMap" : [ 0, 0, 1],
            "VifGroupSensorSelect" : [
                {
                    "gpio" : [ {"no" : 55, "pol" : 0} ]
                },
                {
                    "gpio" : [ {"no" : 55, "pol" : 1} ]
                },
                {
                    "na" : [ ]
                }
            ]
        }
    }
    

    modparam.json file is under /config, parameters under section "E_MI_MODULE_ID_VIF" will be loaded when vif initialize.

    modparam.json could only fill parameters which you need, others will be default value inside MI vif.

    "u32PatGen":[vif_grouid, pattern_gen_width, pattern_gen_height, patgen_gen_fps, pixfmt, pattern_gen_chn_num(1-multi/2-multi/4-multi), fieldEn(0:progressive format, 1;interlace format), hdr_mode_en, pattern_gen_en].


    6.2. VIF parameters and description

    Parameters Default Support platform Customer configuration Function
    u32threadPriority 98 All Chip N Configure mi vif thread priority
    u32DevDebugLevel 0 All Chip Y Configure mi vif debug log level
    bDevEnableFrameStartPts false Ifackel and later chips Y Configure whether each dev in mi vif records and passes FrameStartPts, with the array index corresponding to the dev ID
    u32PatGen 0,0,0,0,0,0,0,0,0 Ifado/Iford/Pcupid/Souffle/Iford/Ifackel/Jaguar1 N Configure vif group pattern gen attribute
    vif_clk 288000000 Ifado/Iford/Pcupid/Souffle/Iford/Ifackel/Jaguar1 Y Configure vif back-end clk(from isp clk)
    VifGroupSensorSelect NULL Ifado/Ifackel Y Describe the structure for switching between virtual Groups, representing the virtual VIF Group ID, with the corresponding Json structure representing the settings required to switch to that virtual VIF Group.Child node 'gpio' describes the GPIO settings for switching to a virtual group, with no gpio number and pol gpio polarity. If there is no switching requirement, use 'na' instead
    u8MulSnrRtVifGroupCnt 0 Ifado/Ifackel Y The number of virtual VIF groups
    u8MulSnrRtVifGroupPhyMap NULL Ifado/Ifackel Y The mapping relationship between the virtual VIF Group ID and the physical Group ID is set. The array index represents the virtual VIF Group ID, and the corresponding value represents the mapped physical Group

    6.3. PARAMETER USAGE EXAMPLE

    6.3.1. u32DevDebugLevel

    This parameter controls the debug level for each MI_VIF device. Debug levels can be combined using bitwise OR operations. The level definitions are as follows:

    debug level meaning
    0x0001 enable MI_VIF internal buffer check log
    0x0002 enable MI_VIF internal buffer transmission log
    0x0004 enable MI_VIF internal interrupt log
    0x0008 enable MI_VIF internal flow log
    0x0080 enable MI_VIF latency check log
    • "u32DevDebugLevel":0, disable all MI_VIF debug level

    • "u32DevDebugLevel":9, enable buffer check and buffer transmission level

    • "u32DevDebugLevel":143, enable all MI_VIF debug level

    6.3.2. vif_clk

    This parameter config vif backend clock(from isp).

    • "vif_clk":288000000, isp clk is 288M

    6.3.3. bUseReset

    This parameter controls whether to reset the VIF upon FIFO full condition.

    • "bUseReset":0, do not reset when fifo full

    • "bUseReset":1, reset when fifo full

    6.3.4. bCrcEnable

    This parameter controls the CRC verification switch for VIF data integrity checking.

    • "bCrcEnable":0, disable VIF CRC

    • "bCrcEnable":1, enable VIF CRC

    6.3.5. u8CompressMode

    This parameter controls the FBC (Frame Buffer Compression) enable/disable switch for the VIF module, VIF FBC only supports to compress 12bit/pixel to 8bit/pixel

    • "u8CompressMode":0, disable VIF FBC

    • "u8CompressMode":4, enable VIF FBC