hi3516 mpp


原文链接: hi3516 mpp
  1. 系统自带的支持imx327 镜头

  2. 修改系统支持 335 镜头

vi Makefile.param

SENSOR0_TYPE ?= SONY_IMX335_MIPI_5M_30FPS_12BIT 
SENSOR1_TYPE ?= SONY_IMX335_MIPI_5M_30FPS_12BIT 
  1. 修改系统支持 imx385 镜头
    a. vi mpp/include/hi_sns_ctrl.h

    typedef struct hiISP_SNS_OBJ_S
            {
                HI_S32  (*pfnRegisterCallback)(VI_PIPE ViPipe, ALG_LIB_S *pstAeLib, ALG_LIB_S *pstAwbLib);
                HI_S32  (*pfnUnRegisterCallback)(VI_PIPE ViPipe, ALG_LIB_S *pstAeLib, ALG_LIB_S *pstAwbLib);
                HI_S32  (*pfnSetBusInfo)(VI_PIPE ViPipe, ISP_SNS_COMMBUS_U unSNSBusInfo);
                HI_VOID (*pfnStandby)(VI_PIPE ViPipe);
                HI_VOID (*pfnRestart)(VI_PIPE ViPipe);
                HI_VOID (*pfnMirrorFlip)(VI_PIPE ViPipe, ISP_SNS_MIRRORFLIP_TYPE_E eSnsMirrorFlip);
                HI_S32  (*pfnWriteReg)(VI_PIPE ViPipe, HI_S32 s32Addr, HI_S32 s32Data);
                HI_S32  (*pfnReadReg)(VI_PIPE ViPipe, HI_S32 s32Addr);
                HI_S32  (*pfnSetInit)(VI_PIPE ViPipe, ISP_INIT_ATTR_S *pstInitAttr);
            } ISP_SNS_OBJ_S;
    
    75行 添加 :
    extern ISP_SNS_OBJ_S stSnsImx385Obj;
    

    b. vi mpp/sample/common/sample_comm.h

    typedef enum hiSAMPLE_SNS_TYPE_E
    {
    SONY_IMX327_MIPI_2M_30FPS_12BIT,
    SONY_IMX327_MIPI_2M_30FPS_12BIT_WDR2TO1,
    SONY_IMX327_2L_MIPI_2M_30FPS_12BIT,
    SONY_IMX327_2L_MIPI_2M_30FPS_12BIT_WDR2TO1,
    SONY_IMX307_MIPI_2M_30FPS_12BIT,
    SONY_IMX307_MIPI_2M_30FPS_12BIT_WDR2TO1,
    SONY_IMX335_MIPI_5M_30FPS_12BIT,
    SONY_IMX335_MIPI_5M_30FPS_10BIT_WDR2TO1,
    SONY_IMX335_MIPI_4M_30FPS_12BIT,
    SONY_IMX335_MIPI_4M_30FPS_10BIT_WDR2TO1,
    SONY_IMX458_MIPI_8M_30FPS_10BIT,
    SONY_IMX458_MIPI_12M_20FPS_10BIT,
    SONY_IMX458_MIPI_4M_60FPS_10BIT,
    SONY_IMX458_MIPI_4M_40FPS_10BIT,
    SONY_IMX458_MIPI_2M_90FPS_10BIT,
    SONY_IMX458_MIPI_1M_129FPS_10BIT,
    PANASONIC_MN34220_LVDS_2M_30FPS_12BIT,
    OMNIVISION_OS05A_MIPI_4M_30FPS_12BIT,
    OMNIVISION_OS05A_MIPI_4M_30FPS_10BIT_WDR2TO1,

    SONY_IMX385_MIPI_2M_30FPS_12BIT, // 增加IMX385 支持
    SAMPLE_SNS_TYPE_BUTT,
    } SAMPLE_SNS_TYPE_E;

    c. vi mpp/sample/common/sample_comm_isp.c

    增加注释部分

    // ISP_PUB_ATTR_S ISP_PUB_ATTR_IMX385_2M_30FPS =
    // {
    //     {0, 0, 1920, 1080},
    //     {1920, 1080},
    //     30,
    //     BAYER_RGGB,
    //     WDR_MODE_NONE,
    //     0,
    // };
    
    HI_S32 SAMPLE_COMM_ISP_GetIspAttrBySns(SAMPLE_SNS_TYPE_E enSnsType, ISP_PUB_ATTR_S* pstPubAttr)
    {
    switch (enSnsType)
    {
    		// case SONY_IMX385_MIPI_2M_30FPS_12BIT:
    		// 	memcpy(pstPubAttr, &ISP_PUB_ATTR_IMX385_2M_30FPS, sizeof(ISP_PUB_ATTR_S));
        //     break;
    		
        case SONY_IMX327_MIPI_2M_30FPS_12BIT:
        case SONY_IMX327_2L_MIPI_2M_30FPS_12BIT:
            memcpy(pstPubAttr, &ISP_PUB_ATTR_IMX327_2M_30FPS, sizeof(ISP_PUB_ATTR_S));
            break;
    
        case SONY_IMX327_MIPI_2M_30FPS_12BIT_WDR2TO1:
        case SONY_IMX327_2L_MIPI_2M_30FPS_12BIT_WDR2TO1:
            memcpy(pstPubAttr, &ISP_PUB_ATTR_IMX327_MIPI_2M_30FPS_WDR2TO1_LINE, sizeof(ISP_PUB_ATTR_S));
            break;
    
    
        ...
    
        default:
            memcpy(pstPubAttr, &ISP_PUB_ATTR_IMX327_2M_30FPS, sizeof(ISP_PUB_ATTR_S));
            break;
    }
    
    return HI_SUCCESS;
    }
    
    ISP_SNS_OBJ_S* SAMPLE_COMM_ISP_GetSnsObj(HI_U32 u32SnsId)
    {
    SAMPLE_SNS_TYPE_E enSnsType;
    
    enSnsType = g_enSnsType[u32SnsId];
    
    switch (enSnsType)
    {
    		// case SONY_IMX385_MIPI_2M_30FPS_12BIT:
    		// 	return &stSnsImx385Obj;
    
        case SONY_IMX327_MIPI_2M_30FPS_12BIT:
        case SONY_IMX327_MIPI_2M_30FPS_12BIT_WDR2TO1:
            return &stSnsImx327Obj;
    
    ....
    
        default:
            return HI_NULL;
    }
    }
    

