Exemplo n.º 1
0
/******************************************************************************
* funciton : stop ISP, and stop isp thread
******************************************************************************/
HI_VOID SAMPLE_COMM_ISP_Stop()
{
    ISP_DEV IspDev = 0;
    HI_S32 s32Ret;
    ALG_LIB_S stLib;

    if (!gbIspInited)
    {
        return;
    }

    HI_MPI_ISP_Exit(IspDev);
    if (gs_IspPid)
    {
        pthread_join(gs_IspPid, 0);
        gs_IspPid = 0;
    }
    gbIspInited = HI_FALSE;

    /* unregister hisi af lib */
    stLib.s32Id = 0;
    strcpy(stLib.acLibName, HI_AF_LIB_NAME);
    s32Ret = HI_MPI_AF_UnRegister(IspDev, &stLib);
    if (s32Ret != HI_SUCCESS)
    {
        printf("%s: HI_MPI_AF_UnRegister failed!\n", __FUNCTION__);
        return;
    }

    /* unregister hisi awb lib */
    stLib.s32Id = 0;
    strcpy(stLib.acLibName, HI_AWB_LIB_NAME);
    s32Ret = HI_MPI_AWB_UnRegister(IspDev, &stLib);
    if (s32Ret != HI_SUCCESS)
    {
        printf("%s: HI_MPI_AWB_UnRegister failed!\n", __FUNCTION__);
        return;
    }

    /* unregister hisi ae lib */
    stLib.s32Id = 0;
    strcpy(stLib.acLibName, HI_AE_LIB_NAME);
    s32Ret = HI_MPI_AE_UnRegister(IspDev, &stLib);
    if (s32Ret != HI_SUCCESS)
    {
        printf("%s: HI_MPI_AE_UnRegister failed!\n", __FUNCTION__);
        return;
    }

    /* sensor unregister callback */
    s32Ret = sensor_unregister_callback_fn();
    if (s32Ret != HI_SUCCESS)
    {
        printf("%s: sensor_unregister_callback_fn failed with %#x!\n", \
               __FUNCTION__, s32Ret);
        return;
    }

    return;
}
Exemplo n.º 2
0
bool HimppVideoISP::disableObject()
{
	HI_MPI_ISP_Exit();
	unregisterAlgorithm();
	unloadSensorModule();

	pthread_join(isp_thread, 0);

	return true;
}
Exemplo n.º 3
0
/******************************************************************************
* funciton : stop ISP, and stop isp thread
******************************************************************************/
static HI_VOID vdIspStop(VI_ATTR_S * pstViAttr)
{
    ISP_DEV IspDev = pstViAttr->IspDev;

    if (!gbIspInited)
    {
        return;
    }
    
    HI_MPI_ISP_Exit(IspDev);
    if (gs_IspPid)
    {
        pthread_join(gs_IspPid, 0);
        gs_IspPid = 0;
    }
    gbIspInited = HI_FALSE;
    return;
}
Exemplo n.º 4
0
/******************************************************************************
* funciton : stop ISP, and stop isp thread
******************************************************************************/
HI_VOID SAMPLE_COMM_ISP_Stop()
{
    ISP_DEV IspDev = 0;

    if (!gbIspInited)
    {
        return;
    }
    
    HI_MPI_ISP_Exit(IspDev);
    if (gs_IspPid)
    {
        pthread_join(gs_IspPid, 0);
        gs_IspPid = 0;
    }
    gbIspInited = HI_FALSE;
    return;
}
Exemplo n.º 5
0
/******************************************************************************
* funciton : stop ISP, and stop isp thread
******************************************************************************/
HI_VOID SAMPLE_COMM_ISP_Stop()
{
    HI_MPI_ISP_Exit();
#ifdef ISP_V2

    ALG_LIB_S stLib;
    stLib.s32Id = 0;
    strcpy(stLib.acLibName, HI_AE_LIB_NAME);
    HI_MPI_AE_UnRegister(&stLib);
    stLib.s32Id = 0;
    strcpy(stLib.acLibName, HI_AWB_LIB_NAME);
    HI_MPI_AWB_UnRegister(&stLib);
    stLib.s32Id = 0;
    strcpy(stLib.acLibName, HI_AF_LIB_NAME);
    HI_MPI_AF_UnRegister(&stLib);
    sensor_unregister_callback();

#endif
    pthread_join(gs_IspPid, 0);
    return;
}
Exemplo n.º 6
0
bool HimppVideoISP::enableObject()
{
	HI_S32 s32Ret;
	ISP_IMAGE_ATTR_S *pstImageAttr = *video_sensor;
	ISP_INPUT_TIMING_S *pstInputTiming = *video_sensor;

	if (!loadSensorModule())
		return false;

	if (!registerAlgorithm())
		goto err_unload_mod;

	if ((s32Ret = HI_MPI_ISP_Init()) != HI_SUCCESS) {
		goto err_unreg_alg;
	}

	if (HI_MPI_ISP_SetImageAttr(pstImageAttr) != HI_SUCCESS) {
		goto err_exit_isp;
	}

	if (HI_MPI_ISP_SetInputTiming(pstInputTiming) != HI_SUCCESS) {
		goto err_exit_isp;
	}

	if (pthread_create(&isp_thread, 0, isp_thread_routine, NULL))
		goto err_exit_isp;

	ISP_OP_TYPE_E exp_opmode;
	exp_opmode = (_exposure._mode == IVideoSource::Imaging::Exposure::AUTO_EXPOSURE) ?
		OP_TYPE_AUTO : OP_TYPE_MANUAL;
	if (HI_MPI_ISP_SetExposureType(exp_opmode) != HI_SUCCESS) {
		fprintf(stderr, "HI_MPI_ISP_SetExposureType failed\n");
    }

	// initialize Exposure
	ISP_AE_ATTR_EX_S ae_attr;
	if (HI_MPI_ISP_GetAEAttrEx(&ae_attr) == HI_SUCCESS) {
        ae_attr.enAEMode = (_exposure._priority == IVideoSource::Imaging::Exposure::LOWNOISE_PRIORITY) ? \
                            AE_MODE_LOW_NOISE : AE_MODE_FRAME_RATE;
		ae_attr.u32ExpTimeMin = _exposure._min_exp_time;
		ae_attr.u32ExpTimeMax = _exposure._max_exp_time;
		ae_attr.u32AGainMin = _exposure._min_gain;
		ae_attr.u32AGainMax = _exposure._max_gain;

		if (HI_MPI_ISP_SetAEAttrEx(&ae_attr) != HI_SUCCESS) {
			fprintf(stderr, "HI_MPI_ISP_SetAEAttrEx failed\n");
		}
	}

	ISP_ME_ATTR_EX_S me_attr;
	if (HI_MPI_ISP_GetMEAttrEx(&me_attr) == HI_SUCCESS) {
		me_attr.u32ExpLine = _exposure._exp_time;
		me_attr.s32AGain = _exposure._gain;
		if (HI_MPI_ISP_SetMEAttrEx(&me_attr) != HI_SUCCESS) {
			fprintf(stderr, "HI_MPI_ISP_SetMEAttrEx failed\n");
		}
	}

	// Initialize WhiteBalance
	ISP_OP_TYPE_E wb_opmode;
	wb_opmode = (_whitebalance._mode == IVideoSource::Imaging::WhiteBalance::AUTO_WB) ?
		OP_TYPE_AUTO : OP_TYPE_MANUAL;
	if (HI_MPI_ISP_SetWBType(wb_opmode) != HI_SUCCESS) {
		fprintf(stderr, "HI_MPI_ISP_SetWBType failed\n");
    }

	if (_whitebalance._mode == IVideoSource::Imaging::WhiteBalance::AUTO_WB) {
		ISP_AWB_ATTR_S awb_attr;
		if (HI_MPI_ISP_GetAWBAttr(&awb_attr) == HI_SUCCESS) {
			awb_attr.u8BGStrength = (HI_U8)_whitebalance._cb_gain;
			awb_attr.u8RGStrength = (HI_U8)_whitebalance._cr_gain;
			if (HI_MPI_ISP_SetAWBAttr(&awb_attr) != HI_SUCCESS)
				fprintf(stderr, "HI_MPI_ISP_SetWBType failed\n");
		}
	}
	else {
		ISP_MWB_ATTR_S mwb_attr;
		if (HI_MPI_ISP_GetMWBAttr(&mwb_attr) == HI_SUCCESS)
			mwb_attr.u16Rgain = (HI_U16)_whitebalance._r_gain;
			mwb_attr.u16Ggain = (HI_U16)_whitebalance._g_gain;
			mwb_attr.u16Bgain = (HI_U16)_whitebalance._b_gain;
			if (HI_MPI_ISP_SetMWBAttr(&mwb_attr) != HI_SUCCESS)
				throw IpcamError("Cannot set MWB attr");
	}

	return true;

err_exit_isp:
	HI_MPI_ISP_Exit();
err_unreg_alg:
	unregisterAlgorithm();
err_unload_mod:
	unloadSensorModule();

	return false;
}