⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 camera_process.c

📁 MTK6225 支持的200W像素的代码
💻 C
📖 第 1 页 / 共 5 页
字号:
	config_image_processor(scene_id);
	config_pixel_resizer(scene_id);
#elif (defined(DRV_ISP_6228_SERIES)||defined(DRV_ISP_6229_SERIES))
	open_image_data_path(scene_id);
	config_camera_preview_data_path(scene_id,&ipp_preview_data);
#endif

#if (defined(DRV_ISP_6219_SERIES)||defined(DRV_ISP_6227_SERIES)||defined(DRV_ISP_6225_SERIES))
	resizer_buf_ptr=(kal_uint32 *) (*((volatile unsigned int *)0x8061005C));		/* resizer working memory */
	*resizer_buf_ptr=0x55AAAA55;
#endif

	isp_operation_state=ISP_PREVIEW_STATE;

#if (!defined(DRV_ISP_6219_SERIES))
	/* camera operation setting */
	if(isp_preview_config_data.continue_capture==0)
	{
		camera_operation_setting(CAM_DSC_MODE,isp_preview_config_data.dsc_mode);
		camera_operation_setting(CAM_AE_METERING,isp_preview_config_data.ae_metering_mode);
		camera_operation_setting(CAM_AF_MODE,isp_preview_config_data.af_mode);
		camera_operation_setting(CAM_AF_METERING,isp_preview_config_data.af_metering_mode);
		camera_operation_setting(CAM_SHUTTER_PRIORITY,isp_preview_config_data.tv_setting);
		camera_operation_setting(CAM_APERTURE_PRIORITY,isp_preview_config_data.av_setting);
		camera_operation_setting(CAM_ISO,isp_preview_config_data.iso_setting);
		camera_operation_setting(CAM_FLASH_MODE,isp_preview_config_data.flash_mode);
	}
#endif

	camera_image_setting(CAM_PARAM_EFFECT,isp_preview_config_data.image_effect);
	set_camera_mode_para(CAMERA_PARA_PREVIEW_MODE);
	if(isp_preview_config_data.image_effect==CAM_EFFECT_ENC_NORMAL)
	{
		camera_image_setting(CAM_PARAM_CONTRAST,isp_preview_config_data.contrast_level);
		camera_image_setting(CAM_PARAM_BRIGHTNESS,isp_preview_config_data.brightness_level);
		camera_image_setting(CAM_PARAM_HUE,isp_preview_config_data.hue_value);
		camera_image_setting(CAM_PARAM_SATURATION,isp_preview_config_data.saturation_value);
	}
	camera_image_setting(CAM_PARAM_WB,isp_preview_config_data.wb_mode);
	camera_image_setting(CAM_PARAM_EXPOSURE,isp_preview_config_data.ev_value);
	camera_image_setting(CAM_PARAM_BANDING,isp_preview_config_data.banding_freq);
	camera_image_setting(CAM_PARAM_NIGHT_MODE,(kal_uint16)isp_preview_config_data.night_mode);
	if((isp_preview_config_data.image_effect==CAM_EFFECT_ENC_NORMAL) && (isp_preview_config_data.night_mode))
		set_camera_mode_para(CAMERA_PARA_NIGHT_MODE);
#if (!defined(DRV_ISP_6219_SERIES))
	if(isp_preview_config_data.image_effect==CAM_EFFECT_ENC_NORMAL)
		set_anti_low_light_para(AE_INDEX_ENV);
#if (!defined(YUV_SENSOR_SUPPORT))
    /* init AE/AWB setting */
	AE_INDEX = ae_apply_index_update(dsc_status.dscmode, dsc_status.ae.iso, AE_INDEX_ENV);
    AE_INDEX_C = AE_INDEX;
    eShutter=AE_LUT[AE_INDEX].shutter;		        /* Get Shutter */
    	sensor_pregain=ae_get_sensor_gain(dsc_status.dscmode, dsc_status.ae.iso);     /* Get Gain */	
    isp_pregain=AE_LUT[AE_INDEX].ispgain;
    pregain=sensor_pregain*isp_pregain/BASEGAIN;
    image_sensor_func->set_sensor_eshutter(eShutter);
    image_sensor_func->set_sensor_gain(sensor_pregain);
    ae_set_isp_pregain();