vi mpp/sample/common/sample_comm_vi.c

// 开头增加
// combo_dev_attr_t MIPI_4lane_CHN0_SENSOR_IMX385_12BIT_2M_NOWDR_ATTR =
// {
//     .devno = 0,
//     .input_mode = INPUT_MODE_MIPI,
//     .data_rate = MIPI_DATA_RATE_X1,
//     .img_rect = {0, 0, 1920, 1080},

//     {
//         .mipi_attr =
//         {
//             DATA_TYPE_RAW_12BIT,
//             HI_MIPI_WDR_MODE_NONE,
//             {0, 1, 2, 3}
//         }
//     }
// };

// // 425行 增加 VI_DEV_ATTR_S
// VI_DEV_ATTR_S DEV_ATTR_IMX385_2M_BASE =
// {
//     VI_MODE_MIPI,
//     VI_WORK_MODE_1Multiplex,
//     {0xFFF00000,    0x0},
//     VI_SCAN_PROGRESSIVE,
//     {-1, -1, -1, -1},
//     VI_DATA_SEQ_YUYV,

//     {
//     /*port_vsync   port_vsync_neg     port_hsync        port_hsync_neg        */
//     VI_VSYNC_PULSE, VI_VSYNC_NEG_LOW, VI_HSYNC_VALID_SINGNAL,VI_HSYNC_NEG_HIGH,VI_VSYNC_VALID_SINGAL,VI_VSYNC_VALID_NEG_HIGH,

