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

📄 image_sensor.c.svn-base

📁 MTK 25平台 camera 自适应驱动
💻 SVN-BASE
📖 第 1 页 / 共 3 页
字号:
    write_cmos_sensor(0x2f,0x00);
    write_cmos_sensor(0x23,0x00);
    write_cmos_sensor(0x81,0x68);
    write_cmos_sensor(0xa4,0x88);
    write_cmos_sensor(0xa5,0x02);
    write_cmos_sensor(0xa8,0xf0);
    write_cmos_sensor(0xa1,0x03);
    write_cmos_sensor(0x51,0x04);
    write_cmos_sensor(0x52,0x11);
    write_cmos_sensor(0x53,0x8c);
    write_cmos_sensor(0x54,0x9d);
    write_cmos_sensor(0x57,0x80);
    write_cmos_sensor(0x58,0x9a);
    write_cmos_sensor(0x59,0x83);
    write_cmos_sensor(0x5a,0x0d);
    write_cmos_sensor(0x5b,0xcd);
    write_cmos_sensor(0xb1,0x0c);
    write_cmos_sensor(0xb2,0x0e);
    write_cmos_sensor(0x3f,0x00);
    write_cmos_sensor(0x39,0x2a);
    write_cmos_sensor(0x40,0xc0);
    write_cmos_sensor(0x41,0x38);                                      
    write_cmos_sensor(0x42,0x00);
    write_cmos_sensor(0x43,0x14);                                      
    write_cmos_sensor(0x44,0xf2);                                      
    write_cmos_sensor(0x45,0x39);
    write_cmos_sensor(0x46,0x62);
    write_cmos_sensor(0x47,0x3d);
    write_cmos_sensor(0x48,0x55);
    write_cmos_sensor(0x49,0x00);
    write_cmos_sensor(0x4b,0x09);                                      
    write_cmos_sensor(0x4c,0x00);
    write_cmos_sensor(0x4e,0x20);
    write_cmos_sensor(0x4f,0x88);
    write_cmos_sensor(0x50,0x8b);
    write_cmos_sensor(0x3b,0x12);
    write_cmos_sensor(0x8e,0x00);
    write_cmos_sensor(0x8f,0x00);
    write_cmos_sensor(0x80,0x5b);
    write_cmos_sensor(0x83,0x7f);
    write_cmos_sensor(0x84,0x89);
    write_cmos_sensor(0x88,0xd3);
    write_cmos_sensor(0x89,0xe8);
    write_cmos_sensor(0xa2,0x02);
    
    
    


    //L99 LENS
    write_cmos_sensor(0x62,0x00);
    write_cmos_sensor(0x63,0x00);
    write_cmos_sensor(0x64,0x06);
    write_cmos_sensor(0x65,0x00);
    write_cmos_sensor(0x66,0x05);
    write_cmos_sensor(0x94,0x05);
    //write_cmos_sensor(0x95,0x0D); //OVT joe 12/14/2006
    write_cmos_sensor(0x95,0x09);	//OVT joe 12/14/2006
    //write_cmos_sensor(0x95,0x0a);	//OVT joe 12/14/2006
    //camera_para_to_sensor();    // switch to preview mode key setting
	normal_gain=read_cmos_sensor(0x00);
	sensor_gain_base=read_OV76X0_gain();

	return 1;
}	/* init_cmos_sensor() */

/*************************************************************************
* FUNCTION
*	power_off_OV76X0
*
* DESCRIPTION
*	This function is to turn off sensor module power.
*
* PARAMETERS
*	None
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/

void power_off_OV76X0(void)
{
	cis_module_power_on(KAL_FALSE);      // Power Off CIS Power
	UPLL_Disable(UPLL_OWNER_ISP);
	#ifndef HW_SCCB
	   SET_SCCB_CLK_LOW;
	   SET_SCCB_DATA_LOW;
	#endif
}	/* power_off_OV76X0 */

