//=========================================================
//Information section
//=========================================================
info_name=1200-0117_KATE;
info_vendor=Foxconn;
info_major_ver=3;
info_minor_ver=3;
cam_i2c_address=60;
//=========================================================
//Revision history
//=========================================================
// 1a 2006-10-11 Johan Säfholm
//     Copied from Sania setup file 1c, changed power on sequence
//     to a first qualified guess that should work for SOFIA
// 1b 2006-11-13 Johan Säfholm
//     Added property 26 for evaluation of color schemes
//     Added macro for setting individual bits in registers NOT WORKING!!!
//     Corrected typo in SQCIF VF rendering yellowish image
//     Added FIFO delay in 400x400 SS
//     Some layout changes for readability
// 1c 2006-11-20 Johan Säfholm (Thomas Hansen)
//     Changed power on and power off according to ITP suggestion
// 1.0 2006-11-20 Johan Säfholm
//     Copied from Sania release 2.0
//     Changed cam_init_result to only check MSB in product Id number
// 1.1 2006-11-22 Johan Säfholm
//     Release for SOFIA EP1.2 = Sensor rev 1b.
//     Might give strange image if used on sensor rev 1a.
//     Changed power on sequence for dual cam operation NOT WORKING!!! 
//     Need to pull reset pin instead of use power save mode in main cam
//     Changed property ID 29 to 30 for color bar test pattern
// 1.2 2006-12-12 Johan Säfholm
//     Removed Sania revision history
//	   Corrected gamma curve settings  
// 1.3 2006-12-14 Johan Säfholm
//     Added support for both sensor revision 1a and 1b in firmware
//     Added 2x colour saturation to reduce risk of colours disappearing in MPEG-4 encoding (To be verified in SSW during call)
//     Changed firmware settings for colour matrix to be same as PSA from Foxconn
//     Changed VF QVGA to 12fps and moved settings for 12fps to seq_vf_start
// 1.4 2007-02-08 Johan Säfholm
//     Removed GPIO settings in power off. Now only clock and VDD off. In coop with Murat Gummussoy
// 1.5 2007-02-08 Johan Säfholm
//     Modified Lens shading correction settings
// 1.6 2007-02-23 Johan Säfholm
//     Adjusted mirroring to fit SSW
// 1.7 2007-03-10 Johan Säfholm
//     Added stream off before changing zoom parameters
//     Changed property 0 from setting brightness to changing AE target
// 1.8 2007-03-10 Johan Säfholm
//     Adjusted flicker settings for 12fps
// 1.9 2007-03-14 Johan Säfholm
//     Minor changes
// 3.0 2007-03-20 Johan Säfholm
//     ---===** Major update **===---
//     Changed firmware settings to OVT suggestion turing tuning at OVT facilities
//     FIRMWARE_2 will be used instead of FIRMWARE_1
//     Skin color 3 (prop. 0x6,7) is used as default
//     Removed QVGA snapshot
//     Added size_ID 2d, QCIF 10fps according to SW requirement.
//     Removed FIRMWARE_1
//     Added macros for different framerates, including variable from 6 to 12, possibla candidate for night mode in future
// 3.1 2007-05-03 Johan Säfholm
//     Set LCC V-mirror in FIRMWARE_2
//     Set V-mirror and LCC V-mirror in 400x400 SS
//     Set V-mirror in ITP QVGA VF
//     Updated settings according to OVT R2.9 for WP-correction in SS
//     Some layout changes
//     Addad property 2a for ESD detection and recovery
//     2007-05-24 Tomokazu Ohmura
//     Release for Shinobu/Akiko ITP and signaling build
// 3.2 2007-11-27 Wang Derek
//     Change power sequence.
// 3.3 2008-05-30 Gao Lisa
//     Change power sequence for Kate board. 
//==============================================================================
// Kate Sub camera Power on sequence ( First do main camera power on and set in to power save mode
//==============================================================================
cam_power_on_0 = 5, 2, 90, 0, 05;   	// Active Videocamera RST pin (AppGPIO_08 = GPIO_90), delay 5ms 				
cam_power_on_1 = 5, 2, 91, 1, 05;   	// Videocamera standby (AppGPIO_09 = GPIO_91)			
cam_power_on_2 = 5, 2, 96, 1, 02;   	// Vcam_SA (AppGPIO_14=GPIO_96) delay 2ms   			
cam_power_on_3 = 5, 2, 85, 1, 00;   	// Vcam_Core_AF (AppGPIO_05=GPIO_85)  				
cam_power_on_4 = 5, 2, 95, 1, 05;   	// Vcam_IO (AppGPIO_13=GPIO_95) delay 5ms				
cam_power_on_5 = 5, 3, 09, 32C8, 05; 	// Turn on 13 MHz clock, delay 5ms
cam_power_on_6 = 5, 2, 90, 1, 1F4;   	// Disable Videocamera RST pin (AppGPIO_08 = GPIO_90), delay 500ms
cam_power_on_7 = 5, 4, 0, 1, 1;       // Set main cam in power save mode = all outputs tri state except I2C
cam_power_on_8 = 5, 2, 90, 0, 5;  	  // CIRES_N, Disable, Wait 5 ms	
cam_power_on_9 = 5, 3, 9, 32C8, 00;  // CAMSYSCLK, Enable 13MHz
cam_power_on_a= 5, 2, 90, 1, 0;        // Videocamera Normal mode
cam_power_on_b= 5, 2, 90, 0, 2;  	    // Videocamera Reset mode
cam_power_on_c= 5, 2, 90, 1, 0;  	    // Videocamera Normal mode
cam_power_on_d= 5, 2, 91, 0, 0;       // CIF_STANDY = 0 normal mode (AppGPIO11), Wait 0ms
cam_power_on_e= 5, 4,  0, 0, 0;	      // Do dummy write to i2c to stabilize the i2c bus at first power on.


cam_power_I2c_0 = $a60 12 80 $f 12 00 $f; 
cam_power_I2c_1 = $a1f 5c 01 $f $a60; // Register 5c is main cam power save mode register


//========================================================= 
// Kate Power off sequence 
//========================================================= 
cam_power_off_0 = 5, 3, 9, 0, 0;  // CAMSYSCLK, Disable with invert, Wait 0ms
cam_power_off_1 = 5, 2, 90, 0, 1;  // Active Videocamera RST pin (AppGPIO_08 = GPIO_90), Wait 1ms
cam_power_off_2 = 5, 2, 85, 0, 00;   // Turn Off Vcam_Core_AF (AppGPIO_05=GPIO_85)  					
cam_power_off_3 = 5, 2, 95, 0, 05;   // Turn Off Vcam_IO (AppGPIO_13=GPIO_95) delay 5ms					
cam_power_off_4 = 5, 2, 96, 0, 05;   // Turn off Vcam_SA (AppGPIO_14=GPIO_96) delay 5ms

//====================================================================	  
// Platform registers used 
//====================================================================	
//reg 0 = Return register for cam_init_result
//reg 1 = Return Register for cam_init_result
//reg 2 = Used in swapping frog view values in verticval mirror property 
//reg 3
//  bit 0 = Used to store output format for zooming property. 0=QCIF, 1=SQCIF 
//  bit 1 = Used to store fps-setting. 0 = 12 fps, 1 = 8fps
//  bit 2 =
//  bit 3 =
//  bit 4 =
//  bit 5 =
//  bit 6 =
//  bit 7 = 
//reg 4 = Used in CLEAR_BIT_XX and SET_BIT_XX
//reg 5 = Used in REGISTER_WRITE to verify write result
//reg 6 =  
//reg 7 = 
//reg 8 = 
//reg 9 = 
//reg a = Used in Register dump macro for iteration
//reg b = Used in Register dump macro for dump
//reg c = Used in Register dump macro
//reg d = Used in light meter output 
//reg e = Used in light meter output 
//reg f = Used as platform return register 
//===================================================================== 
//========================================================= 
// MACROS used in writing and reading to/from OV6680 sensor 
//========================================================= 

CLEAR_BIT_0=$b4 00 0 1;
  SET_BIT_0=$b4 01 0 1;
CLEAR_BIT_1=$b4 00 1 1;
  SET_BIT_1=$b4 01 1 1;
CLEAR_BIT_2=$b4 00 2 1;
  SET_BIT_2=$b4 01 2 1;
CLEAR_BIT_3=$b4 00 3 1;
  SET_BIT_3=$b4 01 3 1;
CLEAR_BIT_4=$b4 00 4 1;
  SET_BIT_4=$b4 01 4 1;
CLEAR_BIT_5=$b4 00 5 1;
  SET_BIT_5=$b4 01 5 1;
CLEAR_BIT_6=$b4 00 6 1;
  SET_BIT_6=$b4 01 6 1;
CLEAR_BIT_7=$b4 00 7 1;
  SET_BIT_7=$b4 01 7 1;

REGISTER_READ= !0 $f $r1 4;  // read 1 byte from cam reg !0 into internal 4
REGISTER_WRITE=!0 $w4 $f     // write internal register 4 to selected register
							 !0 $f $r1 5   // Read back value from selected register and store in internal reg 5
							 $c5 r4        // Check if reg4 and reg5 are equal
							 //$"CAM_REGISTER_WRITE_OPERATION_SUCCEEDED"       // Yes, 4 and 5 are equal, do nothing
							 $cl // No, register 4 and 5 not equal, print error message
							 $"CAM_REG_WRITE_OP_FAILED_:_VALUE_TO_BE_%4_BUT_IS_%5"
							 $cx
							 ;
// Reads out register !0, performs operation !1, then writes back
// register !0.  
REGISTER_MODIFY= 
  #REGISTER_READ(!0)  // read one byte from cam reg !0 into internal 4
  !1                  // perform !1
  #REGISTER_WRITE(!0) // write back to selected register
  ;