//     /*hsync_hfb    hsync_act    hsync_hhb*/
//     {0,            1280,        0,
//     /*vsync0_vhb vsync0_act vsync0_hhb*/
//      0,            720,        0,
//     /*vsync1_vhb vsync1_act vsync1_hhb*/
//      0,            0,            0}
//     },
//     VI_DATA_TYPE_RGB,
//     HI_FALSE,
//     {1920, 1080},
//     {
//         {
//             {1920 , 1080},

//         },
//         {
//             VI_REPHASE_MODE_NONE,
//             VI_REPHASE_MODE_NONE
//         }
//     },
//     {
//         WDR_MODE_NONE,
//         1080
//     },
//     DATA_RATE_X1
// };

// 1660 行

HI_S32 SAMPLE_COMM_VI_GetComboAttrBySns(SAMPLE_SNS_TYPE_E enSnsType, combo_dev_t MipiDev, combo_dev_attr_t* pstComboAttr)
{
    switch (enSnsType)
    {
		// case SONY_IMX385_MIPI_2M_30FPS_12BIT:
		// 	hi_memcpy(pstComboAttr, sizeof(combo_dev_attr_t), &MIPI_4lane_CHN0_SENSOR_IMX385_12BIT_2M_NOWDR_ATTR, sizeof(combo_dev_attr_t));
        //     break;
			
        case SONY_IMX327_MIPI_2M_30FPS_12BIT:
            hi_memcpy(pstComboAttr, sizeof(combo_dev_attr_t), &MIPI_4lane_CHN0_SENSOR_IMX327_12BIT_2M_NOWDR_ATTR, sizeof(combo_dev_attr_t));
            break;

        case SONY_IMX327_MIPI_2M_30FPS_12BIT_WDR2TO1:
            hi_memcpy(pstComboAttr, sizeof(combo_dev_attr_t), &MIPI_4lane_CHN0_SENSOR_IMX327_12BIT_2M_WDR2to1_ATTR, sizeof(combo_dev_attr_t));
            break;

        case SONY_IMX327_2L_MIPI_2M_30FPS_12BIT:
            if (0 == MipiDev)
            {
                memcpy(pstComboAttr, &MIPI_2lane_CHN0_SENSOR_IMX327_12BIT_2M_NOWDR_ATTR, sizeof(combo_dev_attr_t));
            }
            else if (1 == MipiDev)
            {
                memcpy(pstComboAttr, &MIPI_2lane_CHN1_SENSOR_IMX327_12BIT_2M_NOWDR_ATTR, sizeof(combo_dev_attr_t));
            }

            break;

        case SONY_IMX327_2L_MIPI_2M_30FPS_12BIT_WDR2TO1:
            if (0 == MipiDev)
            {
                memcpy(pstComboAttr, &MIPI_2lane_CHN0_SENSOR_IMX327_12BIT_2M_WDR2to1_ATTR, sizeof(combo_dev_attr_t));
            }
            else if (1 == MipiDev)
            {
                memcpy(pstComboAttr, &MIPI_2lane_CHN1_SENSOR_IMX327_12BIT_2M_WDR2to1_ATTR, sizeof(combo_dev_attr_t));
            }

            break;

      ...

        default:
            SAMPLE_PRT("not support enSnsType: %d\n", enSnsType);
            hi_memcpy(pstComboAttr, sizeof(combo_dev_attr_t), &MIPI_4lane_CHN0_SENSOR_IMX327_12BIT_2M_NOWDR_ATTR, sizeof(combo_dev_attr_t));
    }


    return HI_SUCCESS;
}


HI_S32 SAMPLE_COMM_VI_GetDevAttrBySns(SAMPLE_SNS_TYPE_E enSnsType, VI_DEV_ATTR_S* pstViDevAttr)
{
    switch (enSnsType)
    {
		// case SONY_IMX385_MIPI_2M_30FPS_12BIT:
		// 	hi_memcpy(pstViDevAttr, sizeof(VI_DEV_ATTR_S), &DEV_ATTR_IMX385_2M_BASE, sizeof(VI_DEV_ATTR_S));
        //     break;
			
        case SONY_IMX327_MIPI_2M_30FPS_12BIT:
        case SONY_IMX327_2L_MIPI_2M_30FPS_12BIT:
        case SONY_IMX327_2L_MIPI_2M_30FPS_12BIT_WDR2TO1:
            hi_memcpy(pstViDevAttr, sizeof(VI_DEV_ATTR_S), &DEV_ATTR_IMX327_2M_BASE, sizeof(VI_DEV_ATTR_S));
            break;

        case SONY_IMX327_MIPI_2M_30FPS_12BIT_WDR2TO1:
            hi_memcpy(pstViDevAttr, sizeof(VI_DEV_ATTR_S), &DEV_ATTR_IMX327_2M_BASE, sizeof(VI_DEV_ATTR_S));
            pstViDevAttr->au32ComponentMask[0] = 0xFFC00000;
            break;

        case SONY_IMX307_MIPI_2M_30FPS_12BIT:
            hi_memcpy(pstViDevAttr, sizeof(VI_DEV_ATTR_S), &DEV_ATTR_IMX307_2M_BASE, sizeof(VI_DEV_ATTR_S));
            break;

        case SONY_IMX307_MIPI_2M_30FPS_12BIT_WDR2TO1:
            hi_memcpy(pstViDevAttr, sizeof(VI_DEV_ATTR_S), &DEV_ATTR_IMX307_2M_BASE, sizeof(VI_DEV_ATTR_S));
            pstViDevAttr->au32ComponentMask[0] = 0xFFC00000;
            break;

       ...

        default:
            hi_memcpy(pstViDevAttr, sizeof(VI_DEV_ATTR_S), &DEV_ATTR_IMX327_2M_BASE, sizeof(VI_DEV_ATTR_S));
    }

    return HI_SUCCESS;
}

HI_S32 SAMPLE_COMM_VI_GetPipeAttrBySns(SAMPLE_SNS_TYPE_E enSnsType, VI_PIPE_ATTR_S* pstPipeAttr)
{
    switch (enSnsType)
    {
		// case SONY_IMX385_MIPI_2M_30FPS_12BIT:
        case SONY_IMX327_MIPI_2M_30FPS_12BIT:
        case SONY_IMX327_2L_MIPI_2M_30FPS_12BIT:
        case SONY_IMX327_2L_MIPI_2M_30FPS_12BIT_WDR2TO1:
            hi_memcpy(pstPipeAttr, sizeof(VI_PIPE_ATTR_S), &PIPE_ATTR_1920x1080_RAW12_420_3DNR_RFR, sizeof(VI_PIPE_ATTR_S));
            break;

        case SONY_IMX327_MIPI_2M_30FPS_12BIT_WDR2TO1:
            hi_memcpy(pstPipeAttr, sizeof(VI_PIPE_ATTR_S), &PIPE_ATTR_1920x1080_RAW12_420_3DNR_RFR, sizeof(VI_PIPE_ATTR_S));
            pstPipeAttr->enPixFmt = PIXEL_FORMAT_RGB_BAYER_10BPP;
            pstPipeAttr->enBitWidth = DATA_BITWIDTH_10;
            break;

        case SONY_IMX307_MIPI_2M_30FPS_12BIT:
            hi_memcpy(pstPipeAttr, sizeof(VI_PIPE_ATTR_S), &PIPE_ATTR_1920x1080_RAW12_420_3DNR_RFR, sizeof(VI_PIPE_ATTR_S));
            break;

        case SONY_IMX307_MIPI_2M_30FPS_12BIT_WDR2TO1:
            hi_memcpy(pstPipeAttr, sizeof(VI_PIPE_ATTR_S), &PIPE_ATTR_1920x1080_RAW12_420_3DNR_RFR, sizeof(VI_PIPE_ATTR_S));
            pstPipeAttr->enPixFmt = PIXEL_FORMAT_RGB_BAYER_10BPP;
            pstPipeAttr->enBitWidth = DATA_BITWIDTH_10;
            break;

        ....

        default:
            hi_memcpy(pstPipeAttr, sizeof(VI_PIPE_ATTR_S), &PIPE_ATTR_1920x1080_RAW12_420_3DNR_RFR, sizeof(VI_PIPE_ATTR_S));
    }

    return HI_SUCCESS;
}

