📄 ov2640.c
字号:
/*****************************************************************************
*
* Filename:
* ---------
* Ov2640.c
*
* Project:
* --------
* Maui_sw
*
* Description:
* ------------
* Image sensor driver function
*
****************************************************************************/
#include "drv_comm.h"
#include "IntrCtrl.h"
#include "reg_base.h"
#include "gpio_sw.h"
#include "sccb.h"
#include "isp_if.h"
#include "ov2640.h"
#include "camera_para.h"
#include "upll_ctrl.h"
#include "med_api.h"
static kal_uint8 start_grab_x_offset = 0, start_grab_y_offset = 0;
static kal_bool gVGAmode = KAL_TRUE, sensor_night_mode = KAL_FALSE, MPEG4_encode_mode = KAL_FALSE, g_bMJPEG_mode = KAL_FALSE;
static kal_uint8 normal_gain = 0, night_gain = SENSOR_NIGHT_MODE_GAIN_OV2640;
static kal_uint8 preview_pclk_division = 0, capture_pclk_division = 0;
static kal_uint16 dummy_pixels = 0, dummy_lines = 0, extra_exposure_lines = 0;
static kal_uint16 exposure_lines = 0;
static kal_uint16 sensor_global_gain = BASEGAIN, sensor_gain_base = 0x0;
/* Debug Message, Don't Care */
static kal_uint16 sensor_frame_rate;
/* Parameter For Engineer mode function */
static kal_uint32 FAC_SENSOR_REG;
/* Image Sensor ID */
static kal_uint16 sensor_id = 0;
extern kal_uint8 Camera_name;
static kal_bool sensor_cap_state = KAL_FALSE;
extern kal_uint8 jpeg_capture_flag;
/*****************************************************************************
* FUNCTION
* write_OV2640_shutter
* DESCRIPTION
*
* PARAMETERS
* shutter [IN]
* RETURNS
* void
*****************************************************************************/
void write_OV2640_shutter(kal_uint16 shutter)
{
}
/*****************************************************************************
* FUNCTION
* read_OV2640_shutter
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
*
*****************************************************************************/
kal_uint16 read_OV2640_shutter(void)
{
}
/*****************************************************************************
* FUNCTION
* write_OV2640_gain
* DESCRIPTION
*
* PARAMETERS
* gain [IN]
* RETURNS
* void
*****************************************************************************/
void write_OV2640_gain(kal_uint16 gain)
{
}
/*****************************************************************************
* FUNCTION
* read_OV2640_gain
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
*
*****************************************************************************/
kal_uint16 read_OV2640_gain(void)
{
}
/*****************************************************************************
* FUNCTION
* set_OV2640_dummy
* DESCRIPTION
*
* PARAMETERS
* pixels [IN]
* lines [IN]
* RETURNS
* void
*****************************************************************************/
void set_OV2640_dummy(kal_uint16 pixels, kal_uint16 lines)
{
// kal_uint16 temp;
/*
temp = read_cmos_sensor(0x2A);
pixels += ((0xB0 & 0x70) << 4) | 0x0B;
write_cmos_sensor(0x2B, pixels & 0xFF);
write_cmos_sensor(0x2C, lines & 0xFF);
write_cmos_sensor(0x2A, ((pixels >> 4) & 0x70) | ((lines >> 8) & 0x0F) | (temp & 0x80));
*/
}
const kal_int8 OV2640_Preview[][2]=
{
{0xff, 0x01},
{0x12, 0x80},
{0xff, 0x00},
{0x2c, 0xff},
{0x2e, 0xdf},
{0xff, 0x01},
{0x3c, 0x32},
{0x2b, 0x4e},
{0x12, 0x00},
{0x11, 0x00},
{0x17, 0x11},
{0x18, 0x75},
{0x19, 0x01},
{0x1a, 0x97},
{0x32, 0x36},
{0x11, 0x00},
{0x09, 0x02},
{0x04, 0x28},
{0x13, 0xe5},
{0x14, 0x28},
{0x2c, 0x0c},
{0x33, 0x78},
{0x3a, 0x33},
{0x3b, 0xfB},
{0x3e, 0x00},
{0x43, 0x11},
{0x16, 0x10},
{0x39, 0x82},
{0x35, 0x88},
{0x22, 0x09},
{0x37, 0x40},
{0x23, 0x00},
{0x34, 0xa0},
{0x36, 0x1a},
{0x06, 0x02},
{0x07, 0xc0},
{0x0d, 0xb7},
{0x0e, 0x01},
{0x4c, 0x00},
{0x4a, 0x81},
{0x21, 0x99},
{0x24, 0x40},
{0x25, 0x38},
{0x26, 0x82},
{0x5c, 0x00},
{0x63, 0x00},
{0x46, 0x3f},
{0x0c, 0x3c},
{0x61, 0x70},
{0x62, 0x80},
{0x7c, 0x05},
{0x20, 0x80},
{0x28, 0x30},
{0x6c, 0x00},
{0x6d, 0x80},
{0x6e, 0x00},
{0x70, 0x02},
{0x71, 0x94},
{0x73, 0xc1},
{0x3d, 0x34},
{0x5a, 0x57},
{0x4f, 0xb4},
{0x50, 0x94},
{0xff, 0x00},
{0xe5, 0x7f},
{0xf9, 0xc0},
{0x41, 0x24},
{0xe0, 0x14},
{0x76, 0xff},
{0x33, 0xa0},
{0x42, 0x20},
{0x43, 0x18},
{0x4c, 0x00},
{0x87, 0xd0},
{0x88, 0x3f},
{0xd7, 0x03},
{0xd9, 0x10},
{0xd3, 0x82},
{0xc8, 0x08},
{0xc9, 0x80},
{0x7c, 0x00},
{0x7d, 0x00},
{0x7c, 0x03},
{0x7d, 0x40},
{0x7d, 0x40},
{0x7c, 0x08},
{0x7d, 0x20},
{0x7d, 0x10},
{0x7d, 0x0e},
{0x96, 0x00},
{0x97, 0x0C},
{0x97, 0x13},
{0x97, 0x04},
{0x97, 0x0d},
{0x97, 0x27},
{0x97, 0x34},
{0x97, 0x31},
{0x97, 0x30},
{0x97, 0x01},
{0x97, 0x98},
{0x97, 0x80},
{0x97, 0x00},
{0x97, 0x00},
{0xff, 0x00},
{0xc3, 0xef},
{0xa6, 0x00},
{0xa7, 0xbc},
{0xa7, 0x58},
{0xa7, 0x78},
{0xa7, 0x23},
{0xa7, 0x00},
{0xa7, 0x23},
{0xa7, 0xbc},
{0xa7, 0x6c},
{0xa7, 0x6b},
{0xa7, 0x23},
{0xa7, 0x00},
{0xa7, 0x23},
{0xa7, 0x8a},
{0xa7, 0x58},
{0xa7, 0x63},
{0xa7, 0x23},
{0xa7, 0x00},
{0xa7, 0x23},
{0xff, 0x00},
{0xba, 0xdc},
{0xbb, 0x08},
{0xb6, 0x1b},
{0xb8, 0x2b},
{0xb7, 0x20},
{0xb9, 0x30},
{0xb3, 0x9d},
{0xb4, 0xca},
{0xb5, 0x34},
{0xb0, 0x46},
{0xb1, 0x3c},
{0xb2, 0x06},
{0xc7, 0x00},
{0xc6, 0x51},
{0xc5, 0x11},
{0xc4, 0x9c},
{0xbf, 0x00},
{0x92, 0x00},
{0x93, 0x06},
{0x93, 0xe3},
{0x93, 0x05},
{0x93, 0x05},
{0x93, 0x02},
{0x93, 0x04},
{0x93, 0x00},
{0x93, 0x00},
{0x93, 0x00},
{0x93, 0x00},
{0x93, 0x00},
{0x93, 0x00},
{0x93, 0x00},
{0x90, 0x00},
{0x91, 0x0f},
{0x91, 0x1e},
{0x91, 0x3a},
{0x91, 0x62},
{0x91, 0x74},
{0x91, 0x82},
{0x91, 0x8e},
{0x91, 0x98},
{0x91, 0xa0},
{0x91, 0xa7},
{0x91, 0xb5},
{0x91, 0xc0},
{0x91, 0xd2},
{0x91, 0xe1},
{0x91, 0xed},
{0x91, 0x19},
{0xff, 0x01},
{0x5c, 0x00},
{0x63, 0x00},
{0x7c, 0x00},
{0xff, 0x01},
{0x24, 0x48},
{0x25, 0x40},
{0x26, 0x81},
{0x5d, 0x55},
{0x5e, 0x7d},
{0x5f, 0x7d},
{0x60, 0x55},
{0x22, 0x0a},
{0xff, 0x00},
{0x7f, 0x00},
{0xda, 0x01},
{0xe5, 0x1f},
{0xe1, 0x67},
{0xe0, 0x00},
{0xdd, 0xef},
{0x05, 0x00},
{0xc2, 0x0c},
{0xda, 0x01},
{0xff, 0x00},
{0xe0, 0x04},
{0xc0, 0xc8},
{0xc1, 0x96},
{0x86, 0x3d},
{0x50, 0x89},
{0x51, 0x90},
{0x52, 0x2c},
{0x53, 0x00},
{0x54, 0x00},
{0x55, 0x88},
{0x57, 0x00},
{0x5a, 0xa0},
{0x5b, 0x78},
{0x5c, 0x00},
{0xd3, 0x04},
{0xe0, 0x00}
};
const kal_int8 OV2640_Capture_1M[][2]=
{
{0xff, 0x01},
{0x12, 0x00},
{0x17, 0x11},
{0x18, 0x75},
{0x32, 0x36},
{0x19, 0x01},
{0x1a, 0x97},
{0x03, 0x0f},
{0x4f, 0xb4},
{0x50, 0x9c},
{0x5a, 0x57},
{0x6d, 0x80},
{0x3d, 0x34},
{0x39, 0x02},
{0x35, 0x88},
{0x22, 0x0a},
{0x37, 0x40},
{0x23, 0x00},
{0x34, 0xa0},
{0x36, 0x1a},
{0x06, 0x02},
{0x07, 0xc0},
{0x0d, 0xb7},
{0x0e, 0x01},
{0x4c, 0x00},
{0xff, 0x00},
{0x87, 0xd0},
{0xc0, 0xc8},
{0xc1, 0x96},
{0x86, 0x1d},
{0x05,0x00},
{0xDA,0x10},
{0xD7,0x03},
{0xDF,0x00},
{0x33,0x80},
{0x3c,0x40},
{0xe1,0x77},
{0xD3,0x04},
{0x44,0x05},
{0xff, 0x00},
{0xe0, 0x04},
{0xc0, 0xc8},
{0xc1, 0x96},
{0x8c, 0x00},
{0x86, 0x3d},
{0x50, 0x00},
{0x51, 0x90},
{0x52, 0x2c},
{0x53, 0x00},
{0x54, 0x00},
{0x55, 0x88},
{0x57, 0x00},
{0x5a, 0x40},
{0x5b, 0xf0},
{0x5c, 0x01},
{0xd3, 0x04},
{0xe0, 0x00},
{0xff, 0x00},
{0xe0, 0x14},
{0xe1, 0x77},
{0xe5, 0x1f},
{0xd7, 0x03},
{0xda, 0x10},
{0xd9, 0x10},
{0x33, 0x80},
{0x3c, 0x10},
{0xd3, 0x04},
{0xeb, 0x30},
{0xdd, 0xef},
{0xe0, 0x00},
{0xff, 0x01},
{0x13, 0xe0},
{0x3d, 0x38},
{0x11, 0x01},
{0xff, 0x00},
{0xd3, 0x04},
{0x44, 0x04}
};
const kal_int8 OV2640_Capture_2M[][2]=
{
{0xff, 0x01},
{0x12, 0x00},
{0x17, 0x11},
{0x18, 0x75},
{0x32, 0x36},
{0x19, 0x01},
{0x1a, 0x97},
{0x03, 0x0f},
{0x4f, 0xb4},
{0x50, 0x9c},
{0x5a, 0x57},
{0x6d, 0x80},
{0x3d, 0x34},
{0x39, 0x02},
{0x35, 0x88},
{0x22, 0x0a},
{0x37, 0x40},
{0x23, 0x00},
{0x34, 0xa0},
{0x36, 0x1a},
{0x06, 0x02},
{0x07, 0xc0},
{0x0d, 0xb7},
{0x0e, 0x01},
{0x4c, 0x00},
{0xff, 0x00},
{0x87, 0xd0},
{0xc0, 0xc8},
{0xc1, 0x96},
{0x86, 0x1d},
{0x05,0x00},
{0xDA,0x10},
{0xD7,0x03},
{0xDF,0x00},
{0x33,0x80},
{0x3c,0x40},
{0xe1,0x77},
{0xD3,0x04},
{0x44,0x05},
{0xff, 0x01},
{0x13, 0xe0},
{0x11, 0x01},
{0xff, 0x00},
{0xe0, 0x04},
{0xc0, 0xc8},
{0xc1, 0x96},
{0x8c, 0x00},
{0x86, 0x3d},
{0x50, 0x00},
{0x51, 0x90},
{0x52, 0x2c},
{0x53, 0x00},
{0x54, 0x00},
{0x55, 0x88},
{0x57, 0x00},
{0x5a, 0x90},
{0x5b, 0x2c},
{0x5c, 0x05},
{0xd3, 0x04},
{0xe0, 0x00},
{0xff, 0x00},
{0xe0, 0x14},
{0xe1, 0x77},
{0xe5, 0x1f},
{0xd7, 0x03},
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -