MI DIVP API


1. OVERVIEW


1.1. Module Description

DIVP supports pre-processing of an input image, such as cropping, image pixel format conversion, rotation, mirroring, etc., and separate scaling processing for each channel, and finally outputs a variety of images with different resolutions.

The specific image processing functions supported by DIVP include image cropping, image pixel format conversion, image rotation, image mirror operation, and image stretching and scaling.


1.2. Flow Chart

Note:

Rotation is NOT supported by chip series including Macaron、Taiyaki、Takoyaki、Ispahan series.


1.3. Keyword

  • Crop

    Image cropping

  • Rotate

    Image rotation

  • Scaling up/down

    Image stretching and scaling

  • Mirror/Flip

    Image mirror operation

  • Pixel Format Conversion

    Image pixel format conversion


2. API LIST

The MI DIVP module provides the following APIs:

Name of API Function
MI_DIVP_CreateChn Create a DIVP channel.
MI_DIVP_DestroyChn Destroy a DIVP channel.
MI_DIVP_SetChnAttr Set the DIVP channel attribute.
MI_DIVP_GetChnAttr Get the DIVP channel attribute.
MI_DIVP_StartChn Start a channel.
MI_DIVP_StopChn Stop a channel.
MI_DIVP_SetOutputPortAttr Set the DIVP output port attribute.
MI_DIVP_GetOutputPortAttr Get the DIVP output port attribute.
MI_DIVP_RefreshChn Refresh a channel in pause state.
MI_DIVP_StretchBuf Stretch or crop image in specified memory to target memory
MI_DIVP_InitDev Initialize DIVP device
MI_DIVP_DeInitDev De-initialize DIVP device
MI_DIVP_StretchBufEx Scale, stretch, crop the image data in the specified memory area, and output to the target memory

2.1. MI_DIVP_CreateChn

  • Function

    Create a new DIVP channel.

  • Syntax

    MI_S32 MI_DIVP_CreateChn (
    
    MI_DIVP_CHN DivpChn,
    
    MI_DIVP_ChnAttr_t* pstAttr);
    
  • Parameter

    Parameter Name Description Input/Output
    DivpChn Return the ID of the created DIVP channel. DIVP supports maximum 6 channels, parameter range: [0, 5]. Input
    pstAttr DIVP channel attribute pointer, used to set the attribute of the created channel. Input
  • Return Value

    • MI_SUCCESS: DIVP channel created successfully

    • MI_DIVP_ERR_FAILED: Attempt to create DIVP channel failed

    • MI_DIVP_ERR_NO_RESOUCE: System resource not enough; attempt to create DIVP channel failed

  • Requirement

    • Header: mi_divp.h, mi_divp_datatype.h

    • Library: libmi_divp.so

  • Note

    The DIVP module supports maximum 6 channels. When the total number of channels created exceeds 6 or the system resource is insufficient, the channel creation task will fail.

  • Example

    MI_DIVP_CHN u32ChnId = 0;
    
    MI_DIVP_ChnAttr_t stDivpChnAttr;
    
    MI_DIVP_OutputPortAttr_t stDivpOutputPortAttr;
    
    memset(&stDivpChnAttr,0,sizeof(MI_DIVP_ChnAttr_t));
    
    memset(&stDivpOutputPortAttr,0,sizeof(MI_DIVP_OutputPortAttr_t));
    
    stDivpChnAttr.bHorMirror =  false;
    
    stDivpChnAttr.bVerMirror = false;
    
    stDivpChnAttr.eDiType = E_MI_DIVP_DI_TYPE_OFF;
    
    stDivpChnAttr.eRotateType = E_MI_SYS_ROTATE_90;
    
    stDivpChnAttr.eTnrLevel = E_MI_DIVP_TNR_LEVEL_OFF;
    
    stDivpChnAttr.stCropRect.u16X = 0;
    
    stDivpChnAttr.stCropRect.u16Y = 0;
    
    stDivpChnAttr.stCropRect.u16Width = 1280;
    
    stDivpChnAttr.stCropRect.u16Height = 720;
    
    stDivpChnAttr.u32MaxWidth = 1920;
    
    stDivpChnAttr.u32MaxHeight = 1080;
    
    MI_DIVP_CreateChn(u32ChnId,&stDivpChnAttr);
    
    MI_DIVP_GetChnAttr(u32ChnId,&stDivpChnAttr);
    
    stDivpChnAttr.stCropRect.u16X = 0;
    
    stDivpChnAttr.stCropRect.u16Y = 0;
    
    stDivpChnAttr.stCropRect.u16Width = 1920;
    
    stDivpChnAttr.stCropRect.u16Height = 1080;
    
    MI_DIVP_SetChnAttr(u32ChnId,&stDivpChnAttr);
    
    stDivpOutputPortAttr.eCompMode = E_MI_SYS_COMPRESS_MODE_NONE;
    
    stDivpOutputPortAttr.ePixelFormat = E_MI_SYS_PIXEL_FRAME_YUV422_YUYV;
    
    stDivpOutputPortAttr.u32Width = 1920;
    
    stDivpOutputPortAttr.u32Height = 1080;
    
    MI_DIVP_SetOutputPortAttr(u32ChnId,&stDivpOutputPortAttr);
    
    MI_DIVP_StartChn(u32ChnId);
    
    //exit flow
    
    MI_DIVP_StopChn(u32ChnId);
    
    MI_DIVP_DestroyChn(u32ChnId);
    
  • Related API

    MI_DIVP_DestroyChn

2.2. MI_DIVP_DestroyChn

  • Function

    Destroy a DIVP channel.

  • Syntax

    MI_S32 MI_DIVP_DestroyChn(MI_DIVP_CHN DivpChn);
    
  • Parameter

    Parameter Name Description Input/Output
    DivpChn ID of the destroyed DVIP channel Input
  • Return Value

    • MI_SUCCESS: DVIP channel destroyed successfully

    • MI_DIVP_ERR_FAILED: Attempt to destroy DVIP channel failed

  • Requirement

    • Header: mi_divp.h, mi_divp_datatype.h

    • Library: libmi_divp.so

  • Related API

    MI_DIVP_CreateChn

2.3. MI_DIVP_SetChnAttr

  • Function

    Set the DIVP channel attribute.

  • Syntax

    MI_S32 MI_DIVP_SetChnAttr(
    
    MI_DIVP_CHN DivpChn,
    
    MI_DIVP_ChnAttr_t* pstAttr);
    
  • Parameter

    Parameter Name Description Input/Output
    DivpChn DIVP channel ID. Input
    pstAttr Pointer to the set DVIP channel attribute structure. Input
  • Return Value

    • MI_SUCCESS: DIVP channel attribute set successfully

    • MI_DIVP_ERR_FAILED: Attempt to set DIVP channel attribute failed

    • MI_ERR_INVALID_PARAMETER: Invalid parameter used. Please refer to MI_DIVP_ChnAttr_t

  • Requirement

    • Header: mi_divp.h, mi_divp_datatype.h

    • Library: libmi_divp.so

  • Note

    The maximum width and the maximum height of input image in channel attribute structure member are static attributes which cannot be modified once the channel is created.

  • Related API

    MI_DIVP_GetChnAttr

2.4. MI_DIVP_GetChnAttr

  • Function

    Get the DIVP channel attribute.

  • Syntax

    MI_S32 MI_DIVP_GetChnAttr(
    
    MI_DIVP_CHN DivpChn,
    
    MI_DIVP_ChnAttr_t* pstAttr);
    
  • Parameter

    Parameter Name Description Input/Output
    DivpChn DIVP channel ID. Input
    pstAttr Pointer to the returned DVIP channel attribute structure. Output
  • Return Value

    • MI_SUCCESS: DIVP channel attribute gotten successfully

    • MI_DIVP_ERR_FAILED: Attempt to get DIVP channel attribute failed

  • Requirement

    • Header: mi_divp.h, mi_divp_datatype.h

    • Library: libmi_divp.so

  • Note

    Initial value will be returned with the first successful attempt to get the DIVP channel attribute.

  • Related API

    MI_DIVP_SetChnAttr

2.5. MI_DIVP_StartChn

  • Function

    Start a channel.

  • Syntax

    MI_S32 MI_DIVP_StartChn(MI_DIVP_CHN DivpChn);
    
  • Parameter

    Parameter Name Description Input/Output
    DivpChn DIVP channel ID. Input
  • Return Value

    • MI_SUCCESS: DIVP channel started successfully

    • MI_DIVP_ERR_FAILED: Attempt to start DIVP channel failed

  • Requirement

    • Header: mi_divp.h, mi_divp_datatype.h

    • Library: libmi_divp.so

  • Note

    Channels to be started must be created beforehand and not destroyed.

  • Related API

    MI_DIVP_StopChn

2.6. MI_DIVP_StopChn

  • Function

    Stop a channel.

  • Syntax

    MI_S32 MI_DIVP_StopChn(MI_DIVP_CHN DivpChn);
    
  • Parameter

    Parameter Name Description Input/Output
    DivpChn DIVP channel ID. Input
  • Return Value

    • MI_SUCCESS: DIVP channel stopped successfully

    • MI_DIVP_ERR_FAILED: Attempt to stop DIVP channel failed

  • Requirement

    • Header: mi_divp.h, mi_divp_datatype.h

    • Library: libmi_divp.so

  • Note

    Repeated execution of this stop function will return MI_SUCCESS.

  • Related API

    MI_DIVP_StartChn

2.7. MI_DIVP_SetOutputPortAttr

  • Function

    Set the DIVP channel output port attribute.

  • Syntax

    MI_S32 MI_DIVP_SetOutputPortAttr (
    
    MI_DIVP_CHN DivpChn,
    
    MI_DIVP_OutputPortAttr_t * pstOutputPortAttr);
    
  • Parameter

Parameter Name Description Input/Output
DivpChn DIVP channel ID. Input
pstOutputPortAttr Output port attribute pointer. Input
  • Return Value

    • MI_SUCCESS: DIVP channel output port attribute set successfully

    • MI_DIVP_ERR_FAILED: Attempt to set DIVP channel output port attribute failed

  • Requirement

    • Header: mi_divp.h, mi_divp_datatype.h

    • Library: libmi_divp.so

  • Related API

    MI_DIVP_GetOutputPortAttr

2.8. MI_DIVP_GetOutputPortAttr

  • Function

    Get the DIVP output port attribute.

  • Syntax

    MI_S32 MI_DIVP_GetOutputPortAttr(
    
    MI_DIVP_CHN DivpChn,
    
    MI_DIVP_OutputPortAttr_t * pstOutputPortAttr);
    
  • Parameter

    Parameter Name Description Input/Output
    DivpChn DIVP channel ID. Input
    pstOutputPortAttr Output port attribute pointer. Output
  • Return Value

    • MI_SUCCESS: DIVP channel output port attribute gotten successfully

    • MI_DIVP_ERR_FAILED: Attempt to get DIVP channel output port attribute failed

  • Requirement

    • Header: mi_divp.h, mi_divp_datatype.h

    • Library: libmi_divp.so

  • Related API

    MI_DIVP_SetOutputPortAttr

