#ifndef _OV5642CFG_H
#define _OV5642CFG_H

//ʼĴмӦֵ
unsigned char ov5642_init_reg_tbl[][3]=
{   
		 //15fps VGA YUV output  // 24MHz input clock, 24MHz PCLK
		{0x31,0x03,0x11},// system clock from pad, bit[1]
		{0x30,0x08,0x82},// software reset, bit[7]// delay 5ms
		{0x30,0x08,0x42},// software power down, bit[6]
		{0x31,0x03,0x03},// system clock from PLL, bit[1]
		{0x30,0x17,0xff},// FREX, Vsync, HREF, PCLK, D[9:6] output enable
		{0x30,0x18,0xff},// D[5:0], GPIO[1:0] output enable
		{0x30,0x34,0x1A},// MIPI 10-bit
		{0x30,0x37,0x13},// PLL root divider, bit[4], PLL pre-divider, bit[3:0]
		{0x31,0x08,0x01},// PCLK root divider, bit[5:4], SCLK2x root divider, bit[3:2] // SCLK root divider, bit[1:0]
		{0x36,0x30,0x36},
		{0x36,0x31,0x0e},
		{0x36,0x32,0xe2},
		{0x36,0x33,0x12},
		{0x36,0x21,0xe0},
		{0x37,0x04,0xa0},
		{0x37,0x03,0x5a},
		{0x37,0x15,0x78},
		{0x37,0x17,0x01},
		{0x37,0x0b,0x60},
		{0x37,0x05,0x1a},
		{0x39,0x05,0x02},
		{0x39,0x06,0x10},
		{0x39,0x01,0x0a},
		{0x37,0x31,0x12},
		{0x36,0x00,0x08},// VCM control
		{0x36,0x01,0x33},// VCM control
		{0x30,0x2d,0x60},// system control
		{0x36,0x20,0x52},
		{0x37,0x1b,0x20},
		{0x47,0x1c,0x50},
		{0x3a,0x13,0x43},// pre-gain = 1.047x
		{0x3a,0x18,0x00},// gain ceiling
		{0x3a,0x19,0xf8},// gain ceiling = 15.5x
		{0x36,0x35,0x13},
		{0x36,0x36,0x03},
		{0x36,0x34,0x40},
		{0x36,0x22,0x01}, // 50/60Hz detection     50/60Hz ƹƹ
		{0x3c,0x01,0x34},// Band auto, bit[7]
		{0x3c,0x04,0x28},// threshold low sum
		{0x3c,0x05,0x98},// threshold high sum
		{0x3c,0x06,0x00},// light meter 1 threshold[15:8]
		{0x3c,0x07,0x08},// light meter 1 threshold[7:0]
		{0x3c,0x08,0x00},// light meter 2 threshold[15:8]
		{0x3c,0x09,0x1c},// light meter 2 threshold[7:0]
		{0x3c,0x0a,0x9c},// sample number[15:8]
		{0x3c,0x0b,0x40},// sample number[7:0]
		{0x38,0x10,0x00},// Timing Hoffset[11:8]
		{0x38,0x11,0x10},// Timing Hoffset[7:0]
		{0x38,0x12,0x00},// Timing Voffset[10:8]
		{0x37,0x08,0x64},
		{0x40,0x01,0x02},// BLC start from line 2
		{0x40,0x05,0x1a},// BLC always update
		{0x30,0x00,0x00},// enable blocks
		{0x30,0x04,0xff},// enable clocks
		{0x30,0x0e,0x58},// MIPI power down, DVP enable
		{0x30,0x2e,0x00},
		{0x43,0x00,0x60},// RGB565
		{0x50,0x1f,0x01},// ISP RGB
		{0x44,0x0e,0x00},
		{0x50,0x00,0xa7}, // Lenc on, raw gamma on, BPC on, WPC on, CIP on // AEC target    Զع
		{0x3a,0x0f,0x30},// stable range in high
		{0x3a,0x10,0x28},// stable range in low
		{0x3a,0x1b,0x30},// stable range out high
		{0x3a,0x1e,0x26},// stable range out low
		{0x3a,0x11,0x60},// fast zone high
		{0x3a,0x1f,0x14},// fast zone low// Lens correction for ?   ͷ
		{0x58,0x00,0x23},
		{0x58,0x01,0x14},
		{0x58,0x02,0x0f},
		{0x58,0x03,0x0f},
		{0x58,0x04,0x12},
		{0x58,0x05,0x26},
		{0x58,0x06,0x0c},
		{0x58,0x07,0x08},
		{0x58,0x08,0x05},
		{0x58,0x09,0x05},
		{0x58,0x0a,0x08},
		{0x58,0x0b,0x0d},
		{0x58,0x0c,0x08},
		{0x58,0x0d,0x03},
		{0x58,0x0e,0x00},
		{0x58,0x0f,0x00},
		{0x58,0x10,0x03},
		{0x58,0x11,0x09},
		{0x58,0x12,0x07},
		{0x58,0x13,0x03},
		{0x58,0x14,0x00},
		{0x58,0x15,0x01},
		{0x58,0x16,0x03},
		{0x58,0x17,0x08},
		{0x58,0x18,0x0d},
		{0x58,0x19,0x08},
		{0x58,0x1a,0x05},
		{0x58,0x1b,0x06},
		{0x58,0x1c,0x08},
		{0x58,0x1d,0x0e},
		{0x58,0x1e,0x29},
		{0x58,0x1f,0x17},
		{0x58,0x20,0x11},
		{0x58,0x21,0x11},
		{0x58,0x22,0x15},
		{0x58,0x23,0x28},
		{0x58,0x24,0x46},
		{0x58,0x25,0x26},
		{0x58,0x26,0x08},
		{0x58,0x27,0x26},
		{0x58,0x28,0x64},
		{0x58,0x29,0x26},
		{0x58,0x2a,0x24},
		{0x58,0x2b,0x22},
		{0x58,0x2c,0x24},
		{0x58,0x2d,0x24},
		{0x58,0x2e,0x06},
		{0x58,0x2f,0x22},
		{0x58,0x30,0x40},
		{0x58,0x31,0x42},
		{0x58,0x32,0x24},
		{0x58,0x33,0x26},
		{0x58,0x34,0x24},
		{0x58,0x35,0x22},
		{0x58,0x36,0x22},
		{0x58,0x37,0x26},
		{0x58,0x38,0x44},
		{0x58,0x39,0x24},
		{0x58,0x3a,0x26},
		{0x58,0x3b,0x28},
		{0x58,0x3c,0x42},
		{0x58,0x3d,0xce},// lenc BR offset // AWB   Զƽ
		{0x51,0x80,0xff},// AWB B block
		{0x51,0x81,0xf2},// AWB control
		{0x51,0x82,0x00},// [7:4] max local counter, [3:0] max fast counter
		{0x51,0x83,0x14},// AWB advanced
		{0x51,0x84,0x25},
		{0x51,0x85,0x24},
		{0x51,0x86,0x09},
		{0x51,0x87,0x09},
		{0x51,0x88,0x09},
		{0x51,0x89,0x75},
		{0x51,0x8a,0x54},
		{0x51,0x8b,0xe0},
		{0x51,0x8c,0xb2},
		{0x51,0x8d,0x42},
		{0x51,0x8e,0x3d},
		{0x51,0x8f,0x56},
		{0x51,0x90,0x46},
		{0x51,0x91,0xf8},// AWB top limit
		{0x51,0x92,0x04},// AWB bottom limit
		{0x51,0x93,0x70},// red limit
		{0x51,0x94,0xf0},// green limit
		{0x51,0x95,0xf0},// blue limit
		{0x51,0x96,0x03},// AWB control
		{0x51,0x97,0x01},// local limit
		{0x51,0x98,0x04},
		{0x51,0x99,0x12},
		{0x51,0x9a,0x04},
		{0x51,0x9b,0x00},
		{0x51,0x9c,0x06},
		{0x51,0x9d,0x82},
		{0x51,0x9e,0x38},// AWB control // Gamma    ٤
		{0x54,0x80,0x01},// Gamma bias plus on, bit[0]
		{0x54,0x81,0x08},
		{0x54,0x82,0x14},
		{0x54,0x83,0x28},
		{0x54,0x84,0x51},
		{0x54,0x85,0x65},
		{0x54,0x86,0x71},
		{0x54,0x87,0x7d},
		{0x54,0x88,0x87},
		{0x54,0x89,0x91},
		{0x54,0x8a,0x9a},
		{0x54,0x8b,0xaa},
		{0x54,0x8c,0xb8},
		{0x54,0x8d,0xcd},
		{0x54,0x8e,0xdd},
		{0x54,0x8f,0xea},
		{0x54,0x90,0x1d},// color matrix   ɫʾ
		{0x53,0x81,0x1e},// CMX1 for Y
		{0x53,0x82,0x5b},// CMX2 for Y
		{0x53,0x83,0x08},// CMX3 for Y
		{0x53,0x84,0x0a},// CMX4 for U
		{0x53,0x85,0x7e},// CMX5 for U
		{0x53,0x86,0x88},// CMX6 for U
		{0x53,0x87,0x7c},// CMX7 for V
		{0x53,0x88,0x6c},// CMX8 for V
		{0x53,0x89,0x10},// CMX9 for V
		{0x53,0x8a,0x01},// sign[9]
		{0x53,0x8b,0x98}, // sign[8:1] // UV adjust   UVɫʱͶȵ
		{0x55,0x80,0x06},// saturation on, bit[1]
		{0x55,0x83,0x40},
		{0x55,0x84,0x10},
		{0x55,0x89,0x10},
		{0x55,0x8a,0x00},
		{0x55,0x8b,0xf8},
		{0x50,0x1d,0x40},// enable manual offset of contrast// CIP  񻯺ͽ
		{0x53,0x00,0x08},// CIP sharpen MT threshold 1
		{0x53,0x01,0x30},// CIP sharpen MT threshold 2
		{0x53,0x02,0x10},// CIP sharpen MT offset 1
		{0x53,0x03,0x00},// CIP sharpen MT offset 2
		{0x53,0x04,0x08},// CIP DNS threshold 1
		{0x53,0x05,0x30},// CIP DNS threshold 2
		{0x53,0x06,0x08},// CIP DNS offset 1
		{0x53,0x07,0x16},// CIP DNS offset 2
		{0x53,0x09,0x08},// CIP sharpen TH threshold 1
		{0x53,0x0a,0x30},// CIP sharpen TH threshold 2
		{0x53,0x0b,0x04},// CIP sharpen TH offset 1
		{0x53,0x0c,0x06},// CIP sharpen TH offset 2
		{0x50,0x25,0x00},
		{0x30,0x08,0x02}, // wake up from standby, bit[6]
		//640x480 30֡/, night mode 5fps, input clock =24Mhz, PCLK =56Mhz
		{0x30,0x35,0x11},// PLL
		{0x30,0x36,0x46},// PLL
		{0x3c,0x07,0x08},// light meter 1 threshold [7:0]
		{0x38,0x20,0x43},// Sensor flip off, ISP flip on
		{0x38,0x21,0x04},// Sensor mirror on, ISP mirror on, H binning on
		{0x38,0x14,0x31},// X INC
		{0x38,0x15,0x31},// Y INC
		{0x38,0x00,0x00},// HS: X address start high byte
		{0x38,0x01,0x00},// HS: X address start low byte
		{0x38,0x02,0x00},// VS: Y address start high byte
		{0x38,0x03,0x04},// VS: Y address start high byte
		{0x38,0x04,0x0a},// HW (HE)
		{0x38,0x05,0x3f},// HW (HE)
		{0x38,0x06,0x07},// VH (VE)
		{0x38,0x07,0x9b},// VH (VE)
		{0x38,0x08,0x03},// DVPHO           //800
		{0x38,0x09,0x20},// DVPHO
		{0x38,0x0a,0x01},// DVPVO           //480
		{0x38,0x0b,0xe0},// DVPVO
		{0x38,0x0c,0x07},// HTS            //Total horizontal size
		{0x38,0x0d,0x68},// HTS
		{0x38,0x0e,0x03},// VTS            //total vertical size
		{0x38,0x0f,0xd8},// VTS
		{0x38,0x13,0x06},// Timing Voffset
		{0x36,0x18,0x00},
		{0x36,0x12,0x29},
		{0x37,0x09,0x52},
		{0x37,0x0c,0x03},
		{0x3a,0x02,0x17},// 60Hz max exposure, night mode 5fps
		{0x3a,0x03,0x10},// 60Hz max exposure // banding filters are calculated automatically in camera driver
		{0x3a,0x14,0x17},// 50Hz max exposure, night mode 5fps
		{0x3a,0x15,0x10},// 50Hz max exposure
		{0x40,0x04,0x02},// BLC 2 lines
		{0x30,0x02,0x1c},// reset JFIFO, SFIFO, JPEG
		{0x30,0x06,0xc3},// disable clock of JPEG2x, JPEG
		{0x47,0x13,0x03},// JPEG mode 3
		{0x44,0x07,0x04},// Quantization scale
		{0x46,0x0b,0x35},
		{0x46,0x0c,0x22},
		{0x48,0x37,0x22}, // DVP CLK divider
		{0x38,0x24,0x02}, // DVP CLK divider
		{0x50,0x01,0xa3}, // SDE on, scale on, UV average off, color matrix on, AWB on
		{0x35,0x03,0x00}, // AEC/AGC on
		{0x30,0x16,0x02}, //Strobe output enable
		{0x3b,0x07,0x0a}, //FREX strobe mode1

		 //strobe flash and frame exposure
		{0x3b,0x00,0x83},              //STROBE CTRL: strobe request ON, Strobe mode: LED3
		{0x3b,0x00,0x00},              //STROBE CTRL: strobe request OFF
//
//		{0x50,0x3d, 0x82},
//		{0x47,0x41, 0x00},


}; 

#endif