HI_S32 SAMPLE_COMM_VI_GetChnAttrBySns(SAMPLE_SNS_TYPE_E enSnsType, VI_CHN_ATTR_S* pstChnAttr)
{
    switch (enSnsType)
    {
		// case SONY_IMX385_MIPI_2M_30FPS_12BIT:
        case SONY_IMX327_MIPI_2M_30FPS_12BIT:
        case SONY_IMX327_MIPI_2M_30FPS_12BIT_WDR2TO1:
        case SONY_IMX327_2L_MIPI_2M_30FPS_12BIT:
        case SONY_IMX327_2L_MIPI_2M_30FPS_12BIT_WDR2TO1:
            hi_memcpy(pstChnAttr, sizeof(VI_CHN_ATTR_S), &CHN_ATTR_1920x1080_420_SDR8_LINEAR, sizeof(VI_CHN_ATTR_S));
            break;

        case SONY_IMX307_MIPI_2M_30FPS_12BIT:
        case SONY_IMX307_MIPI_2M_30FPS_12BIT_WDR2TO1:
            hi_memcpy(pstChnAttr, sizeof(VI_CHN_ATTR_S), &CHN_ATTR_1920x1080_420_SDR8_LINEAR, sizeof(VI_CHN_ATTR_S));
            break;

        ...

        default:
            hi_memcpy(pstChnAttr, sizeof(VI_CHN_ATTR_S), &CHN_ATTR_1920x1080_420_SDR8_LINEAR, sizeof(VI_CHN_ATTR_S));
    }

    return HI_SUCCESS;
}

	

//  funciton : Get enSize by diffrent sensor
HI_S32 SAMPLE_COMM_VI_GetSizeBySensor(SAMPLE_SNS_TYPE_E enMode, PIC_SIZE_E* penSize)
{
    HI_S32 s32Ret = HI_SUCCESS;

    if (!penSize)
    {
        return HI_FAILURE;
    }

    switch (enMode)
    {
		// case SONY_IMX385_MIPI_2M_30FPS_12BIT:
        case SONY_IMX327_MIPI_2M_30FPS_12BIT:
        case SONY_IMX327_MIPI_2M_30FPS_12BIT_WDR2TO1:
            *penSize = PIC_1080P;
            break;


        case SONY_IMX335_MIPI_5M_30FPS_12BIT:
        case SONY_IMX335_MIPI_5M_30FPS_10BIT_WDR2TO1:
            *penSize = PIC_2592x1944;
            break;

        case SONY_IMX335_MIPI_4M_30FPS_12BIT:
        case SONY_IMX335_MIPI_4M_30FPS_10BIT_WDR2TO1:
            *penSize = PIC_2592x1536;
            break;
  ....

        default:
            *penSize = PIC_1080P;
            break;
    }

    return s32Ret;
}