2.9. MI_DIVP_RefreshChn

  • Function

    Refresh a DIVP channel in pause state.

  • Syntax

    MI_S32 MI_DIVP_RefreshChn (
    
    MI_DIVP_CHN DivpChn);
    
  • Parameter

    Parameter Name Description Input/Output
    DivpChn ID of refreshed channel. Input
  • Return Value

    • MI_SUCCESS: DIVP channel refreshed successfully.

    • MI_DIVP_ERR_NO_CONTENT: No content in the channel being refreshed.

  • Requirement

    • Header: mi_divp.h, mi_divp_datatype.h

    • Library: libmi_divp.so

  • Note

    This interface is used for refreshing a channel under pause state.

  • Example

    In the scenario where DIVP is bound to VDEC, this interface is called. DIVP can retain the last frame of the picture after VDEC stops streaming, and repeat the processing and then send it to the back end. DIVP will not process the new picture until VDEC restarts streaming.

2.10. MI_DIVP_StretchBuf

  • Function

    Stretch or crop image in specified memory to target memory.

  • Syntax

    MI_S32 MI_DIVP_StretchBuf(MI_DIVP_DirectBuf_t *pstSrcBuf,
    MI_SYS_WindowRect_t *pstSrcCrop,
    MI_DIVP_DirectBuf_t *pstDstBuf);
    
  • Parameter

    Parameter Name Description Input/Output
    pstSrcBuf Information pointer of specified buff used to store source image. Cannot be NULL. Input
    pstSrcCrop Pointer to image crop attribute, If you don't need to crop the image, pass NULL. Input
    pstDstBuf Information pointer of target buff used to store processed image. Cannot be NULL. Input
  • Return Value

    • MI_SUCCESS: Image stretched successfully.

    • MI_DIVP_ERR_FAILED: Image stretching failed.

  • Requirement

    • Header: mi_divp.h, mi_divp_datatype.h

    • Library: libmi_divp.so

  • Note

    Supports only YUV420SP or ARGB8888 image pixel format

  • Example

    #define SRC_WIDTH 1280
    #define SRC_HEIGHT 720
    #define SRC_BUFF_STRIDE (ALIGN_UP(SRC_WIDTH,16))
    #define SRC_BUFF_SIZE (SRC_BUFF_STRIDE*SRC_HEIGHT*3/2)
    
    #define DST_WIDTH 640
    #define DST_HEIGHT 480
    #define DST_BUFF_STRIDE (ALIGN_UP(DST_WIDTH,16))
    #define DST_BUFF_SIZE (DST_BUFF_STRIDE*DST_HEIGHT*3/2)
    
    #define CROP_X 200
    #define CROP_Y 100
    #define CROP_W 68
    #define CROP_H 48
    
    int main(void)
    {
    MI_PHY phySrcBufAddr = 0;
    MI_PHY phyDstBufAddr = 0;
    MI_DIVP_DirectBuf_t stSrcBuf;
    MI_DIVP_DirectBuf_t stDstBuf;
    MI_SYS_WindowRect_t stSrcCrop;
    
    MI_SYS_MMA_Alloc(NULL, SRC_BUFF_SIZE, &phySrcBufAddr);
    MI_SYS_MMA_Alloc(NULL, DST_BUFF_SIZE, &phyDstBufAddr);
    
    stSrcBuf.ePixelFormat = E_MI_SYS_PIXEL_FRAME_YUV_SEMIPLANAR_420;
    stSrcBuf.u32Width = SRC_WIDTH;
    stSrcBuf.u32Height = SRC_HEIGHT;
    stSrcBuf.u32Stride[0] = SRC_BUFF_STRIDE;
    stSrcBuf.u32Stride[1] = SRC_BUFF_STRIDE;
    stSrcBuf.phyAddr[0] = phySrcBufAddr;
    stSrcBuf.phyAddr[1] = stSrcBuf.phyAddr[0] + SRC_BUFF_STRIDE*SRC_HEIGHT;
    stDstBuf.ePixelFormat = E_MI_SYS_PIXEL_FRAME_YUV_SEMIPLANAR_420;
    stDstBuf.u32Width = DST_WIDTH;
    stDstBuf.u32Height = DST_HEIGHT;
    stDstBuf.u32Stride[0] = DST_BUFF_STRIDE;
    stDstBuf.u32Stride[1] = DST_BUFF_STRIDE;
    stDstBuf.phyAddr[0] = phyDstBufAddr;
    stDstBuf.phyAddr[1] = stDstBuf.phyAddr[0] + DST_BUFF_STRIDE*DST_HEIGHT;
    
    stSrcCrop.u16X = CROP_X;
    stSrcCrop.u16Y = CROP_Y;
    stSrcCrop.u16Width = CROP_W;
    stSrcCrop.u16Height = CROP_H;
    
    if(FillSrcBuf("./1280x720_yuv420.yuv", &stSrcBuf))
    return NULL;
    if(MI_SUCCESS == MI_DIVP_StretchBuf(&stSrcBuf, &stSrcCrop, &stDstBuf))
    {
    if(DumpDstBuf(&stDstBuf))
    return NULL;
    }
    
    MI_SYS_MMA_Free(phySrcBufAddr);
    MI_SYS_MMA_Free(phyDstBufAddr);
    }
    
    //fill src buff with yuv420/argb8888 image data
    static int FillSrcBuf(const char* FilePath,MI_DIVP_DirectBuf_t *pstDirectSrcBuf)
    {
        int ret = 0;
        FILE *fp;
        void *pVirSrcBufAddr = NULL;
        int LineIdx = 0;
        int ReadSize = 0;
    
        fp = fopen(FilePath,"r");
        if(!fp)
        {
            divp_ut_dbg("open file[%s] failed\n",FilePath);
            ret = -1;
            goto EXIT;
        }
    
        MI_SYS_Mmap(pstDirectSrcBuf->phyAddr[0], SRC_BUFF_SIZE, &pVirSrcBufAddr, FALSE);
        if(!pVirSrcBufAddr)
        {
            divp_ut_dbg("mmap dst buff failed\n");
            ret = -1;
            goto EXIT;
        }
    
        for(LineIdx = 0; LineIdx < SRC_HEIGHT*3/2; LineIdx++)
        {
            ReadSize += fread(pVirSrcBufAddr+LineIdx*SRC_BUFF_STRIDE, 1, SRC_WIDTH, fp);
        }
        if(ReadSize < SRC_WIDTH*SRC_HEIGHT*3/2)
        {
            fseek(fp, 0, SEEK_SET);
            ReadSize = 0;
            for(LineIdx = 0; LineIdx < SRC_HEIGHT*3/2; LineIdx++)
            {
                ReadSize += fread(pVirSrcBufAddr+LineIdx*SRC_BUFF_STRIDE, 1, SRC_WIDTH, fp);
            }
            if(ReadSize < SRC_WIDTH*SRC_HEIGHT*3/2)
            {
                divp_ut_dbg("read file failed, read size:%d\n",ReadSize);
                ret = -1;
                goto EXIT;
            }
        }
    
    EXIT:
        if(fp)
            fclose(fp);
        if(pVirSrcBufAddr)
            MI_SYS_Munmap(pVirSrcBufAddr, SRC_BUFF_SIZE);
    
        return ret;
    }
    
    //image processing result is stored in dst buff
    static int DumpDstBuf(MI_DIVP_DirectBuf_t *pstDirectDstBuf)
    {
        int ret = 0;
        FILE *fp;
        void *pVirDstBufAddr = NULL;
        int LineIdx = 0;
        int WriteSize = 0;
        char outputfile[128];
        struct timeval timestamp;
    
        gettimeofday(&timestamp, 0);
        sprintf(outputfile, "output_%dx%d_%d_%08d.yuv",pstDirectDstBuf->u32Width,pstDirectDstBuf->u32Height,(int)timestamp.tv_sec,(int)timestamp.tv_usec);
    
        fp = fopen(outputfile,"w+");
        if(!fp)
        {
            divp_ut_dbg("open file[%s] failed\n",outputfile);
            ret = -1;
            goto EXIT;
        }
    
        MI_SYS_Mmap(pstDirectDstBuf->phyAddr[0], DST_BUFF_SIZE, &pVirDstBufAddr, FALSE);
        if(!pVirDstBufAddr)
        {
            divp_ut_dbg("mmap dst buff failed\n");
            ret = -1;
            goto EXIT;
        }
    
        for(LineIdx = 0; LineIdx < DST_HEIGHT*3/2; LineIdx++)
        {
            WriteSize += fwrite(pVirDstBufAddr+LineIdx*DST_BUFF_STRIDE, 1, DST_WIDTH, fp);
        }
        if(WriteSize < DST_WIDTH*DST_HEIGHT*3/2)
        {
            divp_ut_dbg("write file failed, write size:%d\n",WriteSize);
        }
        fflush(fp);
        sync();
        divp_ut_dbg("save stretch dst buff to[%s]\n",outputfile);
    
    EXIT:
        if(fp)
            fclose(fp);
        if(pVirDstBufAddr)
            MI_SYS_Munmap(pVirDstBufAddr, DST_BUFF_SIZE);
    
        return 0;
    }
    