#endif
#endif

	kal_set_eg_events(camera_isp_event_id,0,KAL_AND);
	wait_first_frame_flag=KAL_TRUE;
	isp_preview_frame=0;
	SET_CAMERA_PREVIEW_MODE;
	SET_CAMERA_FRAME_RATE(0);
#if  (defined(DRV_ISP_6227_SERIES)||defined(DRV_ISP_6229_SERIES))
   // Enable AE Count before Start Preview
	REG_ISP_PREPROCESS_CTRL2 &= ~REG_PREPROCESS2_AE_COUNT_CLEAR_BIT;
	ENABLE_AE_COUNT;
#endif
#if  (defined(DRV_ISP_6228_SERIES))
	RESET_ISP;
	CLEAR_RESET_ISP;
#endif

   #ifdef IMAGE_DATA_PATH_TIMING_ANALYSIS
      ENABLE_CAMERA_ISP_DONE_INT
      ENABLE_LCD_TRANSFER_COMPLETE_INT
   #endif

#if (defined(DRV_ISP_6228_SERIES)||defined(DRV_ISP_6229_SERIES))
	ENABLE_CMOS_SESNOR;
#endif
	ENABLE_VIEW_FINDER_MODE;

	ae_awb_cal_complete=1;
	isp_preview_2a_enable=0;
	ae_count=0;
	hist_idx=0;

#if (defined(DRV_ISP_6219_SERIES)||defined(DRV_ISP_6227_SERIES))
	sensor_check_count=0;
	sensor_fail_count=0;
	kal_sleep_task(10);
	while (sensor_check_count<=25)
	{
		kal_sleep_task(10);
		if ((*resizer_buf_ptr==0x55AAAA55) && (ae_count==0))
		{
			if (sensor_check_count==25)
			{
				sensor_fail_count++;
				if(sensor_fail_count>2)
					return KAL_FALSE;

				ae_on_off(KAL_TRUE);
				awb_on_off(KAL_TRUE);
				awb_set_gain();

				DISABLE_VIEW_FINDER_MODE;

				RESZ_Stop(scene_id);
				RESZ_Close(scene_id);
				clean_imgprc_coefficient(scene_id);
				IMGPROC_Stop(scene_id);
				IMGPROC_Close(scene_id);
				stop_image_dma(scene_id);
				IMGDMA_Close(scene_id);

				intmem_deinit();
				extmem_deinit();

				kal_set_eg_events(camera_isp_event_id,0,KAL_AND);

				ENABLE_CMOS_SESNOR;
				REG_ISP_CMOS_SENSOR_MODE_CONFIG |= REG_CMOS_SENSOR_RESET_BIT;		/* reset CMOS senosr */
				for (i=0;i<0x1000;i++);
				REG_ISP_CMOS_SENSOR_MODE_CONFIG &= ~REG_CMOS_SENSOR_RESET_BIT;

				image_sensor_func->sensor_init();
				for (i=0;i<0x1000;i++);
				image_sensor_func->sensor_preview_setting(&exposure_window,&sensor_config_data);

				intmem_init((kal_uint32 *) isp_preview_config_data.intmem_start_address,
								isp_preview_config_data.intmem_size);
				extmem_init((kal_uint32 *) isp_preview_config_data.extmem_start_address,
								isp_preview_config_data.extmem_size);

				config_image_dma(scene_id,isp_data->target_width,isp_data->target_height);
				config_image_processor(scene_id);
				config_pixel_resizer(scene_id);

				camera_image_setting(CAM_PARAM_EFFECT,isp_preview_config_data.image_effect);
				set_camera_mode_para(CAMERA_PARA_PREVIEW_MODE);
				if(isp_preview_config_data.image_effect==0)
				{
					camera_image_setting(CAM_PARAM_CONTRAST,isp_preview_config_data.contrast_level);
					camera_image_setting(CAM_PARAM_BRIGHTNESS,isp_preview_config_data.brightness_level);
					camera_image_setting(CAM_PARAM_HUE,isp_preview_config_data.hue_value);
					camera_image_setting(CAM_PARAM_SATURATION,isp_preview_config_data.saturation_value);
				}
				camera_image_setting(CAM_PARAM_WB,isp_preview_config_data.wb_mode);
				camera_image_setting(CAM_PARAM_EXPOSURE,isp_preview_config_data.ev_value);
				camera_image_setting(CAM_PARAM_BANDING,isp_preview_config_data.banding_freq);
				camera_image_setting(CAM_PARAM_NIGHT_MODE,(kal_uint16)isp_preview_config_data.night_mode);
				if((isp_preview_config_data.image_effect==0) && (isp_preview_config_data.night_mode))
					set_camera_mode_para(CAMERA_PARA_NIGHT_MODE);

				isp_preview_2a_enable=0;
				ae_count=0;
				hist_idx=0;
				sensor_check_count=0;
				resizer_buf_ptr=(kal_uint32 *) (*((volatile unsigned int *)0x8061005C));		/* resizer working memory */
				*resizer_buf_ptr=0x55AAAA55;

				ENABLE_VIEW_FINDER_MODE;
			}
			else
				sensor_check_count++;
		}
		else
			sensor_check_count=26;
	};
