2 /* Copyright Statement:
4 * This software/firmware and related documentation ("MediaTek Software") are
5 * protected under relevant copyright laws. The information contained herein
6 * is confidential and proprietary to MediaTek Inc. and/or its licensors.
7 * Without the prior written permission of MediaTek inc. and/or its licensors,
8 * any reproduction, modification, use or disclosure of MediaTek Software,
9 * and information contained herein, in whole or in part, shall be strictly prohibited.
11 /* MediaTek Inc. (C) 2010. All rights reserved.
13 * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
14 * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
15 * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
16 * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
19 * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
20 * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
21 * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
22 * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
23 * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
24 * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
25 * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
26 * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
27 * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
28 * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
29 * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
30 * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
32 * The following software/firmware and/or related documentation ("MediaTek Software")
33 * have been modified by MediaTek Inc. All revisions are subject to any receiver's
34 * applicable license agreements with MediaTek Inc.
38 /*****************************************************************************
39 * Copyright Statement:
40 * --------------------
41 * This software is protected by Copyright and the information contained
42 * herein is confidential. The software may not be copied and the information
43 * contained herein may not be used or disclosed except with the written
44 * permission of MediaTek Inc. (C) 2008
46 * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
47 * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
48 * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
49 * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
50 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
51 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
52 * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
53 * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
54 * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
55 * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
56 * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
57 * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
59 * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
60 * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
61 * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
62 * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
63 * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
65 * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
66 * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
67 * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
68 * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
69 * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
71 *****************************************************************************//*****************************************************************************
83 * Source code of Sensor driver
90 *============================================================================
92 * Below this line, this part is controlled by CC/CQ. DO NOT MODIFY!!
93 *------------------------------------------------------------------------------
99 * [ALPS00059464] hi708 sensor check in
103 *------------------------------------------------------------------------------
104 * Upper this line, this part is controlled by CC/CQ. DO NOT MODIFY!!
105 *============================================================================
106 ****************************************************************************/
107 #include <linux/videodev2.h>
108 #include <linux/i2c.h>
109 #include <linux/platform_device.h>
110 #include <linux/delay.h>
111 #include <linux/cdev.h>
112 #include <linux/uaccess.h>
113 #include <linux/fs.h>
114 #include <asm/atomic.h>
115 //#include <mach/mt6516_pll.h>
117 #include "kd_camera_hw.h"
118 #include "kd_imgsensor.h"
119 #include "kd_imgsensor_define.h"
120 #include "kd_imgsensor_errcode.h"
121 #include "kd_camera_feature.h"
123 #include "hi708yuv_Sensor.h"
124 #include "hi708yuv_Camera_Sensor_para.h"
125 #include "hi708yuv_CameraCustomized.h"
127 #define HI708YUV_DEBUG
128 #ifdef HI708YUV_DEBUG
129 #define SENSORDB printk
132 #define SENSORDB(x,...)
136 extern int iReadReg(u16 a_u2Addr
, u8
* a_puBuff
, u16 i2cId
);
137 extern int iWriteReg(u16 a_u2Addr
, u32 a_u4Data
, u32 a_u4Bytes
, u16 i2cId
);
138 static int sensor_id_fail
= 0;
139 #define HI708_write_cmos_sensor(addr, para) iWriteReg((u16) addr , (u32) para ,1,HI708_WRITE_ID)
140 #define HI708_write_cmos_sensor_2(addr, para, bytes) iWriteReg((u16) addr , (u32) para ,bytes,HI708_WRITE_ID)
141 kal_uint16
HI708_read_cmos_sensor(kal_uint32 addr
)
143 kal_uint16 get_byte
=0;
144 iReadReg((u16
) addr
,(u8
*)&get_byte
,HI708_WRITE_ID
);
150 #if defined(DTV_NMI5625) || defined(ATV_NMI168H)
151 extern bool g_bIsAtvStart
;
154 static DEFINE_SPINLOCK(hi708_yuv_drv_lock
);
156 extern int iReadRegI2C(u8
*a_pSendData
, u16 a_sizeSendData
, u8
* a_pRecvData
, u16 a_sizeRecvData
, u16 i2cId
);
157 extern int iWriteRegI2C(u8
*a_pSendData
, u16 a_sizeSendData
, u16 i2cId
);
158 kal_uint16
HI708_write_cmos_sensor(kal_uint8 addr
, kal_uint8 para
)
160 char puSendCmd
[2] = {(char)(addr
& 0xFF) , (char)(para
& 0xFF)};
161 iWriteRegI2C(puSendCmd
, 2,HI708_WRITE_ID
);
164 kal_uint16
HI708_read_cmos_sensor(kal_uint8 addr
)
166 kal_uint16 get_byte
=0;
167 char puSendCmd
= { (char)(addr
& 0xFF) };
168 iReadRegI2C(&puSendCmd
, 1, (u8
*)&get_byte
,1,HI708_WRITE_ID
);
172 #define HI708_LOAD_FROM_T_FLASH
173 #ifdef HI708_LOAD_FROM_T_FLASH
175 static kal_uint8 fromsd
= 0;
176 kal_uint16
HI708_write_cmos_sensor(kal_uint8 addr
, kal_uint8 para
);
178 #define HI708_OP_CODE_INI 0x00 /* Initial value. */
179 #define HI708_OP_CODE_REG 0x01 /* Register */
180 #define HI708_OP_CODE_DLY 0x02 /* Delay */
181 #define HI708_OP_CODE_END 0x03 /* End of initial setting. */
186 u16 init_val
; /* Save the register value and delay tick */
187 u8 op_code
; /* 0 - Initial value, 1 - Register, 2 - Delay, 3 - End of setting. */
188 } HI708_initial_set_struct
;
190 HI708_initial_set_struct HI708_Init_Reg
[1000];
192 u32
strtol(const char *nptr
, u8 base
)
195 if(!nptr
|| (base
!=16 && base
!=10 && base
!=8))
197 printk("%s(): NULL pointer input\n", __FUNCTION__
);
200 for(ret
=0; *nptr
; nptr
++)
202 if((base
==16 && *nptr
>='A' && *nptr
<='F') ||
203 (base
==16 && *nptr
>='a' && *nptr
<='f') ||
204 (base
>=10 && *nptr
>='0' && *nptr
<='9') ||
205 (base
>=8 && *nptr
>='0' && *nptr
<='7') )
208 if(base
==16 && *nptr
>='A' && *nptr
<='F')
210 else if(base
==16 && *nptr
>='a' && *nptr
<='f')
212 else if(base
>=10 && *nptr
>='0' && *nptr
<='9')
214 else if(base
>=8 && *nptr
>='0' && *nptr
<='7')
223 u8
Hi708_Initialize_from_T_Flash()
225 //FS_HANDLE fp = -1; /* Default, no file opened. */
226 //u8 *data_buff = NULL;
229 //u32 bytes_read = 0;
231 u8 func_ind
[4] = {0}; /* REG or DLY */
237 static u8 data_buff
[10*1024] ;
239 fp
= filp_open("/storage/sdcard0/hi708_sd.dat", O_RDONLY
, 0);
241 printk("create file error\n");
245 printk("Hi708_Initialize_from_T_Flash Open File Success\n");
250 file_size
= vfs_llseek(fp
, 0, SEEK_END
);
251 vfs_read(fp
, data_buff
, file_size
, &pos
);
252 filp_close(fp
, NULL
);
257 /* Start parse the setting witch read from t-flash. */
258 curr_ptr
= data_buff
;
259 while (curr_ptr
< (data_buff
+ file_size
))
261 while ((*curr_ptr
== ' ') || (*curr_ptr
== '\t'))/* Skip the Space & TAB */
264 if (((*curr_ptr
) == '/') && ((*(curr_ptr
+ 1)) == '*'))
266 while (!(((*curr_ptr
) == '*') && ((*(curr_ptr
+ 1)) == '/')))
268 curr_ptr
++; /* Skip block comment code. */
271 while (!((*curr_ptr
== 0x0D) && (*(curr_ptr
+1) == 0x0A)))
276 curr_ptr
+= 2; /* Skip the enter line */
281 if (((*curr_ptr
) == '/') || ((*curr_ptr
) == '{') || ((*curr_ptr
) == '}')) /* Comment line, skip it. */
283 while (!((*curr_ptr
== 0x0D) && (*(curr_ptr
+1) == 0x0A)))
288 curr_ptr
+= 2; /* Skip the enter line */
292 /* This just content one enter line. */
293 if (((*curr_ptr
) == 0x0D) && ((*(curr_ptr
+ 1)) == 0x0A))
298 //printk(" curr_ptr1 = %s\n",curr_ptr);
299 memcpy(func_ind
, curr_ptr
, 3);
301 if (strcmp((const char *)func_ind
, "REG") == 0) /* REG */
303 curr_ptr
+= 6; /* Skip "REG(0x" or "DLY(" */
304 HI708_Init_Reg
[i
].op_code
= HI708_OP_CODE_REG
;
306 HI708_Init_Reg
[i
].init_reg
= strtol((const char *)curr_ptr
, 16);
307 curr_ptr
+= 5; /* Skip "00, 0x" */
309 HI708_Init_Reg
[i
].init_val
= strtol((const char *)curr_ptr
, 16);
310 curr_ptr
+= 4; /* Skip "00);" */
314 /* Need add delay for this setting. */
316 HI708_Init_Reg
[i
].op_code
= HI708_OP_CODE_DLY
;
318 HI708_Init_Reg
[i
].init_reg
= 0xFF;
319 HI708_Init_Reg
[i
].init_val
= strtol((const char *)curr_ptr
, 10); /* Get the delay ticks, the delay should less then 50 */
323 /* Skip to next line directly. */
324 while (!((*curr_ptr
== 0x0D) && (*(curr_ptr
+1) == 0x0A)))
331 /* (0xFFFF, 0xFFFF) means the end of initial setting. */
332 HI708_Init_Reg
[i
].op_code
= HI708_OP_CODE_END
;
333 HI708_Init_Reg
[i
].init_reg
= 0xFF;
334 HI708_Init_Reg
[i
].init_val
= 0xFF;
336 //for (j=0; j<i; j++)
337 //printk(" %x == %x\n",SP2528_Init_Reg[j].init_reg, SP2528_Init_Reg[j].init_val);
339 /* Start apply the initial setting to sensor. */
343 if (HI708_Init_Reg
[j
].op_code
== HI708_OP_CODE_END
) /* End of the setting. */
347 else if (HI708_Init_Reg
[j
].op_code
== HI708_OP_CODE_DLY
)
349 msleep(HI708_Init_Reg
[j
].init_val
); /* Delay */
351 else if (HI708_Init_Reg
[j
].op_code
== HI708_OP_CODE_REG
)
353 HI708_write_cmos_sensor((kal_uint8
)HI708_Init_Reg
[j
].init_reg
, (kal_uint8
)HI708_Init_Reg
[j
].init_val
);
357 printk("REG ERROR!\n");
367 /*******************************************************************************
368 * // Adapter for Winmo typedef
369 ********************************************************************************/
372 #define Sleep(ms) mdelay(ms)
373 #define RETAILMSG(x,...)
377 /*******************************************************************************
378 * follow is define by jun
379 ********************************************************************************/
380 MSDK_SENSOR_CONFIG_STRUCT HI708SensorConfigData
;
382 static struct HI708_sensor_STRUCT HI708_sensor
;
383 static kal_uint32 HI708_zoom_factor
= 0;
384 static kal_bool HI708_night_flag
= 0;
385 static int sensor_id_fail
= 0;
386 const HI708_SENSOR_INIT_INFO HI708_Initial_Setting_Info
[] =
392 {0x11,0x93},//ForNoFixedFramerateBit[2]
393 {0x12,0x05},//PCLKINV
405 {0x40, 0x01}, //HBLANK: 0x70 = 112
407 {0x42, 0x00}, //VBLANK: 0x40 = 64
408 {0x43, 0x14}, //0x04 -> 0x40: For Max Framerate = 30fps
416 {0x89,0x48},//BLChold
424 {0xa0,0x43},//DarkBLC
425 {0xa8,0x43},//NormalBLC
491 {0x10,0x03},//03;//ISPCTL1;YUVORDER{FIX)
493 {0x12,0xF0},//Yoffet;dyoffseetenable
495 {0x41,0x00},//00DYOFS
498 {0x48,0x94},//Contrast //0xaa
504 {0x63,0x90},//SATR 0x8a
511 {0x10,0x25}, //LPF_CTL1//0x01
512 {0x11,0x07}, //TestSetting
513 {0x20,0x00}, //LPF_AUTO_CTL
514 {0x21,0x38}, //LPF_PGA_TH
515 {0x22,0x00}, //LPF_TIME_TH
516 {0x23,0x10}, //TestSetting
517 {0x60,0x10}, //ZARA_SIGMA_TH//40->10
519 {0x62,0x00}, //ZARA_HLVL_CTL
520 {0x63,0x00}, //ZARA_LLVL_CTL
521 {0x64,0x00}, //ZARA_DY_CTL
523 {0x67,0xA0}, //TestSetting
524 {0x68,0x40}, //TestSetting
525 {0x69,0x10}, //TestSetting
529 {0x40,0xeb}, //YC2D_LPF_CTL1
530 {0x41,0x10}, //YC2D_LPF_CTL2
531 {0x50,0x18}, //TestSetting
532 {0x51,0x24}, //TestSetting
533 {0x70,0x1f}, //GBGR_CTL1//0x1f
534 {0x71,0x00}, //TestSetting
535 {0x72,0x00}, //TestSetting
536 {0x73,0x00}, //TestSetting
537 {0x74,0x10}, //GBGR_G_UNIT_TH
538 {0x75,0x10}, //GBGR_RB_UNIT_TH
539 {0x76,0x20}, //GBGR_EDGE_TH
540 {0x77,0x80}, //GBGR_HLVL_TH
541 {0x78,0x88}, //GBGR_HLVL_COMP
542 {0x79,0x18}, //TestSetting
551 {0x14,0x08}, //TestSetting
552 {0x20,0x06}, //SHARP_SLOPE
553 {0x21,0x05}, //SHARP_SLOPE_TH
554 {0x23,0x30}, //SHARP_DY_CTL
555 {0x24,0x33}, //40->33
556 {0x25,0x08}, //SHARP_PGA_TH
557 {0x26,0x18}, //TestSetting
558 {0x27,0x00}, //TestSetting
559 {0x28,0x08}, //TestSetting
561 {0x2a,0xe0}, //regionratio
562 {0x2b,0x10}, //TestSetting
563 {0x2c,0x28}, //TestSetting
564 {0x2d,0x40}, //TestSetting
565 {0x2e,0x00}, //TestSetting
566 {0x2f,0x00}, //TestSetting
567 {0x30,0x11}, //TestSetting
568 {0x80,0x03}, //SHARP2D_CTL
569 {0x81,0x07}, //TestSetting
570 {0x90,0x06}, //SHARP2D_SLOPE
571 {0x91,0x05}, //SHARP2D_DIFF_CTL
572 {0x92,0x00}, //SHARP2D_HI_CLIP
573 {0x93,0x20}, //SHARP2D_DY_CTL
574 {0x94,0x42}, //TestSetting
575 {0x95,0x60}, //TestSetting
582 {0x22,0x54},//76;34;2b
583 {0x23,0x50},//4b;15;0d
584 {0x24,0x44},//3b;10;0b
635 //AutoFlickerCancellation
665 {0x70,0x48},//YTarget42
667 {0x76,0x22},//Unlockbnd1
668 {0x77,0x02},//Unlockbnd2
677 {0x83, 0x01}, //EXP Normal 33.33 fps
680 {0x86, 0x00}, //EXPMin 3250.00 fps
682 {0x88, 0x01}, //EXP Max 7.14 fps
685 {0x8B, 0x1f}, //EXP100
687 {0x8D, 0x1a}, //EXP120
689 {0x9c, 0x03}, //EXP Limit 812.50 fps
691 {0x9e, 0x00}, //EXP Unit
715 {0xc0, 0x1a}, //0x1a->0x16
778 {0xff,0xff}//EndofInitialSetting
781 static void HI708_Set_VGA_mode(void)
783 HI708_write_cmos_sensor(0x01, HI708_read_cmos_sensor(0x01)|0x01); //Sleep: For Write Reg
785 HI708_write_cmos_sensor(0x03, 0x00);
786 HI708_write_cmos_sensor(0x10, 0x00); //VGA Size
788 HI708_write_cmos_sensor(0x20, 0x00);
789 HI708_write_cmos_sensor(0x21, 0x04);
791 HI708_write_cmos_sensor(0x40, 0x01); //HBLANK: 0x70 = 112
792 HI708_write_cmos_sensor(0x41, 0x58);
793 HI708_write_cmos_sensor(0x42, 0x00); //VBLANK: 0x04 = 4
794 HI708_write_cmos_sensor(0x43, 0x14);
796 // HI708_write_cmos_sensor(0x03, 0x11);
797 // HI708_write_cmos_sensor(0x10, 0x25);
799 HI708_write_cmos_sensor(0x03, 0x20);
801 HI708_write_cmos_sensor(0x10, HI708_read_cmos_sensor(0x10)&0x7f); //Close AE
802 HI708_write_cmos_sensor(0x18, HI708_read_cmos_sensor(0x18)|0x08); //Reset AE
804 //HI708_write_cmos_sensor(0x83, 0x00);
805 // HI708_write_cmos_sensor(0x84, 0xbe);
806 //HI708_write_cmos_sensor(0x85, 0x6e);
807 HI708_write_cmos_sensor(0x86, 0x00);
808 HI708_write_cmos_sensor(0x87, 0xfa);
810 HI708_write_cmos_sensor(0x8b, 0x1f);
811 HI708_write_cmos_sensor(0x8c, 0xbd);
812 HI708_write_cmos_sensor(0x8d, 0x1a);
813 HI708_write_cmos_sensor(0x8e, 0x5e);
815 HI708_write_cmos_sensor(0x9c, 0x03);//0b
816 HI708_write_cmos_sensor(0x9d, 0x6b);//b8
817 HI708_write_cmos_sensor(0x9e, 0x00);
818 HI708_write_cmos_sensor(0x9f, 0xfa);
820 HI708_write_cmos_sensor(0x01, HI708_read_cmos_sensor(0x01)&0xfe); //Exit Sleep: For Write Reg
822 HI708_write_cmos_sensor(0x03, 0x20);
823 HI708_write_cmos_sensor(0x10, HI708_read_cmos_sensor(0x10)|0x80); //Open AE
824 HI708_write_cmos_sensor(0x18, HI708_read_cmos_sensor(0x18)&0xf7); //Reset AE
828 static void HI708_Initial_Setting(void)
831 for(iEcount
=0;(!((0xff==(HI708_Initial_Setting_Info
[iEcount
].address
))&&(0xff==(HI708_Initial_Setting_Info
[iEcount
].data
))));iEcount
++)
833 HI708_write_cmos_sensor(HI708_Initial_Setting_Info
[iEcount
].address
, HI708_Initial_Setting_Info
[iEcount
].data
);
836 HI708_Set_VGA_mode();
839 static void HI708_Init_Parameter(void)
841 spin_lock(&hi708_yuv_drv_lock
);
842 HI708_sensor
.first_init
= KAL_TRUE
;
843 HI708_sensor
.pv_mode
= KAL_TRUE
;
844 HI708_sensor
.night_mode
= KAL_FALSE
;
845 HI708_sensor
.MPEG4_Video_mode
= KAL_FALSE
;
847 HI708_sensor
.cp_pclk
= HI708_sensor
.pv_pclk
;
849 HI708_sensor
.pv_dummy_pixels
= 0;
850 HI708_sensor
.pv_dummy_lines
= 0;
851 HI708_sensor
.cp_dummy_pixels
= 0;
852 HI708_sensor
.cp_dummy_lines
= 0;
855 HI708_sensor
.exposure
= 0;
856 HI708_sensor
.effect
= 0;
857 HI708_sensor
.banding
= AE_FLICKER_MODE_50HZ
;
859 HI708_sensor
.pv_line_length
= 640;
860 HI708_sensor
.pv_frame_height
= 480;
861 HI708_sensor
.cp_line_length
= 640;
862 HI708_sensor
.cp_frame_height
= 480;
863 spin_unlock(&hi708_yuv_drv_lock
);
866 static kal_uint8
HI708_power_on(void)
868 kal_uint8 HI708_sensor_id
= 0;
869 spin_lock(&hi708_yuv_drv_lock
);
870 HI708_sensor
.pv_pclk
= 13000000;
871 spin_unlock(&hi708_yuv_drv_lock
);
873 HI708_write_cmos_sensor(0x01,0xf1);
874 HI708_write_cmos_sensor(0x01,0xf3);
875 HI708_write_cmos_sensor(0x01,0xf1);
878 HI708_sensor_id
= HI708_read_cmos_sensor(0x04);
879 SENSORDB("[HI708YUV]:read Sensor ID:%x\n",HI708_sensor_id
);
880 return HI708_sensor_id
;
884 /*************************************************************************
889 * This function initialize the registers of CMOS sensor
899 *************************************************************************/
900 UINT32
HI708Open(void)
902 spin_lock(&hi708_yuv_drv_lock
);
904 spin_unlock(&hi708_yuv_drv_lock
);
905 SENSORDB("[Enter]:HI708 Open func:");
908 if (HI708_power_on() != HI708_SENSOR_ID
)
910 SENSORDB("[HI708]Error:read sensor ID fail\n");
911 spin_lock(&hi708_yuv_drv_lock
);
913 spin_unlock(&hi708_yuv_drv_lock
);
914 return ERROR_SENSOR_CONNECT_FAIL
;
917 /* Apply sensor initail setting*/
919 #ifdef HI708_LOAD_FROM_T_FLASH
924 //static char buf[10*1024] ;
926 printk("HI708 Open File Start\n");
927 fp
= filp_open("/storage/sdcard0/hi708_sd.dat", O_RDONLY
, 0);
931 printk("open file error\n");
936 printk("open file success\n");
938 //SP2528_Initialize_from_T_Flash();
939 filp_close(fp
, NULL
);
943 Hi708_Initialize_from_T_Flash();
946 HI708_Initial_Setting();
948 HI708_Init_Parameter();
950 /* Apply sensor initail setting*/
951 HI708_Initial_Setting();
952 HI708_Init_Parameter();
957 SENSORDB("[Exit]:HI708 Open func\n");
961 UINT32
HI708Init(void)
963 UINT32 open_ret
= HI708Open();
965 if (ERROR_SENSOR_CONNECT_FAIL
!= open_ret
)
967 HI708_write_cmos_sensor(0x03, 0x00);
968 HI708_write_cmos_sensor(0x08, 0x0f);
969 HI708_write_cmos_sensor(0x01, 0xf1); //sensor sleep mode
976 /*************************************************************************
981 * This function get the sensor ID
991 *************************************************************************/
992 static kal_uint32
HI708_GetSensorID(kal_uint32
*sensorID
)
994 SENSORDB("[Enter]:HI708 Open func ");
995 *sensorID
= HI708_power_on() ;
997 if (*sensorID
!= HI708_SENSOR_ID
)
999 SENSORDB("[HI708]Error:read sensor ID fail\n");
1000 spin_lock(&hi708_yuv_drv_lock
);
1002 spin_unlock(&hi708_yuv_drv_lock
);
1003 *sensorID
= 0xFFFFFFFF;
1004 return ERROR_SENSOR_CONNECT_FAIL
;
1011 /*************************************************************************
1016 * This function is to turn off sensor module power.
1026 *************************************************************************/
1027 UINT32
HI708Close(void)
1031 } /* HI708Close() */
1034 static void HI708_Set_Mirror_Flip(kal_uint8 image_mirror
)
1036 /********************************************************
1037 * Page Mode 0: Reg 0x0011 bit[1:0] = [Y Flip : X Flip]
1039 *********************************************************/
1040 kal_uint8 temp_data
;
1041 SENSORDB("[Enter]:HI708 set Mirror_flip func:image_mirror=%d\n",image_mirror
);
1042 HI708_write_cmos_sensor(0x03,0x00); //Page 0
1043 temp_data
= (HI708_read_cmos_sensor(0x11) & 0xfc);
1044 spin_lock(&hi708_yuv_drv_lock
);
1045 //HI708_sensor.mirror = (HI708_read_cmos_sensor(0x11) & 0xfc);
1046 switch (image_mirror
)
1049 //HI708_sensor.mirror |= 0x00;
1052 case IMAGE_H_MIRROR
:
1053 //HI708_sensor.mirror |= 0x01;
1056 case IMAGE_V_MIRROR
:
1057 //HI708_sensor.mirror |= 0x02;
1060 case IMAGE_HV_MIRROR
:
1061 //HI708_sensor.mirror |= 0x03;
1065 //HI708_sensor.mirror |= 0x00;
1068 HI708_sensor
.mirror
= temp_data
;
1069 spin_unlock(&hi708_yuv_drv_lock
);
1070 HI708_write_cmos_sensor(0x11, HI708_sensor
.mirror
);
1071 SENSORDB("[Exit]:HI708 set Mirror_flip func\n");
1075 static void HI708_set_dummy(kal_uint16 dummy_pixels
,kal_uint16 dummy_lines
)
1077 HI708_write_cmos_sensor(0x03, 0x00); //Page 0
1078 HI708_write_cmos_sensor(0x40,((dummy_pixels
& 0x0F00))>>8); //HBLANK
1079 HI708_write_cmos_sensor(0x41,(dummy_pixels
& 0xFF));
1080 HI708_write_cmos_sensor(0x42,((dummy_lines
& 0xFF00)>>8)); //VBLANK ( Vsync Type 1)
1081 HI708_write_cmos_sensor(0x43,(dummy_lines
& 0xFF));
1088 static void HI708_Cal_Min_Frame_Rate(kal_uint16 min_framerate
)
1090 kal_uint32 HI708_expmax
= 0;
1091 kal_uint32 HI708_expbanding
= 0;
1092 kal_uint32 temp_data
;
1094 SENSORDB("[HI708] HI708_Cal_Min_Frame_Rate:min_fps=%d\n",min_framerate
);
1096 //No Fixed Framerate
1097 HI708_write_cmos_sensor(0x01, HI708_read_cmos_sensor(0x01)|0x01); //Sleep: For Write Reg
1098 HI708_write_cmos_sensor(0x03, 0x00);
1099 HI708_write_cmos_sensor(0x11, HI708_read_cmos_sensor(0x11)&0xfb);
1101 HI708_write_cmos_sensor(0x03, 0x20);
1102 HI708_write_cmos_sensor(0x10, HI708_read_cmos_sensor(0x10)&0x7f); //Close AE
1103 HI708_write_cmos_sensor(0x18, HI708_read_cmos_sensor(0x18)|0x08); //Reset AE
1104 //HI708_write_cmos_sensor(0x11, 0x04);
1105 //HI708_write_cmos_sensor(0x18, HI708_read_cmos_sensor(0x18)|0x08); //Reset AE
1106 //HI708_write_cmos_sensor(0x2a, 0xf0);
1107 //HI708_write_cmos_sensor(0x2b, 0x34);
1109 HI708_write_cmos_sensor(0x03, 0x00);
1110 temp_data
= ((HI708_read_cmos_sensor(0x40)<<8)|HI708_read_cmos_sensor(0x41));
1111 spin_lock(&hi708_yuv_drv_lock
);
1112 HI708_sensor
.pv_dummy_pixels
= temp_data
;
1113 HI708_sensor
.pv_line_length
= HI708_VGA_DEFAULT_PIXEL_NUMS
+ HI708_sensor
.pv_dummy_pixels
;
1114 spin_unlock(&hi708_yuv_drv_lock
);
1116 if(HI708_sensor
.banding
== AE_FLICKER_MODE_50HZ
)
1118 HI708_expbanding
= (HI708_sensor
.pv_pclk
/HI708_sensor
.pv_line_length
/100)*HI708_sensor
.pv_line_length
/8;
1119 HI708_expmax
= HI708_expbanding
*10*(100/min_framerate
) ;
1121 else if(HI708_sensor
.banding
== AE_FLICKER_MODE_60HZ
)
1123 HI708_expbanding
= (HI708_sensor
.pv_pclk
/HI708_sensor
.pv_line_length
/120)*HI708_sensor
.pv_line_length
/8;
1124 HI708_expmax
= HI708_expbanding
*10*(120/min_framerate
) ;
1128 SENSORDB("[HI708][Error] Wrong Banding Setting!!!...");
1131 HI708_write_cmos_sensor(0x03, 0x00);
1132 HI708_write_cmos_sensor(0x12, 0x05);
1134 HI708_write_cmos_sensor(0x03, 0x20);
1136 HI708_write_cmos_sensor(0x8b, 0x1f);
1137 HI708_write_cmos_sensor(0x8c, 0xbd);
1138 HI708_write_cmos_sensor(0x8d, 0x1a);
1139 HI708_write_cmos_sensor(0x8e, 0x5e);
1141 HI708_write_cmos_sensor(0x9c, 0x03);//0b
1142 HI708_write_cmos_sensor(0x9d, 0x6b);//b8
1143 HI708_write_cmos_sensor(0x9e, 0x00);
1144 HI708_write_cmos_sensor(0x9f, 0xfa);
1147 if(HI708_sensor
.night_mode
)
1149 HI708_write_cmos_sensor(0x03, 0x20);
1150 HI708_write_cmos_sensor(0x83, 0x02);//(HI708_expmax>>16)&0xff);//7fps
1151 HI708_write_cmos_sensor(0x84, 0x49);//(HI708_expmax>>8)&0xff);
1152 HI708_write_cmos_sensor(0x85, 0xf0);//(HI708_expmax>>0)&0xff);
1153 HI708_write_cmos_sensor(0x88, 0x02);//(HI708_expmax>>16)&0xff);//7fps
1154 HI708_write_cmos_sensor(0x89, 0x49);//(HI708_expmax>>8)&0xff);
1155 HI708_write_cmos_sensor(0x8a, 0xf0);//(HI708_expmax>>0)&0xff);
1156 HI708_night_flag
= KAL_TRUE
;
1159 if(HI708_night_flag
)
1161 HI708_write_cmos_sensor(0x83, 0x02);//(HI708_expmax>>16)&0xff);//01 10fps
1162 HI708_write_cmos_sensor(0x84, 0x7a);//(HI708_expmax>>8)&0xff);//bc
1163 HI708_write_cmos_sensor(0x85, 0xc4);//(HI708_expmax>>0)&0xff);//56
1164 HI708_night_flag
= KAL_FALSE
;
1166 HI708_write_cmos_sensor(0x88, 0x02);//(HI708_expmax>>16)&0xff);//01 10fps
1167 HI708_write_cmos_sensor(0x89, 0x7a);//(HI708_expmax>>8)&0xff);//bc
1168 HI708_write_cmos_sensor(0x8a, 0xc4);//(HI708_expmax>>0)&0xff);//56
1171 HI708_write_cmos_sensor(0x03, 0x20);
1172 HI708_write_cmos_sensor(0x10, HI708_read_cmos_sensor(0x10)|0x80); //Open AE
1173 HI708_write_cmos_sensor(0x18, HI708_read_cmos_sensor(0x18)&0xf7); //Reset AE
1174 HI708_write_cmos_sensor(0x03, 0x00);
1175 HI708_write_cmos_sensor(0x01, HI708_read_cmos_sensor(0x01)&0xfe); //Exit Sleep: For Write Reg
1180 static void HI708_Fix_Video_Frame_Rate(kal_uint16 fix_framerate
)
1182 kal_uint32 HI708_expfix
;
1183 kal_uint32 HI708_expfix_temp
;
1184 kal_uint32 HI708_expmax
= 0;
1185 kal_uint32 HI708_expbanding
= 0;
1186 kal_uint32 temp_data1
,temp_data2
;
1188 SENSORDB("[Enter]HI708 Fix_video_frame_rate func: fix_fps=%d\n",fix_framerate
);
1190 spin_lock(&hi708_yuv_drv_lock
);
1191 HI708_sensor
.video_current_frame_rate
= fix_framerate
;
1192 spin_unlock(&hi708_yuv_drv_lock
);
1194 HI708_write_cmos_sensor(0x01, HI708_read_cmos_sensor(0x01)|0x01); //Sleep: For Write Reg
1196 HI708_write_cmos_sensor(0x03, 0x00);
1197 //HI708_write_cmos_sensor(0x11, HI708_read_cmos_sensor(0x11)|0x04);
1199 //HI708_write_cmos_sensor(0x12,HI708_read_cmos_sensor(0x12)&0xfe);
1201 HI708_write_cmos_sensor(0x03, 0x20);
1202 HI708_write_cmos_sensor(0x10, HI708_read_cmos_sensor(0x10)&0x7f); //Close AE
1204 HI708_write_cmos_sensor(0x11, 0x00);
1205 HI708_write_cmos_sensor(0x18, HI708_read_cmos_sensor(0x18)|0x08); //Reset AE
1206 //HI708_write_cmos_sensor(0x2a, 0x00);
1207 //HI708_write_cmos_sensor(0x2b, 0x35);
1209 HI708_write_cmos_sensor(0x03, 0x00);
1210 temp_data1
= ((HI708_read_cmos_sensor(0x40)<<8)|HI708_read_cmos_sensor(0x41));
1211 temp_data2
= ((HI708_read_cmos_sensor(0x42)<<8)|HI708_read_cmos_sensor(0x43));
1212 spin_lock(&hi708_yuv_drv_lock
);
1213 HI708_sensor
.pv_dummy_pixels
= temp_data1
;
1214 HI708_sensor
.pv_line_length
= HI708_VGA_DEFAULT_PIXEL_NUMS
+ HI708_sensor
.pv_dummy_pixels
;
1215 HI708_sensor
.pv_dummy_lines
= temp_data2
;
1216 spin_unlock(&hi708_yuv_drv_lock
);
1218 HI708_expfix_temp
= ((HI708_sensor
.pv_pclk
*10/fix_framerate
)-(HI708_sensor
.pv_line_length
*HI708_sensor
.pv_dummy_lines
))/8;
1219 HI708_expfix
= ((HI708_expfix_temp
*8/HI708_sensor
.pv_line_length
)*HI708_sensor
.pv_line_length
)/8;
1221 HI708_write_cmos_sensor(0x03, 0x20);
1222 //HI708_write_cmos_sensor(0x83, (HI708_expfix>>16)&0xff);
1223 //HI708_write_cmos_sensor(0x84, (HI708_expfix>>8)&0xff);
1224 //HI708_write_cmos_sensor(0x85, (HI708_expfix>>0)&0xff);
1225 HI708_write_cmos_sensor(0x8b, 0x1f);
1226 HI708_write_cmos_sensor(0x8c, 0xbd);
1227 HI708_write_cmos_sensor(0x8d, 0x1a);
1228 HI708_write_cmos_sensor(0x8e, 0x5e);
1230 if(HI708_sensor.night_mode)
1232 HI708_write_cmos_sensor(0x83, 0x02);//(HI708_expfix>>16)&0xff);//10fps
1233 HI708_write_cmos_sensor(0x84, 0x7a);//(HI708_expfix>>8)&0xff);
1234 HI708_write_cmos_sensor(0x85, 0xc4);//(HI708_expfix>>0)&0xff);
1235 HI708_write_cmos_sensor(0x88, 0x02);//(HI708_expfix>>16)&0xff);//10fps
1236 HI708_write_cmos_sensor(0x89, 0x7a);//(HI708_expfix>>8)&0xff);
1237 HI708_write_cmos_sensor(0x8a, 0xc4);//(HI708_expfix>>0)&0xff);
1238 HI708_write_cmos_sensor(0x91, 0x02);//(HI708_expfix>>16)&0xff);//10fps
1239 HI708_write_cmos_sensor(0x92, 0x71);//(HI708_expfix>>8)&0xff);
1240 HI708_write_cmos_sensor(0x93, 0x00);//(HI708_expfix>>0)&0xff);
1243 HI708_write_cmos_sensor(0x83, 0x01);//(HI708_expfix>>16)&0xff);//11fps
1244 HI708_write_cmos_sensor(0x84, 0xbc);//(HI708_expfix>>8)&0xff);
1245 HI708_write_cmos_sensor(0x85, 0x56);//(HI708_expfix>>0)&0xff);
1246 HI708_write_cmos_sensor(0x88, 0x00);//(HI708_expfix>>16)&0xff);//11fps
1247 HI708_write_cmos_sensor(0x89, 0xde);//(HI708_expfix>>8)&0xff);
1248 HI708_write_cmos_sensor(0x8a, 0x2b);//(HI708_expfix>>0)&0xff);
1249 HI708_write_cmos_sensor(0x91, 0x01);//(HI708_expfix>>16)&0xff);//10fps
1250 HI708_write_cmos_sensor(0x92, 0xbb);//(HI708_expfix>>8)&0xff);
1251 HI708_write_cmos_sensor(0x93, 0x5c);//(HI708_expfix>>0)&0xff);
1253 if(HI708_sensor
.banding
== AE_FLICKER_MODE_50HZ
)
1255 HI708_expbanding
= ((HI708_read_cmos_sensor(0x8b)<<8)|HI708_read_cmos_sensor(0x8c));
1257 else if(HI708_sensor
.banding
== AE_FLICKER_MODE_60HZ
)
1259 HI708_expbanding
= ((HI708_read_cmos_sensor(0x8d)<<8)|HI708_read_cmos_sensor(0x8e));
1263 SENSORDB("[HI708]Wrong Banding Setting!!!...");
1265 HI708_expmax
= ((HI708_expfix_temp
-HI708_expbanding
)/HI708_expbanding
)*HI708_expbanding
;
1267 HI708_write_cmos_sensor(0x03, 0x20);
1268 //HI708_write_cmos_sensor(0x88, (HI708_expmax>>16)&0xff);
1269 //HI708_write_cmos_sensor(0x89, (HI708_expmax>>8)&0xff);
1270 //HI708_write_cmos_sensor(0x8a, (HI708_expmax>>0)&0xff);
1272 HI708_write_cmos_sensor(0x03, 0x20);
1273 HI708_write_cmos_sensor(0x10, HI708_read_cmos_sensor(0x10)|0x80); //Open AE
1274 HI708_write_cmos_sensor(0x18, HI708_read_cmos_sensor(0x18)&0xf7); //Reset AE
1276 HI708_write_cmos_sensor(0x01, HI708_read_cmos_sensor(0x01)&0xfe); //Exit Sleep: For Write Reg
1281 static void HI708_Set_QVGA_mode(void)
1283 HI708_write_cmos_sensor(0x01, HI708_read_cmos_sensor(0x01)|0x01); //Sleep: For Write Reg
1285 HI708_write_cmos_sensor(0x03, 0x00);
1286 HI708_write_cmos_sensor(0x10, 0x01); //QVGA Size: 0x10 -> 0x01
1288 HI708_write_cmos_sensor(0x20, 0x00);
1289 HI708_write_cmos_sensor(0x21, 0x02);
1291 HI708_write_cmos_sensor(0x40, 0x01); //HBLANK: 0x0158 = 344
1292 HI708_write_cmos_sensor(0x41, 0x58);
1293 HI708_write_cmos_sensor(0x42, 0x00); //VBLANK: 0x14 = 20
1294 HI708_write_cmos_sensor(0x43, 0x14);
1296 HI708_write_cmos_sensor(0x03, 0x11); //QVGA Fixframerate
1297 HI708_write_cmos_sensor(0x10, 0x21);
1299 HI708_write_cmos_sensor(0x03, 0x20);
1300 HI708_write_cmos_sensor(0x10, HI708_read_cmos_sensor(0x10)&0x7f); //Close AE
1301 HI708_write_cmos_sensor(0x18, HI708_read_cmos_sensor(0x18)|0x08); //Reset AE
1303 HI708_write_cmos_sensor(0x83, 0x00);
1304 HI708_write_cmos_sensor(0x84, 0xaf);
1305 HI708_write_cmos_sensor(0x85, 0xc8);
1306 HI708_write_cmos_sensor(0x86, 0x00);
1307 HI708_write_cmos_sensor(0x87, 0xfa);
1309 HI708_write_cmos_sensor(0x8b, 0x3a);
1310 HI708_write_cmos_sensor(0x8c, 0x98);
1311 HI708_write_cmos_sensor(0x8d, 0x30);
1312 HI708_write_cmos_sensor(0x8e, 0xd4);
1314 HI708_write_cmos_sensor(0x9c, 0x0b);
1315 HI708_write_cmos_sensor(0x9d, 0x3b);
1316 HI708_write_cmos_sensor(0x9e, 0x00);
1317 HI708_write_cmos_sensor(0x9f, 0xfa);
1319 HI708_write_cmos_sensor(0x01, HI708_read_cmos_sensor(0x01)&0xfe); //Exit Sleep: For Write Reg
1321 HI708_write_cmos_sensor(0x03, 0x20);
1322 HI708_write_cmos_sensor(0x10, HI708_read_cmos_sensor(0x10)|0x80); //Open AE
1323 HI708_write_cmos_sensor(0x18, HI708_read_cmos_sensor(0x18)&0xf7); //Reset AE
1327 void HI708_night_mode(kal_bool enable
)
1329 SENSORDB("HHL[Enter]HI708 night mode func:enable = %d\n",enable
);
1330 SENSORDB("HI708_sensor.video_mode = %d\n",HI708_sensor
.MPEG4_Video_mode
);
1331 SENSORDB("HI708_sensor.night_mode = %d\n",HI708_sensor
.night_mode
);
1332 spin_lock(&hi708_yuv_drv_lock
);
1333 HI708_sensor
.night_mode
= enable
;
1334 spin_unlock(&hi708_yuv_drv_lock
);
1336 if(HI708_sensor
.MPEG4_Video_mode
== KAL_TRUE
)
1342 if (HI708_sensor
.banding
== AE_FLICKER_MODE_50HZ
)
1345 SENSORDB("[HI708]HI708NightMode Disable AE_FLICKER_MODE_50HZ\n");
1347 HI708_write_cmos_sensor(0x03, 0x20);
1349 HI708_write_cmos_sensor(0x10, HI708_read_cmos_sensor(0x10)&0x7f); //Close AE
1350 HI708_write_cmos_sensor(0x18, HI708_read_cmos_sensor(0x18)|0x08); //Reset AE
1352 //BEGIN <> <20130922> <improve the camera experience that before to capture the next photo, the screen lighten instantly> panzaoyan
1353 HI708_write_cmos_sensor(0x83, 0x02);
1354 HI708_write_cmos_sensor(0x84, 0x7a);
1355 HI708_write_cmos_sensor(0x85, 0xc4);//15fps
1356 HI708_write_cmos_sensor(0x86, 0x00);
1357 HI708_write_cmos_sensor(0x87, 0xfa);
1358 //END <> <20130922> <improve the camera experience that before to capture the next photo, the screen lighten instantly> panzaoyan
1359 HI708_write_cmos_sensor(0x88, 0x02);
1360 HI708_write_cmos_sensor(0x89, 0x7a);
1361 HI708_write_cmos_sensor(0x8A, 0xc4);//7
1363 HI708_write_cmos_sensor(0x8b, 0x1f);
1364 HI708_write_cmos_sensor(0x8c, 0xbd);
1365 HI708_write_cmos_sensor(0x8d, 0x1a);
1366 HI708_write_cmos_sensor(0x8e, 0x5e);
1368 HI708_write_cmos_sensor(0x9c, 0x03);
1369 HI708_write_cmos_sensor(0x9d, 0x6b);
1370 HI708_write_cmos_sensor(0x9e, 0x00);
1371 HI708_write_cmos_sensor(0x9f, 0xfa);
1374 HI708_write_cmos_sensor(0x01, HI708_read_cmos_sensor(0x01)&0xfe); //Exit Sleep: For Write Reg
1376 HI708_write_cmos_sensor(0x03, 0x20);
1377 HI708_write_cmos_sensor(0x10, HI708_read_cmos_sensor(0x10)|0x80); //Open AE
1378 HI708_write_cmos_sensor(0x18, HI708_read_cmos_sensor(0x18)&0xf7); //Reset AE
1385 SENSORDB("[HI708]HI708NightMode Disable AE_FLICKER_MODE_60HZ\n");
1386 HI708_write_cmos_sensor(0x03, 0x20);
1388 HI708_write_cmos_sensor(0x10, HI708_read_cmos_sensor(0x10)&0x7f); //Close AE
1389 HI708_write_cmos_sensor(0x18, HI708_read_cmos_sensor(0x18)|0x08); //Reset AE
1391 //BEGIN <> <20130922> <improve the camera experience that before to capture the next photo, the screen lighten instantly> panzaoyan
1393 HI708_write_cmos_sensor(0x83, 0x02);
1394 HI708_write_cmos_sensor(0x84, 0x78);
1395 HI708_write_cmos_sensor(0x85, 0xd0);//15fps
1396 HI708_write_cmos_sensor(0x86, 0x00);
1397 HI708_write_cmos_sensor(0x87, 0xfa);
1398 //END <> <20130922> <improve the camera experience that before to capture the next photo, the screen lighten instantly> panzaoyan
1399 HI708_write_cmos_sensor(0x88, 0x02);
1400 HI708_write_cmos_sensor(0x89, 0x78);
1401 HI708_write_cmos_sensor(0x8A, 0xd0);//7
1403 HI708_write_cmos_sensor(0x8b, 0x1f);
1404 HI708_write_cmos_sensor(0x8c, 0xbd);
1405 HI708_write_cmos_sensor(0x8d, 0x1a);
1406 HI708_write_cmos_sensor(0x8e, 0x5e);
1408 HI708_write_cmos_sensor(0x9c, 0x03);
1409 HI708_write_cmos_sensor(0x9d, 0x6b);
1410 HI708_write_cmos_sensor(0x9e, 0x00);
1411 HI708_write_cmos_sensor(0x9f, 0xfa);
1414 HI708_write_cmos_sensor(0x01, HI708_read_cmos_sensor(0x01)&0xfe); //Exit Sleep: For Write Reg
1416 HI708_write_cmos_sensor(0x03, 0x20);
1417 HI708_write_cmos_sensor(0x10, HI708_read_cmos_sensor(0x10)|0x80); //Open AE
1418 HI708_write_cmos_sensor(0x18, HI708_read_cmos_sensor(0x18)&0xf7); //Reset AE
1427 if (HI708_sensor
.banding
== AE_FLICKER_MODE_50HZ
)
1428 { SENSORDB("[HI708]HI708NightMode Enable AE_FLICKER_MODE_50HZ\n");
1429 HI708_write_cmos_sensor(0x03, 0x20);
1431 HI708_write_cmos_sensor(0x10, HI708_read_cmos_sensor(0x10)&0x7f); //Close AE
1432 HI708_write_cmos_sensor(0x18, HI708_read_cmos_sensor(0x18)|0x08); //Reset AE
1433 //BEGIN <> <20130922> <improve the camera experience that before to capture the next photo, the screen lighten instantly> panzaoyan
1434 HI708_write_cmos_sensor(0x83, 0x01);
1435 HI708_write_cmos_sensor(0x84, 0xbc);
1436 HI708_write_cmos_sensor(0x85, 0x56);//15fps
1437 HI708_write_cmos_sensor(0x86, 0x00);
1438 HI708_write_cmos_sensor(0x87, 0xfa);
1439 //END <> <20130922> <improve the camera experience that before to capture the next photo, the screen lighten instantly> panzaoyan
1440 HI708_write_cmos_sensor(0x88, 0x01);
1441 HI708_write_cmos_sensor(0x89, 0xbc);
1442 HI708_write_cmos_sensor(0x8A, 0x56);//7
1444 HI708_write_cmos_sensor(0x8b, 0x1f);
1445 HI708_write_cmos_sensor(0x8c, 0xbd);
1446 HI708_write_cmos_sensor(0x8d, 0x1a);
1447 HI708_write_cmos_sensor(0x8e, 0x5e);
1449 HI708_write_cmos_sensor(0x9c, 0x03);
1450 HI708_write_cmos_sensor(0x9d, 0x6b);
1451 HI708_write_cmos_sensor(0x9e, 0x00);
1452 HI708_write_cmos_sensor(0x9f, 0xfa);
1455 HI708_write_cmos_sensor(0x01, HI708_read_cmos_sensor(0x01)&0xfe); //Exit Sleep: For Write Reg
1457 HI708_write_cmos_sensor(0x03, 0x20);
1458 HI708_write_cmos_sensor(0x10, HI708_read_cmos_sensor(0x10)|0x80); //Open AE
1459 HI708_write_cmos_sensor(0x18, HI708_read_cmos_sensor(0x18)&0xf7); //Reset AE
1463 { SENSORDB("[HI708]HI708NightMode Enable AE_FLICKER_MODE_60HZ\n");
1465 HI708_write_cmos_sensor(0x03, 0x20);
1467 HI708_write_cmos_sensor(0x10, HI708_read_cmos_sensor(0x10)&0x7f); //Close AE
1468 HI708_write_cmos_sensor(0x18, HI708_read_cmos_sensor(0x18)|0x08); //Reset AE
1469 //BEGIN <> <20130922> <improve the camera experience that before to capture the next photo, the screen lighten instantly> panzaoyan
1470 HI708_write_cmos_sensor(0x83, 0x01);
1471 HI708_write_cmos_sensor(0x84, 0xc0);
1472 HI708_write_cmos_sensor(0x85, 0x3e);//15fps
1473 HI708_write_cmos_sensor(0x86, 0x00);
1474 HI708_write_cmos_sensor(0x87, 0xfa);
1475 //END<> <20130922> <improve the camera experience that before to capture the next photo, the screen lighten instantly> panzaoyan
1476 HI708_write_cmos_sensor(0x88, 0x01);
1477 HI708_write_cmos_sensor(0x89, 0xc0);
1478 HI708_write_cmos_sensor(0x8A, 0x3e);//7
1480 HI708_write_cmos_sensor(0x8b, 0x1f);
1481 HI708_write_cmos_sensor(0x8c, 0xbd);
1482 HI708_write_cmos_sensor(0x8d, 0x1a);
1483 HI708_write_cmos_sensor(0x8e, 0x5e);
1485 HI708_write_cmos_sensor(0x9c, 0x03);
1486 HI708_write_cmos_sensor(0x9d, 0x6b);
1487 HI708_write_cmos_sensor(0x9e, 0x00);
1488 HI708_write_cmos_sensor(0x9f, 0xfa);
1491 HI708_write_cmos_sensor(0x01, HI708_read_cmos_sensor(0x01)&0xfe); //Exit Sleep: For Write Reg
1493 HI708_write_cmos_sensor(0x03, 0x20);
1494 HI708_write_cmos_sensor(0x10, HI708_read_cmos_sensor(0x10)|0x80); //Open AE
1495 HI708_write_cmos_sensor(0x18, HI708_read_cmos_sensor(0x18)&0xf7); //Reset AE
1503 /*************************************************************************
1508 * This function start the sensor preview.
1511 * *image_window : address pointer of pixel numbers in one period of HSYNC
1512 * *sensor_config_data : address pointer of line numbers in one period of VSYNC
1519 *************************************************************************/
1520 static UINT32
HI708Preview(MSDK_SENSOR_EXPOSURE_WINDOW_STRUCT
*image_window
,
1521 MSDK_SENSOR_CONFIG_STRUCT
*sensor_config_data
)
1524 HI708_write_cmos_sensor(0x03, 0x22);
1525 HI708_write_cmos_sensor(0x10, 0xfb);
1526 spin_lock(&hi708_yuv_drv_lock
);
1527 sensor_config_data
->SensorImageMirror
= IMAGE_HV_MIRROR
;
1528 if(HI708_sensor
.first_init
== KAL_TRUE
)
1530 HI708_sensor
.MPEG4_Video_mode
= HI708_sensor
.MPEG4_Video_mode
;
1534 HI708_sensor
.MPEG4_Video_mode
= KAL_FALSE
;//!HI708_sensor.MPEG4_Video_mode;
1536 spin_unlock(&hi708_yuv_drv_lock
);
1538 SENSORDB("HHL[Enter]:HI708 preview func:");
1539 SENSORDB("HI708_sensor.video_mode = %d\n",HI708_sensor
.MPEG4_Video_mode
);
1541 spin_lock(&hi708_yuv_drv_lock
);
1542 HI708_sensor
.first_init
= KAL_FALSE
;
1543 HI708_sensor
.pv_mode
= KAL_TRUE
;
1544 spin_unlock(&hi708_yuv_drv_lock
);
1547 // SENSORDB("[HI708]preview set_VGA_mode\n");
1551 //HI708_write_cmos_sensor(0x03, 0x10);
1552 //HI708_write_cmos_sensor(0x40, 0x03);
1553 //HI708_write_cmos_sensor(0x62, 0x83);
1554 //HI708_write_cmos_sensor(0x63, 0x9a);
1556 // HI708_Set_Mirror_Flip(sensor_config_data->SensorImageMirror);
1557 // HI708_Set_Mirror_Flip(IMAGE_V_MIRROR);
1559 SENSORDB("[Exit]:HI708 preview func\n");
1561 HI708_night_mode(HI708_sensor
.night_mode
);
1563 } /* HI708_Preview */
1566 UINT32
HI708Capture(MSDK_SENSOR_EXPOSURE_WINDOW_STRUCT
*image_window
,
1567 MSDK_SENSOR_CONFIG_STRUCT
*sensor_config_data
)
1569 kal_uint32 CapShutter
;
1570 SENSORDB("HHL[HI708][Enter]HI708_capture_func\n");
1571 spin_lock(&hi708_yuv_drv_lock
);
1572 HI708_sensor
.pv_mode
= KAL_FALSE
;
1573 spin_unlock(&hi708_yuv_drv_lock
);
1575 HI708_write_cmos_sensor(0x03, 0x20);
1576 HI708_sensor
.PvShutter
= (HI708_read_cmos_sensor(0x80) << 16)|(HI708_read_cmos_sensor(0x81) << 8)|HI708_read_cmos_sensor(0x82);
1577 CapShutter
= HI708_sensor
.PvShutter
;
1578 HI708_sensor
.CapExposure
=HI708_sensor
.PvShutter
*8*76923
1580 HI708_write_cmos_sensor(0x03, 0x20);
1581 HI708_write_cmos_sensor(0x83, (CapShutter
>> 16) & 0xFF);
1582 HI708_write_cmos_sensor(0x84, (CapShutter
>> 8) & 0xFF);
1583 HI708_write_cmos_sensor(0x85, CapShutter
& 0xFF);
1586 } /* HM3451Capture() */
1589 UINT32
HI708GetResolution(MSDK_SENSOR_RESOLUTION_INFO_STRUCT
*pSensorResolution
)
1591 SENSORDB("[Enter]:HI708 get Resolution func\n");
1593 pSensorResolution
->SensorFullWidth
=HI708_IMAGE_SENSOR_FULL_WIDTH
;
1594 pSensorResolution
->SensorFullHeight
=HI708_IMAGE_SENSOR_FULL_HEIGHT
;
1595 pSensorResolution
->SensorPreviewWidth
=HI708_IMAGE_SENSOR_PV_WIDTH
;
1596 pSensorResolution
->SensorPreviewHeight
=HI708_IMAGE_SENSOR_PV_HEIGHT
;
1597 pSensorResolution
->SensorVideoWidth
=HI708_IMAGE_SENSOR_PV_WIDTH
;
1598 pSensorResolution
->SensorVideoHeight
=HI708_IMAGE_SENSOR_PV_HEIGHT
;
1599 pSensorResolution
->Sensor3DFullWidth
=HI708_IMAGE_SENSOR_FULL_WIDTH
;
1600 pSensorResolution
->Sensor3DFullHeight
=HI708_IMAGE_SENSOR_FULL_HEIGHT
;
1601 pSensorResolution
->Sensor3DPreviewWidth
=HI708_IMAGE_SENSOR_PV_WIDTH
;
1602 pSensorResolution
->Sensor3DPreviewHeight
=HI708_IMAGE_SENSOR_PV_HEIGHT
;
1603 pSensorResolution
->Sensor3DVideoWidth
=HI708_IMAGE_SENSOR_PV_WIDTH
;
1604 pSensorResolution
->Sensor3DVideoHeight
=HI708_IMAGE_SENSOR_PV_HEIGHT
;
1606 SENSORDB("[Exit]:HI708 get Resolution func\n");
1608 } /* HI708GetResolution() */
1610 UINT32
HI708GetInfo(MSDK_SCENARIO_ID_ENUM ScenarioId
,
1611 MSDK_SENSOR_INFO_STRUCT
*pSensorInfo
,
1612 MSDK_SENSOR_CONFIG_STRUCT
*pSensorConfigData
)
1618 case MSDK_SCENARIO_ID_CAMERA_ZSD
:
1619 pSensorInfo
->SensorPreviewResolutionX
=HI708_IMAGE_SENSOR_PV_WIDTH
;
1620 pSensorInfo
->SensorPreviewResolutionY
=HI708_IMAGE_SENSOR_PV_HEIGHT
;
1621 pSensorInfo
->SensorFullResolutionX
=HI708_IMAGE_SENSOR_FULL_WIDTH
;
1622 pSensorInfo
->SensorFullResolutionY
=HI708_IMAGE_SENSOR_FULL_HEIGHT
;
1623 pSensorInfo
->SensorCameraPreviewFrameRate
=15;
1626 case MSDK_SCENARIO_ID_CAMERA_PREVIEW
:
1627 case MSDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG
:
1628 pSensorInfo
->SensorPreviewResolutionX
=HI708_IMAGE_SENSOR_PV_WIDTH
;
1629 pSensorInfo
->SensorPreviewResolutionY
=HI708_IMAGE_SENSOR_PV_HEIGHT
;
1630 pSensorInfo
->SensorFullResolutionX
=HI708_IMAGE_SENSOR_FULL_WIDTH
;
1631 pSensorInfo
->SensorFullResolutionY
=HI708_IMAGE_SENSOR_FULL_HEIGHT
;
1632 pSensorInfo
->SensorCameraPreviewFrameRate
=30;
1634 case MSDK_SCENARIO_ID_VIDEO_PREVIEW
:
1635 pSensorInfo
->SensorPreviewResolutionX
=HI708_IMAGE_SENSOR_PV_WIDTH
;
1636 pSensorInfo
->SensorPreviewResolutionY
=HI708_IMAGE_SENSOR_PV_HEIGHT
;
1637 pSensorInfo
->SensorFullResolutionX
=HI708_IMAGE_SENSOR_FULL_WIDTH
;
1638 pSensorInfo
->SensorFullResolutionY
=HI708_IMAGE_SENSOR_FULL_HEIGHT
;
1639 pSensorInfo
->SensorCameraPreviewFrameRate
=30;
1641 case MSDK_SCENARIO_ID_CAMERA_3D_PREVIEW
: //added
1642 case MSDK_SCENARIO_ID_CAMERA_3D_VIDEO
:
1643 case MSDK_SCENARIO_ID_CAMERA_3D_CAPTURE
: //added
1644 pSensorInfo
->SensorPreviewResolutionX
=HI708_IMAGE_SENSOR_PV_WIDTH
;
1645 pSensorInfo
->SensorPreviewResolutionY
=HI708_IMAGE_SENSOR_PV_HEIGHT
;
1646 pSensorInfo
->SensorFullResolutionX
=HI708_IMAGE_SENSOR_FULL_WIDTH
;
1647 pSensorInfo
->SensorFullResolutionY
=HI708_IMAGE_SENSOR_FULL_HEIGHT
;
1648 pSensorInfo
->SensorCameraPreviewFrameRate
=30;
1652 pSensorInfo
->SensorPreviewResolutionX
=HI708_IMAGE_SENSOR_PV_WIDTH
;
1653 pSensorInfo
->SensorPreviewResolutionY
=HI708_IMAGE_SENSOR_PV_HEIGHT
;
1654 pSensorInfo
->SensorFullResolutionX
=HI708_IMAGE_SENSOR_FULL_WIDTH
;
1655 pSensorInfo
->SensorFullResolutionY
=HI708_IMAGE_SENSOR_FULL_HEIGHT
;
1656 pSensorInfo
->SensorCameraPreviewFrameRate
=30;
1663 SENSORDB("[Enter]:HI708 getInfo func:ScenarioId = %d\n",ScenarioId
);
1665 // pSensorInfo->SensorPreviewResolutionX=HI708_IMAGE_SENSOR_PV_WIDTH;
1666 // pSensorInfo->SensorPreviewResolutionY=HI708_IMAGE_SENSOR_PV_HEIGHT;
1667 // pSensorInfo->SensorFullResolutionX=HI708_IMAGE_SENSOR_FULL_WIDTH;
1668 // pSensorInfo->SensorFullResolutionY=HI708_IMAGE_SENSOR_FULL_HEIGHT;
1670 pSensorInfo
->SensorCameraPreviewFrameRate
=30;
1671 pSensorInfo
->SensorVideoFrameRate
=30;
1672 pSensorInfo
->SensorStillCaptureFrameRate
=30;
1673 pSensorInfo
->SensorWebCamCaptureFrameRate
=15;
1674 pSensorInfo
->SensorResetActiveHigh
=FALSE
;//low is to reset
1675 pSensorInfo
->SensorResetDelayCount
=4; //4ms
1676 pSensorInfo
->SensorOutputDataFormat
=SENSOR_OUTPUT_FORMAT_YUYV
; //SENSOR_OUTPUT_FORMAT_YVYU;
1677 pSensorInfo
->SensorClockPolarity
=SENSOR_CLOCK_POLARITY_LOW
;
1678 pSensorInfo
->SensorClockFallingPolarity
=SENSOR_CLOCK_POLARITY_LOW
;
1679 pSensorInfo
->SensorHsyncPolarity
= SENSOR_CLOCK_POLARITY_LOW
;
1680 pSensorInfo
->SensorVsyncPolarity
= SENSOR_CLOCK_POLARITY_LOW
;
1681 pSensorInfo
->SensorInterruptDelayLines
= 1;
1682 pSensorInfo
->SensroInterfaceType
=SENSOR_INTERFACE_TYPE_PARALLEL
;
1685 pSensorInfo
->CaptureDelayFrame
= 2;
1686 pSensorInfo
->PreviewDelayFrame
= 2;//10;
1687 pSensorInfo
->VideoDelayFrame
= 0;
1688 pSensorInfo
->SensorMasterClockSwitch
= 0;
1689 pSensorInfo
->SensorDrivingCurrent
= ISP_DRIVING_8MA
;
1693 case MSDK_SCENARIO_ID_CAMERA_PREVIEW
:
1694 case MSDK_SCENARIO_ID_VIDEO_PREVIEW
:
1695 case MSDK_SCENARIO_ID_CAMERA_3D_PREVIEW
:
1696 case MSDK_SCENARIO_ID_CAMERA_3D_VIDEO
:
1697 pSensorInfo
->SensorClockFreq
=26;
1698 pSensorInfo
->SensorClockDividCount
= 3;
1699 pSensorInfo
->SensorClockRisingCount
= 0;
1700 pSensorInfo
->SensorClockFallingCount
= 2;
1701 pSensorInfo
->SensorPixelClockCount
= 3;
1702 pSensorInfo
->SensorDataLatchCount
= 2;
1703 pSensorInfo
->SensorGrabStartX
= 4;
1704 pSensorInfo
->SensorGrabStartY
= 2;
1706 case MSDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG
:
1707 case MSDK_SCENARIO_ID_CAMERA_3D_CAPTURE
:
1708 pSensorInfo
->SensorClockFreq
=26;
1709 pSensorInfo
->SensorClockDividCount
= 3;
1710 pSensorInfo
->SensorClockRisingCount
= 0;
1711 pSensorInfo
->SensorClockFallingCount
= 2;
1712 pSensorInfo
->SensorPixelClockCount
= 3;
1713 pSensorInfo
->SensorDataLatchCount
= 2;
1714 pSensorInfo
->SensorGrabStartX
= 4;
1715 pSensorInfo
->SensorGrabStartY
= 2;//4;
1718 pSensorInfo
->SensorClockFreq
=26;
1719 pSensorInfo
->SensorClockDividCount
=3;
1720 pSensorInfo
->SensorClockRisingCount
=0;
1721 pSensorInfo
->SensorClockFallingCount
=2;
1722 pSensorInfo
->SensorPixelClockCount
=3;
1723 pSensorInfo
->SensorDataLatchCount
=2;
1724 pSensorInfo
->SensorGrabStartX
= 4;
1725 pSensorInfo
->SensorGrabStartY
= 2;//4;
1728 // HI708_PixelClockDivider=pSensorInfo->SensorPixelClockCount;
1729 memcpy(pSensorConfigData
, &HI708SensorConfigData
, sizeof(MSDK_SENSOR_CONFIG_STRUCT
));
1731 SENSORDB("[Exit]:HI708 getInfo func\n");
1733 } /* HI708GetInfo() */
1736 UINT32
HI708Control(MSDK_SCENARIO_ID_ENUM ScenarioId
, MSDK_SENSOR_EXPOSURE_WINDOW_STRUCT
*pImageWindow
,
1737 MSDK_SENSOR_CONFIG_STRUCT
*pSensorConfigData
)
1739 SENSORDB("HHL [Enter]:HI708 Control func:ScenarioId = %d\n",ScenarioId
);
1743 case MSDK_SCENARIO_ID_CAMERA_PREVIEW
:
1744 case MSDK_SCENARIO_ID_VIDEO_PREVIEW
:
1745 //case MSDK_SCENARIO_ID_CAMERA_3D_PREVIEW:
1746 //case MSDK_SCENARIO_ID_CAMERA_3D_VIDEO:
1747 HI708Preview(pImageWindow
, pSensorConfigData
);
1749 case MSDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG
:
1750 //case MSDK_SCENARIO_ID_CAMERA_3D_CAPTURE:
1751 HI708Capture(pImageWindow
, pSensorConfigData
);
1753 // case MSDK_SCENARIO_ID_CAMERA_3D_PREVIEW: //added
1754 // case MSDK_SCENARIO_ID_CAMERA_3D_VIDEO:
1755 // case MSDK_SCENARIO_ID_CAMERA_3D_CAPTURE: //added
1756 // HI708Preview(pImageWindow, pSensorConfigData);
1758 // case MSDK_SCENARIO_ID_CAMERA_ZSD:
1759 // HI708Capture(pImageWindow, pSensorConfigData);
1765 SENSORDB("[Exit]:HI708 Control func\n");
1767 } /* HI708Control() */
1770 /*************************************************************************
1772 * HI708_set_param_wb
1785 *************************************************************************/
1786 BOOL
HI708_set_param_wb(UINT16 para
)
1788 //This sensor need more time to balance AWB,
1789 //we suggest higher fps or drop some frame to avoid garbage color when preview initial
1790 SENSORDB("[Enter]HI708 set_param_wb func:para = %d\n",para
);
1792 if(HI708_sensor
.wb
== para
) return KAL_TRUE
;
1794 spin_lock(&hi708_yuv_drv_lock
);
1795 HI708_sensor
.wb
= para
;
1796 spin_unlock(&hi708_yuv_drv_lock
);
1802 HI708_write_cmos_sensor(0x03, 0x22);
1803 HI708_write_cmos_sensor(0x11, 0x2e);
1804 HI708_write_cmos_sensor(0x80, 0x38);
1805 HI708_write_cmos_sensor(0x82, 0x30);
1806 HI708_write_cmos_sensor(0x83, 0x46);//56
1807 HI708_write_cmos_sensor(0x84, 0x16);
1808 HI708_write_cmos_sensor(0x85, 0x57);
1809 HI708_write_cmos_sensor(0x86, 0x28);
1812 case AWB_MODE_CLOUDY_DAYLIGHT
:
1814 HI708_write_cmos_sensor(0x03, 0x22);
1815 HI708_write_cmos_sensor(0x11, 0x28);
1816 HI708_write_cmos_sensor(0x80, 0x52);
1817 HI708_write_cmos_sensor(0x81, 0x20);
1818 HI708_write_cmos_sensor(0x82, 0x2e);
1819 HI708_write_cmos_sensor(0x83, 0x5d);
1820 HI708_write_cmos_sensor(0x84, 0x55);
1821 HI708_write_cmos_sensor(0x85, 0x30);
1822 HI708_write_cmos_sensor(0x86, 0x25);
1825 case AWB_MODE_DAYLIGHT
:
1827 HI708_write_cmos_sensor(0x03, 0x22);
1828 HI708_write_cmos_sensor(0x11, 0x28);
1829 HI708_write_cmos_sensor(0x80, 0x50);
1830 HI708_write_cmos_sensor(0x81, 0x20);
1831 HI708_write_cmos_sensor(0x82, 0x2d);
1832 HI708_write_cmos_sensor(0x83, 0x52);
1833 HI708_write_cmos_sensor(0x84, 0x40);
1834 HI708_write_cmos_sensor(0x85, 0x30);
1835 HI708_write_cmos_sensor(0x86, 0x1c);
1838 case AWB_MODE_INCANDESCENT
:
1840 HI708_write_cmos_sensor(0x03, 0x22);
1841 HI708_write_cmos_sensor(0x11, 0x28);
1842 HI708_write_cmos_sensor(0x80, 0x29);
1843 HI708_write_cmos_sensor(0x82, 0x54);
1844 HI708_write_cmos_sensor(0x83, 0x2e);
1845 HI708_write_cmos_sensor(0x84, 0x23);
1846 HI708_write_cmos_sensor(0x85, 0x58);
1847 HI708_write_cmos_sensor(0x86, 0x4f);
1850 case AWB_MODE_FLUORESCENT
:
1852 HI708_write_cmos_sensor(0x03, 0x22);
1853 HI708_write_cmos_sensor(0x11, 0x28);
1854 HI708_write_cmos_sensor(0x80, 0x40);
1855 HI708_write_cmos_sensor(0x81, 0x20);
1856 HI708_write_cmos_sensor(0x82, 0x4f);
1857 HI708_write_cmos_sensor(0x83, 0x44);
1858 HI708_write_cmos_sensor(0x84, 0x3a);
1859 HI708_write_cmos_sensor(0x85, 0x47);
1860 HI708_write_cmos_sensor(0x86, 0x3a);
1863 case AWB_MODE_TUNGSTEN
:
1865 HI708_write_cmos_sensor(0x03, 0x22);
1866 HI708_write_cmos_sensor(0x80, 0x24);
1867 HI708_write_cmos_sensor(0x81, 0x20);
1868 HI708_write_cmos_sensor(0x82, 0x58);
1869 HI708_write_cmos_sensor(0x83, 0x27);
1870 HI708_write_cmos_sensor(0x84, 0x22);
1871 HI708_write_cmos_sensor(0x85, 0x58);
1872 HI708_write_cmos_sensor(0x86, 0x52);
1877 SENSORDB("HI708 AWB OFF");
1878 HI708_write_cmos_sensor(0x03, 0x22);
1879 HI708_write_cmos_sensor(0x10, 0xe2);
1887 } /* HI708_set_param_wb */
1889 /*************************************************************************
1891 * HI708_set_param_effect
1904 *************************************************************************/
1905 BOOL
HI708_set_param_effect(UINT16 para
)
1907 SENSORDB("[Enter]HI708 set_param_effect func:para = %d\n",para
);
1909 if(HI708_sensor
.effect
== para
) return KAL_TRUE
;
1911 spin_lock(&hi708_yuv_drv_lock
);
1912 HI708_sensor
.effect
= para
;
1913 spin_unlock(&hi708_yuv_drv_lock
);
1919 HI708_write_cmos_sensor(0x03, 0x10);
1920 HI708_write_cmos_sensor(0x11, 0x43);
1921 HI708_write_cmos_sensor(0x12, 0xF0);
1922 HI708_write_cmos_sensor(0x13, 0x03);
1923 HI708_write_cmos_sensor(0x44, 0x80);
1924 HI708_write_cmos_sensor(0x45, 0x80);
1926 HI708_write_cmos_sensor(0x47, 0x7f);
1927 //HI708_write_cmos_sensor(0x03, 0x13);
1928 // HI708_write_cmos_sensor(0x20, 0x07);
1929 //HI708_write_cmos_sensor(0x21, 0x07);
1936 HI708_write_cmos_sensor(0x03, 0x10);
1937 HI708_write_cmos_sensor(0x11, 0x03);
1938 HI708_write_cmos_sensor(0x12, 0x23);
1939 HI708_write_cmos_sensor(0x13, 0x00);
1940 HI708_write_cmos_sensor(0x44, 0x6c);
1941 HI708_write_cmos_sensor(0x45, 0x9a);
1943 HI708_write_cmos_sensor(0x47, 0x7f);
1944 // HI708_write_cmos_sensor(0x03, 0x13);
1945 // HI708_write_cmos_sensor(0x20, 0x07);
1946 //HI708_write_cmos_sensor(0x21, 0x07);
1951 case MEFFECT_NEGATIVE
:
1953 HI708_write_cmos_sensor(0x03, 0x10);
1954 HI708_write_cmos_sensor(0x11, 0x03);
1955 HI708_write_cmos_sensor(0x12, 0x08);
1956 HI708_write_cmos_sensor(0x13, 0x00);
1957 HI708_write_cmos_sensor(0x14, 0x00);
1960 case MEFFECT_SEPIAGREEN
:
1962 HI708_write_cmos_sensor(0x03, 0x10);
1963 HI708_write_cmos_sensor(0x11, 0x03);
1964 HI708_write_cmos_sensor(0x12, 0x03);
1965 //HI708_write_cmos_sensor(0x40, 0x00);
1966 HI708_write_cmos_sensor(0x13, 0x00);
1967 HI708_write_cmos_sensor(0x44, 0x30);
1968 HI708_write_cmos_sensor(0x45, 0x50);
1971 case MEFFECT_SEPIABLUE
:
1973 HI708_write_cmos_sensor(0x03, 0x10);
1974 HI708_write_cmos_sensor(0x11, 0x03);
1975 HI708_write_cmos_sensor(0x12, 0x03);
1976 //HI708_write_cmos_sensor(0x40, 0x00);
1977 HI708_write_cmos_sensor(0x13, 0x00);
1978 HI708_write_cmos_sensor(0x44, 0xb0);
1979 HI708_write_cmos_sensor(0x45, 0x40);
1984 HI708_write_cmos_sensor(0x03, 0x10);
1985 HI708_write_cmos_sensor(0x11, 0x03);
1986 HI708_write_cmos_sensor(0x12, 0x03);
1987 //HI708_write_cmos_sensor(0x40, 0x00);
1988 HI708_write_cmos_sensor(0x44, 0x80);
1989 HI708_write_cmos_sensor(0x45, 0x80);
1997 } /* HI708_set_param_effect */
1999 /*************************************************************************
2001 * HI708_set_param_banding
2014 *************************************************************************/
2015 BOOL
HI708_set_param_banding(UINT16 para
)
2017 SENSORDB("[Enter]HI708 set_param_banding func:para = %d\n",para
);
2019 if(HI708_sensor
.banding
== para
) return KAL_TRUE
;
2021 spin_lock(&hi708_yuv_drv_lock
);
2022 HI708_sensor
.banding
= para
;
2023 spin_unlock(&hi708_yuv_drv_lock
);
2027 case AE_FLICKER_MODE_50HZ
:
2029 HI708_write_cmos_sensor(0x03,0x20);
2030 HI708_write_cmos_sensor(0x10,0x1c);
2031 HI708_write_cmos_sensor(0x18,0x38);
2032 //BEGIN <> <20130922> <improve the camera experience that before to capture the next photo, the screen lighten instantly> panzaoyan
2033 HI708_write_cmos_sensor(0x83, 0x01);
2034 HI708_write_cmos_sensor(0x84, 0xbc);
2035 HI708_write_cmos_sensor(0x85, 0x56);//15fps
2036 //END <> <20130922> <improve the camera experience that before to capture the next photo, the screen lighten instantly> panzaoyan
2037 HI708_write_cmos_sensor(0x88, 0x01);
2038 HI708_write_cmos_sensor(0x89, 0xbc);
2039 HI708_write_cmos_sensor(0x8A, 0x56);//50HZ
2041 HI708_write_cmos_sensor(0x18, 0x30);
2042 HI708_write_cmos_sensor(0x10, 0x9c);
2045 case AE_FLICKER_MODE_60HZ
:
2047 HI708_write_cmos_sensor(0x03,0x20);
2048 HI708_write_cmos_sensor(0x10,0x0c);
2049 HI708_write_cmos_sensor(0x18,0x38);
2050 //BEGIN <> <20130922> <improve the camera experience that before to capture the next photo, the screen lighten instantly> panzaoyan
2051 HI708_write_cmos_sensor(0x83, 0x01);
2052 HI708_write_cmos_sensor(0x84, 0xc0);
2053 HI708_write_cmos_sensor(0x85, 0x3e);//15fps
2054 HI708_write_cmos_sensor(0x86, 0x00);
2055 HI708_write_cmos_sensor(0x87, 0xfa);
2056 //END <> <20130922> <improve the camera experience that before to capture the next photo, the screen lighten instantly> panzaoyan
2057 HI708_write_cmos_sensor(0x88, 0x01);
2058 HI708_write_cmos_sensor(0x89, 0xc0);
2059 HI708_write_cmos_sensor(0x8A, 0x3e);//60HZ
2061 HI708_write_cmos_sensor(0x18, 0x30);
2062 HI708_write_cmos_sensor(0x10, 0x8c);
2067 HI708_write_cmos_sensor(0x03,0x20);
2068 HI708_write_cmos_sensor(0x10,0x1c);
2069 HI708_write_cmos_sensor(0x18,0x38);
2070 //BEGIN <> <20130922> <improve the camera experience that before to capture the next photo, the screen lighten instantly> panzaoyan
2071 HI708_write_cmos_sensor(0x83, 0x01);
2072 HI708_write_cmos_sensor(0x84, 0xbc);
2073 HI708_write_cmos_sensor(0x85, 0x56);//15fps
2074 //END <> <20130922> <improve the camera experience that before to capture the next photo, the screen lighten instantly> panzaoyan
2075 HI708_write_cmos_sensor(0x88, 0x01);
2076 HI708_write_cmos_sensor(0x89, 0xbc);
2077 HI708_write_cmos_sensor(0x8A, 0x56);//50HZ
2079 HI708_write_cmos_sensor(0x18, 0x30);
2080 HI708_write_cmos_sensor(0x10, 0x9c);
2085 } /* HI708_set_param_banding */
2090 /*************************************************************************
2092 * HI708_set_param_exposure
2105 *************************************************************************/
2106 BOOL
HI708_set_param_exposure(UINT16 para
)
2108 SENSORDB("[Enter]HI708 set_param_exposure func:para = %d\n",para
);
2110 if(HI708_sensor
.exposure
== para
) return KAL_TRUE
;
2112 spin_lock(&hi708_yuv_drv_lock
);
2113 HI708_sensor
.exposure
= para
;
2114 spin_unlock(&hi708_yuv_drv_lock
);
2116 HI708_write_cmos_sensor(0x03,0x10);
2117 HI708_write_cmos_sensor(0x12,HI708_read_cmos_sensor(0x12)|0x10);
2120 /*GIONEE: malp 20130625 add for CR00828155 start*/
2121 case AE_EV_COMP_20
: //+2 EV
2122 HI708_write_cmos_sensor(0x40,0x30);
2124 /*GIONEE: malp 20130625 add for CR00828155 end*/
2125 case AE_EV_COMP_13
: //+1.3 EV
2126 HI708_write_cmos_sensor(0x40,0x20);
2128 case AE_EV_COMP_10
: //+1 EV
2129 HI708_write_cmos_sensor(0x40,0x15);
2131 case AE_EV_COMP_07
: //+0.7 EV
2132 HI708_write_cmos_sensor(0x40,0x10);
2134 case AE_EV_COMP_03
: // +0.3 EV
2135 HI708_write_cmos_sensor(0x40,0x05);
2137 case AE_EV_COMP_00
: // +0 EV
2138 HI708_write_cmos_sensor(0x40,0x88);//90//96 wangc modified for reducing previewer brightness at 2012-10-24
2141 case AE_EV_COMP_n03
: // -0.3 EV
2142 HI708_write_cmos_sensor(0x40,0x95);//98//a3
2145 case AE_EV_COMP_n07
: // -0.7 EV
2146 HI708_write_cmos_sensor(0x40,0xa0);
2148 case AE_EV_COMP_n10
: //-1 EV
2149 HI708_write_cmos_sensor(0x40,0xa5);
2151 case AE_EV_COMP_n13
: // -1.3 EV
2152 HI708_write_cmos_sensor(0x40,0xb0);
2154 /*GIONEE: malp 20130625 add for CR00828155 start*/
2155 case AE_EV_COMP_n20
: //-2 EV
2156 HI708_write_cmos_sensor(0x40,0xc0);
2158 /*GIONEE: malp 20130625 add for CR00828155 end*/
2164 } /* HI708_set_param_exposure */
2166 void HI708_set_AE_mode(UINT32 iPara
)
2168 UINT8 temp_AE_reg
= 0;
2169 SENSORDB("HI708_set_AE_mode = %d E \n",iPara
);
2170 HI708_write_cmos_sensor(0x03,0x20);
2171 temp_AE_reg
= HI708_read_cmos_sensor(0x10);
2173 if (AE_MODE_OFF
== iPara
)
2176 HI708_write_cmos_sensor(0x10,temp_AE_reg
&~ 0x10);
2180 HI708_write_cmos_sensor(0x10,temp_AE_reg
| 0x10);
2183 UINT32
HI708YUVSensorSetting(FEATURE_ID iCmd
, UINT32 iPara
)
2185 SENSORDB("[Enter]HI708YUVSensorSetting func:cmd = %d\n",iCmd
);
2189 case FID_SCENE_MODE
: //auto mode or night mode
2190 if (iPara
== SCENE_MODE_OFF
)//auto mode
2192 HI708_night_mode(FALSE
);
2194 else if (iPara
== SCENE_MODE_NIGHTSCENE
)//night mode
2196 HI708_night_mode(TRUE
);
2200 HI708_set_param_wb(iPara
);
2202 case FID_COLOR_EFFECT
:
2203 HI708_set_param_effect(iPara
);
2206 HI708_set_param_exposure(iPara
);
2208 case FID_AE_FLICKER
:
2209 HI708_set_param_banding(iPara
);
2211 case FID_ZOOM_FACTOR
:
2212 spin_lock(&hi708_yuv_drv_lock
);
2213 HI708_zoom_factor
= iPara
;
2214 spin_unlock(&hi708_yuv_drv_lock
);
2216 case FID_AE_SCENE_MODE
:
2217 HI708_set_AE_mode(iPara
);
2223 } /* HI708YUVSensorSetting */
2225 UINT32
HI708YUVSetVideoMode(UINT16 u2FrameRate
)
2227 /* spin_lock(&hi708_yuv_drv_lock);
2228 HI708_sensor.MPEG4_Video_mode = KAL_TRUE;
2229 spin_unlock(&hi708_yuv_drv_lock);
2230 SENSORDB("[Enter]HI708 Set Video Mode:FrameRate= %d\n",u2FrameRate);
2231 SENSORDB("HI708_sensor.video_mode = %d\n",HI708_sensor.MPEG4_Video_mode);
2233 // if(u2FrameRate == 30) u2FrameRate = 20;
2236 spin_lock(&hi708_yuv_drv_lock);
2237 HI708_sensor.fix_framerate = u2FrameRate * 10;
2238 spin_unlock(&hi708_yuv_drv_lock);
2240 if(HI708_sensor.fix_framerate <= 300 )
2242 HI708_Fix_Video_Frame_Rate(HI708_sensor.fix_framerate);
2246 SENSORDB("Wrong Frame Rate");
2253 void HI708GetAFMaxNumFocusAreas(UINT32
*pFeatureReturnPara32
)
2255 *pFeatureReturnPara32
= 0;
2256 SENSORDB("HI708GetAFMaxNumFocusAreas *pFeatureReturnPara32 = %d\n", *pFeatureReturnPara32
);
2259 void HI708GetAEMaxNumMeteringAreas(UINT32
*pFeatureReturnPara32
)
2261 *pFeatureReturnPara32
= 0;
2262 SENSORDB("HI708GetAEMaxNumMeteringAreas *pFeatureReturnPara32 = %d\n", *pFeatureReturnPara32
);
2265 void HI708GetExifInfo(UINT32 exifAddr
)
2267 SENSOR_EXIF_INFO_STRUCT
* pExifInfo
= (SENSOR_EXIF_INFO_STRUCT
*)exifAddr
;
2268 pExifInfo
->FNumber
= 28;
2269 pExifInfo
->AEISOSpeed
= AE_ISO_100
;
2270 pExifInfo
->AWBMode
= HI708_sensor
.wb
;
2271 pExifInfo
->CapExposureTime
= 0;
2272 pExifInfo
->FlashLightTimeus
= 0;
2273 pExifInfo
->RealISOValue
= AE_ISO_100
;
2276 /*****add by zero *********/
2277 UINT32
HI708SetTestPatternMode(kal_bool bEnable
)
2279 printk("zero %s\n ",__func__
);
2280 HI708_Set_Mirror_Flip(IMAGE_NORMAL
);
2282 /*******end*************/
2284 UINT32
HI708FeatureControl(MSDK_SENSOR_FEATURE_ENUM FeatureId
,
2285 UINT8
*pFeaturePara
,UINT32
*pFeatureParaLen
)
2287 //UINT16 u2Temp = 0;
2288 UINT16
*pFeatureReturnPara16
=(UINT16
*) pFeaturePara
;
2289 UINT16
*pFeatureData16
=(UINT16
*) pFeaturePara
;
2290 UINT32
*pFeatureReturnPara32
=(UINT32
*) pFeaturePara
;
2291 UINT32
*pFeatureData32
=(UINT32
*) pFeaturePara
;
2292 MSDK_SENSOR_CONFIG_STRUCT
*pSensorConfigData
=(MSDK_SENSOR_CONFIG_STRUCT
*) pFeaturePara
;
2293 MSDK_SENSOR_REG_INFO_STRUCT
*pSensorRegData
=(MSDK_SENSOR_REG_INFO_STRUCT
*) pFeaturePara
;
2294 SENSORDB("HHL [Enter]:HI708 Feature Control func:FeatureId = %d\n",FeatureId
);
2298 case SENSOR_FEATURE_GET_RESOLUTION
:
2299 *pFeatureReturnPara16
++=HI708_IMAGE_SENSOR_FULL_WIDTH
;
2300 *pFeatureReturnPara16
=HI708_IMAGE_SENSOR_FULL_HEIGHT
;
2303 case SENSOR_FEATURE_GET_PERIOD
:
2304 *pFeatureReturnPara16
++=HI708_IMAGE_SENSOR_PV_WIDTH
;//+HI708_sensor.pv_dummy_pixels;
2305 *pFeatureReturnPara16
=HI708_IMAGE_SENSOR_PV_HEIGHT
;//+HI708_sensor.pv_dummy_lines;
2308 case SENSOR_FEATURE_GET_PIXEL_CLOCK_FREQ
:
2309 //*pFeatureReturnPara32 = HI708_sensor_pclk/10;
2312 case SENSOR_FEATURE_SET_ESHUTTER
:
2315 case SENSOR_FEATURE_SET_NIGHTMODE
:
2316 HI708_night_mode((BOOL
) *pFeatureData16
);
2318 case SENSOR_FEATURE_SET_GAIN
:
2320 case SENSOR_FEATURE_SET_FLASHLIGHT
:
2322 case SENSOR_FEATURE_SET_ISP_MASTER_CLOCK_FREQ
:
2324 case SENSOR_FEATURE_SET_REGISTER
:
2325 HI708_write_cmos_sensor(pSensorRegData
->RegAddr
, pSensorRegData
->RegData
);
2327 case SENSOR_FEATURE_GET_REGISTER
:
2328 pSensorRegData
->RegData
= HI708_read_cmos_sensor(pSensorRegData
->RegAddr
);
2330 case SENSOR_FEATURE_GET_CONFIG_PARA
:
2331 memcpy(pSensorConfigData
, &HI708SensorConfigData
, sizeof(MSDK_SENSOR_CONFIG_STRUCT
));
2332 *pFeatureParaLen
=sizeof(MSDK_SENSOR_CONFIG_STRUCT
);
2334 case SENSOR_FEATURE_SET_CCT_REGISTER
:
2335 case SENSOR_FEATURE_GET_CCT_REGISTER
:
2336 case SENSOR_FEATURE_SET_ENG_REGISTER
:
2337 case SENSOR_FEATURE_GET_ENG_REGISTER
:
2338 case SENSOR_FEATURE_GET_REGISTER_DEFAULT
:
2339 case SENSOR_FEATURE_CAMERA_PARA_TO_SENSOR
:
2340 case SENSOR_FEATURE_SENSOR_TO_CAMERA_PARA
:
2341 case SENSOR_FEATURE_GET_GROUP_INFO
:
2342 case SENSOR_FEATURE_GET_ITEM_INFO
:
2343 case SENSOR_FEATURE_SET_ITEM_INFO
:
2344 case SENSOR_FEATURE_GET_ENG_INFO
:
2346 case SENSOR_FEATURE_GET_GROUP_COUNT
:
2347 // *pFeatureReturnPara32++=0;
2348 //*pFeatureParaLen=4;
2351 case SENSOR_FEATURE_GET_LENS_DRIVER_ID
:
2352 // get the lens driver ID from EEPROM or just return LENS_DRIVER_ID_DO_NOT_CARE
2353 // if EEPROM does not exist in camera module.
2354 *pFeatureReturnPara32
=LENS_DRIVER_ID_DO_NOT_CARE
;
2357 case SENSOR_FEATURE_SET_YUV_CMD
:
2358 HI708YUVSensorSetting((FEATURE_ID
)*pFeatureData32
, *(pFeatureData32
+1));
2360 case SENSOR_FEATURE_SET_VIDEO_MODE
:
2361 HI708YUVSetVideoMode(*pFeatureData16
);
2363 case SENSOR_FEATURE_CHECK_SENSOR_ID
:
2364 HI708_GetSensorID(pFeatureData32
);
2366 case SENSOR_FEATURE_GET_AF_MAX_NUM_FOCUS_AREAS
:
2367 HI708GetAFMaxNumFocusAreas(pFeatureReturnPara32
);
2370 case SENSOR_FEATURE_GET_AE_MAX_NUM_METERING_AREAS
:
2371 HI708GetAEMaxNumMeteringAreas(pFeatureReturnPara32
);
2374 case SENSOR_FEATURE_GET_EXIF_INFO
:
2375 SENSORDB("SENSOR_FEATURE_GET_EXIF_INFO\n");
2376 SENSORDB("EXIF addr = 0x%x\n",*pFeatureData32
);
2377 HI708GetExifInfo(*pFeatureData32
);
2379 case SENSOR_FEATURE_SET_TEST_PATTERN
:
2380 HI708SetTestPatternMode((BOOL
)*pFeatureData16
); //add by zero
2386 } /* HI708FeatureControl() */
2389 SENSOR_FUNCTION_STRUCT SensorFuncHI708
=
2394 HI708FeatureControl
,
2399 UINT32
HI708_YUV_SensorInit(PSENSOR_FUNCTION_STRUCT
*pfFunc
)
2402 /* To Do : Check Sensor status here */
2404 *pfFunc
=&SensorFuncHI708
;
2407 } /* SensorInit() */