/*************************************************************************
* FUNCTION
*	get_OV76X0_id
*
* DESCRIPTION
*	This function return the sensor read/write id of SCCB interface.
*
* PARAMETERS
*	*sensor_write_id : address pointer of sensor write id
*  *sensor_read_id  : address pointer of sensor read id
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void get_OV76X0_id(kal_uint8 *sensor_write_id, kal_uint8 *sensor_read_id)
{
	*sensor_write_id=OV76X0_WRITE_ID;
	*sensor_read_id=OV76X0_READ_ID;
}	/* get_OV76X0_id */

/*************************************************************************
* FUNCTION
*	get_OV76X0_size
*
* DESCRIPTION
*	This function return the image width and height of image sensor.
*
* PARAMETERS
*	*sensor_width : address pointer of horizontal effect pixels of image sensor
*  *sensor_height : address pointer of vertical effect pixels of image sensor
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void get_OV76X0_size(kal_uint16 *sensor_width, kal_uint16 *sensor_height)
{
	*sensor_width=IMAGE_SENSOR_VGA_WIDTH;			/* pixel numbers actually used in one frame */
	*sensor_height=IMAGE_SENSOR_VGA_HEIGHT;		/* line numbers actually used in one frame */
}	/* get_OV76X0_size */

/*************************************************************************
* FUNCTION
*	get_OV76X0_period
*
* DESCRIPTION
*	This function return the image width and height of image sensor.
*
* PARAMETERS
*	*pixel_number : address pointer of pixel numbers in one period of HSYNC
*  *line_number : address pointer of line numbers in one period of VSYNC
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void get_OV76X0_period(kal_uint16 *pixel_number, kal_uint16 *line_number)
{
	*pixel_number=VGA_PERIOD_PIXEL_NUMS;		/* pixel numbers in one period of HSYNC */
	*line_number=VGA_PERIOD_LINE_NUMS;			/* line numbers in one period of VSYNC */
}	/* get_OV76X0_period */