// Macros for different size and zoom settings
FROG_VIEW_AND_SCALE =   12 40 $f 2f 07 $f 18 c8 $f 60 7f $f 73 16 $f 74 01 $f 77 01 $f 78 18 $f;
QCIF_WITH_FROG_1x_ZOOM = 06 44 $f 12 40 $f 2f 07 $f 04 02 $f 17 40 $f 19 39 $f 18 cc $f
												 1a 90 $f 5a 58 $f 5b 48 $f 60 ff $f 73 16	$f 74 01 $f
												 77 0c $f 78 18 $f;
QCIF_NO_FROG_2x_ZOOM =  06 40 $f 12 00 $f 2f 0f $f 04 00 $f 17 5c $f 19 43 $f
												18 5a $f 1a 48 $f	5a 58 $f 5b 48 $f 77 20 $f 60 e7 $f
												73 06 $f 74 20 $f;
SQCIF_WITH_FROG_1x_ZOOM = 06 44 $f 12 00 $f 2f 0f $f 04 00 $f 17 52 $f 19 37 $f 18 82 $f 1a 60 $f
												  5a 40 $f 5b 30 $f 60 f7 $f 77 20 $f 73 06 $f 74 20 $f;
SQCIF_WITH_FROG_2x_ZOOM = 06 40 $f 12 00 $f 2f 0f $f 17 62 $f 19 4f $f 18 42 $f 1a 30 $f
												  5a 40 $f 5b 30 $f 77 20 $f 60 e7 $f 73 06 $f 74 20 $f;

// Macros for shifting between different fps settings while maintaining correct banding filter
MACRO_30_FPS_SETTINGS = 57 2e $f 59 07 $f 5f a3 $f 59 08 $f 5f 54 $f 0e 40 $f 11 00 $f
								        2a 00 $f 2b 3a $f 2c 3a $f 2d 00 $f 2e 00 $f 4f 82 $f 50 6c $f
								        21 23 $f 14 30 $f 0f 29 $f
								        ;
MACRO_15_FPS_SETTINGS = 57 0e $f 59 07 $f 5f a3 $f 59 08 $f 5f 54 $f 0e 40 $f 11 01 $f
								        2a 00 $f 2b 3a $f 2c 00 $f 2d 00 $f 2e 00 $f 4f 41 $f 50 36 $f
								        21 57 $f 14 30 $f 0f 29 $f
								        ;
MACRO_12_FPS_SETTINGS = 57 0e $f 59 07 $f 5f a3 $f 59 08 $f 5f 54 $f 0e 40 $f 11 01 $f
								        2a 00 $f 2b 3a $f 2c 6d $f 2d 00 $f 2e 00 $f 4f 41 $f 50 36 $f
								        21 79 $f 14 30 $f 0f 29 $f
								        ;
MACRO_10_FPS_SETTINGS = 57 0e $f 59 07 $f 5f 93 $f 59 08 $f 5f 54 $f 0e 40 $f 11 01 $f
								        2a 00 $f 2b 3a $f 2c da $f 2d 00 $f 2e 00 $f 4f 41 $f 50 36 $f
								        21 9b $f 14 30 $f 0f 29 $f
								        ;                        
MACRO_8_FPS_SETTINGS = 57 0e $f 59 07 $f 5f a3 $f 59 08 $f 5f 54 $f 0e 40 $f 11 01 $f
								       2a 01 $f 2b 3a $f 2c 7d $f 2d 00 $f 2e 00 $f 4f 41 $f 50 36 $f
								       21 9b $f 14 30 $f 0f 29 $f
								       ;
MACRO_7_5_FPS_SETTINGS = 57 0e $f 59 07 $f 5f 93 $f 59 08 $f 5f 54 $f 0e 40 $f 11 03 $f
								       2a 00 $f 2b 3a $f 2c 00 $f 2d 00 $f 2e 00 $f 4f 20 $f 50 1b $f
								       21 cf $f 14 30 $f 0f 29 $f
								       ;
MACRO_6_FPS_SETTINGS = 57 0e $f 59 07 $f 5f a3 $f 59 08 $f 5f 54 $f 0e 40 $f 11 03 $f
								       2a 00 $f 2b 44 $f 2c 6d $f 2d 00 $f 2e 00 $f 4f 20 $f 50 1b $f
								       21 03 $f 14 33 $f 0f 29 $f
								       ;
MACRO_VARIABLE_FRAMERATE_6_TO_12_FPS = 57 0e $f 59 07 $f 5f a3 $f 59 08 $f 5f 54 $f
                                       0e 98 $f 11 01 $f 2a 00 $f 2b 3a $f 2c 6d $f 
                                       2d 00 $f 2e 00 $f 4f 41 $f 50 36 $f 21 79 $f 
                                       14 30 $f 0f 29 $f;                   
STREAM_OFF =  #REGISTER_MODIFY(38,#SET_BIT_6)	
 							#REGISTER_MODIFY(38,#SET_BIT_5)
 							#REGISTER_MODIFY(38,#SET_BIT_4);
STREAM_ON =  	#REGISTER_MODIFY(38,#CLEAR_BIT_6)
 							#REGISTER_MODIFY(38,#CLEAR_BIT_5)
 							#REGISTER_MODIFY(38,#CLEAR_BIT_4);


