import PULS_20180308
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / imgsensor / src / mt8127 / ov56702nd_mipi_raw / ov56702ndmipi_Sensor.c
1 /*****************************************************************************
2 *
3 * Filename:
4 * ---------
5 * OV56702NDmipi_Sensor.c
6 *
7 * Project:
8 * --------
9 * ALPS
10 *
11 * Description:
12 * ------------
13 * Source code of Sensor driver
14 *
15 *
16 *------------------------------------------------------------------------------
17 * Upper this line, this part is controlled by CC/CQ. DO NOT MODIFY!!
18 *============================================================================
19 ****************************************************************************/
20
21 #include <linux/videodev2.h>
22 #include <linux/i2c.h>
23 #include <linux/platform_device.h>
24 #include <linux/delay.h>
25 #include <linux/cdev.h>
26 #include <linux/uaccess.h>
27 #include <linux/fs.h>
28 #include <asm/atomic.h>
29 #include <linux/xlog.h>
30 #include <asm/system.h>
31
32 #include "kd_camera_hw.h"
33 #include "kd_imgsensor.h"
34 #include "kd_imgsensor_define.h"
35 #include "kd_imgsensor_errcode.h"
36
37 #include "ov56702ndmipi_Sensor.h"
38
39 #include "ov56702ndmipiraw_Camera_Sensor_para.h"
40 #include "ov56702ndmipiraw_CameraCustomized.h"
41 static DEFINE_SPINLOCK(ov56702ndmipiraw_drv_lock);
42 static int module_id = 0;
43
44 #define OV56702ND_DEBUG
45 #ifdef OV56702ND_DEBUG
46 #define OV56702NDDB(fmt, arg...) xlog_printk(ANDROID_LOG_DEBUG, "[OV56702NDRaw] ", fmt, ##arg)
47 #else
48 #define OV56702NDDB(fmt, arg...)
49 #endif
50
51
52 kal_uint32 OV56702ND_FeatureControl_PERIOD_PixelNum=OV56702ND_PV_PERIOD_PIXEL_NUMS;
53 kal_uint32 OV56702ND_FeatureControl_PERIOD_LineNum=OV56702ND_PV_PERIOD_LINE_NUMS;
54
55 UINT16 OV56702ND_VIDEO_MODE_TARGET_FPS = 30;
56
57 MSDK_SCENARIO_ID_ENUM OV56702NDCurrentScenarioId = MSDK_SCENARIO_ID_CAMERA_PREVIEW;
58 MSDK_SENSOR_CONFIG_STRUCT OV56702NDSensorConfigData;
59 static OV56702ND_PARA_STRUCT OV56702ND;
60 kal_uint32 OV56702ND_FAC_SENSOR_REG;
61
62
63 SENSOR_REG_STRUCT OV56702NDSensorCCT[]=CAMERA_SENSOR_CCT_DEFAULT_VALUE;
64 SENSOR_REG_STRUCT OV56702NDSensorReg[ENGINEER_END]=CAMERA_SENSOR_REG_DEFAULT_VALUE;
65
66
67 #define OV56702ND_TEST_PATTERN_CHECKSUM 0xca3667da //0x5d8082f0 //0x75bef806 //0xa2230d9f //0xf5e2f1ce
68 kal_bool OV56702ND_During_testpattern = KAL_FALSE;
69
70 extern int iReadReg(u16 a_u2Addr , u8 * a_puBuff , u16 i2cId);
71 extern int iWriteReg(u16 a_u2Addr , u32 a_u4Data , u32 a_u4Bytes , u16 i2cId);
72
73 #define OV56702ND_write_cmos_sensor(addr, para) iWriteReg((u16) addr , (u32) para , 1, OV56702NDMIPI_WRITE_ID)
74
75 kal_uint16 OV56702ND_read_cmos_sensor(kal_uint32 addr)
76 {
77 kal_uint16 get_byte=0;
78 iReadReg((u16) addr ,(u8*)&get_byte,OV56702NDMIPI_WRITE_ID);
79 return get_byte;
80 }
81
82
83 void OV56702ND_Init_Para(void)
84 {
85
86 spin_lock(&ov56702ndmipiraw_drv_lock);
87 OV56702ND.sensorMode = SENSOR_MODE_INIT;
88 OV56702ND.OV56702NDAutoFlickerMode = KAL_FALSE;
89 OV56702ND.OV56702NDVideoMode = KAL_FALSE;
90 OV56702ND.DummyLines= 0;
91 OV56702ND.DummyPixels= 0;
92 OV56702ND.pvPclk = (10285);
93 OV56702ND.videoPclk = (10285);
94 OV56702ND.capPclk = (10285);
95
96 OV56702ND.shutter = 0x4C00;
97 OV56702ND.ispBaseGain = BASEGAIN;
98 OV56702ND.sensorGlobalGain = 0x0200;
99 spin_unlock(&ov56702ndmipiraw_drv_lock);
100 }
101
102 #define RG_Ratio_Typical 264
103 #define BG_Ratio_Typical 236
104
105 struct otp_struct {
106 int flag; // bit[7]: info, bit[6]:wb
107 int module_integrator_id;
108 int lens_id;
109 int production_year;
110 int production_month;
111 int production_day;
112 int rg_ratio;
113 int bg_ratio;
114 };
115
116
117 static void otp_i2c_write( uint32_t addr, kal_uint16 data)
118 {
119 OV56702ND_write_cmos_sensor(addr, data);
120 }
121
122 static kal_uint16 otp_i2c_read(uint32_t addr)
123
124 {
125 return OV56702ND_read_cmos_sensor(addr);
126 }
127
128
129 // return value:
130 // bit[7]: 0 no otp info, 1 valid otp info
131 // bit[6]: 0 no otp wb, 1 valib otp wb
132 static int read_otp(struct otp_struct *otp_ptr)
133 {
134 int otp_flag, addr, temp, i;
135 //set 0x5002[3] to “0”
136 int temp1;
137
138 temp1 = otp_i2c_read(0x5002);
139 otp_i2c_write(0x5002, (0x00 & 0x08) | (temp1 & (~0x08)));
140
141 // read OTP into buffer
142 otp_i2c_write(0x3d84, 0xC0);
143 otp_i2c_write(0x3d88, 0x70); // OTP start address
144 otp_i2c_write(0x3d89, 0x10);
145 otp_i2c_write(0x3d8A, 0x70); // OTP end address
146 otp_i2c_write(0x3d8B, 0x29);
147 otp_i2c_write(0x3d81, 0x01); // load otp into buffer
148 mdelay(5);
149
150 // OTP into
151 otp_flag = otp_i2c_read(0x7010);
152 addr = 0;
153
154 if((otp_flag & 0xc0) == 0x40) {
155 addr = 0x7011; // base address of info group 1
156 } else if((otp_flag & 0x30) == 0x10) {
157 addr = 0x7016; // base address of info group 2
158 }else if((otp_flag & 0x0c) == 0x04) {
159 addr = 0x701b; // base address of info group 3
160 }
161
162 if(addr != 0) {
163 (*otp_ptr).flag = 0x80; // valid base info in OTP
164 (*otp_ptr).module_integrator_id = otp_i2c_read( addr );
165 (*otp_ptr).lens_id = otp_i2c_read( addr + 1);
166 (*otp_ptr).production_year = otp_i2c_read( addr + 2);
167 (*otp_ptr).production_month = otp_i2c_read( addr + 3);
168 (*otp_ptr).production_day = otp_i2c_read( addr + 4);
169 } else {
170 (*otp_ptr).flag = 0x00; // not info in OTP
171 (*otp_ptr).module_integrator_id = 0;
172 (*otp_ptr).lens_id = 0;
173 (*otp_ptr).production_year = 0;
174 (*otp_ptr).production_month = 0;
175 (*otp_ptr).production_day = 0;
176 }
177
178 module_id = (*otp_ptr).module_integrator_id;
179 // OTP WB Calibration
180 otp_flag = otp_i2c_read(0x7020);
181 addr = 0;
182
183 if((otp_flag & 0xc0) == 0x40) {
184 addr = 0x7021; // base address of WB Calibration group 1
185 }else if((otp_flag & 0x30) == 0x10) {
186 addr = 0x7024; // base address of WB Calibration group 2
187 }else if((otp_flag & 0x0c) == 0x04) {
188 addr = 0x7027; // base address of WB Calibration group 3
189 }
190
191 if(addr != 0) {
192 (*otp_ptr).flag |= 0x40;
193 temp = otp_i2c_read( addr + 2);
194 (*otp_ptr).rg_ratio = (otp_i2c_read(addr)<<2) + ((temp>>6) & 0x03);
195 (*otp_ptr).bg_ratio = (otp_i2c_read( addr + 1)<<2) + ((temp>>4) & 0x03);
196 }else {
197 (*otp_ptr).rg_ratio = 0;
198 (*otp_ptr).bg_ratio = 0;
199 }
200
201 for(i=0x7010;i<=0x7029;i++) {
202 otp_i2c_write(i,0); // clear OTP buffer, recommended use continuous write to accelarate
203 }
204
205 //set 0x5002[3] to “1”
206 temp1 = otp_i2c_read(0x5002);
207 otp_i2c_write(0x5002, (0x02 & 0x08) | (temp1 & (~0x08)));
208 return (*otp_ptr).flag ;
209 }
210
211 static int apply_otp(struct otp_struct *otp_ptr)
212 {
213 int rg, bg, R_gain, G_gain, B_gain, Base_gain;
214
215 // apply OTP WB Calibration
216 if ((*otp_ptr).flag & 0x40) {
217 rg = (*otp_ptr). rg_ratio;
218 bg = (*otp_ptr).bg_ratio;
219 //calculate G gain
220 R_gain = (RG_Ratio_Typical*1000) / rg;
221 B_gain = (BG_Ratio_Typical*1000) / bg;
222 G_gain = 1000;
223
224 if (R_gain < 1000 || B_gain < 1000)
225 {
226 if (R_gain < B_gain)
227 Base_gain = R_gain;
228 else
229 Base_gain = B_gain;
230 }
231 else
232 {
233 Base_gain = G_gain;
234 }
235
236 R_gain = 0x400 * R_gain / (Base_gain);
237 B_gain = 0x400 * B_gain / (Base_gain);
238 G_gain = 0x400 * G_gain / (Base_gain);
239 // update sensor WB gain
240 if (R_gain>0x400) {
241 otp_i2c_write(0x5032, R_gain>>8);
242 otp_i2c_write(0x5033, R_gain & 0x00ff);
243 }
244 if (G_gain>0x400) {
245 otp_i2c_write(0x5034, G_gain>>8);
246 otp_i2c_write(0x5035, G_gain & 0x00ff);
247 }
248 if (B_gain>0x400) {
249 otp_i2c_write(0x5036, B_gain>>8);
250 otp_i2c_write(0x5037, B_gain & 0x00ff);
251 }
252 }
253 return (*otp_ptr).flag ;
254 }
255
256 void ov56702nd_otp_config()
257 {
258 struct otp_struct otp_info ;
259
260 read_otp(&otp_info);
261 apply_otp(&otp_info) ;
262 }
263 kal_uint32 GetOV56702NDLineLength(void)
264 {
265 kal_uint32 OV56702ND_line_length = 0;
266 if ( SENSOR_MODE_PREVIEW == OV56702ND.sensorMode )
267 {
268 OV56702ND_line_length = OV56702ND_PV_PERIOD_PIXEL_NUMS + OV56702ND.DummyPixels;
269 }
270 else if( SENSOR_MODE_VIDEO == OV56702ND.sensorMode )
271 {
272 OV56702ND_line_length = OV56702ND_VIDEO_PERIOD_PIXEL_NUMS + OV56702ND.DummyPixels;
273 }
274 else
275 {
276 OV56702ND_line_length = OV56702ND_FULL_PERIOD_PIXEL_NUMS + OV56702ND.DummyPixels;
277 }
278
279 return OV56702ND_line_length;
280
281 }
282
283
284 kal_uint32 GetOV56702NDFrameLength(void)
285 {
286 kal_uint32 OV56702ND_frame_length = 0;
287
288 if ( SENSOR_MODE_PREVIEW == OV56702ND.sensorMode )
289 {
290 OV56702ND_frame_length = OV56702ND_PV_PERIOD_LINE_NUMS + OV56702ND.DummyLines ;
291 }
292 else if( SENSOR_MODE_VIDEO == OV56702ND.sensorMode )
293 {
294 OV56702ND_frame_length = OV56702ND_VIDEO_PERIOD_LINE_NUMS + OV56702ND.DummyLines ;
295 }
296 else
297 {
298 OV56702ND_frame_length = OV56702ND_FULL_PERIOD_LINE_NUMS + OV56702ND.DummyLines ;
299 }
300
301 return OV56702ND_frame_length;
302 }
303
304
305 kal_uint32 OV56702ND_CalcExtra_For_ShutterMargin(kal_uint32 shutter_value,kal_uint32 shutterLimitation)
306 {
307 kal_uint32 extra_lines = 0;
308
309
310 if (shutter_value <4 ){
311 shutter_value = 4;
312 }
313
314
315 if (shutter_value > shutterLimitation)
316 {
317 extra_lines = shutter_value - shutterLimitation;
318 }
319 else
320 extra_lines = 0;
321
322 return extra_lines;
323
324 }
325
326
327 kal_uint32 OV56702ND_CalcFrameLength_For_AutoFlicker(void)
328 {
329
330 kal_uint32 AutoFlicker_min_framelength = 0;
331
332 switch(OV56702NDCurrentScenarioId)
333 {
334 case MSDK_SCENARIO_ID_CAMERA_ZSD:
335 case MSDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG:
336 AutoFlicker_min_framelength = (OV56702ND.capPclk*10000) /(OV56702ND_FULL_PERIOD_PIXEL_NUMS + OV56702ND.DummyPixels)/OV56702ND_AUTOFLICKER_OFFSET_25*10 ;
337 break;
338 case MSDK_SCENARIO_ID_VIDEO_PREVIEW:
339 if(OV56702ND_VIDEO_MODE_TARGET_FPS==30)
340 {
341 AutoFlicker_min_framelength = (OV56702ND.videoPclk*10000) /(OV56702ND_VIDEO_PERIOD_PIXEL_NUMS + OV56702ND.DummyPixels)/OV56702ND_AUTOFLICKER_OFFSET_30*10 ;
342 }
343 else if(OV56702ND_VIDEO_MODE_TARGET_FPS==15)
344 {
345 AutoFlicker_min_framelength = (OV56702ND.videoPclk*10000) /(OV56702ND_VIDEO_PERIOD_PIXEL_NUMS + OV56702ND.DummyPixels)/OV56702ND_AUTOFLICKER_OFFSET_15*10 ;
346 }
347 else
348 {
349 AutoFlicker_min_framelength = OV56702ND_VIDEO_PERIOD_LINE_NUMS + OV56702ND.DummyLines;
350 }
351 break;
352
353 case MSDK_SCENARIO_ID_CAMERA_PREVIEW:
354 default:
355 AutoFlicker_min_framelength = (OV56702ND.pvPclk*10000) /(OV56702ND_PV_PERIOD_PIXEL_NUMS + OV56702ND.DummyPixels)/OV56702ND_AUTOFLICKER_OFFSET_30*10 ;
356 break;
357 }
358
359 OV56702NDDB("AutoFlicker_min_framelength =%d,OV56702NDCurrentScenarioId =%d\n", AutoFlicker_min_framelength,OV56702NDCurrentScenarioId);
360
361 return AutoFlicker_min_framelength;
362
363 }
364
365
366 void OV56702ND_write_shutter(kal_uint32 shutter)
367 {
368 kal_uint32 min_framelength = OV56702ND_PV_PERIOD_PIXEL_NUMS, max_shutter=0;
369 kal_uint32 line_length = 0;
370 kal_uint32 frame_length = 0;
371 unsigned long flags;
372
373 //for test
374 //shutter = 0x7fc; //issue
375
376
377 line_length = GetOV56702NDLineLength();
378 frame_length = GetOV56702NDFrameLength();
379
380 max_shutter = frame_length-OV56702ND_SHUTTER_MARGIN;
381
382 frame_length = frame_length + OV56702ND_CalcExtra_For_ShutterMargin(shutter,max_shutter);
383
384
385
386 if(OV56702ND.OV56702NDAutoFlickerMode == KAL_TRUE)
387 {
388 min_framelength = OV56702ND_CalcFrameLength_For_AutoFlicker();
389
390 if(frame_length < min_framelength)
391 frame_length = min_framelength;
392 }
393
394
395 spin_lock_irqsave(&ov56702ndmipiraw_drv_lock,flags);
396 OV56702ND_FeatureControl_PERIOD_PixelNum = line_length;
397 OV56702ND_FeatureControl_PERIOD_LineNum = frame_length;
398 spin_unlock_irqrestore(&ov56702ndmipiraw_drv_lock,flags);
399
400 //Set total frame length //VTS
401 OV56702ND_write_cmos_sensor(0x380e, (frame_length >> 8) & 0xFF);
402 OV56702ND_write_cmos_sensor(0x380f, frame_length & 0xFF);
403
404 //Set shutter
405 OV56702ND_write_cmos_sensor(0x3500, (shutter>>12) & 0x0F);
406 OV56702ND_write_cmos_sensor(0x3501, (shutter>>4) & 0xFF);
407 OV56702ND_write_cmos_sensor(0x3502, (shutter<<4) & 0xF0); /* Don't use the fraction part. */
408
409 OV56702NDDB("ov56702nd write shutter=%x, line_length=%x, frame_length=%x\n", shutter, line_length, frame_length);
410
411 }
412
413
414 static kal_uint16 OV56702NDReg2Gain(const kal_uint16 iReg)
415 {
416 kal_uint16 iGain =0;
417
418 iGain = iReg*BASEGAIN/OV56702ND_GAIN_BASE;
419 return iGain;
420
421 }
422
423 static kal_uint16 OV56702NDGain2Reg(const kal_uint16 Gain)
424 {
425 kal_uint32 iReg = 0x0000;
426 kal_uint32 TempGain = BASEGAIN;
427
428
429 TempGain = Gain;
430 if(TempGain < BASEGAIN){
431 TempGain = BASEGAIN;
432 //OV56702NDDB("###ov56702nd write gain underflow### Gain =%x\n", Gain);
433 }
434 if(TempGain > 16*BASEGAIN){
435 TempGain = 16*BASEGAIN;
436 //OV56702NDDB("###ov56702nd write gain overflow### Gain =%x\n", Gain);
437 }
438
439 iReg = (TempGain*OV56702ND_GAIN_BASE)/BASEGAIN;
440
441 //iReg = ((TempGain /BASEGAIN)<<7)+((TempGain % BASEGAIN)<<7/BASEGAIN);
442 iReg = iReg & 0xFFFF;
443
444 //OV56702NDDB("###ov56702nd write Reg ### iReg =%x\n", iReg);
445
446 return iReg;
447
448 }
449
450 void write_OV56702ND_gain(kal_uint16 gain)
451 {
452 kal_uint16 iGain =1;
453 kal_uint8 ChangeFlag=0x01;
454
455 kal_uint16 read_gain;
456
457 iGain=(gain / OV56702ND_GAIN_BASE);
458
459 if(iGain<2){
460 ChangeFlag= 0x00;
461 }
462 else if(iGain<4){
463 ChangeFlag= 0x01;
464 }
465 else if(iGain<8){
466 ChangeFlag= 0x03;
467 }
468 else{
469 ChangeFlag= 0x07;
470 }
471
472 //ChangeFlag= 0x07;
473
474 OV56702ND_write_cmos_sensor(0x301d, 0xf0);
475 OV56702ND_write_cmos_sensor(0x3209, 0x00);
476 OV56702ND_write_cmos_sensor(0x320a, 0x01);
477
478 //group write hold
479 //group 0:delay 0x366a for one frame,then active with gain
480 OV56702ND_write_cmos_sensor(0x3208, 0x00);
481 OV56702ND_write_cmos_sensor(0x366a, ChangeFlag);
482 OV56702ND_write_cmos_sensor(0x3208, 0x10);
483
484 //group 1:all other registers( gain)
485 OV56702ND_write_cmos_sensor(0x3208, 0x01);
486 OV56702ND_write_cmos_sensor(0x3508,(gain>>8));
487 OV56702ND_write_cmos_sensor(0x3509,(gain&0xff));
488
489 OV56702ND_write_cmos_sensor(0x3208, 0x11);
490
491 //group lanch
492 OV56702ND_write_cmos_sensor(0x320B, 0x15);
493 OV56702ND_write_cmos_sensor(0x3208, 0xA1);
494
495 //read_gain=(((OV56702ND_read_cmos_sensor(0x3508)&0x1F) << 8) | OV56702ND_read_cmos_sensor(0x3509));
496 //OV56702NDDB("[OV56702ND_SetGain]0x3508|0x3509=0x%x \n",read_gain);
497 //OV56702NDDB("[OV56702ND_SetGain]0x366a=%d \n",(OV56702ND_read_cmos_sensor(0x366a)));
498
499 return;
500
501 }
502
503 void OV56702ND_SetGain(UINT16 iGain)
504 {
505 unsigned long flags;
506 spin_lock_irqsave(&ov56702ndmipiraw_drv_lock,flags);
507
508 OV56702NDDB("OV56702ND_SetGain iGain = %d :\n ",iGain);
509
510 OV56702ND.realGain = iGain;
511 OV56702ND.sensorGlobalGain = OV56702NDGain2Reg(iGain);
512 spin_unlock_irqrestore(&ov56702ndmipiraw_drv_lock,flags);
513
514 write_OV56702ND_gain(OV56702ND.sensorGlobalGain);
515 OV56702NDDB(" [OV56702ND_SetGain]OV56702ND.sensorGlobalGain=0x%x,OV56702ND.realGain =%d",OV56702ND.sensorGlobalGain,
516 OV56702ND.realGain);
517
518 //temperature test
519 //OV56702ND_write_cmos_sensor(0x4d12,0x01);
520 //OV56702NDDB("Temperature read_reg 0x4d13 =%x \n",OV56702ND_read_cmos_sensor(0x4d13));
521 }
522
523 kal_uint16 read_OV56702ND_gain(void)
524 {
525 kal_uint16 read_gain=0;
526
527 read_gain=(((OV56702ND_read_cmos_sensor(0x3508)&0x1F) << 8) | OV56702ND_read_cmos_sensor(0x3509));
528
529 spin_lock(&ov56702ndmipiraw_drv_lock);
530 OV56702ND.sensorGlobalGain = read_gain;
531 OV56702ND.realGain = OV56702NDReg2Gain(OV56702ND.sensorGlobalGain);
532 spin_unlock(&ov56702ndmipiraw_drv_lock);
533
534 OV56702NDDB("OV56702ND.sensorGlobalGain=0x%x,OV56702ND.realGain=%d\n",OV56702ND.sensorGlobalGain,OV56702ND.realGain);
535
536 return OV56702ND.sensorGlobalGain;
537 }
538
539
540 #if 1
541 void OV56702ND_camera_para_to_sensor(void)
542 {
543 kal_uint32 i;
544 for(i=0; 0xFFFFFFFF!=OV56702NDSensorReg[i].Addr; i++)
545 {
546 OV56702ND_write_cmos_sensor(OV56702NDSensorReg[i].Addr, OV56702NDSensorReg[i].Para);
547 }
548 for(i=ENGINEER_START_ADDR; 0xFFFFFFFF!=OV56702NDSensorReg[i].Addr; i++)
549 {
550 OV56702ND_write_cmos_sensor(OV56702NDSensorReg[i].Addr, OV56702NDSensorReg[i].Para);
551 }
552 for(i=FACTORY_START_ADDR; i<FACTORY_END_ADDR; i++)
553 {
554 OV56702ND_write_cmos_sensor(OV56702NDSensorCCT[i].Addr, OV56702NDSensorCCT[i].Para);
555 }
556 }
557
558 void OV56702ND_sensor_to_camera_para(void)
559 {
560 kal_uint32 i, temp_data;
561 for(i=0; 0xFFFFFFFF!=OV56702NDSensorReg[i].Addr; i++)
562 {
563 temp_data = OV56702ND_read_cmos_sensor(OV56702NDSensorReg[i].Addr);
564 spin_lock(&ov56702ndmipiraw_drv_lock);
565 OV56702NDSensorReg[i].Para =temp_data;
566 spin_unlock(&ov56702ndmipiraw_drv_lock);
567 }
568 for(i=ENGINEER_START_ADDR; 0xFFFFFFFF!=OV56702NDSensorReg[i].Addr; i++)
569 {
570 temp_data = OV56702ND_read_cmos_sensor(OV56702NDSensorReg[i].Addr);
571 spin_lock(&ov56702ndmipiraw_drv_lock);
572 OV56702NDSensorReg[i].Para = temp_data;
573 spin_unlock(&ov56702ndmipiraw_drv_lock);
574 }
575 }
576
577 kal_int32 OV56702ND_get_sensor_group_count(void)
578 {
579 return GROUP_TOTAL_NUMS;
580 }
581
582 void OV56702ND_get_sensor_group_info(kal_uint16 group_idx, kal_int8* group_name_ptr, kal_int32* item_count_ptr)
583 {
584 switch (group_idx)
585 {
586 case PRE_GAIN:
587 sprintf((char *)group_name_ptr, "CCT");
588 *item_count_ptr = 2;
589 break;
590 case CMMCLK_CURRENT:
591 sprintf((char *)group_name_ptr, "CMMCLK Current");
592 *item_count_ptr = 1;
593 break;
594 case FRAME_RATE_LIMITATION:
595 sprintf((char *)group_name_ptr, "Frame Rate Limitation");
596 *item_count_ptr = 2;
597 break;
598 case REGISTER_EDITOR:
599 sprintf((char *)group_name_ptr, "Register Editor");
600 *item_count_ptr = 2;
601 break;
602 default:
603 ASSERT(0);
604 }
605 }
606
607 void OV56702ND_get_sensor_item_info(kal_uint16 group_idx,kal_uint16 item_idx, MSDK_SENSOR_ITEM_INFO_STRUCT* info_ptr)
608 {
609 kal_int16 temp_reg=0;
610 kal_uint16 temp_gain=0, temp_addr=0, temp_para=0;
611
612 switch (group_idx)
613 {
614 case PRE_GAIN:
615 switch (item_idx)
616 {
617 case 0:
618 sprintf((char *)info_ptr->ItemNamePtr,"Pregain-R");
619 temp_addr = PRE_GAIN_R_INDEX;
620 break;
621 case 1:
622 sprintf((char *)info_ptr->ItemNamePtr,"Pregain-Gr");
623 temp_addr = PRE_GAIN_Gr_INDEX;
624 break;
625 case 2:
626 sprintf((char *)info_ptr->ItemNamePtr,"Pregain-Gb");
627 temp_addr = PRE_GAIN_Gb_INDEX;
628 break;
629 case 3:
630 sprintf((char *)info_ptr->ItemNamePtr,"Pregain-B");
631 temp_addr = PRE_GAIN_B_INDEX;
632 break;
633 case 4:
634 sprintf((char *)info_ptr->ItemNamePtr,"SENSOR_BASEGAIN");
635 temp_addr = SENSOR_BASEGAIN;
636 break;
637 default:
638 ASSERT(0);
639 }
640
641 temp_para= OV56702NDSensorCCT[temp_addr].Para;
642 //temp_gain= (temp_para/OV56702ND.sensorBaseGain) * 1000;
643
644 info_ptr->ItemValue=temp_gain;
645 info_ptr->IsTrueFalse=KAL_FALSE;
646 info_ptr->IsReadOnly=KAL_FALSE;
647 info_ptr->IsNeedRestart=KAL_FALSE;
648 info_ptr->Min= OV56702ND_MIN_ANALOG_GAIN * 1000;
649 info_ptr->Max= OV56702ND_MAX_ANALOG_GAIN * 1000;
650 break;
651 case CMMCLK_CURRENT:
652 switch (item_idx)
653 {
654 case 0:
655 sprintf((char *)info_ptr->ItemNamePtr,"Drv Cur[2,4,6,8]mA");
656
657 //temp_reg=MT9P017SensorReg[CMMCLK_CURRENT_INDEX].Para;
658 temp_reg = ISP_DRIVING_2MA;
659 if(temp_reg==ISP_DRIVING_2MA)
660 {
661 info_ptr->ItemValue=2;
662 }
663 else if(temp_reg==ISP_DRIVING_4MA)
664 {
665 info_ptr->ItemValue=4;
666 }
667 else if(temp_reg==ISP_DRIVING_6MA)
668 {
669 info_ptr->ItemValue=6;
670 }
671 else if(temp_reg==ISP_DRIVING_8MA)
672 {
673 info_ptr->ItemValue=8;
674 }
675
676 info_ptr->IsTrueFalse=KAL_FALSE;
677 info_ptr->IsReadOnly=KAL_FALSE;
678 info_ptr->IsNeedRestart=KAL_TRUE;
679 info_ptr->Min=2;
680 info_ptr->Max=8;
681 break;
682 default:
683 ASSERT(0);
684 }
685 break;
686 case FRAME_RATE_LIMITATION:
687 switch (item_idx)
688 {
689 case 0:
690 sprintf((char *)info_ptr->ItemNamePtr,"Max Exposure Lines");
691 info_ptr->ItemValue= 111;
692 info_ptr->IsTrueFalse=KAL_FALSE;
693 info_ptr->IsReadOnly=KAL_TRUE;
694 info_ptr->IsNeedRestart=KAL_FALSE;
695 info_ptr->Min=0;
696 info_ptr->Max=0;
697 break;
698 case 1:
699 sprintf((char *)info_ptr->ItemNamePtr,"Min Frame Rate");
700 info_ptr->ItemValue=12;
701 info_ptr->IsTrueFalse=KAL_FALSE;
702 info_ptr->IsReadOnly=KAL_TRUE;
703 info_ptr->IsNeedRestart=KAL_FALSE;
704 info_ptr->Min=0;
705 info_ptr->Max=0;
706 break;
707 default:
708 ASSERT(0);
709 }
710 break;
711 case REGISTER_EDITOR:
712 switch (item_idx)
713 {
714 case 0:
715 sprintf((char *)info_ptr->ItemNamePtr,"REG Addr.");
716 info_ptr->ItemValue=0;
717 info_ptr->IsTrueFalse=KAL_FALSE;
718 info_ptr->IsReadOnly=KAL_FALSE;
719 info_ptr->IsNeedRestart=KAL_FALSE;
720 info_ptr->Min=0;
721 info_ptr->Max=0xFFFF;
722 break;
723 case 1:
724 sprintf((char *)info_ptr->ItemNamePtr,"REG Value");
725 info_ptr->ItemValue=0;
726 info_ptr->IsTrueFalse=KAL_FALSE;
727 info_ptr->IsReadOnly=KAL_FALSE;
728 info_ptr->IsNeedRestart=KAL_FALSE;
729 info_ptr->Min=0;
730 info_ptr->Max=0xFFFF;
731 break;
732 default:
733 ASSERT(0);
734 }
735 break;
736 default:
737 ASSERT(0);
738 }
739 }
740
741
742
743 kal_bool OV56702ND_set_sensor_item_info(kal_uint16 group_idx, kal_uint16 item_idx, kal_int32 ItemValue)
744 {
745 kal_uint16 temp_gain=0,temp_addr=0, temp_para=0;
746
747 switch (group_idx)
748 {
749 case PRE_GAIN:
750 switch (item_idx)
751 {
752 case 0:
753 temp_addr = PRE_GAIN_R_INDEX;
754 break;
755 case 1:
756 temp_addr = PRE_GAIN_Gr_INDEX;
757 break;
758 case 2:
759 temp_addr = PRE_GAIN_Gb_INDEX;
760 break;
761 case 3:
762 temp_addr = PRE_GAIN_B_INDEX;
763 break;
764 case 4:
765 temp_addr = SENSOR_BASEGAIN;
766 break;
767 default:
768 ASSERT(0);
769 }
770
771 temp_gain=((ItemValue*BASEGAIN+500)/1000); //+500:get closed integer value
772
773 if(temp_gain>=1*BASEGAIN && temp_gain<=16*BASEGAIN)
774 {
775 // temp_para=(temp_gain * OV56702ND.sensorBaseGain + BASEGAIN/2)/BASEGAIN;
776 }
777 else
778 ASSERT(0);
779
780 spin_lock(&ov56702ndmipiraw_drv_lock);
781 OV56702NDSensorCCT[temp_addr].Para = temp_para;
782 spin_unlock(&ov56702ndmipiraw_drv_lock);
783 OV56702ND_write_cmos_sensor(OV56702NDSensorCCT[temp_addr].Addr,temp_para);
784
785 break;
786 case CMMCLK_CURRENT:
787 switch (item_idx)
788 {
789 case 0:
790 //no need to apply this item for driving current
791 break;
792 default:
793 ASSERT(0);
794 }
795 break;
796 case FRAME_RATE_LIMITATION:
797 ASSERT(0);
798 break;
799 case REGISTER_EDITOR:
800 switch (item_idx)
801 {
802 case 0:
803 spin_lock(&ov56702ndmipiraw_drv_lock);
804 OV56702ND_FAC_SENSOR_REG=ItemValue;
805 spin_unlock(&ov56702ndmipiraw_drv_lock);
806 break;
807 case 1:
808 OV56702ND_write_cmos_sensor(OV56702ND_FAC_SENSOR_REG,ItemValue);
809 break;
810 default:
811 ASSERT(0);
812 }
813 break;
814 default:
815 ASSERT(0);
816 }
817 return KAL_TRUE;
818 }
819 #endif
820
821
822 static void OV56702ND_SetDummy( const kal_uint32 iPixels, const kal_uint32 iLines )
823 {
824 kal_uint32 line_length = 0;
825 kal_uint32 frame_length = 0;
826
827 if ( SENSOR_MODE_PREVIEW == OV56702ND.sensorMode )
828 {
829 line_length = OV56702ND_PV_PERIOD_PIXEL_NUMS + iPixels;
830 frame_length = OV56702ND_PV_PERIOD_LINE_NUMS + iLines;
831 }
832 else if( SENSOR_MODE_VIDEO== OV56702ND.sensorMode )
833 {
834 line_length = OV56702ND_VIDEO_PERIOD_PIXEL_NUMS + iPixels;
835 frame_length = OV56702ND_VIDEO_PERIOD_LINE_NUMS + iLines;
836 }
837 else
838 {
839 line_length = OV56702ND_FULL_PERIOD_PIXEL_NUMS + iPixels;
840 frame_length = OV56702ND_FULL_PERIOD_LINE_NUMS + iLines;
841 }
842
843 spin_lock(&ov56702ndmipiraw_drv_lock);
844 OV56702ND_FeatureControl_PERIOD_PixelNum = line_length;
845 OV56702ND_FeatureControl_PERIOD_LineNum = frame_length;
846 spin_unlock(&ov56702ndmipiraw_drv_lock);
847
848 //Set total frame length
849 OV56702ND_write_cmos_sensor(0x380e, (frame_length >> 8) & 0xFF);
850 OV56702ND_write_cmos_sensor(0x380f, frame_length & 0xFF);
851 //Set total line length
852 OV56702ND_write_cmos_sensor(0x380c, (line_length >> 8) & 0xFF);
853 OV56702ND_write_cmos_sensor(0x380d, line_length & 0xFF);
854
855 }
856
857
858 void OV56702NDPreviewSetting(void)
859 {
860 OV56702NDDB(" OV56702NDPreviewSetting_2lane enter\n");
861
862 /* //
863
864 //@@PV_Quarter_size_30fps_800Mbps/lane
865 //99 1296 960
866 //;;102 3601 157c
867 //;;PCLK=HTS*VTS*fps=0x68c*0x7fd*30=1676*2045*30=102.85M
868
869 OV56702ND_write_cmos_sensor(0x0100, 0x00); //
870
871 OV56702ND_write_cmos_sensor(0x3501, 0x3d); //
872 OV56702ND_write_cmos_sensor(0x366e, 0x08); //
873 OV56702ND_write_cmos_sensor(0x370b, 0x1b); //
874 OV56702ND_write_cmos_sensor(0x3808, 0x05); //
875 OV56702ND_write_cmos_sensor(0x3809, 0x10); //
876 OV56702ND_write_cmos_sensor(0x380a, 0x03); //
877 OV56702ND_write_cmos_sensor(0x380b, 0xc0); //
878 OV56702ND_write_cmos_sensor(0x380c, 0x06); //
879 OV56702ND_write_cmos_sensor(0x380d, 0x8c); //
880 OV56702ND_write_cmos_sensor(0x380e, 0x07); //;03
881 OV56702ND_write_cmos_sensor(0x380f, 0xfd); //;e0
882 OV56702ND_write_cmos_sensor(0x3814, 0x03); //
883 OV56702ND_write_cmos_sensor(0x3820, 0x90); //
884 OV56702ND_write_cmos_sensor(0x3821, 0x47); //
885 OV56702ND_write_cmos_sensor(0x382a, 0x03); //
886 OV56702ND_write_cmos_sensor(0x4009, 0x05); //
887 OV56702ND_write_cmos_sensor(0x4502, 0x48); //
888 OV56702ND_write_cmos_sensor(0x4508, 0x55); //
889 OV56702ND_write_cmos_sensor(0x4509, 0x55); //
890 OV56702ND_write_cmos_sensor(0x4600, 0x00); //
891 OV56702ND_write_cmos_sensor(0x4601, 0x81); //
892 OV56702ND_write_cmos_sensor(0x4017, 0x10); //; threshold = 4LSB for Binning sum format.
893 OV56702ND_write_cmos_sensor(0x400a, 0x02); //;
894 OV56702ND_write_cmos_sensor(0x400b, 0x00); //;
895
896 OV56702ND_write_cmos_sensor(0x0100, 0x01); //
897 */
898
899 //@@PV_Quarter_size_30fps_800Mbps/lane_1296x972
900 //99 1296 972
901 //;;102 3601 157c
902 //;;PCLK=HTS*VTS*fps=0x68c*0x7fd*30=1676*2045*30=102.85M
903
904 OV56702ND_write_cmos_sensor(0x0100, 0x00); //
905
906 OV56702ND_write_cmos_sensor(0x3501, 0x73); //
907 OV56702ND_write_cmos_sensor(0x3502, 0x00); //
908 OV56702ND_write_cmos_sensor(0x3508, 0x01); //
909 OV56702ND_write_cmos_sensor(0x3509, 0x80); //
910 OV56702ND_write_cmos_sensor(0x366e, 0x08); //
911 OV56702ND_write_cmos_sensor(0x370b, 0x1b); //
912 OV56702ND_write_cmos_sensor(0x3808, 0x05); //
913 OV56702ND_write_cmos_sensor(0x3809, 0x10); //
914 OV56702ND_write_cmos_sensor(0x380a, 0x03); //
915 OV56702ND_write_cmos_sensor(0x380b, 0xcc); //;c0
916 OV56702ND_write_cmos_sensor(0x380c, 0x06); //
917 OV56702ND_write_cmos_sensor(0x380d, 0x8c); //
918 OV56702ND_write_cmos_sensor(0x380e, 0x07); //;03
919 OV56702ND_write_cmos_sensor(0x380f, 0xfd); //;e0
920 OV56702ND_write_cmos_sensor(0x3814, 0x03); //
921 OV56702ND_write_cmos_sensor(0x3820, 0x90); //
922 OV56702ND_write_cmos_sensor(0x3821, 0x47); //
923 OV56702ND_write_cmos_sensor(0x382a, 0x03); //
924 OV56702ND_write_cmos_sensor(0x3845, 0x02); //
925 OV56702ND_write_cmos_sensor(0x4009, 0x05); //
926 OV56702ND_write_cmos_sensor(0x4502, 0x48); //
927 OV56702ND_write_cmos_sensor(0x4508, 0x55); //
928 OV56702ND_write_cmos_sensor(0x4509, 0x55); //
929 OV56702ND_write_cmos_sensor(0x4600, 0x00); //
930 OV56702ND_write_cmos_sensor(0x4601, 0x81); //
931 OV56702ND_write_cmos_sensor(0x4017, 0x10); //; threshold = 4LSB for Binning
932 OV56702ND_write_cmos_sensor(0x400a, 0x02); //;
933 OV56702ND_write_cmos_sensor(0x400b, 0x00); //;
934
935 OV56702ND_write_cmos_sensor(0x0100, 0x01); //
936 }
937
938
939 void OV56702NDVideoSetting(void)
940 {
941 OV56702NDDB(" OV56702NDvideoSetting_2lane enter:video/preview sync\n");
942
943 OV56702NDPreviewSetting();
944 }
945
946
947
948 void OV56702NDCaptureSetting(void)
949 {
950 OV56702NDDB("OV56702NDCaptureSetting_2lane enter\n");
951
952 OV56702ND_write_cmos_sensor(0x0100, 0x00);
953
954 OV56702ND_write_cmos_sensor(0x3501, 0x5f); //long exposure
955 OV56702ND_write_cmos_sensor(0x3502, 0xd0); //long exposure
956
957 OV56702ND_write_cmos_sensor(0x3508, 0x03); //gain
958 OV56702ND_write_cmos_sensor(0x3509, 0x00); //gain
959
960 OV56702ND_write_cmos_sensor(0x366e, 0x10);
961 OV56702ND_write_cmos_sensor(0x370b, 0x1b);
962 OV56702ND_write_cmos_sensor(0x3808, 0x0a);
963 OV56702ND_write_cmos_sensor(0x3809, 0x20);
964 OV56702ND_write_cmos_sensor(0x380a, 0x07);
965 OV56702ND_write_cmos_sensor(0x380b, 0x98);
966 OV56702ND_write_cmos_sensor(0x380c, 0x07); //;06
967 OV56702ND_write_cmos_sensor(0x380d, 0xdc); //;8c
968 OV56702ND_write_cmos_sensor(0x380e, 0x07);
969 OV56702ND_write_cmos_sensor(0x380f, 0xfd);
970 OV56702ND_write_cmos_sensor(0x3814, 0x01);
971 OV56702ND_write_cmos_sensor(0x3820, 0x80);
972 OV56702ND_write_cmos_sensor(0x3821, 0x46);
973 OV56702ND_write_cmos_sensor(0x382a, 0x01);
974
975 OV56702ND_write_cmos_sensor(0x3845, 0x00); //v_offset for auto size mode
976
977 OV56702ND_write_cmos_sensor(0x4009, 0x0d);
978 OV56702ND_write_cmos_sensor(0x4502, 0x40);
979 OV56702ND_write_cmos_sensor(0x4508, 0xaa);
980 OV56702ND_write_cmos_sensor(0x4509, 0xaa);
981 OV56702ND_write_cmos_sensor(0x4600, 0x01);
982 OV56702ND_write_cmos_sensor(0x4601, 0x03);
983 OV56702ND_write_cmos_sensor(0x4017, 0x08); //threshold= 2LSB for full size
984 OV56702ND_write_cmos_sensor(0x400a, 0x02); //
985 OV56702ND_write_cmos_sensor(0x400b, 0x00); //
986
987 OV56702ND_write_cmos_sensor(0x0100, 0x01);
988
989 }
990
991
992 static void OV56702ND_Sensor_Init(void)
993 {
994 OV56702NDDB("OV56702ND_Sensor_Init_2lane enter\n");
995
996 OV56702ND_write_cmos_sensor(0x0103,0x01);// ; software reset
997 mdelay(10);
998 OV56702ND_write_cmos_sensor(0x0100, 0x00);// ; software standby
999 OV56702ND_write_cmos_sensor(0x0100, 0x00);
1000 OV56702ND_write_cmos_sensor(0x0300, 0x04);
1001 OV56702ND_write_cmos_sensor(0x0301, 0x00);
1002 OV56702ND_write_cmos_sensor(0x0302, 0x64); //;78
1003 OV56702ND_write_cmos_sensor(0x0303, 0x00);
1004 OV56702ND_write_cmos_sensor(0x0304, 0x03);
1005 OV56702ND_write_cmos_sensor(0x0305, 0x01);
1006 OV56702ND_write_cmos_sensor(0x0306, 0x01);
1007 OV56702ND_write_cmos_sensor(0x030a, 0x00);
1008 OV56702ND_write_cmos_sensor(0x030b, 0x00);
1009 OV56702ND_write_cmos_sensor(0x030c, 0x00);
1010 OV56702ND_write_cmos_sensor(0x030d, 0x1e);
1011 OV56702ND_write_cmos_sensor(0x030e, 0x00);
1012 OV56702ND_write_cmos_sensor(0x030f, 0x06);
1013 OV56702ND_write_cmos_sensor(0x0312, 0x01);
1014 OV56702ND_write_cmos_sensor(0x3000, 0x00);
1015 OV56702ND_write_cmos_sensor(0x3002, 0x21);
1016 OV56702ND_write_cmos_sensor(0x3005, 0xf0);
1017 OV56702ND_write_cmos_sensor(0x3007, 0x00);
1018 OV56702ND_write_cmos_sensor(0x3015, 0x0f);
1019 OV56702ND_write_cmos_sensor(0x3018, 0x32);
1020 OV56702ND_write_cmos_sensor(0x301a, 0xf0);
1021 OV56702ND_write_cmos_sensor(0x301b, 0xf0);
1022 OV56702ND_write_cmos_sensor(0x301c, 0xf0);
1023 OV56702ND_write_cmos_sensor(0x301d, 0xf0);
1024 OV56702ND_write_cmos_sensor(0x301e, 0xf0);
1025 OV56702ND_write_cmos_sensor(0x3030, 0x00);
1026 OV56702ND_write_cmos_sensor(0x3031, 0x0a);
1027 OV56702ND_write_cmos_sensor(0x303c, 0xff);
1028 OV56702ND_write_cmos_sensor(0x303e, 0xff);
1029 OV56702ND_write_cmos_sensor(0x3040, 0xf0);
1030 OV56702ND_write_cmos_sensor(0x3041, 0x00);
1031 OV56702ND_write_cmos_sensor(0x3042, 0xf0);
1032 OV56702ND_write_cmos_sensor(0x3106, 0x11);
1033 OV56702ND_write_cmos_sensor(0x3500, 0x00);
1034 OV56702ND_write_cmos_sensor(0x3501, 0x7b);
1035 OV56702ND_write_cmos_sensor(0x3502, 0x00);
1036 OV56702ND_write_cmos_sensor(0x3503, 0x04);
1037 OV56702ND_write_cmos_sensor(0x3504, 0x03);
1038 OV56702ND_write_cmos_sensor(0x3505, 0x83);
1039 OV56702ND_write_cmos_sensor(0x3508, 0x07);
1040 OV56702ND_write_cmos_sensor(0x3509, 0x80);
1041 OV56702ND_write_cmos_sensor(0x350e, 0x04);
1042 OV56702ND_write_cmos_sensor(0x350f, 0x00);
1043 OV56702ND_write_cmos_sensor(0x3510, 0x00);
1044 OV56702ND_write_cmos_sensor(0x3511, 0x02);
1045 OV56702ND_write_cmos_sensor(0x3512, 0x00);
1046 OV56702ND_write_cmos_sensor(0x3601, 0xc8);
1047 OV56702ND_write_cmos_sensor(0x3610, 0x88);
1048 OV56702ND_write_cmos_sensor(0x3612, 0x48);
1049 OV56702ND_write_cmos_sensor(0x3614, 0x5b);
1050 OV56702ND_write_cmos_sensor(0x3615, 0x96);
1051 OV56702ND_write_cmos_sensor(0x3621, 0xd0);
1052 OV56702ND_write_cmos_sensor(0x3622, 0x00);
1053 OV56702ND_write_cmos_sensor(0x3623, 0x00);
1054 OV56702ND_write_cmos_sensor(0x3633, 0x13);
1055 OV56702ND_write_cmos_sensor(0x3634, 0x13);
1056 OV56702ND_write_cmos_sensor(0x3635, 0x13);
1057 OV56702ND_write_cmos_sensor(0x3636, 0x13);
1058 OV56702ND_write_cmos_sensor(0x3645, 0x13);
1059 OV56702ND_write_cmos_sensor(0x3646, 0x82);
1060 OV56702ND_write_cmos_sensor(0x3650, 0x00);
1061 OV56702ND_write_cmos_sensor(0x3652, 0xff);
1062 OV56702ND_write_cmos_sensor(0x3655, 0x20);
1063 OV56702ND_write_cmos_sensor(0x3656, 0xff);
1064 OV56702ND_write_cmos_sensor(0x365a, 0xff);
1065 OV56702ND_write_cmos_sensor(0x365e, 0xff);
1066 OV56702ND_write_cmos_sensor(0x3668, 0x00);
1067 OV56702ND_write_cmos_sensor(0x366a, 0x07);
1068 OV56702ND_write_cmos_sensor(0x366e, 0x10);
1069 OV56702ND_write_cmos_sensor(0x366d, 0x00);
1070 OV56702ND_write_cmos_sensor(0x366f, 0x80);
1071 OV56702ND_write_cmos_sensor(0x3700, 0x28);
1072 OV56702ND_write_cmos_sensor(0x3701, 0x10);
1073 OV56702ND_write_cmos_sensor(0x3702, 0x3a);
1074 OV56702ND_write_cmos_sensor(0x3703, 0x19);
1075 OV56702ND_write_cmos_sensor(0x3704, 0x10);
1076 OV56702ND_write_cmos_sensor(0x3705, 0x00);
1077 OV56702ND_write_cmos_sensor(0x3706, 0x66);
1078 OV56702ND_write_cmos_sensor(0x3707, 0x08);
1079 OV56702ND_write_cmos_sensor(0x3708, 0x34);
1080 OV56702ND_write_cmos_sensor(0x3709, 0x40);
1081 OV56702ND_write_cmos_sensor(0x370a, 0x01);
1082 OV56702ND_write_cmos_sensor(0x370b, 0x1b);
1083 OV56702ND_write_cmos_sensor(0x3714, 0x24);
1084 OV56702ND_write_cmos_sensor(0x371a, 0x3e);
1085 OV56702ND_write_cmos_sensor(0x3733, 0x00);
1086 OV56702ND_write_cmos_sensor(0x3734, 0x00);
1087 OV56702ND_write_cmos_sensor(0x373a, 0x05);
1088 OV56702ND_write_cmos_sensor(0x373b, 0x06);
1089 OV56702ND_write_cmos_sensor(0x373c, 0x0a);
1090 OV56702ND_write_cmos_sensor(0x373f, 0xa0);
1091 OV56702ND_write_cmos_sensor(0x3755, 0x00);
1092 OV56702ND_write_cmos_sensor(0x3758, 0x00);
1093 OV56702ND_write_cmos_sensor(0x375b, 0x0e);
1094 OV56702ND_write_cmos_sensor(0x3766, 0x5f);
1095 OV56702ND_write_cmos_sensor(0x3768, 0x00);
1096 OV56702ND_write_cmos_sensor(0x3769, 0x22);
1097 OV56702ND_write_cmos_sensor(0x3773, 0x08);
1098 OV56702ND_write_cmos_sensor(0x3774, 0x1f);
1099 OV56702ND_write_cmos_sensor(0x3776, 0x06);
1100 OV56702ND_write_cmos_sensor(0x37a0, 0x88);
1101 OV56702ND_write_cmos_sensor(0x37a1, 0x5c);
1102 OV56702ND_write_cmos_sensor(0x37a7, 0x88);
1103 OV56702ND_write_cmos_sensor(0x37a8, 0x70);
1104 OV56702ND_write_cmos_sensor(0x37aa, 0x88);
1105 OV56702ND_write_cmos_sensor(0x37ab, 0x48);
1106 OV56702ND_write_cmos_sensor(0x37b3, 0x66);
1107 OV56702ND_write_cmos_sensor(0x37c2, 0x04);
1108 OV56702ND_write_cmos_sensor(0x37c5, 0x00);
1109 OV56702ND_write_cmos_sensor(0x37c8, 0x00);
1110 OV56702ND_write_cmos_sensor(0x3800, 0x00);
1111 OV56702ND_write_cmos_sensor(0x3801, 0x0c);
1112 OV56702ND_write_cmos_sensor(0x3802, 0x00);
1113 OV56702ND_write_cmos_sensor(0x3803, 0x04);
1114 OV56702ND_write_cmos_sensor(0x3804, 0x0a);
1115 OV56702ND_write_cmos_sensor(0x3805, 0x33);
1116 OV56702ND_write_cmos_sensor(0x3806, 0x07);
1117 OV56702ND_write_cmos_sensor(0x3807, 0xa3);
1118 OV56702ND_write_cmos_sensor(0x3808, 0x0a);
1119 OV56702ND_write_cmos_sensor(0x3809, 0x20);
1120 OV56702ND_write_cmos_sensor(0x380a, 0x07);
1121 OV56702ND_write_cmos_sensor(0x380b, 0x98);
1122 OV56702ND_write_cmos_sensor(0x380c, 0x07); // ;06
1123 OV56702ND_write_cmos_sensor(0x380d, 0xdc); // ;8c
1124 OV56702ND_write_cmos_sensor(0x380e, 0x07);
1125 OV56702ND_write_cmos_sensor(0x380f, 0xb8);
1126 OV56702ND_write_cmos_sensor(0x3811, 0x04);
1127 OV56702ND_write_cmos_sensor(0x3813, 0x02);
1128 OV56702ND_write_cmos_sensor(0x3814, 0x01);
1129 OV56702ND_write_cmos_sensor(0x3815, 0x01);
1130 OV56702ND_write_cmos_sensor(0x3816, 0x00);
1131 OV56702ND_write_cmos_sensor(0x3817, 0x00);
1132 OV56702ND_write_cmos_sensor(0x3818, 0x00);
1133 OV56702ND_write_cmos_sensor(0x3819, 0x00);
1134 OV56702ND_write_cmos_sensor(0x3820, 0x80);
1135 OV56702ND_write_cmos_sensor(0x3821, 0x46);
1136 OV56702ND_write_cmos_sensor(0x3822, 0x48);
1137 OV56702ND_write_cmos_sensor(0x3826, 0x00);
1138 OV56702ND_write_cmos_sensor(0x3827, 0x08);
1139 OV56702ND_write_cmos_sensor(0x382a, 0x01);
1140 OV56702ND_write_cmos_sensor(0x382b, 0x01);
1141 OV56702ND_write_cmos_sensor(0x3830, 0x08);
1142 OV56702ND_write_cmos_sensor(0x3836, 0x02);
1143 OV56702ND_write_cmos_sensor(0x3837, 0x00);
1144 OV56702ND_write_cmos_sensor(0x3838, 0x10);
1145 OV56702ND_write_cmos_sensor(0x3841, 0xff);
1146 OV56702ND_write_cmos_sensor(0x3846, 0x48);
1147 OV56702ND_write_cmos_sensor(0x3861, 0x00);
1148 OV56702ND_write_cmos_sensor(0x3862, 0x04);//x00);
1149 OV56702ND_write_cmos_sensor(0x3863, 0x06);//0x18);
1150 OV56702ND_write_cmos_sensor(0x3a11, 0x01);
1151 OV56702ND_write_cmos_sensor(0x3a12, 0x78);
1152 OV56702ND_write_cmos_sensor(0x3b00, 0x00);
1153 OV56702ND_write_cmos_sensor(0x3b02, 0x00);
1154 OV56702ND_write_cmos_sensor(0x3b03, 0x00);
1155 OV56702ND_write_cmos_sensor(0x3b04, 0x00);
1156 OV56702ND_write_cmos_sensor(0x3b05, 0x00);
1157 OV56702ND_write_cmos_sensor(0x3c00, 0x89);
1158 OV56702ND_write_cmos_sensor(0x3c01, 0xab);
1159 OV56702ND_write_cmos_sensor(0x3c02, 0x01);
1160 OV56702ND_write_cmos_sensor(0x3c03, 0x00);
1161 OV56702ND_write_cmos_sensor(0x3c04, 0x00);
1162 OV56702ND_write_cmos_sensor(0x3c05, 0x03);
1163 OV56702ND_write_cmos_sensor(0x3c06, 0x00);
1164 OV56702ND_write_cmos_sensor(0x3c07, 0x05);
1165 OV56702ND_write_cmos_sensor(0x3c0c, 0x00);
1166 OV56702ND_write_cmos_sensor(0x3c0d, 0x00);
1167 OV56702ND_write_cmos_sensor(0x3c0e, 0x00);
1168 OV56702ND_write_cmos_sensor(0x3c0f, 0x00);
1169 OV56702ND_write_cmos_sensor(0x3c40, 0x00);
1170 OV56702ND_write_cmos_sensor(0x3c41, 0xa3);
1171 OV56702ND_write_cmos_sensor(0x3c43, 0x7d);
1172 OV56702ND_write_cmos_sensor(0x3c45, 0xd7);
1173 OV56702ND_write_cmos_sensor(0x3c47, 0xfc);
1174 OV56702ND_write_cmos_sensor(0x3c50, 0x05);
1175 OV56702ND_write_cmos_sensor(0x3c52, 0xaa);
1176 OV56702ND_write_cmos_sensor(0x3c54, 0x71);
1177 OV56702ND_write_cmos_sensor(0x3c56, 0x80);
1178 OV56702ND_write_cmos_sensor(0x3d85, 0x17);
1179 OV56702ND_write_cmos_sensor(0x3f03, 0x00);
1180 OV56702ND_write_cmos_sensor(0x3f0a, 0x00);
1181 OV56702ND_write_cmos_sensor(0x3f0b, 0x00);
1182 OV56702ND_write_cmos_sensor(0x4001, 0x60);
1183 OV56702ND_write_cmos_sensor(0x4009, 0x0d);
1184 OV56702ND_write_cmos_sensor(0x4020, 0x00);
1185 OV56702ND_write_cmos_sensor(0x4021, 0x00);
1186 OV56702ND_write_cmos_sensor(0x4022, 0x00);
1187 OV56702ND_write_cmos_sensor(0x4023, 0x00);
1188 OV56702ND_write_cmos_sensor(0x4024, 0x00);
1189 OV56702ND_write_cmos_sensor(0x4025, 0x00);
1190 OV56702ND_write_cmos_sensor(0x4026, 0x00);
1191 OV56702ND_write_cmos_sensor(0x4027, 0x00);
1192 OV56702ND_write_cmos_sensor(0x4028, 0x00);
1193 OV56702ND_write_cmos_sensor(0x4029, 0x00);
1194 OV56702ND_write_cmos_sensor(0x402a, 0x00);
1195 OV56702ND_write_cmos_sensor(0x402b, 0x00);
1196 OV56702ND_write_cmos_sensor(0x402c, 0x00);
1197 OV56702ND_write_cmos_sensor(0x402d, 0x00);
1198 OV56702ND_write_cmos_sensor(0x402e, 0x00);
1199 OV56702ND_write_cmos_sensor(0x402f, 0x00);
1200 OV56702ND_write_cmos_sensor(0x4040, 0x00);
1201 OV56702ND_write_cmos_sensor(0x4041, 0x03);//0x00);
1202 OV56702ND_write_cmos_sensor(0x4042, 0x00);
1203 OV56702ND_write_cmos_sensor(0x4043, 0x7a);//0x80);
1204 OV56702ND_write_cmos_sensor(0x4044, 0x00);
1205 OV56702ND_write_cmos_sensor(0x4045, 0x7a);//0x80);
1206 OV56702ND_write_cmos_sensor(0x4046, 0x00);
1207 OV56702ND_write_cmos_sensor(0x4047, 0x7a);//0x80);
1208 OV56702ND_write_cmos_sensor(0x4048, 0x00);
1209 OV56702ND_write_cmos_sensor(0x4049, 0x7a);//0x80);
1210 OV56702ND_write_cmos_sensor(0x4303, 0x00);
1211 OV56702ND_write_cmos_sensor(0x4307, 0x30);
1212 OV56702ND_write_cmos_sensor(0x4500, 0x58);
1213 OV56702ND_write_cmos_sensor(0x4501, 0x04);
1214 OV56702ND_write_cmos_sensor(0x4502, 0x40);
1215 OV56702ND_write_cmos_sensor(0x4503, 0x10);
1216 OV56702ND_write_cmos_sensor(0x4508, 0xaa);
1217 OV56702ND_write_cmos_sensor(0x4509, 0xaa);
1218 OV56702ND_write_cmos_sensor(0x450a, 0x00);
1219 OV56702ND_write_cmos_sensor(0x450b, 0x00);
1220 OV56702ND_write_cmos_sensor(0x4600, 0x01);
1221 OV56702ND_write_cmos_sensor(0x4601, 0x03);
1222 OV56702ND_write_cmos_sensor(0x4700, 0xa4);
1223 OV56702ND_write_cmos_sensor(0x4800, 0x4c);
1224 OV56702ND_write_cmos_sensor(0x4816, 0x53);
1225 OV56702ND_write_cmos_sensor(0x481f, 0x40);
1226 OV56702ND_write_cmos_sensor(0x4837, 0x14); // ;11
1227 OV56702ND_write_cmos_sensor(0x5000, 0x56);//0x16);
1228 OV56702ND_write_cmos_sensor(0x5001, 0x01);
1229 OV56702ND_write_cmos_sensor(0x5002, 0x28);//0xa8);
1230 OV56702ND_write_cmos_sensor(0x5004, 0x0c);
1231 OV56702ND_write_cmos_sensor(0x5006, 0x0c);
1232 OV56702ND_write_cmos_sensor(0x5007, 0xe0);
1233 OV56702ND_write_cmos_sensor(0x5008, 0x01);
1234 OV56702ND_write_cmos_sensor(0x5009, 0xb0);
1235 OV56702ND_write_cmos_sensor(0x5901, 0x00);
1236 OV56702ND_write_cmos_sensor(0x5a01, 0x00);
1237 OV56702ND_write_cmos_sensor(0x5a03, 0x00);
1238 OV56702ND_write_cmos_sensor(0x5a04, 0x0c);
1239 OV56702ND_write_cmos_sensor(0x5a05, 0xe0);
1240 OV56702ND_write_cmos_sensor(0x5a06, 0x09);
1241 OV56702ND_write_cmos_sensor(0x5a07, 0xb0);
1242 OV56702ND_write_cmos_sensor(0x5a08, 0x06);
1243 OV56702ND_write_cmos_sensor(0x5e00, 0x00);
1244 //for BLC
1245 OV56702ND_write_cmos_sensor(0x3734, 0x40);
1246 OV56702ND_write_cmos_sensor(0x5b00, 0x01);
1247 OV56702ND_write_cmos_sensor(0x5b01, 0x10);
1248 OV56702ND_write_cmos_sensor(0x5b02, 0x01);
1249 OV56702ND_write_cmos_sensor(0x5b03, 0xdb);
1250 OV56702ND_write_cmos_sensor(0x3d8c, 0x71);
1251 OV56702ND_write_cmos_sensor(0x3d8d, 0xea);
1252 OV56702ND_write_cmos_sensor(0x4017, 0x08);
1253
1254 OV56702ND_write_cmos_sensor(0x3618, 0x2a);
1255
1256 //;Ally031414
1257 OV56702ND_write_cmos_sensor(0x3734, 0x40); // ;; Improve HFPN
1258 OV56702ND_write_cmos_sensor(0x5b00, 0x01); // ;; [2:0] otp start addr[10:8]
1259 OV56702ND_write_cmos_sensor(0x5b01, 0x10); // ;; [7:0] otp start addr[7:0]
1260 OV56702ND_write_cmos_sensor(0x5b02, 0x01); // ;; [2:0] otp end addr[10:8]
1261 OV56702ND_write_cmos_sensor(0x5b03, 0xDB); // ;; [7:0] otp end addr[7:0]
1262 OV56702ND_write_cmos_sensor(0x3d8c, 0x71); //; Header address high byte
1263 OV56702ND_write_cmos_sensor(0x3d8d, 0xEA); //; Header address low byte
1264 OV56702ND_write_cmos_sensor(0x4017, 0x08); // ; threshold= 2LSB for full size
1265
1266 //;Strong DPC1.53
1267 OV56702ND_write_cmos_sensor(0x5780, 0x3e);
1268 OV56702ND_write_cmos_sensor(0x5781, 0x0f);
1269 OV56702ND_write_cmos_sensor(0x5782, 0x44);
1270 OV56702ND_write_cmos_sensor(0x5783, 0x02);
1271 OV56702ND_write_cmos_sensor(0x5784, 0x01);
1272 OV56702ND_write_cmos_sensor(0x5785, 0x00);
1273 OV56702ND_write_cmos_sensor(0x5786, 0x00);
1274 OV56702ND_write_cmos_sensor(0x5787, 0x04);
1275 OV56702ND_write_cmos_sensor(0x5788, 0x02);
1276 OV56702ND_write_cmos_sensor(0x5789, 0x0f);
1277 OV56702ND_write_cmos_sensor(0x578a, 0xfd);
1278 OV56702ND_write_cmos_sensor(0x578b, 0xf5);
1279 OV56702ND_write_cmos_sensor(0x578c, 0xf5);
1280 OV56702ND_write_cmos_sensor(0x578d, 0x03);
1281 OV56702ND_write_cmos_sensor(0x578e, 0x08);
1282 OV56702ND_write_cmos_sensor(0x578f, 0x0c);
1283 OV56702ND_write_cmos_sensor(0x5790, 0x08);
1284 OV56702ND_write_cmos_sensor(0x5791, 0x04);
1285 OV56702ND_write_cmos_sensor(0x5792, 0x00);
1286 OV56702ND_write_cmos_sensor(0x5793, 0x52);
1287 OV56702ND_write_cmos_sensor(0x5794, 0xa3);
1288 //;Ping
1289 OV56702ND_write_cmos_sensor(0x380e, 0x07); //; fps fine adjustment
1290 OV56702ND_write_cmos_sensor(0x380f, 0xfd); //; fps fine adjustment
1291 OV56702ND_write_cmos_sensor(0x3503, 0x00); //; real gain [2] gain no delay, shutter no delay
1292 //;added
1293 OV56702ND_write_cmos_sensor(0x3d85, 0x17);
1294 OV56702ND_write_cmos_sensor(0x3655, 0x20);
1295
1296 OV56702ND_write_cmos_sensor(0x0100, 0x01); //;01
1297
1298 ov56702nd_otp_config();
1299 }
1300
1301
1302 UINT32 OV56702NDOpen(void)
1303 {
1304
1305 volatile signed int i;
1306 kal_uint16 sensor_id = 0;
1307
1308 OV56702NDDB("OV56702ND Open enter :\n ");
1309 OV56702ND_write_cmos_sensor(0x0103,0x01);// Reset sensor
1310 mdelay(2);
1311
1312 for(i=0;i<2;i++)
1313 {
1314 sensor_id = (OV56702ND_read_cmos_sensor(0x300B)<<8)|OV56702ND_read_cmos_sensor(0x300C);
1315 OV56702NDDB("OV56702ND READ ID :%x",sensor_id);
1316 if(sensor_id != OV5670MIPI_SENSOR_ID)
1317 {
1318 return ERROR_SENSOR_CONNECT_FAIL;
1319 }else
1320 break;
1321 }
1322
1323 OV56702ND_Sensor_Init();
1324 OV56702ND_Init_Para();
1325 OV56702NDDB("OV56702NDOpen exit :\n ");
1326
1327 return ERROR_NONE;
1328 }
1329
1330 void OV56702NDGetModuleID(void)
1331 {
1332 struct otp_struct otp_info ;
1333
1334 OV56702ND_write_cmos_sensor(0x0100, 0x01); //stream on
1335 read_otp(&otp_info);
1336 OV56702ND_write_cmos_sensor(0x0100, 0x00); //stream off
1337 }
1338
1339 UINT32 OV56702NDGetSensorID(UINT32 *sensorID)
1340 {
1341 int retry = 2;
1342
1343 OV56702NDDB("OV56702NDGetSensorID enter :\n ");
1344 mdelay(5);
1345
1346 do {
1347 *sensorID = (OV56702ND_read_cmos_sensor(0x300B)<<8)|OV56702ND_read_cmos_sensor(0x300C);
1348 if (*sensorID == OV56702NDMIPI_SENSOR_ID)
1349 {
1350 OV56702NDDB("Sensor ID = 0x%04x\n", *sensorID);
1351 OV56702NDGetModuleID();
1352 break;
1353 }
1354 OV56702NDDB("Read Sensor ID Fail = 0x%04x\n", *sensorID);
1355 retry--;
1356 } while (retry > 0);
1357
1358 if (*sensorID != OV56702NDMIPI_SENSOR_ID) {
1359 OV56702NDDB("Read Sensor ID Fail = 0x%04x\n", *sensorID);
1360
1361 *sensorID = 0xFFFFFFFF;
1362 return ERROR_SENSOR_CONNECT_FAIL;
1363 } else {
1364 OV56702NDDB("alexadd %s module_id=%d", __func__, module_id);
1365 if (module_id != 0x44) {
1366 *sensorID = 0xFFFFFFFF;
1367 return ERROR_SENSOR_CONNECT_FAIL;
1368 }
1369 }
1370 return ERROR_NONE;
1371 }
1372
1373
1374 void OV56702ND_SetShutter(kal_uint32 iShutter)
1375 {
1376
1377 spin_lock(&ov56702ndmipiraw_drv_lock);
1378 OV56702ND.shutter= iShutter;
1379 spin_unlock(&ov56702ndmipiraw_drv_lock);
1380
1381 OV56702ND_write_shutter(iShutter);
1382 return;
1383 }
1384
1385
1386
1387 UINT32 OV56702ND_read_shutter(void)
1388 {
1389
1390 kal_uint16 temp_reg1, temp_reg2 ,temp_reg3;
1391 UINT32 shutter =0;
1392 temp_reg1 = OV56702ND_read_cmos_sensor(0x3500); // AEC[b19~b16]
1393 temp_reg2 = OV56702ND_read_cmos_sensor(0x3501); // AEC[b15~b8]
1394 temp_reg3 = OV56702ND_read_cmos_sensor(0x3502); // AEC[b7~b0]
1395
1396 shutter = (temp_reg1 <<12)| (temp_reg2<<4)|(temp_reg3>>4);
1397
1398 return shutter;
1399 }
1400
1401 void OV56702ND_NightMode(kal_bool bEnable)
1402 {
1403
1404 }
1405
1406 UINT32 OV56702NDClose(void)
1407 {
1408
1409 return ERROR_NONE;
1410 }
1411
1412 #if 0
1413 void OV56702NDSetFlipMirror(kal_int32 imgMirror)
1414 {
1415 kal_int16 mirror=0,flip=0;
1416 mirror= OV56702ND_read_cmos_sensor(0x3820);
1417 flip = OV56702ND_read_cmos_sensor(0x3821);
1418
1419 switch (imgMirror)
1420 {
1421 case IMAGE_H_MIRROR://IMAGE_NORMAL:
1422 OV56702ND_write_cmos_sensor(0x3820, (mirror & (0xF9)));//Set normal
1423 OV56702ND_write_cmos_sensor(0x3821, (flip & (0xF9))); //Set normal
1424 break;
1425 case IMAGE_NORMAL://IMAGE_V_MIRROR:
1426 OV56702ND_write_cmos_sensor(0x3820, (mirror & (0xF9)));//Set flip
1427 OV56702ND_write_cmos_sensor(0x3821, (flip | (0x06))); //Set flip
1428 break;
1429 case IMAGE_HV_MIRROR://IMAGE_H_MIRROR:
1430 OV56702ND_write_cmos_sensor(0x3820, (mirror |(0x06))); //Set mirror
1431 OV56702ND_write_cmos_sensor(0x3821, (flip & (0xF9))); //Set mirror
1432 break;
1433 case IMAGE_V_MIRROR://IMAGE_HV_MIRROR:
1434 OV56702ND_write_cmos_sensor(0x3820, (mirror |(0x06))); //Set mirror & flip
1435 OV56702ND_write_cmos_sensor(0x3821, (flip |(0x06))); //Set mirror & flip
1436 break;
1437 }
1438 }
1439 #endif
1440
1441
1442 UINT32 OV56702NDPreview(MSDK_SENSOR_EXPOSURE_WINDOW_STRUCT *image_window,
1443 MSDK_SENSOR_CONFIG_STRUCT *sensor_config_data)
1444 {
1445
1446 OV56702NDDB("OV56702NDPreview enter:");
1447
1448 //OV56702NDPreviewSetting();
1449 OV56702NDCaptureSetting();
1450 spin_lock(&ov56702ndmipiraw_drv_lock);
1451 OV56702ND.sensorMode = SENSOR_MODE_PREVIEW;
1452 OV56702ND.DummyPixels = 0;
1453 OV56702ND.DummyLines = 0 ;
1454 OV56702ND_FeatureControl_PERIOD_PixelNum=OV56702ND_PV_PERIOD_PIXEL_NUMS+ OV56702ND.DummyPixels;
1455 OV56702ND_FeatureControl_PERIOD_LineNum=OV56702ND_PV_PERIOD_LINE_NUMS+OV56702ND.DummyLines;
1456 OV56702ND.imgMirror = sensor_config_data->SensorImageMirror;
1457 spin_unlock(&ov56702ndmipiraw_drv_lock);
1458
1459 //OV56702NDSetFlipMirror(sensor_config_data->SensorImageMirror);
1460
1461 mdelay(40);//THIS DELAY SHOULD BE NEED BY CTS OR MONKEY
1462 OV56702NDDB("OV56702NDPreview exit:\n");
1463
1464
1465 return ERROR_NONE;
1466 }
1467
1468
1469 UINT32 OV56702NDVideo(MSDK_SENSOR_EXPOSURE_WINDOW_STRUCT *image_window,
1470 MSDK_SENSOR_CONFIG_STRUCT *sensor_config_data)
1471 {
1472
1473 OV56702NDDB("OV56702NDVideo enter:");
1474
1475 OV56702NDVideoSetting();
1476
1477 spin_lock(&ov56702ndmipiraw_drv_lock);
1478 OV56702ND.sensorMode = SENSOR_MODE_VIDEO;
1479 OV56702ND_FeatureControl_PERIOD_PixelNum=OV56702ND_VIDEO_PERIOD_PIXEL_NUMS+ OV56702ND.DummyPixels;
1480 OV56702ND_FeatureControl_PERIOD_LineNum=OV56702ND_VIDEO_PERIOD_LINE_NUMS+OV56702ND.DummyLines;
1481 OV56702ND.imgMirror = sensor_config_data->SensorImageMirror;
1482 spin_unlock(&ov56702ndmipiraw_drv_lock);
1483
1484 //OV56702NDSetFlipMirror(sensor_config_data->SensorImageMirror);
1485
1486 mdelay(40);//THIS DELAY SHOULD BE NEED BY CTS OR MONKEY
1487 OV56702NDDB("OV56702NDVideo exit:\n");
1488 return ERROR_NONE;
1489 }
1490
1491
1492 UINT32 OV56702NDCapture(MSDK_SENSOR_EXPOSURE_WINDOW_STRUCT *image_window,
1493 MSDK_SENSOR_CONFIG_STRUCT *sensor_config_data)
1494 {
1495
1496 //kal_uint32 shutter = OV56702ND.shutter;
1497
1498 if( SENSOR_MODE_CAPTURE== OV56702ND.sensorMode)
1499 {
1500 OV56702NDDB("OV56702NDCapture BusrtShot / ZSD!!!\n");
1501 }
1502 else
1503 {
1504 OV56702NDDB("OV56702NDCapture enter:\n");
1505
1506 OV56702NDCaptureSetting();
1507 mdelay(40);//THIS DELAY SHOULD BE NEED BY CTS OR MONKEY
1508
1509 spin_lock(&ov56702ndmipiraw_drv_lock);
1510 OV56702ND.sensorMode = SENSOR_MODE_CAPTURE;
1511 OV56702ND.imgMirror = sensor_config_data->SensorImageMirror;
1512 OV56702ND.DummyPixels = 0;
1513 OV56702ND.DummyLines = 0 ;
1514 OV56702ND_FeatureControl_PERIOD_PixelNum = OV56702ND_FULL_PERIOD_PIXEL_NUMS + OV56702ND.DummyPixels;
1515 OV56702ND_FeatureControl_PERIOD_LineNum = OV56702ND_FULL_PERIOD_LINE_NUMS + OV56702ND.DummyLines;
1516 spin_unlock(&ov56702ndmipiraw_drv_lock);
1517
1518 //OV56702NDSetFlipMirror(sensor_config_data->SensorImageMirror);
1519
1520 OV56702NDDB("OV56702NDCapture exit:\n");
1521 }
1522
1523 if(OV56702ND_During_testpattern == KAL_TRUE)
1524 {
1525 OV56702ND_write_cmos_sensor(0x4303,0x80);
1526 }
1527
1528 return ERROR_NONE;
1529 }
1530
1531
1532
1533 UINT32 OV56702NDGetResolution(MSDK_SENSOR_RESOLUTION_INFO_STRUCT *pSensorResolution)
1534 {
1535
1536 OV56702NDDB("OV56702NDGetResolution!!\n");
1537
1538 pSensorResolution->SensorPreviewWidth = OV56702ND_IMAGE_SENSOR_FULL_WIDTH;
1539 pSensorResolution->SensorPreviewHeight = OV56702ND_IMAGE_SENSOR_FULL_HEIGHT;
1540
1541 pSensorResolution->SensorFullWidth = OV56702ND_IMAGE_SENSOR_FULL_WIDTH;
1542 pSensorResolution->SensorFullHeight = OV56702ND_IMAGE_SENSOR_FULL_HEIGHT;
1543
1544 pSensorResolution->SensorVideoWidth = OV56702ND_IMAGE_SENSOR_VIDEO_WIDTH;
1545 pSensorResolution->SensorVideoHeight = OV56702ND_IMAGE_SENSOR_VIDEO_HEIGHT;
1546 return ERROR_NONE;
1547 }
1548
1549 UINT32 OV56702NDGetInfo(MSDK_SCENARIO_ID_ENUM ScenarioId,
1550 MSDK_SENSOR_INFO_STRUCT *pSensorInfo,
1551 MSDK_SENSOR_CONFIG_STRUCT *pSensorConfigData)
1552 {
1553
1554 spin_lock(&ov56702ndmipiraw_drv_lock);
1555 OV56702ND.imgMirror = pSensorConfigData->SensorImageMirror ;
1556 spin_unlock(&ov56702ndmipiraw_drv_lock);
1557
1558 pSensorInfo->SensorOutputDataFormat= SENSOR_OUTPUT_FORMAT_RAW_B;
1559
1560 pSensorInfo->SensorClockPolarity =SENSOR_CLOCK_POLARITY_LOW;
1561 pSensorInfo->SensorClockFallingPolarity=SENSOR_CLOCK_POLARITY_LOW;
1562 pSensorInfo->SensorHsyncPolarity = SENSOR_CLOCK_POLARITY_LOW;
1563 pSensorInfo->SensorVsyncPolarity = SENSOR_CLOCK_POLARITY_LOW;
1564
1565 pSensorInfo->SensroInterfaceType=SENSOR_INTERFACE_TYPE_MIPI;
1566
1567 pSensorInfo->CaptureDelayFrame = 2;
1568 pSensorInfo->PreviewDelayFrame = 2;
1569 pSensorInfo->VideoDelayFrame = 2;
1570
1571 pSensorInfo->SensorDrivingCurrent = ISP_DRIVING_8MA;
1572 pSensorInfo->AEShutDelayFrame = 0;
1573 pSensorInfo->AESensorGainDelayFrame = 0;
1574 pSensorInfo->AEISPGainDelayFrame = 2;
1575
1576 switch (ScenarioId)
1577 {
1578 case MSDK_SCENARIO_ID_CAMERA_PREVIEW:
1579 pSensorInfo->SensorClockFreq=24;
1580 pSensorInfo->SensorClockRisingCount= 0;
1581
1582 pSensorInfo->SensorGrabStartX = OV56702ND_PV_X_START;
1583 pSensorInfo->SensorGrabStartY = OV56702ND_PV_Y_START;
1584
1585 pSensorInfo->SensorMIPILaneNumber = SENSOR_MIPI_2_LANE;
1586
1587 pSensorInfo->MIPIDataLowPwr2HighSpeedTermDelayCount = 0;
1588 pSensorInfo->MIPIDataLowPwr2HighSpeedSettleDelayCount = 14;
1589 pSensorInfo->MIPICLKLowPwr2HighSpeedTermDelayCount = 0;
1590 pSensorInfo->SensorPacketECCOrder = 1;
1591 break;
1592 case MSDK_SCENARIO_ID_VIDEO_PREVIEW:
1593 pSensorInfo->SensorClockFreq=24;
1594 pSensorInfo->SensorClockRisingCount= 0;
1595
1596 pSensorInfo->SensorGrabStartX = OV56702ND_VIDEO_X_START;
1597 pSensorInfo->SensorGrabStartY = OV56702ND_VIDEO_Y_START;
1598
1599 pSensorInfo->SensorMIPILaneNumber = SENSOR_MIPI_2_LANE;
1600
1601 pSensorInfo->MIPIDataLowPwr2HighSpeedTermDelayCount = 0;
1602 pSensorInfo->MIPIDataLowPwr2HighSpeedSettleDelayCount = 14;
1603 pSensorInfo->MIPICLKLowPwr2HighSpeedTermDelayCount = 0;
1604 pSensorInfo->SensorPacketECCOrder = 1;
1605 break;
1606 case MSDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG:
1607 case MSDK_SCENARIO_ID_CAMERA_ZSD:
1608 pSensorInfo->SensorClockFreq=24;
1609 pSensorInfo->SensorClockRisingCount= 0;
1610
1611 pSensorInfo->SensorGrabStartX = OV56702ND_FULL_X_START;
1612 pSensorInfo->SensorGrabStartY = OV56702ND_FULL_Y_START;
1613
1614 pSensorInfo->SensorMIPILaneNumber = SENSOR_MIPI_2_LANE;
1615
1616 pSensorInfo->MIPIDataLowPwr2HighSpeedTermDelayCount = 0;
1617 pSensorInfo->MIPIDataLowPwr2HighSpeedSettleDelayCount = 14;
1618 pSensorInfo->MIPICLKLowPwr2HighSpeedTermDelayCount = 0;
1619 pSensorInfo->SensorPacketECCOrder = 1;
1620 break;
1621 default:
1622 pSensorInfo->SensorClockFreq=24;
1623 pSensorInfo->SensorClockRisingCount= 0;
1624
1625 pSensorInfo->SensorGrabStartX = OV56702ND_PV_X_START;
1626 pSensorInfo->SensorGrabStartY = OV56702ND_PV_Y_START;
1627
1628 pSensorInfo->SensorMIPILaneNumber = SENSOR_MIPI_2_LANE;
1629
1630 pSensorInfo->MIPIDataLowPwr2HighSpeedTermDelayCount = 0;
1631 pSensorInfo->MIPIDataLowPwr2HighSpeedSettleDelayCount = 14;
1632 pSensorInfo->MIPICLKLowPwr2HighSpeedTermDelayCount = 0;
1633 pSensorInfo->SensorPacketECCOrder = 1;
1634 break;
1635 }
1636
1637 memcpy(pSensorConfigData, &OV56702NDSensorConfigData, sizeof(MSDK_SENSOR_CONFIG_STRUCT));
1638
1639 return ERROR_NONE;
1640 } /* OV56702NDGetInfo() */
1641
1642
1643
1644 UINT32 OV56702NDControl(MSDK_SCENARIO_ID_ENUM ScenarioId, MSDK_SENSOR_EXPOSURE_WINDOW_STRUCT *pImageWindow,
1645 MSDK_SENSOR_CONFIG_STRUCT *pSensorConfigData)
1646 {
1647 spin_lock(&ov56702ndmipiraw_drv_lock);
1648 OV56702NDCurrentScenarioId = ScenarioId;
1649 spin_unlock(&ov56702ndmipiraw_drv_lock);
1650
1651 OV56702NDDB("OV56702NDCurrentScenarioId=%d\n",OV56702NDCurrentScenarioId);
1652
1653 switch (ScenarioId)
1654 {
1655 case MSDK_SCENARIO_ID_CAMERA_PREVIEW:
1656 OV56702NDPreview(pImageWindow, pSensorConfigData);
1657 break;
1658 case MSDK_SCENARIO_ID_VIDEO_PREVIEW:
1659 OV56702NDDB("OV56702ND video_preiew sync\n");
1660 OV56702NDVideo(pImageWindow, pSensorConfigData);
1661 break;
1662 case MSDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG:
1663 case MSDK_SCENARIO_ID_CAMERA_ZSD:
1664 OV56702NDCapture(pImageWindow, pSensorConfigData);
1665 break;
1666
1667 default:
1668 return ERROR_INVALID_SCENARIO_ID;
1669
1670 }
1671 return ERROR_NONE;
1672 } /* OV56702NDControl() */
1673
1674
1675
1676 kal_uint32 OV56702ND_SET_FrameLength_ByVideoMode(UINT16 Video_TargetFps)
1677 {
1678 UINT32 frameRate = 0;
1679 kal_uint32 MIN_FrameLength=0;
1680
1681 if(OV56702ND.OV56702NDAutoFlickerMode == KAL_TRUE)
1682 {
1683 if (Video_TargetFps==30)
1684 frameRate= OV56702ND_AUTOFLICKER_OFFSET_30;
1685 else if(Video_TargetFps==15)
1686 frameRate= OV56702ND_AUTOFLICKER_OFFSET_15;
1687 else
1688 frameRate=Video_TargetFps*10;
1689
1690 MIN_FrameLength = (OV56702ND.videoPclk*10000)/(OV56702ND_VIDEO_PERIOD_PIXEL_NUMS + OV56702ND.DummyPixels)/frameRate*10;
1691 }
1692 else
1693 MIN_FrameLength = (OV56702ND.videoPclk*10000) /(OV56702ND_VIDEO_PERIOD_PIXEL_NUMS + OV56702ND.DummyPixels)/Video_TargetFps;
1694
1695 return MIN_FrameLength;
1696
1697 }
1698
1699
1700
1701 UINT32 OV56702NDSetVideoMode(UINT16 u2FrameRate)
1702 {
1703
1704 kal_uint32 MIN_Frame_length =0,frameRate=0,extralines=0;
1705 OV56702NDDB("[OV56702NDSetVideoMode] frame rate = %d\n", u2FrameRate);
1706
1707 spin_lock(&ov56702ndmipiraw_drv_lock);
1708 OV56702ND_VIDEO_MODE_TARGET_FPS=u2FrameRate;
1709 spin_unlock(&ov56702ndmipiraw_drv_lock);
1710
1711 if(u2FrameRate==0)
1712 {
1713 OV56702NDDB("Disable Video Mode or dynimac fps\n");
1714 return KAL_TRUE;
1715 }
1716 if(u2FrameRate >30 || u2FrameRate <5)
1717 OV56702NDDB("abmornal frame rate seting,pay attention~\n");
1718
1719 if(OV56702ND.sensorMode == SENSOR_MODE_VIDEO)//video ScenarioId recording
1720 {
1721
1722 MIN_Frame_length = OV56702ND_SET_FrameLength_ByVideoMode(u2FrameRate);
1723
1724 if((MIN_Frame_length <=OV56702ND_VIDEO_PERIOD_LINE_NUMS))
1725 {
1726 MIN_Frame_length = OV56702ND_VIDEO_PERIOD_LINE_NUMS;
1727 OV56702NDDB("[OV56702NDSetVideoMode]current fps = %d\n", (OV56702ND.videoPclk*10000) /(OV56702ND_VIDEO_PERIOD_PIXEL_NUMS)/OV56702ND_VIDEO_PERIOD_LINE_NUMS);
1728 }
1729 OV56702NDDB("[OV56702NDSetVideoMode]current fps (10 base)= %d\n", (OV56702ND.videoPclk*10000)*10/(OV56702ND_VIDEO_PERIOD_PIXEL_NUMS + OV56702ND.DummyPixels)/MIN_Frame_length);
1730 extralines = MIN_Frame_length - OV56702ND_VIDEO_PERIOD_LINE_NUMS;
1731
1732 spin_lock(&ov56702ndmipiraw_drv_lock);
1733 OV56702ND.DummyPixels = 0;//define dummy pixels and lines
1734 OV56702ND.DummyLines = extralines ;
1735 spin_unlock(&ov56702ndmipiraw_drv_lock);
1736
1737 OV56702ND_SetDummy(OV56702ND.DummyPixels,extralines);
1738 }
1739
1740 OV56702NDDB("[OV56702NDSetVideoMode]MIN_Frame_length=%d,OV56702ND.DummyLines=%d\n",MIN_Frame_length,OV56702ND.DummyLines);
1741
1742 return KAL_TRUE;
1743 }
1744
1745
1746 UINT32 OV56702NDSetAutoFlickerMode(kal_bool bEnable, UINT16 u2FrameRate)
1747 {
1748
1749 if(bEnable) {
1750 spin_lock(&ov56702ndmipiraw_drv_lock);
1751 OV56702ND.OV56702NDAutoFlickerMode = KAL_TRUE;
1752 spin_unlock(&ov56702ndmipiraw_drv_lock);
1753 OV56702NDDB("OV56702ND Enable Auto flicker\n");
1754 } else {
1755 spin_lock(&ov56702ndmipiraw_drv_lock);
1756 OV56702ND.OV56702NDAutoFlickerMode = KAL_FALSE;
1757 spin_unlock(&ov56702ndmipiraw_drv_lock);
1758 OV56702NDDB("OV56702ND Disable Auto flicker\n");
1759 }
1760
1761 return ERROR_NONE;
1762 }
1763
1764
1765 UINT32 OV56702NDSetTestPatternMode(kal_bool bEnable)
1766 {
1767 OV56702NDDB("[OV56702NDSetTestPatternMode] Test pattern enable:%d\n", bEnable);
1768 if(bEnable == KAL_TRUE)
1769 {
1770 OV56702ND_During_testpattern = KAL_TRUE;
1771
1772 //OV56702ND_write_cmos_sensor(0x5000,0x16);// ; LENC off, MWB on, BPC on, WPC on
1773
1774 OV56702ND_write_cmos_sensor(0x4303,0x08);
1775 }
1776 else
1777 {
1778 OV56702ND_During_testpattern = KAL_FALSE;
1779 //OV56702ND_write_cmos_sensor(0x5000,0x96);// ; LENC on, MWB on, BPC on, WPC on
1780 OV56702ND_write_cmos_sensor(0x4303,0x00);
1781 }
1782
1783 return ERROR_NONE;
1784 }
1785
1786
1787 /*************************************************************************
1788 *
1789 * DESCRIPTION:
1790 * INTERFACE FUNCTION, FOR USER TO SET MAX FRAMERATE;
1791 *
1792 *************************************************************************/
1793 UINT32 OV56702NDMIPISetMaxFramerateByScenario(MSDK_SCENARIO_ID_ENUM scenarioId, MUINT32 frameRate) {
1794 kal_uint32 pclk;
1795 kal_int16 dummyLine;
1796 kal_uint16 lineLength,frameHeight;
1797
1798 OV56702NDDB("OV56702NDMIPISetMaxFramerateByScenario: scenarioId = %d, frame rate = %d\n",scenarioId,frameRate);
1799 switch (scenarioId) {
1800 case MSDK_SCENARIO_ID_CAMERA_PREVIEW:
1801 pclk = OV56702ND_PREVIEW_PCLK;
1802 lineLength = OV56702ND_PV_PERIOD_PIXEL_NUMS;
1803 frameHeight = (10 * pclk)/frameRate/lineLength;
1804 dummyLine = frameHeight - OV56702ND_PV_PERIOD_LINE_NUMS;
1805 if(dummyLine<0)
1806 dummyLine = 0;
1807 spin_lock(&ov56702ndmipiraw_drv_lock);
1808 OV56702ND.sensorMode = SENSOR_MODE_PREVIEW;
1809 spin_unlock(&ov56702ndmipiraw_drv_lock);
1810 OV56702ND_SetDummy(0, dummyLine);
1811 break;
1812 case MSDK_SCENARIO_ID_VIDEO_PREVIEW:
1813 pclk = OV56702ND_VIDEO_PCLK;
1814 lineLength = OV56702ND_VIDEO_PERIOD_PIXEL_NUMS;
1815 frameHeight = (10 * pclk)/frameRate/lineLength;
1816 dummyLine = frameHeight - OV56702ND_VIDEO_PERIOD_LINE_NUMS;
1817 if(dummyLine<0)
1818 dummyLine = 0;
1819 spin_lock(&ov56702ndmipiraw_drv_lock);
1820 OV56702ND.sensorMode = SENSOR_MODE_VIDEO;
1821 spin_unlock(&ov56702ndmipiraw_drv_lock);
1822 OV56702ND_SetDummy(0, dummyLine);
1823 break;
1824 break;
1825 case MSDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG:
1826 case MSDK_SCENARIO_ID_CAMERA_ZSD:
1827 pclk = OV56702ND_CAPTURE_PCLK;
1828 lineLength = OV56702ND_FULL_PERIOD_PIXEL_NUMS;
1829 frameHeight = (10 * pclk)/frameRate/lineLength;
1830 dummyLine = frameHeight - OV56702ND_FULL_PERIOD_LINE_NUMS;
1831 if(dummyLine<0)
1832 dummyLine = 0;
1833 spin_lock(&ov56702ndmipiraw_drv_lock);
1834 OV56702ND.sensorMode = SENSOR_MODE_CAPTURE;
1835 spin_unlock(&ov56702ndmipiraw_drv_lock);
1836 OV56702ND_SetDummy(0, dummyLine);
1837 break;
1838 case MSDK_SCENARIO_ID_CAMERA_3D_PREVIEW:
1839 break;
1840 case MSDK_SCENARIO_ID_CAMERA_3D_VIDEO:
1841 break;
1842 case MSDK_SCENARIO_ID_CAMERA_3D_CAPTURE:
1843 break;
1844 default:
1845 break;
1846 }
1847 return ERROR_NONE;
1848 }
1849
1850
1851 UINT32 OV56702NDMIPIGetDefaultFramerateByScenario(MSDK_SCENARIO_ID_ENUM scenarioId, MUINT32 *pframeRate)
1852 {
1853
1854 switch (scenarioId) {
1855 case MSDK_SCENARIO_ID_CAMERA_PREVIEW:
1856 case MSDK_SCENARIO_ID_VIDEO_PREVIEW:
1857 *pframeRate = OV56702ND_MAX_FPS_PREVIEW;
1858 break;
1859 case MSDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG:
1860 case MSDK_SCENARIO_ID_CAMERA_ZSD:
1861 *pframeRate = OV56702ND_MAX_FPS_CAPTURE;
1862 break;
1863 case MSDK_SCENARIO_ID_CAMERA_3D_PREVIEW: //added
1864 case MSDK_SCENARIO_ID_CAMERA_3D_VIDEO:
1865 case MSDK_SCENARIO_ID_CAMERA_3D_CAPTURE: //added
1866 *pframeRate = OV56702ND_MAX_FPS_CAPTURE;
1867 break;
1868 default:
1869 break;
1870 }
1871
1872 return ERROR_NONE;
1873 }
1874
1875 /* Sensor output window information */
1876
1877 /* SZ TCT xuejian.zhong add for CTS test*/
1878
1879 static void OV56702NDGetAFMaxNumFocusAreas(UINT32 *pFeatureReturnPara32)
1880 {
1881 *pFeatureReturnPara32 = 0;
1882 // SENSORDB("OV56702NDGetAFMaxNumFocusAreas *pFeatureReturnPara32 = %d¥n", *pFeatureReturnPara32);
1883 }
1884
1885 static void OV56702NDGetAEMaxNumMeteringAreas(UINT32 *pFeatureReturnPara32)
1886 {
1887 *pFeatureReturnPara32 = 0;
1888 // SENSORDB("OV56702NDGetAEMaxNumMeteringAreas *pFeatureReturnPara32 = %d¥n", *pFeatureReturnPara32);
1889 }
1890
1891 static void OV56702NDGetExifInfo(UINT32 exifAddr)
1892 {
1893 SENSOR_EXIF_INFO_STRUCT* pExifInfo = (SENSOR_EXIF_INFO_STRUCT*)exifAddr;
1894 pExifInfo->FNumber = 28;
1895 pExifInfo->AEISOSpeed = AE_ISO_100;
1896 pExifInfo->AWBMode = AWB_MODE_AUTO;
1897 pExifInfo->CapExposureTime = 0;
1898 pExifInfo->FlashLightTimeus = 0;
1899 pExifInfo->RealISOValue = AE_ISO_100;
1900 }
1901
1902 /* SZ TCT xuejian.zhong end */
1903
1904
1905 UINT32 OV56702NDFeatureControl(MSDK_SENSOR_FEATURE_ENUM FeatureId,
1906 UINT8 *pFeaturePara,UINT32 *pFeatureParaLen)
1907 {
1908 UINT16 *pFeatureReturnPara16=(UINT16 *) pFeaturePara;
1909 UINT16 *pFeatureData16=(UINT16 *) pFeaturePara;
1910 UINT32 *pFeatureReturnPara32=(UINT32 *) pFeaturePara;
1911 UINT32 *pFeatureData32=(UINT32 *) pFeaturePara;
1912 UINT32 SensorRegNumber;
1913 UINT32 i;
1914 PNVRAM_SENSOR_DATA_STRUCT pSensorDefaultData=(PNVRAM_SENSOR_DATA_STRUCT) pFeaturePara;
1915 MSDK_SENSOR_CONFIG_STRUCT *pSensorConfigData=(MSDK_SENSOR_CONFIG_STRUCT *) pFeaturePara;
1916 MSDK_SENSOR_REG_INFO_STRUCT *pSensorRegData=(MSDK_SENSOR_REG_INFO_STRUCT *) pFeaturePara;
1917 MSDK_SENSOR_GROUP_INFO_STRUCT *pSensorGroupInfo=(MSDK_SENSOR_GROUP_INFO_STRUCT *) pFeaturePara;
1918 MSDK_SENSOR_ITEM_INFO_STRUCT *pSensorItemInfo=(MSDK_SENSOR_ITEM_INFO_STRUCT *) pFeaturePara;
1919 MSDK_SENSOR_ENG_INFO_STRUCT *pSensorEngInfo=(MSDK_SENSOR_ENG_INFO_STRUCT *) pFeaturePara;
1920
1921 switch (FeatureId)
1922 {
1923 case SENSOR_FEATURE_GET_RESOLUTION:
1924 *pFeatureReturnPara16++= OV56702ND_IMAGE_SENSOR_FULL_WIDTH;
1925 *pFeatureReturnPara16= OV56702ND_IMAGE_SENSOR_FULL_HEIGHT;
1926 *pFeatureParaLen=4;
1927 break;
1928 case SENSOR_FEATURE_GET_PERIOD:
1929 *pFeatureReturnPara16++= OV56702ND_FeatureControl_PERIOD_PixelNum;
1930 *pFeatureReturnPara16= OV56702ND_FeatureControl_PERIOD_LineNum;
1931 *pFeatureParaLen=4;
1932 break;
1933 case SENSOR_FEATURE_GET_PIXEL_CLOCK_FREQ:
1934 switch(OV56702NDCurrentScenarioId)
1935 {
1936 case MSDK_SCENARIO_ID_CAMERA_PREVIEW:
1937 *pFeatureReturnPara32 = OV56702ND_PREVIEW_PCLK;
1938 *pFeatureParaLen=4;
1939 break;
1940 case MSDK_SCENARIO_ID_VIDEO_PREVIEW:
1941 *pFeatureReturnPara32 = OV56702ND_VIDEO_PCLK;
1942 *pFeatureParaLen=4;
1943 break;
1944 case MSDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG:
1945 case MSDK_SCENARIO_ID_CAMERA_ZSD:
1946 *pFeatureReturnPara32 = OV56702ND_CAPTURE_PCLK;
1947 *pFeatureParaLen=4;
1948 break;
1949 default:
1950 *pFeatureReturnPara32 = OV56702ND_PREVIEW_PCLK;
1951 *pFeatureParaLen=4;
1952 break;
1953 }
1954 break;
1955
1956 case SENSOR_FEATURE_SET_ESHUTTER:
1957 OV56702ND_SetShutter(*pFeatureData16);
1958 break;
1959 case SENSOR_FEATURE_SET_NIGHTMODE:
1960 OV56702ND_NightMode((BOOL) *pFeatureData16);
1961 break;
1962 case SENSOR_FEATURE_SET_GAIN:
1963 OV56702ND_SetGain((UINT16) *pFeatureData16);
1964 break;
1965 case SENSOR_FEATURE_SET_FLASHLIGHT:
1966 break;
1967 case SENSOR_FEATURE_SET_ISP_MASTER_CLOCK_FREQ:
1968 //OV56702ND_isp_master_clock=*pFeatureData32;
1969 break;
1970 case SENSOR_FEATURE_SET_REGISTER:
1971 OV56702ND_write_cmos_sensor(pSensorRegData->RegAddr, pSensorRegData->RegData);
1972 break;
1973 case SENSOR_FEATURE_GET_REGISTER:
1974 pSensorRegData->RegData = OV56702ND_read_cmos_sensor(pSensorRegData->RegAddr);
1975 break;
1976 case SENSOR_FEATURE_SET_CCT_REGISTER:
1977 SensorRegNumber=FACTORY_END_ADDR;
1978 for (i=0;i<SensorRegNumber;i++)
1979 {
1980 spin_lock(&ov56702ndmipiraw_drv_lock);
1981 OV56702NDSensorCCT[i].Addr=*pFeatureData32++;
1982 OV56702NDSensorCCT[i].Para=*pFeatureData32++;
1983 spin_unlock(&ov56702ndmipiraw_drv_lock);
1984 }
1985 break;
1986 case SENSOR_FEATURE_GET_CCT_REGISTER:
1987 SensorRegNumber=FACTORY_END_ADDR;
1988 if (*pFeatureParaLen<(SensorRegNumber*sizeof(SENSOR_REG_STRUCT)+4))
1989 return FALSE;
1990 *pFeatureData32++=SensorRegNumber;
1991 for (i=0;i<SensorRegNumber;i++)
1992 {
1993 *pFeatureData32++=OV56702NDSensorCCT[i].Addr;
1994 *pFeatureData32++=OV56702NDSensorCCT[i].Para;
1995 }
1996 break;
1997 case SENSOR_FEATURE_SET_ENG_REGISTER:
1998 SensorRegNumber=ENGINEER_END;
1999 for (i=0;i<SensorRegNumber;i++)
2000 {
2001 spin_lock(&ov56702ndmipiraw_drv_lock);
2002 OV56702NDSensorReg[i].Addr=*pFeatureData32++;
2003 OV56702NDSensorReg[i].Para=*pFeatureData32++;
2004 spin_unlock(&ov56702ndmipiraw_drv_lock);
2005 }
2006 break;
2007 case SENSOR_FEATURE_GET_ENG_REGISTER:
2008 SensorRegNumber=ENGINEER_END;
2009 if (*pFeatureParaLen<(SensorRegNumber*sizeof(SENSOR_REG_STRUCT)+4))
2010 return FALSE;
2011 *pFeatureData32++=SensorRegNumber;
2012 for (i=0;i<SensorRegNumber;i++)
2013 {
2014 *pFeatureData32++=OV56702NDSensorReg[i].Addr;
2015 *pFeatureData32++=OV56702NDSensorReg[i].Para;
2016 }
2017 break;
2018 case SENSOR_FEATURE_GET_REGISTER_DEFAULT:
2019 if (*pFeatureParaLen>=sizeof(NVRAM_SENSOR_DATA_STRUCT))
2020 {
2021 pSensorDefaultData->Version=NVRAM_CAMERA_SENSOR_FILE_VERSION;
2022 pSensorDefaultData->SensorId=OV56702NDMIPI_SENSOR_ID;
2023 memcpy(pSensorDefaultData->SensorEngReg, OV56702NDSensorReg, sizeof(SENSOR_REG_STRUCT)*ENGINEER_END);
2024 memcpy(pSensorDefaultData->SensorCCTReg, OV56702NDSensorCCT, sizeof(SENSOR_REG_STRUCT)*FACTORY_END_ADDR);
2025 }
2026 else
2027 return FALSE;
2028 *pFeatureParaLen=sizeof(NVRAM_SENSOR_DATA_STRUCT);
2029 break;
2030 case SENSOR_FEATURE_GET_CONFIG_PARA:
2031 memcpy(pSensorConfigData, &OV56702NDSensorConfigData, sizeof(MSDK_SENSOR_CONFIG_STRUCT));
2032 *pFeatureParaLen=sizeof(MSDK_SENSOR_CONFIG_STRUCT);
2033 break;
2034 case SENSOR_FEATURE_CAMERA_PARA_TO_SENSOR:
2035 OV56702ND_camera_para_to_sensor();
2036 break;
2037
2038 case SENSOR_FEATURE_SENSOR_TO_CAMERA_PARA:
2039 OV56702ND_sensor_to_camera_para();
2040 break;
2041 case SENSOR_FEATURE_GET_GROUP_COUNT:
2042 *pFeatureReturnPara32++=OV56702ND_get_sensor_group_count();
2043 *pFeatureParaLen=4;
2044 break;
2045 case SENSOR_FEATURE_GET_GROUP_INFO:
2046 OV56702ND_get_sensor_group_info(pSensorGroupInfo->GroupIdx, pSensorGroupInfo->GroupNamePtr, &pSensorGroupInfo->ItemCount);
2047 *pFeatureParaLen=sizeof(MSDK_SENSOR_GROUP_INFO_STRUCT);
2048 break;
2049 case SENSOR_FEATURE_GET_ITEM_INFO:
2050 OV56702ND_get_sensor_item_info(pSensorItemInfo->GroupIdx,pSensorItemInfo->ItemIdx, pSensorItemInfo);
2051 *pFeatureParaLen=sizeof(MSDK_SENSOR_ITEM_INFO_STRUCT);
2052 break;
2053
2054 case SENSOR_FEATURE_SET_ITEM_INFO:
2055 OV56702ND_set_sensor_item_info(pSensorItemInfo->GroupIdx, pSensorItemInfo->ItemIdx, pSensorItemInfo->ItemValue);
2056 *pFeatureParaLen=sizeof(MSDK_SENSOR_ITEM_INFO_STRUCT);
2057 break;
2058
2059 case SENSOR_FEATURE_GET_ENG_INFO:
2060 pSensorEngInfo->SensorId = 129;
2061 pSensorEngInfo->SensorType = CMOS_SENSOR;
2062 pSensorEngInfo->SensorOutputDataFormat=SENSOR_OUTPUT_FORMAT_RAW_B;
2063 *pFeatureParaLen=sizeof(MSDK_SENSOR_ENG_INFO_STRUCT);
2064 break;
2065 case SENSOR_FEATURE_GET_LENS_DRIVER_ID:
2066 // get the lens driver ID from EEPROM or just return LENS_DRIVER_ID_DO_NOT_CARE
2067 // if EEPROM does not exist in camera module.
2068 *pFeatureReturnPara32=LENS_DRIVER_ID_DO_NOT_CARE;
2069 *pFeatureParaLen=4;
2070 break;
2071
2072 case SENSOR_FEATURE_INITIALIZE_AF:
2073 break;
2074 case SENSOR_FEATURE_CONSTANT_AF:
2075 break;
2076 case SENSOR_FEATURE_MOVE_FOCUS_LENS:
2077 break;
2078 case SENSOR_FEATURE_SET_VIDEO_MODE:
2079 OV56702NDSetVideoMode(*pFeatureData16);
2080 break;
2081 case SENSOR_FEATURE_CHECK_SENSOR_ID:
2082 OV56702NDGetSensorID(pFeatureReturnPara32);
2083 break;
2084 case SENSOR_FEATURE_SET_AUTO_FLICKER_MODE:
2085 OV56702NDSetAutoFlickerMode((BOOL)*pFeatureData16, *(pFeatureData16+1));
2086 break;
2087 case SENSOR_FEATURE_SET_MAX_FRAME_RATE_BY_SCENARIO:
2088 OV56702NDMIPISetMaxFramerateByScenario((MSDK_SCENARIO_ID_ENUM)*pFeatureData32, *(pFeatureData32+1));
2089 break;
2090 case SENSOR_FEATURE_GET_DEFAULT_FRAME_RATE_BY_SCENARIO:
2091 OV56702NDMIPIGetDefaultFramerateByScenario((MSDK_SCENARIO_ID_ENUM)*pFeatureData32, (MUINT32 *)(*(pFeatureData32+1)));
2092 break;
2093 case SENSOR_FEATURE_SET_TEST_PATTERN:
2094 OV56702NDSetTestPatternMode((BOOL)*pFeatureData16);
2095 break;
2096 case SENSOR_FEATURE_GET_TEST_PATTERN_CHECKSUM_VALUE://for factory mode auto testing
2097 *pFeatureReturnPara32=OV56702ND_TEST_PATTERN_CHECKSUM;
2098 *pFeatureParaLen=4;
2099 break;
2100 /*SZ TCT xuejian.zhong add for CTS test */
2101 case SENSOR_FEATURE_GET_AF_MAX_NUM_FOCUS_AREAS:
2102 OV56702NDGetAFMaxNumFocusAreas(pFeatureData32);
2103 *pFeatureParaLen=4;
2104 break;
2105
2106 case SENSOR_FEATURE_GET_AE_MAX_NUM_METERING_AREAS:
2107 OV56702NDGetAEMaxNumMeteringAreas(pFeatureData32);
2108 *pFeatureParaLen=4;
2109 break;
2110 case SENSOR_FEATURE_GET_EXIF_INFO:
2111 // SENSORDB("SENSOR_FEATURE_GET_EXIF_INFO¥n");
2112 // SENSORDB("EXIF addr = 0x%x¥n",*pFeatureData32);
2113
2114 OV56702NDGetExifInfo(*pFeatureData32);
2115 break;
2116 /* xuejian.zhong add end */
2117 default:
2118 break;
2119 }
2120 return ERROR_NONE;
2121 }
2122
2123
2124 SENSOR_FUNCTION_STRUCT SensorFuncOV56702ND=
2125 {
2126 OV56702NDOpen,
2127 OV56702NDGetInfo,
2128 OV56702NDGetResolution,
2129 OV56702NDFeatureControl,
2130 OV56702NDControl,
2131 OV56702NDClose
2132 };
2133
2134 UINT32 OV56702ND_MIPI_RAW_SensorInit(PSENSOR_FUNCTION_STRUCT *pfFunc)
2135 {
2136 if (pfFunc!=NULL)
2137 *pfFunc=&SensorFuncOV56702ND;
2138
2139 return ERROR_NONE;
2140 }