void OV76X0_preview(image_sensor_exposure_window_struct *image_window, image_sensor_config_struct *sensor_config_data)
{
	volatile kal_uint32 temp_reg2=read_cmos_sensor(0x1E), temp_reg1=(temp_reg2&0x0F);
	kal_uint16 current_shutter;
	
	sensor_cap_state=KAL_FALSE;

	g_bMJPEG_mode = KAL_FALSE;

	//write_cmos_sensor(0x11 ,0x01);
	write_cmos_sensor(0x11,0x81);	//MCLK = PCLK
	
	if((sensor_config_data->isp_op_mode==ISP_MJPEG_PREVIEW_MODE)||
		(sensor_config_data->isp_op_mode==ISP_MJPEG_ENCODE_MODE))
	{
		kal_prompt_trace(MOD_MMI,"video preview");

			MPEG4_encode_mode=KAL_FALSE;
			g_bMJPEG_mode = KAL_TRUE;

			/* config TG of ISP to match the setting of image sensor*/
			SET_TG_OUTPUT_CLK_DIVIDER(3);			//10fps
			SET_CMOS_RISING_EDGE(0);
			SET_CMOS_FALLING_EDGE(2);
			ENABLE_CAMERA_PIXEL_CLKIN_ENABLE;
			SET_TG_PIXEL_CLK_DIVIDER(3);
			SET_CMOS_DATA_LATCH(2);
			dummy_pixels=0;
	      dummy_lines=255;		

//			SET_TG_OUTPUT_CLK_DIVIDER(7);			//7.5fps
//			SET_CMOS_RISING_EDGE(0);
//			SET_CMOS_FALLING_EDGE(3);
//			ENABLE_CAMERA_PIXEL_CLKIN_ENABLE;
//			SET_TG_PIXEL_CLK_DIVIDER(7);
//			SET_CMOS_DATA_LATCH(3);
	}
	else
	{
	    if(sensor_config_data->frame_rate==0x0F)		// MPEG4 Encode Mode
	    {
	    
		kal_prompt_trace(MOD_MMI,"preview 2");
		    MPEG4_encode_mode=KAL_TRUE;
		
		    /* config TG of ISP to match the setting of image sensor*/
		    SET_TG_OUTPUT_CLK_DIVIDER(3);
	    	SET_CMOS_RISING_EDGE(0);
    		SET_CMOS_FALLING_EDGE(2);
		    ENABLE_CAMERA_PIXEL_CLKIN_ENABLE;
	    	SET_TG_PIXEL_CLK_DIVIDER(3);
    		SET_CMOS_DATA_LATCH(2);

    		dummy_pixels=0;
		    dummy_lines=20;
	    }
	    else
	    {
	    
		kal_prompt_trace(MOD_MMI,"preview");
		    MPEG4_encode_mode=KAL_FALSE;
			
		    /* config TG of ISP to match the setting of image sensor*/
		    SET_TG_OUTPUT_CLK_DIVIDER(1);			//30fps  //SET_TG_OUTPUT_CLK_DIVIDER(1);wyw modified  1012
		    SET_CMOS_RISING_EDGE(0);
		    SET_CMOS_FALLING_EDGE(1);
		    ENABLE_CAMERA_PIXEL_CLKIN_ENABLE;
		    SET_TG_PIXEL_CLK_DIVIDER(1);
		    SET_CMOS_DATA_LATCH(1);
		
            dummy_pixels=0;
            dummy_lines=0;
	    }
    }

	preview_pclk_division=((DRV_Reg32(ISP_TG_PHASE_COUNTER_REG)&0xF0)>>4)+1;

	switch (sensor_config_data->image_mirror)
	{
		case IMAGE_NORMAL:
		    SET_CAMERA_INPUT_ORDER(INPUT_ORDER_CbYCrY1);
			//while(temp_reg2 != (0x00|temp_reg1))
			{if(sensor_id2==BF3403_SENSOR_ID)
				{write_cmos_sensor(0x1E,(0x30|temp_reg1)); //wyw modified  1013,write_cmos_sensor(0x1E,(0x00|temp_reg1));
				temp_reg2=(0x00|temp_reg1);//wyw modified  1013,read_cmos_sensor(0x1E);
				}
			else
				{write_cmos_sensor(0x1E,(0x00|temp_reg1)); 
				temp_reg2=read_cmos_sensor(0x1E);
				}
			};
		break;
		case IMAGE_H_MIRROR:
		    SET_CAMERA_INPUT_ORDER(INPUT_ORDER_CbYCrY1);		
			//while(temp_reg2 != (0x20|temp_reg1))
			{
				write_cmos_sensor(0x1E,(0x20|temp_reg1));
				temp_reg2=read_cmos_sensor(0x1E);
			};
		break;
		case IMAGE_V_MIRROR:
		    SET_CAMERA_INPUT_ORDER(INPUT_ORDER_CbYCrY1);		
			//while(temp_reg2 != (0x10|temp_reg1))
			{
				write_cmos_sensor(0x1E,(0x10|temp_reg1));
				temp_reg2=read_cmos_sensor(0x1E);
			};
		break;
		case IMAGE_HV_MIRROR:
		    SET_CAMERA_INPUT_ORDER(INPUT_ORDER_CbYCrY1);		
			//while(temp_reg2 != (0x30|temp_reg1))
			{if(sensor_id2==BF3403_SENSOR_ID)                                                                                                                                                                                                                                                                                                                                                                                                                  
				{write_cmos_sensor(0x1E,(0x00|temp_reg1)); //wyw modified  1013,write_cmos_sensor(0x1E,(0x00|temp_reg1));                                                                                                                                                                                                                                                                                                                                         
				temp_reg2=(0x00|temp_reg1);//wyw modified  1013,read_cmos_sensor(0x1E);                                                                                                                                                                                                                                                                                                                                                                           
				write_cmos_sensor(0xf0,0x01);
				write_cmos_sensor(0xe0,0x0E);
				write_cmos_sensor(0x1f,0x10);
				write_cmos_sensor(0x22,0x10);
				write_cmos_sensor(0x33,0x80);
				write_cmos_sensor(0x34,0x88);
				write_cmos_sensor(0x35,0x20);
				write_cmos_sensor(0x3F,0xA0);
				write_cmos_sensor(0x3f,0xc0);
				write_cmos_sensor(0x39,0xa0);
				write_cmos_sensor(0xf0,0x00);
				}                                                                                                                                                                                                                                                                                                                                                                                                                                                 
			else
				 {write_cmos_sensor(0x1E,(0x30|temp_reg1));
				 temp_reg2=read_cmos_sensor(0x1E);
				 }
			};
		break;
	}

	image_window->grab_start_x=IMAGE_SENSOR_VGA_INSERTED_PIXELS+start_grab_x_offset;
	image_window->grab_start_y=IMAGE_SENSOR_VGA_INSERTED_LINES+dummy_lines+start_grab_y_offset;
	image_window->exposure_window_width=IMAGE_SENSOR_VGA_WIDTH;
	image_window->exposure_window_height=IMAGE_SENSOR_VGA_HEIGHT;
	
	set_OV76X0_dummy(dummy_pixels,dummy_lines);
	write_OV76X0_shutter(exposure_lines);
	kal_sleep_task(30);
	

	if (sensor_config_data->isp_op_mode == ISP_MJPEG_ENCODE_MODE) {
		current_shutter=read_OV76X0_shutter();
		if (current_shutter < 510)
            current_shutter = 510;

		sensor_config_data->sensor_frame_rate = 10 * (48000000 / preview_pclk_division / 784 / current_shutter / 2); //1fps=10
	}else {
	    // ISP_MJPEG_ENCODE_MODE mode does not invok YUV setting API after preview function
	    // If turn on AEC/AGC/AWB in ISP_MJPEG_ENCODE_MODE mode, the AWB setting will be overwriten.
    	write_cmos_sensor(0x13, 0xF7);  // Turn ON AEC/AGC/AWB
	}

	kal_sleep_task(100);		
}	/* OV76X0_preview */

