OV2650 Camera software Application NotesOV2650 Software Application Notes 1.5Document Revision: 1.5OmniVision Technologies, Inc. reserves the right to make changes without further notice to any product herein to improve reliability, function or design. OmniVision does not assume any liability arising out of the application or use of any project, circuit described herein; neither does it convey any license under its patent nor the right of others.This document contains information of a proprietary nature. None of this information shall be divulged to persons other than OmniVision Technologies, Inc. employee authorized by the nature of their duties to receive such information, or individuals or organizations authorized by OmniVision Technologies, Inc.1 OVT ConfidLast Modified: Apri. 16th, 2008entialCompany ConfidentialOV2650 Camera software Application NotesTable of ContentsOV2650 Software Application Notes 1.5.............................................................................................11. How to Select Output format?.....................................................................................................41.1 Back-end with full ISP..........................................................................................................41.2 Back-end with YCbCr ISP....................................................................................................51.3 Back-end without ISP...........................................................................................................51.4 Equations to Convert from One Format to Another.............................................................52. How to Select Output Resolution?...............................................................................................62.1 back-end with ISP.................................................................................................................62.2 back-end without ISP............................................................................................................63. How to Adjust frame rate.............................................................................................................63.1 SVGA Preview, 30fps, 24Mhz input clock, 36Mhz PCLK..................................................63.2 SVGA Preview, 15fps, 24 Mhz input clock, 18Mhz PCLK.................................................73.3 UXGA Capture, 7.5fps, 24 Mhz input clock, 36 Mhz PCLK...............................................74. How to set Night Mode Preview..................................................................................................74.1 Night Mode with Fixed Frame Rate.....................................................................................74.2 Night Mode with Auto Frame Rate.......................................................................................84.3 Night Mode Off.....................................................................................................................85. How to Remove Light Band in Preview Mode..........................................................................105.1 Light Band...........................................................................................................................105.2 Remove Light band.............................................................................................................105.3 Select Banding Filter by Region Information.....................................................................105.4 Select Banding Filter by Automatic Light Frequency Detection........................................115.5 When Light Band can not be Removed..............................................................................126. White Balance............................................................................................................................126.1 Simple White Balance.........................................................................................................126.2 Advanced White Balance....................................................................................................136.3 How to select?.....................................................................................................................137. Defect Pixel Correction.............................................................................................................138. BLC............................................................................................................................................139. Video Mode...............................................................................................................................1410. Digital zoom............................................................................................................................1411. OV2650 Functions...................................................................................................................1411.1 Light Mode........................................................................................................................1411.2 Color Saturation................................................................................................................1511.3 Brightness..........................................................................................................................1511.4 Contrast.............................................................................................................................1611.5 Special effects...................................................................................................................1811.6 Exposure............................................................................................................................1911.7 Sharpness..........................................................................................................................2011.8 Mirror/Flip........................................................................................................................2111.9 YUV Sequence..................................................................................................................2111.10 Clock Polarity.................................................................................................................2212. Deal with Lens.........................................................................................................................22OVT Confid2 entialCompany ConfidentialOV2650 Camera software Application Notes12.1 Light fall off......................................................................................................................2212.2 Dark corner.......................................................................................................................2212.3 Resolution.........................................................................................................................2212.4 Optical contrast.................................................................................................................2212.5 Lens Cover........................................................................................................................2313. Reference Settings...................................................................................................................2313.1 YCbCr Reference Setting..................................................................................................2313.1.1 SVGA Preview..........................................................................................................2313.1.2 Other Preview Resolution DCW from SVGA..........................................................2813.1.3 UXGA Capture..........................................................................................................2913.1.4 Other Capture size DCW from UXGA ....................................................................3313.1.5 Transfer From SVGA to UXGA ..............................................................................3513.1.6 Transfer From UXGA to SVGA ..............................................................................3613.2 Format Transfer Reference Setting...................................................................................3614. Capture Sequence....................................................................................................................3714.1 Shutter...............................................................................................................................3714. 2 Dummy Lines...................................................................................................................3814.2.1 Extra Line..................................................................................................................3814.2.2 Dummy Line..............................................................................................................3814. 3 Dummy Pixels..................................................................................................................3914.4 Gain...................................................................................................................................3914.5 Banding Filter...................................................................................................................4014.5.1 Preview......................................................................................................................4014.5.2 Capture......................................................................................................................4014.6 Auto frame rate.................................................................................................................4014.7 Capture Sequence..............................................................................................................4014.7.1 Preview......................................................................................................................4014.7.2 Stop Preview..............................................................................................................4114.7.3 Calculate Capture Exposure......................................................................................4214.7.4 Switch to UXGA.......................................................................................................4314.7.5 Write Registers..........................................................................................................4314.7.6 Capture......................................................................................................................4514.7.7 Back to preview.........................................................................................................45OVT Confid3 entialCompany ConfidentialOV2650 Camera software Application NotesNOTE: OV2650 use 16bits Register address and 8bits Register data.1. How to Select Output format? OV2650 support 4 output format: YcbCr422,YUV422/420, RGB565/555, Raw RGB, CCIR656. How to choose the right output format for camera phone design or other applications? Let's look at the back-end chip first. The general diagram of back-end chip is as below:Camera InterfaceYCbCrRGBRaw RGBYUVX1.1 Back-end with full ISP This kind of back-end has full ISP. It takes raw RGB input, doing interpolation to generate RGB24 and doing translation to generate YCbCr. This kind of back-end could take Bayer raw RGB or processed raw RGB. The advantage of processed raw RGB over Bayer raw RGB is the output data are processed. Sensor functions such as defect pixel correction, gamma, color matrix, de-noise, sharpness, BLC etc. could be applied. Since the life time of back-end chip is longer than image sensor, sometimes back-end chips could not fix defects of new sensors if taken Bayer raw RGB. But the defects of new sensors could be fixed in processed raw RGB output. If back-end take Bayer raw RGB format from sensor, all the image process operations such as 4 OV The data format at LCD driver are always RGB. For example, RGB444, RGB565, RGB555, RGB888 etc. The data format and memory interface are always JPEG. The JPEG data is compressed from YCbCr data. So Both RGB and YCbCr data are needed inside the back-end chip. The “X” block is different for different back-end chips.T CMemory InterfaceonfidentialLCD DriverRGBJPEGCompany ConfidentialOV2650 Camera software Application Notesdefect pixel correction, lens correction, gamma, color matrix, de-noise, sharpness, BCL etc should be done by back-end. If back-end take processed raw RGB format from sensor, the image process operations such as defect pixel correction, lens correction, gamma, color matrix, de-noise, sharpness, BCL etc could be done either inside sensor or by back-end chips. In other words, user could select the image process operation be done by which side.1.2 Back-end with YCbCr ISP This kind of back-end has ISP, but could take only YCbCr format. The ISP could convert YCbCr to RGB format for LCD display and compress YCbCr to JPEG for storage. This kind of back-end doesn't have ISP built-in. It can not convert from one format to another by hardware. Actually the format conversion is done by software. There are 3 possible solution for this kind of back-end chips. a. Sensor output YCbCr. back-end chip convert YCbCr to RGB for display by software. b. Sensor output RGB565 . Back-end chip convert RGB565 to YCbCR for JPEG compression. c. Sensor output RGB565 for preview, output YCbCr for capture (JPEG compression). Solution a. provide the best picture quality. Since the input data is 24-bit RGB equivalent. It could converted to RGB888 for LCD display. Solution b. provide the worst picture quality. Since the input data is only 16-bit RGB565, even it is converted to YCbCr, the color depth is still 16-bit. The solution c. provide similar picture quality as solution a. But since preview is RGB565, capture is YCbCr, preview picture may looks a little different than captured picture.1.4 Equations to Convert from One Format to AnotherYCbCr to RGB24Y = 0.299R + 0.587G + 0.114BCb = 0.568(B-Y) + 128 = –0.172R – 0.339G + 0.511B + 128Cr = 0.713(R-Y) + 128 = 0.511R – 0.428G – 0.083B + 128Y = ((77 * R + 150 * G + 29 * B) >> 8);Cb = ((-43 * R - 85 * G + 128 * B) >> 8) + 128;Cr = ((128 * R - 107 * G - 21 * B) >> 8) + 128;RGB24 to YcbCr5 OVT Confidential1.3 Back-end without ISPCompany ConfidentialOV2650 Camera software Application NotesR = Y + 1.371(Cr – 128)G = Y – 0.698(Cr – 128) – 0.336(Cb – 128)B = Y + 1.732(Cb – 128) R = Y + (351*(Cr – 128)) >> 8G = Y – (179*(Cr – 128) + 86*(Cb – 128))>>8B = Y + (443*(Cb – 128)) >> 82. How to Select Output Resolution?2.1 back-end with ISP2.2 back-end without ISP3. How to Adjust frame rate The recommended frame rates are 30fps and 15fps preview for 60/50Hz light environment, the recommended frame rate for capture is 10/7.5fps for 60/50hz light environment. The frame rate for night mode is lower, we'll discuss night mode later. Reference settings for above frame rates are listed below.3.1 SVGA Preview, 30fps, 24Mhz input clock, 36Mhz PCLKi2c_salve_Address = 0x60;write_i2c(0x300e, 0x34);write_i2c(0x3011, 0x00);write_i2c(0x302c, 0x00);write_i2c(0x3071, 0x00);6 OV In this case, OV2650 output small resolution for preview, and several other resolution for capture. The resolution for capture may include: QQVGA, QVGA, QCIF, CIF, VGA, SVGA,SXGA,UXGA. For best quality, all capture size are all downscaled from UXGA.T C If back-end chip doesn't have image scale capability, then the LCD scaler of OV2650 must be used to scale output resolution exactly the LCD size. For example, if the LCD size is 176x220, then the LCD scaler will scale the output size to 176x220.onfid If back-end chip has built-in ISP (Full ISP or YCbCr ISP), the ISP could do image scale. So OV2650 outputs only SVGA format for preview and UXGA for capture. ISP scaled SVGA image to other resolution that mobile device needed for LCD display. And the ISP scaled UXGA image to other resolution that the mobile device needed for capture.entialCompany ConfidentialOV2650 Camera software Application Noteswrite_i2c(0x3070, 0xb9);//50Hz banding filterwrite_i2c(0x301c, 0x02);//banding stepwrite_i2c(0x3073, 0x00);//60Hz banding filterwrite_i2c(0x3072, 0x9a);write_i2c(0x301d, 0x03);3.2 SVGA Preview, 15fps, 24 Mhz input clock, 18Mhz PCLKi2c_salve_Address = 0x60;write_i2c(0x300e, 0x34);write_i2c(0x3011, 0x01);write_i2c(0x302c, 0x00);write_i2c(0x3071, 0x00);write_i2c(0x3070, 0x5d);write_i2c(0x301c, 0x05);write_i2c(0x3073, 0x00);write_i2c(0x3072, 0x4d);write_i2c(0x301d, 0x07);3.3 UXGA Capture, 7.5fps, 24 Mhz input clock, 36 Mhz PCLKi2c_salve_Address = 0x60;write_i2c(0x300e, 0x38);write_i2c(0x3011, 0x00);write_i2c(0x302c, 0x00);write_i2c(0x3071, 0x00);write_i2c(0x3070, 0x5d);write_i2c(0x301c, 0x0d);write_i2c(0x3073, 0x00);write_i2c(0x3072, 0x4e);write_i2c(0x301d, 0x0f); There are 2 types of settings for SVGA preview in night mode. One type is set to fixed low frame rate, for example 5fps. The other type is set to auto frame rate, for example from 30fps to 5fps. When environment is bright, the frame rate is increased to 30fps. When environment is dark, the frame rate is decreased to 5fps.4.1 Night Mode with Fixed Frame Rate5fps night mode for 60Hz light environment, 24Mhz clock input, 6Mhz pclki2c_salve_Address = 0x60;write_i2c(0x300e, 0x34);write_i2c(0x3011, 0x05);write_i2c(0x302c, 0x00);write_i2c(0x3071, 0x00);write_i2c(0x3070, 0x31);7 O4. How to set Night Mode PreviewVT ConfidCompany ConfidentialentialOV2650 Camera software Application Noteswrite_i2c(0x301c, 0x13);write_i2c(0x3073, 0x00);write_i2c(0x3072, 0x1a);write_i2c(0x301d, 0x17);4.2 Night Mode with Auto Frame Rate30fps ~ 5fps night mode for 60/50Hz light environment, 24Mhz clock input,36Mzh pclki2c_salve_Address = 0x60;write_i2c(0x300e, 0x34);write_i2c(0x3011, 0x00);write_i2c(0x302c, 0x00);write_i2c(0x3071, 0x00);write_i2c(0x3070, 0xb9);write_i2c(0x301c, 0x02);write_i2c(0x3073, 0x00);write_i2c(0x3072, 0x9a);write_i2c(0x301d, 0x03);write_i2c(0x3014, 0x0c);write_i2c(0x3015, 0x50);//add 5 dummy framewrite_i2c(0x302e, 0x00);write_i2c(0x302d, 0x00);15fps ~ 5fps night mode for 60/50Hz light environment, 24Mhz clock input,18Mhz pclki2c_salve_Address = 0x60;write_i2c(0x300e, 0x34);write_i2c(0x3011, 0x01);write_i2c(0x302c, 0x00);write_i2c(0x3071, 0x00);write_i2c(0x3070, 0x5d);write_i2c(0x301c, 0x05);write_i2c(0x3073, 0x00);write_i2c(0x3072, 0x4d);write_i2c(0x301d, 0x07);write_i2c(0x3014, 0x0c);write_i2c(0x3015, 0x50);write_i2c(0x302e, 0x00);write_i2c(0x302d, 0x00);4.3 Night Mode Offi2c_salve_Address = 0x60;write_i2c(0x3014, 0x04);write_i2c(0x3015, 0x00);8 OVT ConfidentialCompany ConfidentialOV2650 Camera software Application Noteswrite_i2c(0x302e, 0x00);write_i2c(0x302d, 0x00);OVT Confid9 entialCompany ConfidentialOV2650 Camera software Application Notes5. How to Remove Light Band in Preview Mode5.1 Light BandACLightNot n/100, has band5.2 Remove Light band Light band is removed by set exposure to n/100 (n/120 for 60Hz)seconds. The banding filter value tell OV2650 how many lines is 1/100 (1/120 for 60Hz) seconds.Banding filter value = Frame rate*Maximum Exposure Line/100(120)For SVGA: Maximum Exposure line is 1236.For UXGA: Maximum Exposure line is 618.5.3 Select Banding Filter by Region Information The region information of mobile phone could be used to select banding filter values. A light 10 OVT Confid The strength of office light is not even. It changes with AC frequency. For example, if the AC frequency is 50Hz, the light changes strength at 100hz.ential= n/100, no bandExposureCompany ConfidentialOV2650 Camera software Application Notesfrequency table is built to indicate which region uses 50Hz light and which region uses 60Hz light. When region information is got, the light frequency information could be get from the table. Different frame rate could be used for different light frequency. So the frame rate is optimized for both 50hz light condition and 60hz light condition.Banding filter setting for 30/25/15fps SVGA preview, 24Mhz input clock, refer to above settings and below control sample.i2c_salve_Address = 0x60;write_i2c(0x3014, 0x04); bit[7]select 50/60hz banding, 0:60hzwrite_i2c(0x3013, 0xf7); bit[5] banding filter selection on/offwrite_i2c(0x3070, 0xXX); //50Hz banding filter 8 MSBwrite_i2c(0x3071, 0xXX); //50Hz banding filter value 8 LSBwrite_i2c(0x3072, 0xXX); //60Hz banding filter value 8MSBwrite_i2c(0x3073, 0xXX); //60Hz banding filter value 8 LSBwrite_i2c(0x301c, 0xXX); //50Hz maximum exposure stepwrite_i2c(0x301d, 0xXX); //60Hz maximum exposure step Set same frame rate for 50Hz and 60Hz light environment, set 50Hz and 60Hz banding filter value. OV2650 could automatic select 50Hz or 60Hz banding filter based on light frequency detection. i2c_salve_Address = 0x60;write_i2c(0x3014, 0x44); bit[6]Auto select banding filterwrite_i2c(0x3070, 0xXX); //50Hz banding filter 8 MSBwrite_i2c(0x3071, 0xXX); //50Hz banding filter value 8 LSBwrite_i2c(0x3072, 0xXX); //60Hz banding filter value 8MSBwrite_i2c(0x3073, 0xXX); //60Hz banding filter value 8 LSBwrite_i2c(0x301c, 0xXX); //50Hz maximum exposure stepwrite_i2c(0x301d, 0xXX); //60Hz maximum exposure stepBelow is auto 50/60hz banding register settings for QXGA.60 30af 0060 3048 1f 60 3049 4e 60 304a 20 60 304f 20 60 304b 02 60 304c 00 60 304d 02 60 304f 20 60 30a3 10 60 3013 f7 60 3014 44 11 OVT Confid5.4 Select Banding Filter by Automatic Light Frequency DetectionentialCompany ConfidentialOV2650 Camera software Application Notes60 3071 0060 3070 5d60 3073 0060 3072 4d60 301c 0c60 301d 0f 60 304d 42 60 304a 40 60 304f 40 60 3095 07 60 3096 16 60 3097 1d OV2650 support simple white balance and advanced white balance. Advantage of simple AWB Simple white balance is not depend on lens. A general setting for simple white balance could applied for all modules with different lens.Disadvantage of simple AWB The color is not accurate in conditions where “gray world” not true. For example the background has a huge red, blue or green etc. the color of the foreground is not accurate. If the camera target single color such as red, blue, green, the simple white balance will make the single color gray.Settingsi2c_salve_Address = 0x60;write_i2c(0x3320, 0x99); // Simple AWBO Simple white balance assume “gray world”. Which means the average color of world is gray. It is true for most environment. V6.1 Simple White BalanceT C6. White Balanceonfid Normally the light band is removed by banding filter. But there is some special conditions such as mix light of sun light and office light, take picture of florescent light, the light band can not removed. The reason is the exposure time is less than 1/100 second for 50hz light environment and less than 1/120 second for 60hz light environment, so the light band can not be removed. The light band in this conditions could not be removed for all CMOS sensors, not only OV2650. So there is no way to remove light band in this condition.12 ential5.5 When Light Band can not be RemovedCompany ConfidentialOV2650 Camera software Application Notes6.2 Advanced White Balance Advanced white balance uses color temperature information to detect white area and do the white balance.Advantage of Advanced AWB Color is more accurate than simple white balance. Even the background is single color, the camera will not make the single color gray.Disadvantage of Advanced AWB Advanced white balance setting is depend on lens. The setting must be adjusted for every module with new lens. The adjustment must be done by OmniVision FAE in optical lab with some optical equipment such as light box, color checker etc. Generally, for low resolution camera module such as CIF, VGA and 1.3M, simple AWB is selected. For high resolution camera module such as 2M, 3M, advanced AWB is selected. Defect pixel includes dead pixel and wounded pixel. Dead pixel include white dead pixel and black dead pixel. White dead pixel is always white no matter the actual picture is bright or dark. Black dead pixel is always black no matter the actual picture is bright or dark. Wounded pixel may change with light, but not as much as normal pixel. White wounded pixels are much brighter then normal pixels, but not complete white. Black wounded pixels are much darker than normal pixels, but not complete black. OV2650 has built-in defect pixel correction function. If OV2650 output YCbCr, RGB565, Processed raw RGB, the defect pixel correction function could be enabled to fix defect pixels. But if Bayer raw RGB is used, the defect pixel correction function of sensor could not be used. The defect pixel correction of back-end chip should be used instead. Please pay attention to the defect pixel correction function of back-end chip. Some back-end chip may not be able to correct all defect pixels of OV2650.Settingsi2c_salve_Address = 0x60;write_i2c(0x3301, 0xff); // Pixel Correction ON,bit[1:0]: 11,select enable8. BLC The function of Black Level Calibration (BLC) is to product accurate color in the dark area of picture. There is automatic BLC function built-in OV2650. It should always be turned on.13 OVT C7. Defect Pixel Correctiononfid6.3 How to select?entialCompany ConfidentialSettingsi2c_salve_Address = 0x60;write_i2c(0x3320, 0x9a); // Advanced AWBContact with OmniVision local FAE for detailed information.OV2650 Camera software Application Notes9. Video Mode Video mode need high frame rate, usually fixed 15fps. There is no night mode for video mode.10. Digital zoom If OV2650 output image smaller than SVGA, it may support continuous digital zoom. For exampleUXGAno digital zoom supportedSVGA1-2xVGA1-3.2xQVGA1-6.4x If back-end chip support scale up, then more zoom level could be supported.11.1 Light ModeAutoi2c_salve_Address = 0x60;write_i2c(0x3306, 0x00)//AWB auto, bit[1]:0,autoSunnyi2c_salve_Address = 0x60;write_i2c(0x3306, 0x02); //AWB offwrite_i2c(0x3337, 0x5e);write_i2c(0x3338, 0x40);write_i2c(0x3339, 0x46);Cloudyi2c_salve_Address = 0x60;write_i2c(0x3306, 0x082); write_i2c(0x3337, 0x68);write_i2c(0x3338, 0x40);write_i2c(0x3339, 0x4e);Officei2c_salve_Address = 0x60;write_i2c(0x3306, 0x02); write_i2c(0x3337, 0x52);write_i2c(0x3338, 0x40);write_i2c(0x3339, 0x58);Homei2c_salve_Address = 0x60;write_i2c(0x3306, 0x02); write_i2c(0x3337, 0x44);14 OVT ConfidCompany Confidentialential11. OV2650 FunctionsOV2650 Camera software Application Noteswrite_i2c(0x3338, 0x40);write_i2c(0x3339, 0x70);11.2 Color Saturation The color saturation of OV2650 could be adjusted. High color saturation would make the picture looks more vivid, but the side effect is the bigger noise and not accurate skin color.write_i2c(0x3301, 0xff);bit[7]:1, enable SDESaturation + 2(1.75x)i2c_salve_Address = 0x60;write_i2c(0x3391, 0x02); enable color saturation write_i2c(0x3394, 0x70);write_i2c(0x3395, 0x70);Saturation + 1(1.25x)i2c_salve_Address = 0x60;write_i2c(0x3391, 0x02); write_i2c(0x3394, 0x50);write_i2c(0x3395, 0x50);Saturation 0i2c_salve_Address = 0x60;write_i2c(0x3391, 0x02); write_i2c(0x3394, 0x40);write_i2c(0x3395, 0x40);Saturation -1(0.75x)i2c_salve_Address = 0x60;write_i2c(0x3391, 0x02); write_i2c(0x3394, 0x30);write_i2c(0x3395, 0x30);Saturation – 2(0.5x)i2c_salve_Address = 0x60;write_i2c(0x3391, 0x02); write_i2c(0x3394, 0x20);write_i2c(0x3395, 0x20);11.3 Brightness The brightness of OV2650 could be adjusted. Higher brightness will make the picture more bright. The side effect of higher brightness is the picture looks foggy.write_i2c(0x3301, 0xff);Brightness +3i2c_salve_Address = 0x60;15 OVT ConfidCompany ConfidentialentialOV2650 Camera software Application Noteswrite_i2c(0x3391, 0x04); bit[2] enablewrite_i2c(0x3390, 0x41);bit[3] sign of brightnesswrite_i2c(0x339a, 0x30);Brightness +2i2c_salve_Address = 0x60;write_i2c(0x3391, 0x04); write_i2c(0x3390, 0x41);write_i2c(0x339a, 0x20);Brightness +1i2c_salve_Address = 0x60;write_i2c(0x3391, 0x04); write_i2c(0x3390, 0x41);write_i2c(0x339a, 0x10);Brightness 0i2c_salve_Address = 0x60;write_i2c(0x3391, 0x00); write_i2c(0x3390, 0x41);write_i2c(0x339a, 0x00);Brightness -1i2c_salve_Address = 0x60;write_i2c(0x3391, 0x04); write_i2c(0x3390, 0x49);write_i2c(0x339a, 0x10);Brightness -2i2c_salve_Address = 0x60;write_i2c(0x3391, 0x04); write_i2c(0x3390, 0x49);write_i2c(0x339a, 0x20);Brightness -3i2c_salve_Address = 0x60;write_i2c(0x3391, 0x04); write_i2c(0x3390, 0x49);write_i2c(0x339a, 0x30);11.4 Contrast The contrast of OV2650 could be adjusted. Higher contrast will make the picture sharp. But the side effect is loosing dynamic range.write_i2c(0x3301, 0xff);Contrast +3i2c_salve_Address = 0x60;16 OVT ConfidCompany ConfidentialentialOV2650 Camera software Application Noteswrite_i2c(0x3391, 0x04); bit[2] enable contrast/brightnesswrite_i2c(0x3390, 0x45); bit[2] Yoffset signwrite_i2c(0x3398, 0x2c);write_i2c(0x3399, 0x2c);Contrast +2i2c_salve_Address = 0x60;write_i2c(0x3391, 0x04); write_i2c(0x3390, 0x45);write_i2c(0x3398, 0x28);write_i2c(0x3399, 0x28);Contrast +1i2c_salve_Address = 0x60;write_i2c(0x3391, 0x04); write_i2c(0x3390, 0x45);write_i2c(0x3398, 0x24);write_i2c(0x3399, 0x24);Contrast 0i2c_salve_Address = 0x60;write_i2c(0x3391, 0x00); write_i2c(0x3390, 0x41);write_i2c(0x3398, 0x20);write_i2c(0x3399, 0x20);Contrast -1i2c_salve_Address = 0x60;write_i2c(0x3391, 0x04); write_i2c(0x3390, 0x45);write_i2c(0x3398, 0x1c);write_i2c(0x3399, 0x1c);Contrast -2i2c_salve_Address = 0x60;write_i2c(0x3391, 0x04); write_i2c(0x3390, 0x45);write_i2c(0x3398, 0x18);write_i2c(0x3399, 0x18);Contrast -3i2c_salve_Address = 0x60;write_i2c(0x3391, 0x04); write_i2c(0x3390, 0x45);write_i2c(0x3398, 0x18);17 OVT ConfidCompany ConfidentialentialOV2650 Camera software Application Noteswrite_i2c(0x3399, 0x18);11.5 Special effects OV2650 support some special effects such as B/W, negative, sepia, bluish, reddish, greenish,negative, etc. If users need other special effects, it should be supported by back-end chips.write_i2c(0x3301, 0xff);Sepia(antique)i2c_salve_Address = 0x60;write_i2c(0x3391, 0x18);write_i2c(0x3396, 0x40);write_i2c(0x3397, 0xa6);Yellowishi2c_salve_Address = 0x60;write_i2c(0x3391, 0x18);write_i2c(0x3396, 0x30);write_i2c(0x3397, 0x90);B&Wi2c_salve_Address = 0x60;write_i2c(0x3391, 0x20);Negativei2c_salve_Address = 0x60;write_i2c(0x3391, 0x40);bit[6] negativeNormal18 OVReddishi2c_salve_Address = 0x60;write_i2c(0x3391, 0x18);write_i2c(0x3396, 0x80);write_i2c(0x3397, 0xc0);T ConfidCompany ConfidentialGreenishi2c_salve_Address = 0x60;write_i2c(0x3391, 0x18);write_i2c(0x3396, 0x60);write_i2c(0x3397, 0x60);entialBluishi2c_salve_Address = 0x60;write_i2c(0x3391, 0x18);write_i2c(0x3396, 0xa0);write_i2c(0x3397, 0x40);OV2650 Camera software Application Notesi2c_salve_Address = 0x60;write_i2c(0x3391, 0x00);11.6 Exposure OV2650 support different exposure level. It can increase/decrease target brightness by change exposure/gain auto. OV2650 support two exposure algorithm, one is Average, other is Histogram.11.6.1 Average-based Algorithm---Based on Target luminancei2c_salve_Address = 0x60;write_i2c(0x3047,0x05); -3 write_i2c(0x3018, 0x40)write_i2c(0x3019, 0x30)write_i2c(0x301a, 0x71) -2 write_i2c(0x3018, 0x5a)write_i2c(0x3019, 0x4a)write_i2c(0x301a, 0xc2) -0.3EV write_i2c(0x3018, 0x6a)write_i2c(0x3019, 0x5a)write_i2c(0x301a, 0xd4) default write_i2c(0x3018, 0x78)write_i2c(0x3019, 0x68)write_i2c(0x301a, 0xd4) 1 write_i2c(0x3018, 0x88)write_i2c(0x3019, 0x78)write_i2c(0x301a, 0xd5) 2 write_i2c(0x3018, 0xa8)write_i2c(0x3019, 0x98)write_i2c(0x301a, 0xe6) 3 write_i2c(0x3018, 0xc8)write_i2c(0x3019, 0xb8)OVT ConfidCompany Confidential19 entialOV2650 Camera software Application Noteswrite_i2c(0x301a, 0xf7) 11.6.2 Histogram-based Algorithm---Based on Histogram and probability.i2c_salve_Address = 0x60;write_i2c(0x3047,0x85); -3 write_i2c(0x3018, 0x50)write_i2c(0x3019, 0x30) -2 write_i2c(0x3018, 0x60)write_i2c(0x3019, 0x40) -1 write_i2c(0x3018, 0x80)write_i2c(0x3019, 0x60) 0write_i2c(0x3018, 0x98)write_i2c(0x3019, 0x78) 1 write_i2c(0x3018, 0xa8)write_i2c(0x3019, 0x88) 2 write_i2c(0x3018, 0xc8)write_i2c(0x3019, 0xa8)3 write_i2c(0x3018, 0xe8)write_i2c(0x3019, 0xb8)11.7 Sharpnessi2c_salve_Address = 0x60;write_i2c(0x3306, 0x08)Sharpness 1write_i2c(0x3371, 0x00)Sharpness 2write_i2c(0x3371, 0x01)20 OVT ConfidCompany ConfidentialentialOV2650 Camera software Application Notesdefaultwrite_i2c(0x332d, 0x02)Sharpness 4write_i2c(0x332d, 0x03)Sharpness 5write_i2c(0x332d, 0x04)Sharpness autowrite_i2c(0x3306, 0x00)i2c_salve_Address = 0x60;MIRRORwrite_i2c(0x3090, 0x08);FLIPwrite_i2c(0x307c, 0x01);flipMIRROR&FLIPwrite_i2c(0x307c, 0x01)write_i2c(0x3090, 0x08);0x3400[0:1] control YUV sequenceY U Y Vwrite_i2c(0x3400, 0x00) Y V Y Uwrite_i2c(0x3400, 0x01)V Y U Ywrite_i2c(0x3400, 0x03)U Y V Ywrite_i2c(0x3400, 0x02)O11.9 YUV SequenceVNORML write_i2c(0x307c, 0x00);no mirror/flipwrite_i2c(0x3090, 0x08);T ConfidCompany Confidential21 ential11.8 Mirror/FlipOV2650 Camera software Application Notes11.10 Clock PolarityData valid VSYNC high0x3600[0] Control VSYNC polarity 1: Data valid VSYNC High 0: Data valid VSYNC low 0x3600[2] Control PCLK polarity 1: Data update at Falling-edge 0: Data update at Rising-edge0x3600[1] Control HREF polarity 0:Data valid HREF high 1: Data valid HREF Low12. Deal with Lens12.1 Light fall off Some lens may have dark corner. Dark corner means the color of picture looks almost black. It is not possible to correct dark corner with lens correction. So the module with dark corner is NG, it can not be used.12.3 Resolution The resolution of camera module depends on lens design, focus adjustment and sensor resolution as well. The focus adjustment is very important for camera module assembly. For OV2650 the focus distance is about 80~120cm. The depth of field is about from 40~50cm to infinite. If checking resolution of camera module, the resolution chart should be placed 80~120 cm away.12.4 Optical contrast The optical contrast of lens is very important to picture quality. If the optical contrast of lens is not good, the picture would looks foggy. Though it could be improved by increase the sensor 22 OV12.2 Dark cornerT Contact with OmniVision local FAE for Lens correction settings. C Light fall off means the corner of image is darker than center of image. It is caused by the lens. The lens shading correction function of OV2650 could be turned on to compensate the corner brightness and make the whole picture looks same bright.settingsi2c_salve_Address = 0x60;write_i2c(0x3300,0xf8);bit[3]: enable lens correctiononfidentialCompany ConfidentialOV2650 Camera software Application Notescontrast to make the picture sharper, the higher sensor contrast would make the detail lost of dark area of the picture.12.5 Lens Cover The lens cover is the cheapest part in optical path. But it could affect picture quality very much. The lens cover should be made with optical glass with AR coating at both side. Otherwise, the lens cover may cause sensitivity loss and/or stronger lens flare.13. Reference Settings13.1 YCbCr Reference Setting13.1.1 SVGA Preview// OV2650_SVGA_YUV 30 fps// 24 MHz input clock;Soft Reset60 3012 80 ;Add some delay after register reset60 308c 8060 308d 0e60 360b 0060 30b0 ff60 30b1 ff60 30b2 2460 300e 3460 300f a660 3010 8160 3082 0160 30f4 0160 3090 3360 3091 c060 30ac 4260 30d1 0860 30a8 5660 3015 0360 3093 0060 307e e560 3079 0023 OVT ConfidCompany ConfidentialentialOV2650 output maximum 15fps UXGA and maximum 30fps SVGA. For other resolution, only downscale from UXGA or SVGA. Say to, resolution from SVGA can reach up maximum 30fps, resolution from UXGA can reach up maximum 15fps.OV2650 Camera software Application Notes60 30aa 4260 3017 4060 30f3 8260 306a 0c60 306d 0060 336a 3c60 3076 6a60 30d9 8c60 3016 8260 3601 3060 304e 8860 30f1 8260 306f 1460 302a 0260 302b 6a60 3012 1060 3011 01;AEC/AGC60 3013 f760 301c 1360 301d 1760 3070 5d60 3072 4d;D506060 30af 0060 3048 1f 60 3049 4e 60 304a 20 60 304f 20 60 304b 02 60 304c 00 60 304d 02 60 304f 20 60 30a3 10 60 3013 f7 60 3014 44 60 3071 0060 3070 5d60 3073 0060 3072 4d60 301c 0560 301d 06 60 304d 42 60 304a 40 24 OVT ConfidCompany ConfidentialentialOV2650 Camera software Application Notes60 304f 40 60 3095 07 60 3096 16 60 3097 1d ;Window Setup60 300e 3860 3020 0160 3021 1860 3022 0060 3023 0660 3024 0660 3025 5860 3026 0260 3027 6160 3088 0360 30 2060 308a 0260 308b 5860 3316 60 3317 2560 3318 8060 3319 0860 331a 60 331b 4b60 331c 0060 331d 3860 3100 00;AWB60 3320 fa60 3321 1160 3322 9260 3323 0160 3324 9760 3325 0260 3326 ff60 3327 0c60 3328 10 60 3329 1060 332a 5860 332b 5060 332c be60 332d e160 332e 4360 332f 3660 3330 4d25 OVT ConfidCompany ConfidentialentialOV2650 Camera software Application Notes60 3331 4460 3332 f860 3333 0a60 3334 f060 3335 f060 3336 f060 3337 4060 3338 4060 3339 4060 333a 0060 333b 00 ;Color Matrix60 3380 2860 3381 4860 3382 1060 3383 2360 3384 c060 3385 e560 3386 c260 3387 b360 3388 0e60 33 9860 338a 01;Gamma60 3340 0e60 3341 1a60 3342 3160 3343 4560 3344 5a60 3345 6960 3346 7560 3347 7e60 3348 8860 3349 9660 334a a360 334b af60 334c c460 334d d760 334e e860 334f 20;Lens correction60 3350 3260 3351 25 60 3352 80 26 OVT ConfidCompany ConfidentialentialOV2650 Camera software Application Notes60 3353 1e 60 33 00 60 3355 85 60 3356 32 60 3357 25 60 3358 80 60 3359 1b 60 335a 00 60 335b 85 60 335c 32 60 335d 25 60 335e 80 60 335f 1b 60 3360 00 60 3361 85 60 3363 70 60 33 7f 60 3365 00 60 3366 00 ;UVadjust60 3301 ff60 338b 1160 338c 1060 338d 40;Sharpness/De-noise60 3370 d060 3371 0060 3372 0060 3373 4060 3374 1060 3375 1060 3376 0460 3377 0060 3378 0460 3379 80;BLC60 3069 8460 307c 1060 3087 02;Other functions60 3300 fc60 3302 1160 3400 0027 OVT ConfidCompany ConfidentialentialOV2650 Camera software Application Notes60 3606 2060 3601 3060 300e 3460 3011 0060 30f3 8360 304e 8860 3086 0f60 3086 00 13.1.2 Other Preview Resolution DCW from SVGASVGA->VGA60 3302 11 60 3088 02 60 30 80 60 308a 01 60 308b e0 60 331a 2860 331b 1e60 331c 0060 3302 11 SVGA->CIF60 3302 11 60 3088 01 60 30 60 60 308a 01 60 308b 20 60 331a 1660 331b 1260 331c 0060 3302 11 SVGA->QVGA60 3088 01 60 30 40 60 308a 00 60 308b f0 60 331a 1428 OVT ConfidCompany ConfidentialentialBelow is other preview size is DCW from SVGA.OV2650 Camera software Application Notes60 331b 0f60 331c 00 60 3302 11 ;13.1.3 UXGA Capture; OV2650_UXGA_YUV7.5 fps; 24 MHz input clock, 32Mhz output clock60 3012 80 ;Add some delay after register reset60 308c 8060 308d 0e60 360b 0060 30b0 ff60 30b1 ff60 30b2 2460 300e 3460 300f a660 3010 8160 3082 0160 30f4 0160 3090 3360 3091 c060 30ac 4260 30d1 0860 30a8 5660 3015 0360 3093 0060 307e e560 3079 0060 30aa 4260 3017 4060 30f3 8260 306a 0c60 306d 0060 336a 3c60 3076 6a60 30d9 8c60 3016 8260 3601 3060 304e 8860 30f1 82OVT ConfidCompany Confidential29 entialOV2650 Camera software Application Notes60 3011 02;AEC/AGC60 3013 f760 301c 1360 301d 1760 3070 3e60 3072 34;D506060 30af 0060 3048 1f 60 3049 4e 60 304a 20 60 304f 20 60 304b 02 60 304c 00 60 304d 02 60 304f 20 60 30a3 10 60 3013 f7 60 3014 44 60 3071 0060 3070 3e60 3073 0060 3072 3460 301c 1260 301d 16 60 304d 42 60 304a 40 60 304f 40 60 3095 07 60 3096 16 60 3097 1d ;Window Setup60 300e 3860 3020 0160 3021 1860 3022 0060 3023 0a60 3024 0660 3025 5860 3026 0460 3027 bc60 3088 0660 30 4030 OVT ConfidCompany ConfidentialentialOV2650 Camera software Application Notes60 308a 0460 308b b060 3316 60 3317 4b60 3318 0060 331a 60 331b 4b60 331c 0060 3100 00;AWB60 3320 fa60 3321 1160 3322 9260 3323 0160 3324 9760 3325 0260 3326 ff60 3327 0c60 3328 10 60 3329 1060 332a 5860 332b 5060 332c be60 332d e160 332e 4360 332f 3660 3330 4d60 3331 4460 3332 f860 3333 0a60 3334 f060 3335 f060 3336 f060 3337 4060 3338 4060 3339 4060 333a 0060 333b 00 ;Color Matrix60 3380 2860 3381 4860 3382 1060 3383 2360 3384 c060 3385 e531 OVT ConfidCompany ConfidentialentialOV2650 Camera software Application Notes60 3386 c260 3387 b360 3388 0e60 33 9860 338a 01;Gamma60 3340 0e60 3341 1a60 3342 3160 3343 4560 3344 5a60 3345 6960 3346 7560 3347 7e60 3348 8860 3349 9660 334a a360 334b af60 334c c460 334d d760 334e e860 334f 20;Lens correction60 3350 3260 3351 25 60 3352 80 60 3353 1e 60 33 00 60 3355 85 60 3356 32 60 3357 25 60 3358 80 60 3359 1b 60 335a 00 60 335b 85 60 335c 32 60 335d 25 60 335e 80 60 335f 1b 60 3360 00 60 3361 85 60 3363 70 60 33 7f 60 3365 00 60 3366 00 32 OVT ConfidCompany ConfidentialentialOV2650 Camera software Application Notes;UV adjust60 3301 ff60 338b 1160 338c 1060 338d 40;Sharpness/De-noise60 3370 d060 3371 0060 3372 0060 3373 4060 3374 1060 3375 1060 3376 0460 3377 0060 3378 0460 3379 80;BLC60 3069 8460 307c 1060 3087 02;Other functions60 3300 fc60 3302 0160 3400 0060 3606 2060 3601 3060 300e 3460 3011 0160 30f3 8360 304e 8860 3086 0f60 3086 0013.1.4 Other Capture size DCW from UXGA UXGA->SXGA ;1280*102460 3302 11 60 3088 05 60 30 00 60 308a 04 33 OVT ConfidCompany ConfidentialentialOV2650 Camera software Application Notes60 308b 00 60 331a 5060 331b 4060 331c 00UXGA->SXGA ;1280*96060 3302 11 60 3088 05 60 30 00 60 308a 03 60 308b c0 60 331a 5060 331b 3c60 331c 00UXGA->SVGA60 3302 11 60 3088 03 60 30 20 60 308a 02 60 308b 58 60 331a 3260 331b 2560 331c 80 UXGA->VGA60 3302 11 60 3088 02 60 30 80 60 308a 01 60 308b e0 60 331a 2860 331b 1e60 331c 00UXGA->CIF60 3302 11 60 3088 01 60 30 60 60 308a 01 60 308b 20 60 331a 1634 OVT ConfidCompany ConfidentialentialOV2650 Camera software Application Notes60 331b 1260 331c 00UXGA->QVGA60 3302 11 60 3088 01 60 30 40 60 308a 00 60 308b f0 60 331a 1460 331b 0f60 331c 00UXGA->QCIF60 3302 11 60 3088 00 60 30 b0 60 308a 00 60 308b 90 60 331a 0b60 331b 0960 331c 0013.1.5 Transfer From SVGA to UXGA 60 300e 34 60 3011 01 60 3012 00 60 302A 04 60 302B d4 60 306f ;60 3020 0160 3021 1860 3022 0060 3023 0a 60 3024 06 60 3025 58 60 3026 04 60 3027 bc 60 3088 06 60 30 40 60 308a 04 60 308b b0 60 3316 35 OVT ConfidCompany ConfidentialentialOV2650 Camera software Application Notes60 3317 25 60 3318 80 60 3319 2c60 331a ;60 331b 4b;60 331c 00;60 331d 4c;60 3302 01 ;13.1.6 Transfer From UXGA to SVGA 60 300e 34 60 3011 0060 3012 10 60 302A 02 60 302B 6a 60 306f 14 ;60 3020 0160 3021 1860 3022 0060 3023 06 60 3024 06 60 3025 58 60 3026 02 60 3027 61 60 3088 03 60 30 20 60 308a 02 60 308b 58 60 3316 60 3317 25 60 3318 80 60 3319 0860 331a 60 331b 4b60 331c 0060 331d 3860 3302 11 13.2 Format Transfer Reference SettingYUV42260 3100 0060 3300 fc60 3301 ff60 3400 0036 OVT ConfidCompany ConfidentialentialOV2650 Camera software Application Notes60 3606 20RGB56560 3400 41 60 3100 02 Processed raw60 300e 3860 3024 0660 3025 5860 3026 0460 3027 bc60 3088 0660 30 4060 308a 0460 308b b060 3100 0460 3300 f360 3301 ff 60 3302 1060 3400 9060 3606 20Sensor raw60 3103 10 60 3300 71 60 3400 90 60 3606 20 60 3023 0a 60 3024 06 60 3025 40 60 3026 04 60 3027 b0 60 307d 20 14. Capture Sequence14.1 Shutter The shutter of OV2650 controls exposure time. The unit of shutter is line period. There have two exposure mode, one is normal exposure, other is HDR exposure mode. Here only introduce normal exposure mode.OVT ConfidCompany Confidential37 entialOV2650 Camera software Application Notes Shutter value has limitation for each output resolution. If no dummy lines are inserted, the maximum shutter value for UXGA resolution is 1236. The maximum shutter value for SVGA resolution is 618.Default_SVGA_maximum_shutter = 618;Default_UXGA_maximum_shutter = 1236; The shutter value are stored in 2 registers, reg0x3002, reg0x3003 .Shutter = reg0x3002 << 8 + reg0x3003;14. 2 Dummy Lines The are 2 kinds of dummy lines could be inserted. Dummy line before data output and dummy line after data output.14.2.1 Extra Line If dummy lines are inserted before data output, which is called extra line, the actual exposure time is increased. The extra line is controlled by register 0x302d and 0x302e.Exposure = Shutter + Extra_linesExtra_lines = reg0x302d + (reg0x302e << 8); So even shutter value is 0, the minimum exposure time is Extra_lines. Usually, extra lines should be inserted automatically. If the environment is dark, longer exposure time is required, extra line number increased. If the environment is bright, shorter exposure time is required, extra line number decreased. If extra line is inserted manually and the value is fixed, the total exposure time can not be less then extra_line in bright environment, the image would be over exposed. The extra lines are inserted inside the active period of Vsync, the timing of output period in which Vsync is inactive is not changed.14.2.2 Dummy Line If dummy lines are inserted after data output, which is called dummy line, the maximum shutter value is changed. The dummy lines are inserted between two Vsync. The number of dummy lines is controlled by register 0x302a and 0x302b. Different with other sensor, there have default values in such two register, Default_Reg0x302a, Default_Reg0x302b.SVGA_maximum_shutter = Default_SVGA_Maximum_Shutter + Dummy_line38 OVT the maximum shutter value is not changed. Confidential The exposure could be increased further by insert dummy lines. When dummy lines are inserted, frame rate also changes.Company ConfidentialOV2650 Camera software Application NotesUXGA_maximum_shutter = Default_UXGA_Maximum_Shutter + Dummy_lineThe exposure time isExposure = ShutterDummy_line = (Reg0x302a-Default_Reg0x302a) <<8 + Reg0x302b-Default_Reg0x302b;For SVGA: Default_Reg0x302a = 0x02; Default_Reg0x302b = 0x6a;For UXGA: Default_Reg0x302a = 0x04; Default_Reg0x302b = 0xd4;Extra lineRegistersMinimum Shutter ValueMaximum Shutter ValueMinimum ExposureMaximum Exposure0x302d, 0x302e01236 for UXGA618 for SVGAExtra_linesDummy Line0x302a, 0x302b So if both dummy line and extra line are inserted, the exposure time isExposure = Shutter + Extra_LinesAnd the maximum shutter value is14. 3 Dummy Pixels If no dummy pixel is inserted, the line width is called default line width. Dummy pixel register is 0x3028, 0x3029.Default_SVGA_Line_Width = 1940;Default_UXGA_Line_Width = 1940;When dummy pixel is inserted, the line width changes and frame rate also changes.SVGA_Line_Width = Default_SVGA_Line_Width + Dummy_pixelUXGA_Line_Width = Default_UXGA_Line_Width + Dummy_pixel14.4 GainGain is stored in reg0x3000 and Reg0x3001. If only use the gain of Reg0x3001, maximum gain of 32x could be reached. It is enough for camera phone. So we don't discuss reg0x3000 here.OVT SVGA_maximum_shutter = Default_SVGA_Maximum_Shutter + Dummy_lineUXGA_maximum_shutter = Default_UXGA_Maximum_Shutter + Dummy_line ConfidMaximum_Shutter + Extra_linesMaximum_Shutter39 ential001236 + Dummy_line for UXGA618 + Dummy_line for SVGACompany ConfidentialOV2650 Camera software Application NotesGain = (((reg0x3001 & 0xf0)>>4) + 1)*(1 + (reg0x3001 & 0x0f)/16)14.5 Banding Filter14.5.1 PreviewAutomatic Banding filter is used for preview.14.5.2 CaptureManual banding filter is used for capture. For 50Hz, the banding filter calculation isBanding_Filter = Capture_PCLK_Frequency /100 /capture_line_widthBanding_Filter = Capture_PCLK_Frequency /120 /capture_line_widthCapture_Exposure = n*Banding_Filtern is an integer.14.6 Auto frame rate14.7 Capture Sequence14.7.1 Preview// Initialize OV2650 for previewDifferent with other sensor, there have default values in dummy pixel, Default_Reg0x3028, Default_Reg0x3029,dummy lines register, Default_Reg0x302a, Default_Reg0x302b. And SVGA and UXGA have different default values. So dummy pixel values and dummy line values are new values minus default values of such registers.// Dummy pixel and Dummy line could be inserted for previewPreview_dummy_pixel = Preview_dummy_line =If (Resolution == SVGA) {Preview_dummy_pixel_val = Preview_dummy_pixel * 2;}else {Preview_dummy_pixel_val = Preview_dummy_pixel;40 OVT C Auto frame rate could be enabled by turn on night mode. When night mode is enabled, the extra line are adjusted automatically.onfidentialCompany ConfidentialFor 60Hz, the banding filter calculation isOV2650 Camera software Application Notes}Reg0x3029 = Preview_dummy_pixel_val & 0x00ff + Default_Reg0x3029;Reg0x3028 = Preview_dummy_pixel_val >>8 + Default_Reg0x3028;write_i2c(0x3029, Reg0x3029);write_i2c(0x3028, Reg0x3028);// update dummy lineReg0x302b = Preview_dummy_line & 0x00ff + Default_Reg0x302b;Reg0x302a = Preview_dummy_line >>8 + Default_Reg0x302a;write_i2c(0x302a, Reg0x302a);write_i2c(0x302b, Reg0x302b);//Stop AE/AGreg0x3013 = read_i2c(0x3013);Reg0x3013 = reg0x3013 & 0xfa;write_i2c(0x3013,Reg0x3013);//Read back preview shutterreg0x3002 = read_i2c(0x3002);reg0x3003 = read_i2c(0x3003);Shutter = reg0x3002<<8 + reg0x3003;Preview_Exposure = Shutter + Extra_lines;//Read Back Gain for previewreg0x3000 = read_i2c(0x3000);Preview_Gain16 = (((Reg0x3000 & 0xf0)>>4) + 1) * (16 + reg0x3000 & 0x0f);//Read back dummy pixelsreg0x3028 = read_i2c(0x3028);reg0x3029 = read_i2c(0x3029);Preview_dummy_pixels = ((reg0x3028-Default_Reg0x3028) & 0xf0)<<8 + reg0x3029-Default_Reg0x3029;If (Resolution == SVGA) {Preview_dummy_pixels = Preview_dummy_pixels/2 ;}41 OV//Read back extra linereg0x302d = read_i2c(0x302d);reg0x302e = read_i2c(0x302e);Extra_lines = reg0x302e + (reg0x302d<<8);T ConfidCompany Confidentialential14.7.2 Stop PreviewOV2650 Camera software Application Notes14.7.3 Calculate Capture Exposure// Dummy Pixel and Dummy Line could be inserted for captureCapture_dummy_pixel =Capture_dummy_line =Preview_PCLK_frequency =Capture_PCLK_frequency =// Capture maximum gain could be defined.// Capture_max_gain16 = capture_max_gain * 16// Preview_line_width = Default_SVGA_Line_Width + Preview_dummy_pixel ;If (resolution ==SVGA) {Capture_line_width = Default_SVGA_Line_Width + capture_Dummy_pixel;}else {Capture_line_width = Default_UXGA_Line_Width + capture_Dummy_pixel;}If (resolution ==SVGA) {Capture_maximum_shutter = Default_SVGA_maximum_shutter + capture_dummy_lines;}else {Capture_maximum_shutter = Default_UXGA_maximum_shutter + capture_dummy_lines;}Capture_Exposure = Preview_Exposure * Capture_PCLK_Frequency/Preview_PCLK_Frequency * Preview_Line_width/Capture_Line_Width;//Calculate banding filter valueIf (50Hz) {If (format == RGB) {//RGB indicates raw RGBCapture_banding_Filter = Capture_PCLK_Frequency /100 /capture_line_width;}else {Capture_banding_Filter = Capture_PCLK_Frequency/ 100/ (2*capture_line_width);}else {(60Hz)If (format == RGB) {Capture_banding_Filter = Capture_PCLK_Frequency /120 /capture_line_width;}else {Capture_banding_Filter = Capture_PCLK_frequency /120 /(2*capture_line_width);}}OVT Confid42 entialCompany ConfidentialOV2650 Camera software Application Notes//redistribute gain and exposureGain_Exposure = Preview_Gain16 * Capture_Exposure;If (Gain_Exposure < Capture_Banding_Filter * 16) {// Exposure < 1/100Capture_Exposure = Gain_Exposure /16;Capture_Gain16 = (Gain_Exposure*2 + 1)/Capture_Exposure/2;}else {If (Gain_Exposure > Capture_Maximum_Shutter * 16) {// Exposure > Capture_Maximum_ShutterCapture_Exposure = Capture_Maximum_Shutter;Capture_Gain16 = (Gain_Exposure*2 + 1)/Capture_Maximum_Shutter/2;If (Capture_Gain16 > Capture_Max_Gain16) {// gain reach maximum, insert extra lineCapture_Exposure = Gain_Exposure*1.1/Capture_Max_Gain16;// For 50Hz, Exposure = n/100; For 60Hz, Exposure = n/120Capture_Exposure = Gain_Exposure/16/Capture_banding_filter;Capture_Exposure = Capture_Exposure * Capture_banding_filter;Capture_Gain16 = (Gain_Exposure *2+1)/ Capture_Exposure/2;}else{Capture_Exposure = Capture_Exposure/Capture_banding_filter;Capture_Exposure = Capture_Exposure * Capture_banding_filter;Capture_Gain16 = (Gain_Exposure*2 + 1)/Capture_Maximum_Shutter/2;}// 1/100(120) < Exposure < Capture_Maximum_Shutter, Exposure = n/100(120)Capture_Exposure = Gain_Exposure/16/Capture_banding_filter;Capture_Exposure = Capture_Exposure * Capture_banding_filter;Capture_Gain16 = (Gain_Exposure*2 +1) / Capture_Exposure/2;}}14.7.4 Switch to UXGA// Write registers, change to UXGA resolution.14.7.5 Write Registers//write dummy pixelsreg0x3029 = Capture_dummy_pixel & 0x00ff;reg0x3028 = read_i2c(0x3028);reg0x3028 = (reg0x3028 & 0x0f) | ((Capture_dummy_pixel & 0x0f00)>>4);write_i2c(0x3028, reg0x3028);write_i2c(0x302b, reg0x3029);43 OVT }else { ConfidentialCompany ConfidentialOV2650 Camera software Application Notes//Write Dummy LinesReg0x302b = Capture_dummy_line & 0x00ff + Default_Reg0x302b;Reg0x302a = Capture_dummy_line >>8 + Default_Reg0x302a;write_i2c(0x302a, Reg0x302a);write_i2c(0x302b, Reg0x302b);//Write ExposureIf (Capture_Exposure > Capture_maximum_shutter) {Shutter = Capture_maximum_shutter;Extra_lines = Capture_Exposure – Capture_maximum_shutter;}else {Shutter = Capture_Exposure;Extra_lines = 0;}Reg0x3003 = Shutter & 0x00ff;Reg0x3002 = (Shutter >>8) & 0x00ff;// Write GainGain = 0;If (Capture_Gain16 > 16) {Capture_Gain16 = Capture_Gain /2;Gain = 0x10;}If (Capture_Gain16 > 16) {Capture_Gain16 = Capture_Gain /2;Gain = Gain | 0x20;}If (Capture_Gain16 > 16) {Capture_Gain16 = Capture_Gain /2;Gain = Gain | 0x40;}If (Capture_Gain16 > 16) {Capture_Gain16 = Capture_Gain /2;Gain = Gain | 0x80;}OVT C// Write extra linereg0x302e = Extra_lines & 0x00ff;reg0x302d = Extra_lines >> 8;write_i2c(0x302d, reg0x302d);write_i2c(0x302e, reg0x302e);onfidCompany Confidentialwrite_i2c(0x3003, Reg0x3003);write_i2c(0x3002, Reg0x3002);44 entialOV2650 Camera software Application NotesGain = Gain | (Capture_Gain16 -16);write_i2c(0x3000, Gain);14.7.6 Capture// Wait for 2 Vsync// Capture the 3rd frame.14.7.7 Back to preview//Write Registers, Change to SVGA...//Start AG/AEReg0x3013 = Reg0x3013 | 0x05;write_i2c(0x3013, Reg0x3013);Reg0x3013 = read_i2c(0x3013);OVT Confid45 entialCompany ConfidentialOV2650 Camera software Application NotesRev1.1Update ZOOM and Power downRev1.2Update PCLK output when output small sizeUpdate YUV Sequence.Update SharpnessRev 1.3Update exposure/gain algorithmRev 1.4Update settings based on Rev1CRev 1.5Update settings based on Rev1D and add auto 50/60hz settings.OVT Confid46 entialCompany Confidential