2.11. MI_DIVP_InitDev

  • Function

    Initialize DIVP device.

  • Syntax

    MI_S32 MI_DIVP_InitDev(*MI_DIVP_InitParam_t* *pstInitParam);
    
  • Parameters

    Parameter Name Description Input/Output
    pstInitParam Initialization Parameter Input
  • Return Value

    • Zero: Successful

    • Non-zero: Failed, see error code details

  • Requirement

    • Header: mi_divp.h, mi_divp_datatype.h

    • Library: libmi_divp.so

2.12. MI_DIVP_DeInitDev

  • Function

    De-initialize DIVP device.

  • Syntax

    MI_S32 MI_DIVP_DeInitDev(void);
    
  • Return Value

    • Zero: Successful

    • Non-zero: Failed, see error code details

  • Requirement

    • Header: mi_divp.h, mi_divp_datatype.h

    • Library: libmi_divp.so

  • Note

    • This interface should be called after the device has been initialized; otherwise, a failed message will be returned.

    • If this interface is not called after the app exited, the DIVP device will be auto de-initialized.

2.13. MI_DIVP_StretchBufEx

  • Description

    Scale, stretch, crop the image data in the specified memory area, and output to the target memory.

  • Syntax

    MI_S32 MI_DIVP_StretchBufEx(MI_DIVP_DirectBuf_t *pstSrcBuf, MI_SYS_WindowRect_t *pstSrcCrop, MI_DIVP_DirectBuf_t *pstDstBuf, MI_DIVP_FilterType_e eFilterType);
    
  • Parameter

    Parameter Name Description Input/Output
    pstSrcBuf Source buffer information pointer Input
    pstSrcCrop Crop information pointer Input
    pstDstBuf Target buffer information pointer Input
    eFilterType Scaling`s filter type Input
  • Return Value

    • MI_OK: Successful

    • Non-MI_OK: Failed, see error code details

  • Requirement

    Header: mi_divp.h、mi_divp_datatype.h

    Library: libmi_divp.so


3. DIVP DATA TYPE

The table below lists the data structure definitions of the related DIVP data types:

DATA TYPE Description
MI_DIVP_DiType_e Defines DIVP deinterlace type.
MI_DIVP_TnrLevel_e Defines DIVP TNR level.
MI_DIVP_FilterType_e Define DIVP scaling filter type
MI_DIVP_OutputPortAttr_t Defines DIVP output port attribute parameter.
MI_DIVP_ChnAttr_t Defines DIVP channel attribute parameter.
MI_DIVP_DirectBuf_t Memory information for stretching image
MI_DIVP_InitParam_t Define the initialized parameter of DIVP device

NOTE: This section covers only the most important data structures. For data types not listed here, please refer to mi_divp_datatype.h.

3.1. MI_DIVP_DiType_e

  • Description

    Defines DIVP deinterlace type.

  • Definition

    typedef enum
    
    {
    
        E_MI_DIVP_DITYPE_OFF, //off
    
        E_MI_DIVP_DITYPE_2D, ///2.5D DI
    
        E_MI_DIVP_DITYPE_3D, ///3D DI
    
        E_MI_DIVP_DITYPE_NUM,
    
    } MI_DIVP_DiType_e;
    
  • Member

    Member Description
    E_MI_DIVP_DITYPE_OFF Disable deinterlace function on DIVP channel.
    E_MI_DIVP_DITYPE_2D Enable 2.5D deinterlace function on DIVP channel.
    E_MI_DIVP_DITYPE_3D Enable 3D deinterlace function on DIVP channel.
    E_MI_DIVP_DITYPE_NUM Number of deinterlace types on DIVP channel.
  • Note

    • TNR must be turned on when DI is enabled. MSR930 supports 3D DI only, and the TNR level must be set as E_MI_DIVP_TNRLEVEL_MIDDLE.

    • 3D DI conflicts with rotation; the two functions cannot be used at the same time.

    • Note that the following chips do not support the DI function:

      Pretzel

      Macaron

      Taiyaki/Takoyaki

      Pudding

      Ispahan

      Ikayaki

3.2. MI_DIVP_TnrLevel_e

  • Description

    Defines DIVP TNR level.

  • Definition

    typedef enum
    
    {
    
        E_MI_DIVP_TNRLEVEL_OFF,
    
        E_MI_DIVP_TNRLEVEL_LOW,
    
        E_MI_DIVP_TNRLEVEL_MIDDLE,
    
        E_MI_DIVP_TNRLEVEL_HIGH,
    
        E_MI_DIVP_TNRLEVEL_NUM,
    
    } MI_DIVP_TnrLevel_e;
    
  • Member

    Member Description
    E_MI_DIVP_TNRLEVEL_OFF Disable TNR on DIVP channel.
    E_MI_DIVP_TNRLEVEL_LOW Apply low level TNR on DIVP channel.
    E_MI_DIVP_TNRLEVEL_MIDDLE Apply middle level TNR on DIVP channel.
    E_MI_DIVP_TNRLEVEL_HIGH Apply high level TNR on DIVP channel.
    E_MI_DIVP_TNRLEVEL_NUM Number of TNR levels on DIVP channel.
  • Note

    • MSR930 supports TNR, but the TNR level cannot be modified.

    • Note that the following chips do not support the TNR function:

      Pretzel

      Macaron

      Taiyaki/Takoyaki

      Pudding

      Ispahan

      Ikayaki

3.3. MI_DIVP_FilterType_e

  • Description

    Define DIVP scaling filter type .

  • Definition

    typedef enum
    
    {
    
        E_MI_DIVP_FILTER_TYPE_AUTO,
    
        E_MI_DIVP_FILTER_TYPE_BYPASS,
    
        E_MI_DIVP_FILTER_TYPE_BILINEAR,
    
        E_MI_DIVP_FILTER_TYPE_FILTER,
    
    } MI_DIVP_FilterType_e;
    
  • Member

    Member Description
    E_MI_DIVP_FILTER_TYPE_AUTO Auto mode Automatically select bypass or bilinear.
    E_MI_DIVP_FILTER_TYPE_BYPASS Bypass mode
    E_MI_DIVP_FILTER_TYPE_BILINEAR Bilinear mode
    E_MI_DIVP_FILTER_TYPE_FILTER Filter type number
  • Note

    • No scaling.

    • The default is E_MI_DIVP_FILTER_TYPE_BYPASS filter type.

  • Related Data Type and Interface

    MI_DIVP_StretchBufEx

3.4. MI_DIVP_OutputPortAttr_t

  • Description

    Defines DIVP output port attribute parameter.

  • Definition

    typedef struct MI_DIVP_OutputPortAttr_s
    
    {
    
        MI_U32 u32Width;//output width
    
        MI_U32 u32Height;//output height
    
        MI_SYS_PixelFormat_e ePixelFormat;
    
        MI_SYS_CompressMode_e eCompMode;//compress mode
    
    }MI_DIVP_OutputPortAttr_t;
    
  • Member

    Member Description
    u32Width DIVP channel output screen width.
    u32Height DIVP channel output screen height.
    ePixelFormat DIVP channel output screen pixel format.
    eCompMode DIVP channel output image compression mode. DIVP channel can only output images not in compressed format.
  • Note

    The following table lists the different output attributes of each chip:

    Output Attr/Chip Series Output Pixel Format Output Stride Alignment Output Width Alignment Output Height Alignment Output Min Size Output Max Size
    MSR930 YUV422 32 2 2 128x64 4096x4096
    YUV420(NV12)
    ARGB8888
    ABGR8888
    ARGB1555
    MST420
    Pretzel YUV422 32 2 2 64x4 3840x3840
    YUV420(NV12) 16
    ARGB8888/ABGR8888 64
    RGB565 32
    Macaron YUV422 32 2 2 64x4 2688x2688
    YUV420(NV12) 16
    ARGB8888/ABGR8888 64
    RGB565 32
    Taiyaki/Takoyaki YUV422 32 2 2 64x4 1920x1920
    YUV420(NV12) 16
    ARGB8888/ABGR8888 64
    RGB565 32
    Pudding YUV422 32 2 2 Rotate: 16x2
    No rotate: 32x4
    3840x3840
    YUV420(NV12) 16
    ARGB8888/ABGR8888 64
    RGB565 32
    Ispahan YUV422 32 2 2 64x4 2688x2688
    YUV420(NV12) 16
    ARGB8888/ABGR8888 64
    RGB565 32
    Ikayaki YUV422 32 2 2 Rotate:16x16
    No rotate:16x2
    1920x1920
    YUV420(NV12) 16
    ARGB8888/ABGR8888 64
    RGB565 32

3.5. MI_DIVP_ChnAttr_t

  • Description

    Defines DIVP channel attribute parameter.

  • Definition

    typedef struct MI_DIVP_ChnAttr_s
    
    {
    
        MI_U32 u32MaxWidth;//support max input width
    
        MI_U32 u32MaxHeight;//support max input height
    
        MI_DIVP_TnrLevel_e eTnrLevel;//TNR level
    
        MI_DIVP_DiType_e eDiType;//DI type
    
        MI_SYS_Rotate_e eRotateType;//rotate angle
    
        MI_SYS_WindowRect_t stCropRect;//crop information
    
        MI_BOOL bHorMirror;//horizontal mirror
    
        MI_BOOL bVerMirror;//vertical mirror
    
    }MI_DIVP_ChnAttr_t;
    
  • Member

    Member Description
    u32MaxWidth Maximum input width on DIVP channel.
    u32MaxHeight Maximum input height on DIVP channel.
    eTnrLevel TNR level on DIVP channel.
    eDiType Deinterlace type on DIVP channel.
    eRotateType Angle of screen rotation on DIVP channel.
    stCropRect Crop information on DIVP channel.
    bHorMirror Horizontal mirroring on DIVP channel.
    bVerMirror Vertical mirroring on DIVP channel.
  • Note

    Input Attr/Chip Series Input Pixel Format Input Stride Alignment Input Width Alignment Input Height Alignment Input Min Size Input Max Size
    MSR930 YUV422/YUV420(NV12)/ ARGB8888/ ABGR8888/ARGB1555/Tile Mode 32 YUV422:16
    NV12:32
    2 128x64 4096x4096
    Pretzel YUV422 32 2 2 64x4 3840x3840
    YUV420(NV12) 16
    ARGB8888/ABGR8888 64
    RGB565 32
    Macaron YUV422 32 2 2 64x4 2688x2688
    YUV420(NV12) 16
    ARGB8888/ABGR8888 64
    RGB565 32
    Taiyaki/Takoyaki YUV422 32 2 2 64x4 1920x1920
    YUV420(NV12) 16
    ARGB8888/ABGR8888 64
    RGB565 32
    Pudding YUV422 32 2 2 Rotate: 128x128
    No rotate: 32x4
    3840x3840
    YUV420(NV12) 16
    ARGB8888/ABGR8888 64
    RGB565 32
    Ispahan YUV422 32 2 2 64x4 2688x2688
    YUV420(NV12) 16
    ARGB8888/ABGR8888 64
    RGB565 32
    Ikayaki YUV422 32 16 2 Rotate:16x16
    No rotate:16x2
    1920x1920
    YUV420(NV12) 16 16 2
    ARGB8888/ABGR8888 64 16 2

3.6. MI_DIVP_DirectBuf_t

  • Description

    Memory information for stretching image.

  • Definition

    typedef struct MI_DIVP_DirectBuf_s
    
    {
    
        MI_SYS_PixelFormat_e ePixelFormat; //YUV420SP or ARGB888 only
    
        MI_U32 u32Width;
    
        MI_U32 u32Height;
    
        MI_U32 u32Stride[3];
    
        MI_PHY phyAddr[3];
    
    }MI_DIVP_DirectBuf_t;
    
  • Member

    Member Description
    ePixelFormat Pixel format of image
    u32Width Width of image
    u32Height Height of image
    u32Stride Number of bytes per line of an image
    phyAddr Start physical address of buffer
  • Note

    The pixel format of image will only be YUV420SP or ARGB8888.

    The stride cannot be less than 64.

  • Related Data Type and Interface

    MI_DIVP_StretchBuf

3.7. MI_DIVP_InitParam_t

  • Description

    DIVP device initialization parameter.

  • Definition

    typedef struct MI_DIVP_InitParam_s
    
    {
    
        MI_U32 u32DevId;
    
        MI_U8 *u8Data;
    
    } MI_DIVP_InitParam_t;
    
  • Member

    Member Description
    u32DevId Device ID
    u8Data Data pointer buffer
  • Related Data Type and Interface

    MI_DIVP_InitDev


4. DIVP ERROR CODES

The following table lists the DIVP API Error Codes.

Error Code Macro Definition Description
0x0 MI_SUCCESS Successful.
0xa00c2002 MI_DIVP_ERR_INVALID_CHNID Invalid channel ID.
0xa00c2003 MI_DIVP_ERR_INVALID_PARAM Invalid parameter.
0xa00c2006 MI_DIVP_ERR_NULL_PTR Null pointer.
0xa00c201c MI_DIVP_ERR_FAILED DIVP operation failed
0xa00c2005 MI_DIVP_ERR_NO_RESOUCE No resource available.
0xa00c201c MI_DIVP_ERR_NO_CONTENT No content in channel.

5. PROCFS INTRODUCTION


5.1. cat

  • Debug info

    # cat /proc/mi_modules/mi_divp/mi_divp0
    

  • Debug info analysis

    Record the current usage status of a DIVP device, as well as device attributes, layer attributes, and inputport/outputport attributes, which can be dynamically obtained for debugging and testing.

  • Parameter Description

    Parameter Description
    channelinfo ChnId 0~16
    16 Capture Channel is not open to the upper layer
    Status 0: INITED
    1: CREATED
    2: STARTED
    3: STOPED
    4: DISTROYED
    AttrChg 0:not change
    1:changed
    FieldType0,
    FieldType1
    (last two fields's type)
    0: NONE //no field.
    1: TOP //Top field only.
    2: BOTTOM //Bottom field only.
    3: BOTH //Both fields.
    4: NUM
    ChnAttrPre Last setting attributes of channel
    ChnAttrOrg Original setting attributes of channel
    CropX,CropY,
    CropW,CropH
    The crop location set by the upper layer
    bHMirror
    bVMirror
    Horizontal mirror enable
    Vertical mirror enable
    0:disable
    1:enable
    eDiType 0: OFF,//off
    1: 2D,///2.5D DI
    2: 3D,///3D DI
    3: NUM
    eRotateType   0: NONE, //Rotate 0 degrees
    1: 90, //Rotate 90 degrees
    2: 180, //Rotate 180 degrees
    3: 270, //Rotate 270 degrees
    4: NUM
    eTnrLevel 0: OFF,
    1: LOW,
    2: MIDDLE,
    3: HIGH,
    4: NUM
    inputport info ChnId Channel ID  0~16
    InputChg Whether the input port attribute has changed
    bIPChg 0: No change between interlaced and progressive
    1: Interlace switch to progressive, or progressive to interlace
    PreWidth input port width
    PreHeight input port height
    Pixel E_MI_SYS_PIXEL_FRAME_YUV422_YUYV = 0,     E_MI_SYS_PIXEL_FRAME_ARGB8888,     E_MI_SYS_PIXEL_FRAME_ABGR8888,     E_MI_SYS_PIXEL_FRAME_RGB565,     E_MI_SYS_PIXEL_FRAME_ARGB1555,     E_MI_SYS_PIXEL_FRAME_I2,     E_MI_SYS_PIXEL_FRAME_I4,     E_MI_SYS_PIXEL_FRAME_I8,     E_MI_SYS_PIXEL_FRAME_YUV_SEMIPLANAR_422,     E_MI_SYS_PIXEL_FRAME_YUV_SEMIPLANAR_420,     E_MI_SYS_PIXEL_FRAME_YUV_MST_420,    
    //vdec mstar private video format     E_MI_SYS_PIXEL_FRAME_YC420_MSTTILE1_H264,     E_MI_SYS_PIXEL_FRAME_YC420_MSTTILE2_H265,     E_MI_SYS_PIXEL_FRAME_YC420_MSTTILE3_H265,     E_MI_SYS_PIXEL_FRAME_FORMAT_MAX
    Stride Input stride
    2Pmode b2P_Enable value, 1 means enable, 0 means disable
    EnqueueTask Enqueue task number
    GetInTaskCnt OnPreProcessInputTask task number
    Outputport Info ChnId  Channel ID  0~16
    OutputChg  Whether the Output property has changed
    0: not change
    1: changed
    Pixel The same as input pixel
    CompMode  0 //no compress
    1 //compress unit is 256 bytes as a segment
    2 //compress unit is the whole line
    3 //compress unit is the whole frame
    4 //number
    PreWidth  PreHeight  The width and height of the output port set last time
    Stride Output stride
    phyaddr The physical address of the output buffer
    FinishTaskCnt Finish task count
    fps Output port frame rate
    Common Info ChnNum Total number of Channel
    Pixel  The same as input pixel
    PassNum Total number of Pass
    InPortNum  Total number of Input port
    OutPortNum Total number of Output port
    CollectSize Attach pstAllocator size
    current_buf_size The currently requested memory size
    Peak_buf_size Peak memory usage
    user_pid Process id
    user_buf_quota The maximum number of buffers that the user can take
    UsrInjectQ_cnt User inject buffer count
    BindInQ_cnt The number of buffers that the front end gives to the input port enqueue
    TotalPendingBuf_size The total buffer size of each task in the current input working queue
    usrLockedInjectCnt The number of buffers the user gets
    newPulseQ_cnt Buffer count of new_pulse_fifo_inputqueque
    nextTodoPulseQ_cnt Buffer count of next_todo_pulse_inputqueue
    curWorkingQ_cnt Buffer count of cur_working_input_queue
    workingTask_cnt Task count of input_working_tasklist
    lazzyRewindTask_cnt Task count that need to retry
    bind_module_id Binding module id
    bind_module_name Binding module name
    bind_ChnId Binding module channel id
    bind_PortId Binding module port id
    bind_Type Binding type:
    E_MI_SYS_BIND_TYPE_FRAME_BASE = 0x00000001,
    E_MI_SYS_BIND_TYPE_SW_LOW_LATENCY = 0x00000002,
    E_MI_SYS_BIND_TYPE_REALTIME = 0x00000004,
    E_MI_SYS_BIND_TYPE_HW_AUTOSYNC = 0x00000008,
    E_MI_SYS_BIND_TYPE_HW_RING = 0x00000010
    bind_Param Binding parameter
    SrcFrmrate Source frame rate
    DstFrmrate Destination frame rate
    GetFrame/Ms Actual frames/time used
    FPS Actual frame rate
    RewindCnt The number of tasks that need to be retryed
    usrDepth The maximum number of output port buffer user can get
    BufCntQuota The maximum number of buffers output can apply for
    usrLockedCnt The number of buffers user actually get
    totalOutPortInUsed The number of buffers output actually apply for
    DrvBkRefFifoQ_cnt For special driver which need to refer back pre-processed buffer
    DrvBkRefFifoQ_size The total buffer size occupied by stDrvBkRefFifoQueue
    UsrGetFifoQ_cnt Number of buffers from Duplicate to output port
    UsrGetFifoQ_size The total size of the buffer from Duplicate to the output port
    UsrGetFifoQ_seqnum The total number of buffers the output gets
    UsrGetFifoQ_discardnum The number of original buffers abandoned due to new buffer requirements from Output
    finishedTask_cnt Number of Output finish tasks
    GetTotalCnt The total number of buffers output gets
    GetOkCnt Count the number of frames whose index is E_MI_SYS_FRC_OBTAIN
    ISRNum Total number of interruptions received


5.2. echo

Function
Print the PTS of each frame received. If the front end is VDEC, it will print the FrameID sent by VDEC to debug the frame loss problem. Normally, the values of FrameID and PTS are increased.
Command echo checkframeid [ChnID] [Status] > /proc/mi_modules/mi_divp/mi_divp0
Parameter Description [ChnID] Channel ID [0~32]
[Status] ON: Start printing; OFF: Stop printing
Example echo checkframeid 0 ON/OFF > /proc/mi_modules/mi_divp/mi_divp0
[MI DIVP PROCFS]:ChnID 0, receive buffer ID = 63 , H = 0, L = 196615, PTS = 43956000
[MI DIVP PROCFS]:ChnID 0, receive buffer ID = 64 , H = 0, L = 196616, PTS = 43989000
[MI DIVP PROCFS]:ChnID 0, receive buffer ID = 65 , H = 0, L = 196615, PTS = 44022000
[MI DIVP PROCFS]:ChnID 0, receive buffer ID = 66 , H = 0, L = 196615, PTS = 44055000
[MI DIVP PROCFS]:ChnID 0, receive buffer ID = 67 , H = 0, L = 196615, PTS = 44088000
[MI DIVP PROCFS]:ChnID 0, receive buffer ID = 68 , H = 0, L = 196615, PTS = 44121000
[MI DIVP PROCFS]:ChnID 0, receive buffer ID = 69 , H = 0, L = 196614, PTS = 44154000
[MI DIVP PROCFS]:ChnID 0, receive buffer ID = 70 , H = 0, L = 196615, PTS = 44187000
receive buffer ID: Buffer ID received by each channel.
H/L: FrameID sent by VDEC. H high 32 bits, L low 32 bits, if the front end is not VDEC, there is no such printing.
PTS: FrameBuffer PTS.
Function
Count the number of GetBuffers in 1 second, and the average, maximum, and minimum of the interval between two inputbuffers, and debug frame loss problems.
Command echo statintervaltime [ChnID] ON/OFF > /proc/mi_modules/mi_divp/mi_divp0
Parameter Description [ChnID] Channel ID [0~32]
[Status] ON: Start counting and printing; OFF: Stop counting and printing
Example echo statintervaltime 0 ON > /proc/mi_modules/mi_divp/mi_divp0
[MI DIVP PROCFS]:ChnlID 0,1s FrameCnt:19,Average time: 50393 us,MAX 59601 us,57652 us,57534 us,MIN 41401 us,42415 us,42896 us
[MI DIVP PROCFS]:ChnlID 0,1s FrameCnt:19,Average time: 50247 us,MAX 63004 us,62889 us,62845 us,MIN 36896 us,37120 us,37130 us
[MI DIVP PROCFS]:ChnlID 0,1s FrameCnt:18,Average time: 51049 us,MAX 70431 us,59763 us,59736 us,MIN 38873 us,40109 us,40283 us
[MI DIVP PROCFS]:ChnlID 0,1s FrameCnt:20,Average time: 48537 us,MAX 67168 us,67117 us,66953 us,MIN 18513 us,31242 us,32681 us
[MI DIVP PROCFS]:ChnlID 0,1s FrameCnt:19,Average time: 49962 us,MAX 61416 us,61416 us,61338 us,MIN 38564 us,38736 us,38762 us
FrameCnt: Number of GetBuffer in 1 second
Average time: The average time between two buffers
MAX: The three largest values of the interval
MIN: The three smallest values of the interval
Function
DIVP no longer processes a certain channel to save bandwidth and verify bandwidth related issues.
Command echo stoponechannel [ChnID] [Status] > /proc/mi_modules/mi_divp/mi_divp0
Parameter Description [ChnID] Channel ID [0~32]
[Status] ON: Stop processing the set channel; OFF: Continue to process the set channel
Example echo stoponechannel 0 ON > /proc/mi_modules/mi_divp/mi_divp0
The screen of channel 0 will freeze
Function
Dump an input frame.
Command echo dumpframe [ChnID] [frameStorePath] > /proc/mi_modules/mi_divp/mi_divp0
Parameter Description [ChnID] Channel ID [0~16]
[frameStorePath] Specify the location to save the input frame.
Example #echo dumpframe 0 /customer > /proc/mi_modules/mi_divp/mi_divp0
Dump an input frame and save it under /customer.
The default input frame name such as: dump_divp_chn0_frame_w_352_h_288.yuv
Function
Open the debug information of mi divp.
Command echo debug 0/1 > /proc/mi_modules/mi_divp/mi_divp0
Parameter Description [0/1] 0 means off, 1 means on.
Example #echo debug 1 > /proc/mi_modules/mi_divp/mi_divp0
printk in _MI_SYS_IMPL_Common_WriteProc
divp debug:on
#echo debug 0 > /proc/mi_modules/mi_divp/mi_divp0
printk in _MI_SYS_IMPL_Common_WriteProc
divp debug:off