FIRMWARE_2 = //Directly from OVT settings
0c c6 $f 3f 16 $f 0d 30 $f 06 40 $f 28 d0 $f 09 01 $f 17 40 $f
19 03 $f 18 ca $f 1a c8 $f 5a c8 $f 5b c8 $f 13 f7 $f 24 45 $f
25 3D $f 26 92 $f 27 34 $f 29 2C $f 5d A4 $f 60 67 $f 73 06 $f
74 20 $f 75 3c $f 76 40 $f 48 c4 $f 22 81 $f 3c 45 $f 20 b4 $f 
2f 07 $f 30 80 $f 31 49 $f 32 00 $f 33 00 $f 35 00 $f 34 1a $f  
36 1d $f 37 2d $f 40 00 $f 41 09 $f 42 01 $f 43 00 $f 44 00 $f  
45 00 $f 46 00 $f 47 00 $f 63 df $f 64 01 $f 65 02 $f 4a 08 $f  
4b 01 $f 4c c0 $f 5e 20 $f 66 f2 $f 81 12 $f 82 08 $f 83 16 $f  
79 80 $f 7a 6c $f 7b 14 $f 7c 0a $f 7d 7e $f 7e 88 $f 7f 1e $f
84 30 $f 85 5e $f 86 72 $f 87 82 $f 88 8e $f 89 9a $f 8a a4 $f  
8b ac $f 8c b8 $f 8d c3 $f 8e d6 $f 8f e6 $f 90 f2 $f 91 04 $f  
38 04 $f 58 83 $f 59 0e $f 5f 60 $f 56 40 $f 51 e0 $f 57 02 $f  
59 07 $f 5f a3 $f 59 08 $f 5f 54 $f 52 30 $f 56 29 $f 53 20 $f  
54 30 $f 59 00 $f 5f f0 $f 59 01 $f 5f F0 $f 59 0F $f 5f 00 $f  
59 10 $f 5f 7E $f 59 0A $f 5f 80 $f 59 0B $f 5f 01 $f 59 0C $f  
5f 0F $f 59 0D $f 5f 20 $f 59 09 $f 5f 20 $f 59 02 $f 5f 80 $f  
59 03 $f 5f 60 $f 59 04 $f 5f F0 $f 59 05 $f 5f 80 $f 59 06 $f  
5f 04 $f 59 0B $f 5f 31 $f 55 A6 $f 0F 29 $f 21 67 $f 14 30 $f  
4f 41 $f 50 36 $f 11 01 $f 2a 00 $f 2b 3a $f 2c 00 $f 2d 00 $f  
2e 00 $f 4d d1 $f 4e 09 $f 3e 69 $f 04 10 $f 77 20 $f $s3 00;

DUMP_REG = $wa  $f  $r1 b $"CAM_C0_%a_%b" $+a 01;

REGISTER_DUMP_TO_LOG = $"CAM_Register_dump_to_log_started" 
		$sb 00 $sa 00 $sc FF // set internal regs
		$"CAM_Register_dump_loop_starting" 
		[c 94 #DUMP_REG];     // loop through registers 0 to 94 (all above 94=A0) and dump to log	 
//===================================================================== 
// I2C sequences 
//===================================================================== 
SEQ_INIT_MACRO = $"CAM_seq_init" 12 80 $f 5c 40 $f 3d 5a $f 12 00 $f //I2C reset and power settings
	0a $f $r1 0 $"CAM_ID_NUMBER_MSB_%0" 
	0b $f $r1 1 $"CAM_ID_NUMBER_LSB_%1"
	#FIRMWARE_2
	;
seq_init= #SEQ_INIT_MACRO;
seq_ping=;
// ================= Viewfinder ==========================================
//SQCIF (Platform scales down to SQCIF from QCIF to maintain QCIF FOV)
seq_vf_config_27=
  #QCIF_WITH_FROG_1x_ZOOM
  #MACRO_12_FPS_SETTINGS
 	$s3.00 1 // Set internal register 3 to FF for SQCIF zooming 
	;
//QCIF 12fps
seq_vf_config_28=
  #QCIF_WITH_FROG_1x_ZOOM
  #MACRO_12_FPS_SETTINGS
	$s3.00 0 // Set internal register 3 to 00 for QCIF zooming 
	;
// QCIF 10 fps
seq_vf_config_2d=
  #QCIF_WITH_FROG_1x_ZOOM
  #MACRO_10_FPS_SETTINGS
	$s3.00 0 // Set internal register 3 to 00 for QCIF zooming 
	;
//QCIF (COPY OF size_id 28!!!!! for ITP only)
seq_vf_config_4c=
  #QCIF_WITH_FROG_1x_ZOOM
  #MACRO_12_FPS_SETTINGS
  $s3.00 0 // Set internal register 3 to 00 for QCIF zooming 
	;
//QVGA for ITP only
seq_vf_config_4d=	17 3f $f 18 c8 $f 19 03 $f 1a c8 $f 5a 78 $f 5b A0 $f // Set data output to 240x320 
  								#REGISTER_MODIFY(0c,#SET_BIT_6) #REGISTER_MODIFY(31,#SET_BIT_6)
  								;
seq_vf_start= ;
seq_vf_stop=	#STREAM_OFF
							5a c8 $f 5b c8 $f
							#REGISTER_MODIFY(60,#CLEAR_BIT_4)      // Disable scale function
							#REGISTER_MODIFY(60,#CLEAR_BIT_3)      // Disable Frog view
							#REGISTER_MODIFY(06,#CLEAR_BIT_2)      // PCLK not divided by two for scale function
							#REGISTER_MODIFY(12,#CLEAR_BIT_6)      // AEC/AGC option not QCIF
							#STREAM_ON
							$"CAM_seq_vf_stop_done"
							;
	
// ================== Snapshot for ITP only ===========================================
// 400x400 snapshot for ITP testing purposes
seq_ss_config_41= 06 40 $f 12 00 $f 2f 07 $f 04 00 $f 17 40 $f 19 03 $f 18 ca $f 
									1a c8 $f 5a c8 $f 5b c8 $f 77 20 $f 60 e7 $f 73 06 $f 74 20 $f
									#REGISTER_MODIFY(0c,#SET_BIT_6) #REGISTER_MODIFY(31,#SET_BIT_6)
									;  
seq_ss_start= $d044C; //Delay 1,1s to allow AGC/AEC registers to settle
seq_ss_take=;
seq_ss_stop=;
seq_ss_verify=;
//====================================================================	
// DATA 
//====================================================================	
cam_vf_clock_freq=9,32c8;		// Viewfinder 13MHz 
cam_ss_clock_freq=9,32C8;   // Snapshot 13MHz	 	 		
cam_vf_format=B100;			    // YUV422 U Y1 V Y2...
cam_ss_format=B100;    			// YUV422 U Y1 V Y2...
cam_ping_result=; 
cam_init_result=66;         // For OMNIVISION 6680 sensor 
cam_vf_sync=4;              // VSYNC active low, HSYNC active high. Last data sample before VSYNC and HSYNC inactive
cam_ss_sync=4;              // See above
//=========================================================
//Supported sizes 
//========================================================= 
sup_sizes=
27[80,60,04B0, b0, 90],	// 128x96  - VF 12fps SQCIF 
28[b0,90,04B0],					// 176x144 - VF 12fps QCIF 
2d[b0,90,03E8],					// 176x144 - VF 10fps QCIF 
4c[b0,90,04B0],	        // 176x144 - VF 12fps QCIF (copy of 12 for ITP use) 
4d[f0,140,04b0],        // 240x320 - VF 12fps QVGA for ITP use 
41[190,190,0]; 		      // 400x400 - SS YUV for ITP use 
//========================================================= 
// Support Properties: 
//========================================================= 
sup_properties = 
0[0, F,9],   // Exposure (EV-3.0 to EV+2.0 in steps of 0.3) 
1[0, 0,0],   // White balance (auto) 
2[0, 0,0],   // Flicker (auto) 
3[0, 1,1],   // Vertical mirror (0 = off, 1 = on) 
4[0, 1,0],   // Horizontal mirror (0 = off, 1 = on) 
6[a,14,a],    // Zoom (1.0x and 2.0x) 
7[0, 1,0],   // Night mode (0 = off, 1 = on) 
15[0,1,0],   // Frog view mode (0 = off, 1 = on) 
17[0,0,0],   // ISO (auto) 
// Testing and ITP properties: 
25[0,4,0],  // ESD detection and recovery
26[0,c,0],    // Optics testing property
27[0,5,1],   // Light meter control 
28[0,4,0],   // Window positioning 
1e[0,1,0];   // Color bar pattern enable  
//========================================================= 
// Properties: 
//========================================================= 
// --- Brightness property 0 --------------------- 
// 
//  0 => -3 EV  1=> -(2 2/3) EV .... 
//  9 =>  0 EV  .... 
// 15 =>  2 EV 
//------------------------------------------------
seq_set_prop_0_0 = 24 0b $f 25 03 $f 26 10 $f; // -3.0EV
seq_set_prop_0_1 = 24 0c $f 25 04 $f 26 20 $f; // -2.7EV 
seq_set_prop_0_2 = 24 0f $f 25 07 $f 26 20 $f; // -2.3EV 
seq_set_prop_0_3 = 24 11 $f 25 09 $f 26 20 $f; // -2.0EV 
seq_set_prop_0_4 = 24 15 $f 25 0d $f 26 30 $f; // -1.7EV 
seq_set_prop_0_5 = 24 1a $f 25 12 $f 26 30 $f; // -1.3EV 
seq_set_prop_0_6 = 24 20 $f 25 18 $f 26 40 $f; // -1.0EV 
seq_set_prop_0_7 = 24 26 $f 25 1e $f 26 51 $f; // -0.7EV 
seq_set_prop_0_8 = 24 31 $f 25 29 $f 26 61 $f; // -0.3EV 
seq_set_prop_0_9 = 24 3b $f 25 33 $f 26 71 $f; //  0 EV (default)
seq_set_prop_0_a = 24 48 $f 25 40 $f 26 92 $f; //  0.3EV 
seq_set_prop_0_b = 24 5d $f 25 55 $f 26 c2 $f; //  0.7EV 
seq_set_prop_0_c = 24 72 $f 25 6a $f 26 e3 $f; //  1.0EV 
seq_set_prop_0_d = 24 8b $f 25 83 $f 26 f4 $f; //  1.3EV 
seq_set_prop_0_e = 24 b7 $f 25 af $f 26 f5 $f; //  1.7EV 
seq_set_prop_0_f = 24 e0 $f 25 d8 $f 26 f6 $f; //  2.0EV 

// --- White balance property 1 ------------------ 
//
//  (Sania uses auto only) 
//------------------------------------------------ 
seq_set_prop_1_0 = ;  // auto 

// --- Flicker correction property 2 ------------- 
// 
//  (Sania uses only auto) 
//------------------------------------------------ 
seq_set_prop_2_0 = ;	// auto 

// --- Vertical mirror property 3 ---------------- 
// 
//  0 => off, 1 => on 
//------------------------------------------------ 

seq_set_prop_3_0 = $"CAM_Vertical_mirror_off" #REGISTER_MODIFY(0c,#CLEAR_BIT_6)
									 #REGISTER_MODIFY(31,#CLEAR_BIT_6)   // Lens correction not mirrored
									 ;
seq_set_prop_3_1 = $"CAM_Vertical_mirror_on"  #REGISTER_MODIFY(0c,#SET_BIT_6)
									 #REGISTER_MODIFY(31,#SET_BIT_6)   // Lens correction mirrored
									 ;
// --- Horizontal mirror property 4 -------------- 
// 
//  0 => off, 1 => on 
//------------------------------------------------ 
seq_set_prop_4_0 = $"CAM_Horizontal_mirror_off" #REGISTER_MODIFY(0c,#CLEAR_BIT_7)
									 // Following three rows for swapping frog view values when flipping
									 #REGISTER_READ(77) $m2 4// Read reg 77 and move to int reg 2
									 #REGISTER_READ(78) #REGISTER_WRITE(77)// Copy reg 78 to reg 77
									 $m4 2 #REGISTER_WRITE(78)// move int reg 2 to int reg 4 and Write to reg 78
									 77 $f $r1 f $"CAM_Reg_77_content_%f"
									 78 $f $r1 f $"CAM_Reg_78_content_%f"
									 ; 
seq_set_prop_4_1 = $"CAM_Horizontal_mirror_on"  #REGISTER_MODIFY(0c,#SET_BIT_7)
									 // Following three rows for swapping frog view values when flipping
									 #REGISTER_READ(77) $m2 4// Read reg 77 and move to int reg 2
									 #REGISTER_READ(78) #REGISTER_WRITE(77)// Copy reg 78 to reg 77
									 $m4 2 #REGISTER_WRITE(78)// move int reg 2 to int reg 4 and Write to reg 78
									 77 $f $r1 f $"CAM_Reg_77_content_%f"
									 78 $f $r1 f $"CAM_Reg_78_content_%f"
									 ;
// --- Zoom property 6 --------------------------- 
// 
// 10 (0xa) => 1.0 x zoom 
// 20 (0x14) => 2.0 x zoom 
//------------------------------------------------ 
seq_set_prop_6_a=
 $h0 V 01a0  // wait for end of frame or 416ms (> 4/10fps)
 #STREAM_OFF
$c3.01 0    // No night mode
 $d0060     // 96ms >= 1/12fps = 83.3ms
 #QCIF_WITH_FROG_1x_ZOOM
 $"CAM_1x_zoom_no_night_mode"
$cl         // Night mode active, change zoom in day mode and then switch back to night mode
 $d0080     // 128ms >= 1/8fps = 125ms
 #MACRO_12_FPS_SETTINGS
 #QCIF_WITH_FROG_1x_ZOOM
 #MACRO_8_FPS_SETTINGS
 $"CAM_1x_zoom_yes_night_mode"
$cx
 #STREAM_ON
$h0 V 01a0  // wait for end of frame or 416ms (> 4/10fps)
; 

seq_set_prop_6_14=
 $h0 V 01a0  // wait for end of frame or 416ms (> 4/10fps)
 #STREAM_OFF
$c3.00 0 // IF internal reg 3.0 = 0, QCIF format is used in VF 
 #QCIF_NO_FROG_2x_ZOOM
 $"CAM_2x_zoom_QCIF"
$cl // ELSE, internal reg 3.0 ~= 0; means SQCIF is used in VF
 #QCIF_NO_FROG_2x_ZOOM
 $"CAM_2x_zoom_SQCIF"
$cx
 #STREAM_ON
 $h0 V 01a0  // wait for end of frame or 416ms (> 4/10fps)
;
// ---------- Exposure property 7 ----------------
//
//  0 => Normal mode, 1 => Night mode
//------------------------------------------------
seq_set_prop_7_0= #MACRO_12_FPS_SETTINGS $s3.01 0;
seq_set_prop_7_1= #MACRO_8_FPS_SETTINGS $s3.01 1;

// ---------- Frog view property 15 ----------------
//  0 => off, 1 => on
//------------------------------------------------
seq_set_prop_15_0= $"CAM_Disable_frogview" 
 									 #REGISTER_MODIFY(60,#CLEAR_BIT_3)  // Disable frog view
									 $"CAM_Frogview_disabled"
									 ;
seq_set_prop_15_1= $"CAM_Enable_frogview" 
									 #REGISTER_MODIFY(60,#SET_BIT_3)  // Enable frog view
									 $"CAM_Frogview_enabled"
									 ;

// ---------- ISO property 17 ----------------
//
//  (Sania uses auto only)
//------------------------------------------------
seq_set_prop_17_0=; //auto

// ----- ESD test and recovery  property 25 ---------------
// seq_get:
//  Read and Compare Camera Registers that are set in firmware i.e. not contain sensor default values
//  For ESD test
//  R0: 0 => OK, 1 => NG
//
// seq_set_prop_2a_0 => Runs power off sequence
// seq_set_prop_2a_1 => Runs power on sequence for VT-camera only!
// seq_set_prop_2a_2 => Pull VT-cam reset pin during 2ms
// seq_set_prop_2a_3 => Poll two regs to see if camera is alive, reply should be 66 81 in output
// seq_set_prop_2a_4 => Run init settings to simulate seq_vf_start
//------------------------------------------------
CMP_CAM_REG =
  $"CMP==%4=%6=="
  $-4 r6  $"SUB==%4=="

  $c4 00 $s0 00 // if values are equal, no ESD strike
  $cl    $s0 01 // not equal, ESD strike has occured
  $cx
  ;
seq_get_prop_25=
             #REGISTER_READ(0f) $s6 29 #CMP_CAM_REG $"CAM_ESD==0f=%0="
      $c0 00 #REGISTER_READ(27) $s6 34 #CMP_CAM_REG $"CAM_ESD==27=%0="
  $cl $c0 00 #REGISTER_READ(28) $s6 d0 #CMP_CAM_REG $"CAM_ESD==28=%0="
  $cl $c0 00 #REGISTER_READ(29) $s6 2c #CMP_CAM_REG $"CAM_ESD==29=%0="
  $cl $c0 00 #REGISTER_READ(2f) $s6 07 #CMP_CAM_REG $"CAM_ESD==2f=%0="
  $cx $cx $cx $cx
  ;
seq_set_prop_25_0 = $"CAM_PROP_25_0"
										$gt 9 0000 $d0002 $"CAM_CLOCKS_OFF"// Turn 13MHz clock off, wait 2ms
										$gr 1 $d0002      $"CAM_RESET_RELEASE"// Release RESET, wait 2ms
                    $go 30 0          $"CAM_VDD_OFF"// Turn off VDDs
                    ;
seq_set_prop_25_1 = $"CAM_PROP_25_1"
										$go 30 1 $d0001   $"CAM_VDD_ON"// Turn on VDDs (Needed??)
  									$gt 9 32c8        $"CAM_CLOCKS_ON"// Turn 13MHz clock on (Needed??)
  									$gr 0 $gr 1 $d0002 $gr 0 $"CAM_RESET_PULSE"//Send reset pulse length 2ms (Needed!)
  								  $go 20 0          $"CAM_STANDBY_OFF"// Set CIF_STANDBY = 0 (Normal mode) (Needed!)
										#SEQ_INIT_MACRO   $"CAM_SEQ_INIT_MACRO_DONE"// Runs seq_init commands
										;
seq_set_prop_25_2 = $"CAM_PROP_25_2" $gr 0 $d0001 $gr 1 $d0002 $gr 0 $d0001 $"CAM_RESET_PULSE"//Send reset pulse length 2ms
  									;
seq_set_prop_25_3 = $"CAM_PROP_25_3" 0a $f $r1 0 $"CAM_ID_NUMBER_MSB_%0" 0b $f $r1 1 $"CAM_ID_NUMBER_LSB_%1" //Poll regs to se if cam is alive
									  ;
seq_set_prop_25_4 = $"CAM_PROP_25_4" #QCIF_WITH_FROG_1x_ZOOM #MACRO_12_FPS_SETTINGS $"CAM_PROP_25_4_DONE"
										;					  
// ---------- Optics testing property 26 ----------
//
//               TESTING ONLY!!!
//
// 0 => Normal colors
// 1 => Warm colors
// 2 => Skin tones 1
// 3 => Register dump
// 4 => PSA Color settings
// 5 => Skin tones 2
// 6 => LCC compromise
// 7 => Skin tones 3
// 8 => LCC Flextronics
// 9 => Increased contrast
// a => Decreased contrast
// b => Default contrast
// c => LCC Foxconn
//------------------------------------------------
seq_set_prop_26_0=
79 74 $f 7a 5f $f 7b 15 $f 7c 14 $f 7d 68 $f 7e 7c $f 7f 1e $f;
seq_set_prop_26_1=
79 9a $f 7a 83 $f 7b 17 $f 7c 0c $f 7d 8e $f 7e 9a $f 7f 1e $f;
seq_set_prop_26_2=
79 d7 $f 7a c3 $f 7b 14 $f 7c 36 $f 7d ba $f 7e f0 $f 7f 1e $f;
seq_set_prop_26_3=
$"CAM_Prop_26_3" #REGISTER_DUMP_TO_LOG;
seq_set_prop_26_4=
79 7c $f 7a 68 $f 7b 14 $f 7c 0a $f 7d 76 $f 7e 80 $f 7f 1e $f;
seq_set_prop_26_5=
79 81 $f 7a 6d $f 7b 14 $f 7c 0a $f 7d 7e $f 7e 88 $f 7f 1e $f;
seq_set_prop_26_6=
30 80 $f 31 09 $f 32 00 $f 33 00 $f 35 00 $f 34 1a $f 36 1d $f 37 2d $f;
seq_set_prop_26_7= 
79 80 $f 7a 6c $f 7b 14 $f 7c 0a $f 7d 7e $f 7e 88 $f 7f 1e $f;
seq_set_prop_26_8=
30 80 $f 31 09 $f 32 10 $f 33 18 $f 35 00 $f 34 20 $f 36 22 $f 37 38 $f;
seq_set_prop_26_9=
70 60 $f 71 30 $f;
seq_set_prop_26_a=
70 60 $f 71 10 $f;
seq_set_prop_26_b=
70 00 $f 71 20 $f;
seq_set_prop_26_c=
30 80 $f 31 09 $f 32 85 $f 33 18 $f 35 00 $f 34 15 $f 36 18 $f 37 22 $f;
									 
// ---------- Light Meter property 27------------
//
//		       		TESTING ONLY!!!!
//
//  0 => off, 1 => on, 2 => get value via debug print
//  3 => sleep mode off, 4 => sleep mode on
//  5 => get value via I2C
//------------------------------------------------
seq_set_prop_27_0= #REGISTER_MODIFY(30,#CLEAR_BIT_6); 												 //Disable light meter
seq_set_prop_27_1= #REGISTER_MODIFY(30,#SET_BIT_6) 4d a1 $f 4e 06 $f 3e 69 $f; //Enable light meter with complete register settings
seq_set_prop_27_2= 3a $f $r1 d 39 $f $r1 e 
									 $"CAM_Light_meter_value__MSB_q%dq__LSB_z%ez"; 							 //Output value if ENDE=1 in ITP
seq_set_prop_27_3= #REGISTER_MODIFY(09,#CLEAR_BIT_4); 												 //Disable sleep mode
seq_set_prop_27_4= #REGISTER_MODIFY(09,#SET_BIT_4);			 											 //Enable sleep mode
seq_set_prop_27_5= 3a $f 39 $f $"CAM_Light_meter_output_on_I2C_bus"; 					 // Light meter output to I2C instead of by using ENDE=1, for Illumination driver app.
seq_get_prop_27  = 3a $f $r1 0 39 $f $r1 1 $d0002 $"CAM_light_meter_output_%0_%1"; // Light meter output to SW app.

// ---------- WINDOW MOVING property 28 ----------
//
//                  TESTING ONLY!!!
//
// 0 => Reset to original positions 17=0x41, 19=0x20
// 1 => Increase H- startpos with 4 pixels (reg 0x17)
// 2 => Decrease H-startpos with 4 pixels (reg 0x17)
// 3 => Increase V-startpos with 4 pixels (reg 0x19)
// 4 => Decrease V-startpos with 4 pixels (reg 0x19)
//------------------------------------------------
seq_set_prop_28_0=17 41 $f 19 20 $f;
seq_set_prop_28_1=17 $f $r1 f $+f 01 $f 17 $wf $f $"CAM_Reg_17_content_%f";
seq_set_prop_28_2=17 $f $r1 f $-f 01 $f 17 $wf $f $"CAM_Reg_17_content_%f";
seq_set_prop_28_3=19 $f $r1 f $+f 02 $f 19 $wf $f $"CAM_Reg_19_content_%f";
seq_set_prop_28_4=19 $f $r1 f $-f 02 $f 19 $wf $f $"CAM_Reg_19_content_%f";

// ---------- COLOR BAR PATTERN property 1e ----------
//
//               ITP TESTING ONLY!!!
//
// 0 => Disable color bar
// 1 => Enable color bar with fading bars
//------------------------------------------------
seq_set_prop_1e_0= #REGISTER_MODIFY(61,#CLEAR_BIT_1);  // Disable color bar output image
seq_set_prop_1e_1= #REGISTER_MODIFY(61,#SET_BIT_1)     // Enable color bar output image
									 #REGISTER_MODIFY(68,#SET_BIT_6);    // Set color bar to fade-to-gray

