00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include "board.h"
00035
00036
00037 const capture_size ov_sizes[] = {
00038
00039 { 160, 120 },
00040 { 352, 288 },
00041 { 320, 240 },
00042 { 640, 360 },
00043 { 640, 480 },
00044
00045 { 800, 600 },
00046
00047 {1280, 960 },
00048 {1280, 720 },
00049
00050 {1600, 1200 },
00051 };
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 void ov_configure(Twid *pTwid, uint8_t ovType, uint32_t width, uint32_t heigth)
00062 {
00063 const struct ov_reg *reg_conf;
00064 uint8_t goodCaptureSize = 0;
00065 uint8_t i;
00066
00067 reg_conf = ov5640_yuv_vga;
00068 TRACE_DEBUG("ovxxx_configure\n\r");
00069 for( i = 0; i< sizeof(ov_sizes); i++ ) {
00070 if( ov_sizes[i].width == width ) {
00071 if( ov_sizes[i].height != heigth ) {
00072 TRACE_INFO("ov configure vsize not define\n\r");
00073 } else {
00074 goodCaptureSize = 1;
00075 break;
00076 }
00077 }
00078 }
00079 if( goodCaptureSize == 0 ) {
00080 TRACE_ERROR("Problem size\n\r");
00081 while(1);
00082 }
00083 switch (ovType){
00084 case OV_2640: {
00085
00086 reg_conf = ov2640_yuv_qvga;
00087
00088 switch(width) {
00089 case 320:
00090 printf("-I- QVGA 640 x 480\n\r");
00091 reg_conf = ov2640_yuv_qvga;
00092 break;
00093 case 640:
00094 TRACE_INFO("VGA 640 x 480\n\r");
00095 reg_conf = ov2640_yuv_vga;
00096 break;
00097 default:
00098 TRACE_DEBUG("ov2640_configure problem\n\r");
00099 break;
00100 }
00101 break;
00102 }
00103 case OV_7740: {
00104
00105 reg_conf = OV7740_VGA_YUV422;
00106
00107 switch(width) {
00108 case 640:
00109 TRACE_INFO(" VGA 640 x 480\n\r");
00110 reg_conf = OV7740_VGA_YUV422;
00111 break;
00112
00113 case 352:
00114 TRACE_INFO(" VGA 640 x 480\n\r");
00115 reg_conf = OV7740_CIF_YUV422;
00116 break;
00117
00118 case 320:
00119 TRACE_INFO(" QVGA 320 x 240\n\r");
00120 reg_conf = OV7740_QVGA_YUV422;
00121 break;
00122
00123 case 160:
00124 TRACE_INFO(" QVGA 320 x 240\n\r");
00125 reg_conf = OV7740_QQVGA_YUV422;
00126 break;
00127
00128 default:
00129 TRACE_DEBUG("ov7740_configure problem\n\r");
00130 break;
00131 }
00132 break;
00133 }
00134 case OV_9740: {
00135
00136 reg_conf = ov9740_yuv_vga;
00137
00138 switch(width) {
00139 case 640:
00140 TRACE_INFO(" VGA 640 x 360\n\r");
00141 reg_conf = ov9740_yuv_vga;
00142 break;
00143 case 1280:
00144 TRACE_INFO(" VGA 1280 x 720\n\r");
00145 reg_conf = ov9740_yuv_sxga;
00146 break;
00147 default:
00148 TRACE_DEBUG("ov9740_configure problem\n\r");
00149 break;
00150 }
00151 break;
00152 }
00153 case OV_2643: {
00154
00155 reg_conf = ov2643_yuv_vga;
00156
00157 switch(width) {
00158 case 1600:
00159 TRACE_INFO(" UXGA 1600 x 1200 \n\r");
00160 reg_conf = ov2643_yuv_uxga;
00161 break;
00162 case 800:
00163 TRACE_INFO("SWVGA 800 x 600\n\r");
00164 reg_conf = ov2643_yuv_swvga;
00165 break;
00166 case 640:
00167 TRACE_INFO(" VGA 640 x 480\n\r");
00168 reg_conf = ov2643_yuv_vga;
00169 break;
00170 default:
00171 TRACE_DEBUG("ov2643_configure problem\n\r");
00172 break;
00173 }
00174 break;
00175 }
00176 case OV_5640: {
00177
00178 reg_conf = ov5640_yuv_vga;
00179
00180 switch(width) {
00181 case 640:
00182 TRACE_INFO(" VGA 640 x 480\n\r");
00183 reg_conf = ov5640_yuv_vga;
00184 break;
00185 case 1280:
00186 TRACE_INFO(" SXGA 1280 x 720\n\r");
00187 reg_conf = ov5640_yuv_sxga;
00188 break;
00189 default:
00190 TRACE_DEBUG("ov5640_configure problem\n\r");
00191 break;
00192 }
00193 break;
00194 }
00195 }
00196 if ((ovType == OV_5640) || (ovType == OV_9740))
00197 ov_write_regs16(pTwid, reg_conf);
00198 else
00199 ov_write_regs8(pTwid, reg_conf);
00200 }
00201
00202
00203
00204
00205 void ov_5640Afc_Firmware(Twid *pTwid)
00206 {
00207 const struct ov_reg *reg_conf;
00208 reg_conf = ov5640_afc;
00209 ov_write_regs16(pTwid, reg_conf);
00210 }