#endif

	/* wait sensor first frame coming */
#if (defined(DRV_ISP_6219_SERIES))
  	kal_retrieve_eg_events(camera_isp_event_id,CAMERA_ISP_FRAME_READY_EVENT,KAL_OR_CONSUME,
     	                    &event_group,KAL_SUSPEND);
#else
  	kal_retrieve_eg_events(camera_isp_event_id,CAMERA_ISP_VD_READY_EVENT,KAL_OR_CONSUME,
     	                    &event_group,KAL_SUSPEND);
#endif

	/* Wait AE AWB Stable */
	if(isp_first_preview_frame==KAL_TRUE)
	{
		for(i=0;i<camera_oper_data.preview_display_wait_frame;i++)
		{
			j=0;
			while(j<9*camera_oper_data.ae_awb_cal_period)
			{
				if(isp_preview_2a_enable==1)
				{
					ae_awb_main();
					isp_preview_2a_enable=0;
					break;
				}
				else
				{
					kal_sleep_task(2);
					j++;
			}
		}
		}
		isp_first_preview_frame=KAL_FALSE;
	}

	if(isp_preview_config_data.lcd_update==KAL_TRUE)
		lcd_fb_update(&lcd_data);	/* wait first frame ready */
	else
	{
		lcd_data.update_layer&=~lcd_data.hw_update_layer;		
		lcd_fb_update(&lcd_data);		
	}		

  	kal_set_eg_events(camera_isp_event_id,0,KAL_AND);
#if (defined(DRV_ISP_6219_SERIES))
  	kal_retrieve_eg_events(camera_isp_event_id,CAMERA_ISP_FRAME_READY_EVENT,KAL_OR_CONSUME,
     	                    &event_group,KAL_SUSPEND);
#else
  	kal_retrieve_eg_events(camera_isp_event_id,CAMERA_ISP_VD_READY_EVENT,KAL_OR_CONSUME,
     	                    &event_group,KAL_SUSPEND);
#endif
#endif /* YUV_SENSOR_SUPPORT */

	isp_frame_count=0;
	camera_process_stage|=LEAVE_CAMERA_PREVIEW;

#if (defined(YUV_SENSOR_SUPPORT))
	return camera_yuv_preview_process();
#else
	return KAL_TRUE;
#endif /* YUV_SENSOR_SUPPORT */
#endif
}	/* camera_preview_process() */