void OV76X0_capture(image_sensor_exposure_window_struct *image_window, image_sensor_config_struct *sensor_config_data)
{
    volatile kal_uint32 shutter=exposure_lines;
    kal_uint8 temp_reg;
	kal_uint32 tmp_shutter;
    
    sensor_cap_state=KAL_TRUE;
	
	//if(MPEG4_encode_mode)
	   // ASSERT(0);                           //modified by wyw
	
	if(sensor_config_data->enable_shutter_tansfer==KAL_TRUE)
		shutter=sensor_config_data->capture_shutter;
		
	#ifdef OUTPUT_DEBUG_INFO
	sprintf(temp_buffer, "Begin of OV76X0_capture");
	rmmi_write_to_uart((kal_uint8*) temp_buffer, strlen(temp_buffer), KAL_TRUE);
	sprintf(temp_buffer, "cap_shutter:%d, pre_shut:%d", shutter, exposure_lines);
	rmmi_write_to_uart((kal_uint8*) temp_buffer, strlen(temp_buffer), KAL_TRUE);
	#endif

    if(!(sensor_config_data->frame_rate==0xF0))	// If not WEBCAM mode.
    {
		kal_prompt_trace(MOD_MMI,"Not WEBCAM MODE");  

	// turn off night mode
        temp_reg=read_cmos_sensor(0x3B);
        write_cmos_sensor(0x3B,temp_reg&~0x80);

        write_cmos_sensor(0x13,0xE2);  // Turn OFF AEC/AGC/AWB wyw modified 1012,解决婆恼毡淅段侍

⌨️ 快捷键说明

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