/******************************************************************************
* funciton : Get enSize by diffrent sensor
******************************************************************************/
HI_S32 SAMPLE_COMM_VI_GetFrameRateBySensor(SAMPLE_SNS_TYPE_E enMode, HI_U32* pu32FrameRate)
{
    HI_S32 s32Ret = HI_SUCCESS;

    if (!pu32FrameRate)
    {
        return HI_FAILURE;
    }

    switch (enMode)
    {
		// case SONY_IMX385_MIPI_2M_30FPS_12BIT:
        case SONY_IMX327_MIPI_2M_30FPS_12BIT:
        case SONY_IMX327_MIPI_2M_30FPS_12BIT_WDR2TO1:
        case SONY_IMX307_MIPI_2M_30FPS_12BIT:
        case SONY_IMX307_MIPI_2M_30FPS_12BIT_WDR2TO1:
        case SONY_IMX335_MIPI_5M_30FPS_12BIT:
        case SONY_IMX335_MIPI_5M_30FPS_10BIT_WDR2TO1:
        case SONY_IMX335_MIPI_4M_30FPS_12BIT:
        case SONY_IMX335_MIPI_4M_30FPS_10BIT_WDR2TO1:
        case PANASONIC_MN34220_LVDS_2M_30FPS_12BIT:
        case OMNIVISION_OS05A_MIPI_4M_30FPS_12BIT:
        case OMNIVISION_OS05A_MIPI_4M_30FPS_10BIT_WDR2TO1:
            *pu32FrameRate = 30;
            break;

        case SONY_IMX458_MIPI_8M_30FPS_10BIT:
            *pu32FrameRate = 30;
            break;
        case SONY_IMX458_MIPI_12M_20FPS_10BIT:
            *pu32FrameRate = 20;
            break;
        case SONY_IMX458_MIPI_4M_60FPS_10BIT:
            *pu32FrameRate = 60;
            break;
        case SONY_IMX458_MIPI_4M_40FPS_10BIT:
            *pu32FrameRate = 40;
            break;
        case SONY_IMX458_MIPI_2M_90FPS_10BIT:
            *pu32FrameRate = 90;
            break;
        case SONY_IMX458_MIPI_1M_129FPS_10BIT:
            *pu32FrameRate = 129;
            break;

        default:
            *pu32FrameRate = 30;
            break;

    }

    return s32Ret;
}


combo_dev_t SAMPLE_COMM_VI_GetComboDevBySensor(SAMPLE_SNS_TYPE_E enMode, HI_S32 s32SnsIdx)
{
    combo_dev_t dev = 0;

    switch (enMode)
    {
		// case SONY_IMX385_MIPI_2M_30FPS_12BIT:
        case SONY_IMX327_MIPI_2M_30FPS_12BIT:
        case SONY_IMX327_MIPI_2M_30FPS_12BIT_WDR2TO1:
        case SONY_IMX307_MIPI_2M_30FPS_12BIT:
        case SONY_IMX307_MIPI_2M_30FPS_12BIT_WDR2TO1:
        case SONY_IMX335_MIPI_5M_30FPS_12BIT:
        case SONY_IMX335_MIPI_5M_30FPS_10BIT_WDR2TO1:
        case SONY_IMX335_MIPI_4M_30FPS_12BIT:
        case SONY_IMX335_MIPI_4M_30FPS_10BIT_WDR2TO1:
        case SONY_IMX458_MIPI_8M_30FPS_10BIT:
        case SONY_IMX458_MIPI_12M_20FPS_10BIT:
        case SONY_IMX458_MIPI_4M_60FPS_10BIT:
        case SONY_IMX458_MIPI_4M_40FPS_10BIT:
        case SONY_IMX458_MIPI_2M_90FPS_10BIT:
        case SONY_IMX458_MIPI_1M_129FPS_10BIT:
        case PANASONIC_MN34220_LVDS_2M_30FPS_12BIT:
        case OMNIVISION_OS05A_MIPI_4M_30FPS_12BIT:
        case OMNIVISION_OS05A_MIPI_4M_30FPS_10BIT_WDR2TO1:
            if (0 == s32SnsIdx)
            {
                dev = 0;
            }
            else if (1 == s32SnsIdx)
            {
                dev = 2;
            }
            break;

        default:
            dev = 0;
            break;
    }

    return dev;
}



`