/*************************************************************************
* FUNCTION
*	exit_camera_preview_process
*
* DESCRIPTION
*	This function stops the camera preview process
*
* PARAMETERS
*	None
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/
kal_uint8 exit_camera_preview_process(void)
{
#if (defined(ISP_SUPPORT))
   kal_uint32 i=0;
	MMDI_SCENERIO_ID scene_id=SCENARIO_CAMERA_PREVIEW_ID;

	if (isp_operation_state!=ISP_PREVIEW_STATE)
		ASSERT(0);

#if (defined(AF_SUPPORT))//prevent scenario error
#if (!defined(YUV_SENSOR_SUPPORT))
	if ((af_operation_state == AF_COLLECT_STATE) || (af_operation_state == AF_SEARCH_STATE))
	{
	   	camera_operation_setting(CAM_AF_KEY, CAM_AF_RELEASE);
	}
#else
	camera_operation_setting(CAM_AF_KEY, CAM_AF_RELEASE);
#endif
#endif

	isp_idle_done_flag=KAL_FALSE;
	ENABLE_CAMERA_IDLE_INT;
	DISABLE_VIEW_FINDER_MODE;
	i=0;
	while(isp_idle_done_flag==KAL_FALSE)
	{
		i++;
		kal_sleep_task(5);
		if(i>9) break;
	}

	DISABLE_CMOS_SESNOR;
	//if(isp_preview_config_data.lcd_update==KAL_TRUE)
	lcd_stop_hw_update(isp_preview_config_data.lcd_id);

#if (defined(DRV_ISP_6219_SERIES)||defined(DRV_ISP_6227_SERIES))
	RESZ_Stop(scene_id);
	RESZ_Close(scene_id);

	clean_imgprc_coefficient(scene_id);
	IMGPROC_Stop(scene_id);
	IMGPROC_Close(scene_id);

	stop_image_dma(scene_id);
	IMGDMA_Close(scene_id);
#elif (defined(DRV_ISP_6228_SERIES)||defined(DRV_ISP_6229_SERIES))
	close_image_data_path(scene_id);
#elif (defined(DRV_ISP_6225_SERIES))
   RESZ_Stop(scene_id);
   RESZ_Close(scene_id);
#endif
	isp_digital_zoom_flag=KAL_FALSE;
	isp_operation_state=ISP_STANDBY_STATE;

#if (defined(DRV_ISP_6219_SERIES)||defined(DRV_ISP_6227_SERIES)||defined(DRV_ISP_6225_SERIES))
	intmem_deinit();
	extmem_deinit();
#endif
#if (!defined(YUV_SENSOR_SUPPORT))
	ae_on_off(KAL_FALSE);
	awb_on_off(KAL_FALSE);
#endif
	camera_process_stage|=LEAVE_EXIT_CAMERA_PREVIEW;

   #ifdef IMAGE_DATA_PATH_TIMING_ANALYSIS
      DISABLE_CAMERA_ISP_DONE_INT
      DISABLE_LCD_TRANSFER_COMPLETE_INT
   #endif

	return KAL_TRUE;
#endif
}	/* exit_camera_preview_process() */


#if defined(OV2640)

kal_uint16  CAM_CheckLine(void)
{
	kal_uint32 reg;

	reg = DRV_Reg32((CAMERA_base + 0x01DC));
	reg = reg & 0xfff0000;
	reg = (kal_uint16)(reg >> 4);
	return reg;
}


kal_uint8 camera_capture_jpeg(camera_capture_cct_struct_jpeg *isp_cct_data)
{
	kal_uint32 event_group;
	kal_int16 isp_grab_start_x,isp_grab_start_y;
	kal_uint32 isp_capture_shutter;
	kal_uint16 isp_capture_pregain;
	kal_uint32 i;
	kal_uint8 ret_code = KAL_TRUE;	

	kal_uint8 sub_sample=0;

#if (defined(DRV_ISP_6227_SERIES)||defined(DRV_ISP_6228_SERIES)||defined(DRV_ISP_6229_SERIES))		
	kal_uint16 sub_sample=0;
#endif	

	if (isp_operation_state!=ISP_STANDBY_STATE)
		ASSERT(0);
    
	ENABLE_CMOS_SESNOR;

	exposure_window.image_target_width=isp_cct_data->grab_width;
	exposure_window.image_target_height=isp_cct_data->grab_height;
	exposure_window.digital_zoom_factor=10;	
	

	isp_grab_start_x=exposure_window.grab_start_x;
	isp_grab_start_y=exposure_window.grab_start_y;


	SET_TG_GRAB_PIXEL(0,1024);
	SET_TG_GRAB_LINE(0,1500);		


/* set gamma 1024 */
#if (defined(DRV_ISP_6227_SERIES)||defined(DRV_ISP_6229_SERIES))
	apply_take_image_with_gamma_1024_by_flag();
#endif

	ENABLE_REZ_DISCONN;
	DISABLE_REZ_LPF;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -