// Yue camera driver setup file                                               
//************************************************************************
// 
//
// Revision history:
// 1.0 First release based on Yue Ver1.0              2009-1-5
//     Change power setting according to Yue HW spec. 
// ***********************
// 2.1 Fix for DMS00508656 GTCCPRTC: phone crashes in video view finder when press # shortcut key.
//                                                     2008.12.15
// 2.0 Fix for Yellow pictures cause by Autoflash fix. 2008.11.28
// 1.9 Fix for DMS00444457                             2008.11.24
//     Fix for DMS00436227
// 1.8 Fix for DMS00441559                             2008.10.22
//     [Camera] The zoomlevel is not reseted when changing between still mode and video mode
//
// 1.7 Add Property 0x17 into property table.          2008.09.01
// 1.6 Fix for DMS00415100.                            2008.08.26
//     Fix for DMS00409838
//     Add Auto Flash threshold value to property 23.
// 1.5 Add cam_vf_buffer= 0006 for semi transparancy.  2008.08.12
// 1.4 Fix for video recording application errors.     2008.07.23
// 1.3 DMS00393553 Camera: [Kate] There is no differense between a nightmode on or off
//		 DMS00393566 Camera: [Kate] The framerate is 5 fps instead of 7.5 fps 
//                                when recording a video with night mode on   2008.07.21
// 1.2 Set reg07 as Auto draft flag to improve startup speed. 2008.07.21
// 1.1 Change GPIO setting according to HB108 spec.  2008-05-04
// 1.0 First release based on Ning version 2.6       2008-04-14
//     Change power setting according to Kate HW spec.
//
//*****************************************************************************
//---------------------------------------------------------
// Description of internal register usage:
//
// a: used to select EXIF parameter to read
// e: used to remember last size id for snapshot burst mode
//
//---------------------------------------------------------

//Information section
//=========================================================

info_name=MCB850;
info_vendor=Sony;
info_major_ver=1;
info_minor_ver=0;        				// use HEX foramt

//Camera characteristics section
//=========================================================
//=========================================================
// Yue 3M camera Power on sequence
//=======================================================				
cam_power_on_0 = 5, 0, 00, 1, 05;   	// Active Main Camera RST pin, delay 5ms 					
cam_power_on_1 = 5, 2, 92, 0, 05; 		// ATT Enable (AppGPIO_10 = GPIO_92)
cam_power_on_2 = 5, 2, 92, 1, 05; 		// ATT Enable (AppGPIO_10 = GPIO_92)	
cam_power_on_3 = 5, 2, 91, 1, 05; 		// Core Enable (AppGPIO_9 = GPIO_91)							
cam_power_on_4 = 5, 4, 00, 0, 05;     	// I2C sequence 0		
cam_power_on_5 = 5, 3, 09, 32C8, 05; 	// Turn on 13 MHz clock, delay 5ms					
cam_power_on_6 = 5, 0, 00, 0, 32;   	// Disable RST , delay 50ms					

cam_power_i2c_0 = $a60 00 dd $f 01 30 $f 01 34 $f $d0010 01 36 $f 01 3e $f $d0010 $a1f;
			
//=========================================================
// Yue 3M camera Power off sequence
//=======================================================					
cam_power_off_0 = 5, 0, 00, 1, 10;   	// Active Main Camera RST pin, delay 16ms 					
cam_power_off_1 = 5, 3, 09, 0, 05;  	// Turn off 13 MHz clock and wait 5 ms					
cam_power_off_2 = 5, 2, 92, 0, 05; 		// Release ATT Enable (AppGPIO_10 = GPIO_92)	
cam_power_off_3 = 5, 2, 91, 0, 05; 		// Release Core Enable (AppGPIO_9 = GPIO_91)							

//=========================================================


//================================================
//                DATA
//================================================
// TODO: define any of these that are needed:
// cam_i2c_clock_freq=
//       The desired I2C clock frequency in kHz (hexadecimal). Default is 100 kHz
// cam_data_offset=
//       The number of bytes in the data stream to be
//       skipped before the image data appears when
//       taking a snapshot (hexadecimal)
// cam_frame_skip=
//       The number of frames to be skipped before the
//       final image frame is captured when taking a
//       snapshot (hexadecimal)
// cam_ss_retries=
//       The number of times to retry taking a snapshot
// cam_ss_jpeg_buf_size_1=
// cam_ss_jpeg_buf_size_2=
// cam_ss_jpeg_buf_size_3=
// cam_ss_jpeg_buf_size_4=
//       Suggested snapshot buffer size in bytes (hexadecimal)

// cam_post_processing_x=
//       Post processing for size configuration x:
//          0 =   0 degrees rotation
//          1 =  90 degrees clockwise rotation
//          2 = 180 degrees clockwise rotation
//          3 = 270 degrees clockwise rotation
//================================================


cam_i2c_address=1F;
cam_vf_clock_freq=9,32C8; 	// clock ID 9 is SYSCON_SYSCLK_13MHZ,Clock #9 on, frequency 13MHz
cam_ss_clock_freq=9,32C8;		// clock ID 9 is SYSCON_SYSCLK_13MHZ,Clock #9 on, frequency 13MHz
cam_i2c_clock   = ;       	// Default 100 kHz

cam_vf_format=B100;
cam_ss_format=0001;					// JPEG default

cam_ss_format_10 = B100;    // YCbCr
cam_ss_format_11 = B100;    // YCbCr

cam_data_offset=2;        	// JPEG default
cam_data_offset_10 = 0;     // YCbCr
cam_data_offset_11 = 0;     // YCbCr

cam_vf_sync=5;
cam_ss_sync=5;
// 	cam_vf_buffer= 0006;  		// YUV420 Separated 

cam_ss_retries=9;

//-- Rotation setting
cam_post_processing_20 = 1;   // viewfinder rotation
cam_post_processing_25 = 1;   // videotelephony
cam_post_processing_26 = 1;   // videotelephony
cam_post_processing_29 = 1;   // video recording

//-- JPEG buffer sizes 
cam_ss_jpeg_buf_size_1=25800;	// 150 KB buffer for   	640x480 snap
cam_ss_jpeg_buf_size_2=64000;	// 400 KB buffer for  	1280x960 snap
cam_ss_jpeg_buf_size_4=96000;	// 600 KB buffer for 	1632x1244 snap
cam_ss_jpeg_buf_size_5=E1000;	// 900 KB buffer for 	2048x1536 snap

cam_isp_config = 	0;										
cam_ccp2_enabled = 	0;

//================================================
//                SUPPORTED SIZES
//================================================
//-- JPEG snapshot resolutions
//  1 = 640 x 480       2 = 1280 x 960    
//  4 = 1632 x 1224     5 = 2048 x 1536    

//-- YUV422 snapshot resolutions
// 10 = 320 x 240      11 = 640 x 480 

//-- Viewfinder resolutions
// 20 = 320 x 240
// 25 =  96 x 128      
// 26 = 144 x 176      
// 29 = 144 x 176      
// 2a = 320 x 240      
// 2b = 320 x 240
// 2c = 320 x 240
// 2f = 320 x 240
//=================================================

sup_sizes = 

  					1[280,1E0,0],         //  SS 640  x 480  JPEG VGA  
  					2[500,3C0,0],	        //  SS 1280 x 960  JPEG 1M
	 
  					4[660,4C8,0],	        //  SS 1632 x 1224 JPEG 2M   
 					  5[800,600,0],	        //  SS 2048 x 1536 JPEG 3M

  					10[140, F0,0],	      //  SS 320  x 240  YCbCr     
  					11[280,1E0,0],	      //	SS 640  x 480  YCbCr    
			
  					20[140,F0,BB8],       //  VF  320 x 240  YCbCr 30 fps
  
  					25[60,80,4B0],        //  VT   96 x 128  YCbCr 12 fps max
  					26[90,B0,4B0],        //  VT  144 x 176  YCbCr 12 fps max 

  					29[90,B0,3E8],        //  VR  144 x 176  YCbCr 10 fps fixed
  					2a[140,F0,BB8],       //  VR  320 x 240  YCbCr 30 fps fixed
  					2b[140,F0,5DC],       //  VR  320 x 240  YCbCr 15 fps fixed
  					2c[140,F0,2EE],       //  VR  320 x 240  YCbCr 7.5 fps fixed
  
  					2f[140,F0,BB8],       //  VF  320 x 240  YCbCr 30 fps
  					;

//=========================================================	   
// Platform registers used
//=========================================================	
//	0, Used in CLEAR_EVENT_FIFO, 
//             WAIT_FOR_MODE,   
//             jpeg_qtable_selector
//             WAIT_FOR_TRIG
//						 Property 23 Xenon Flash Required 
//	1, Used in SET_REG,
//             CLEAR_EVENT 
//             SEND_COMMAND, 
//             jpeg_qtable_selector
//	2, Used in CLEAR_EVENT (Event info stored), 
//             CLEAR_EVENT_FIFO, 
//             WAIT_FOR_MODE, 
//             jpeg_qtable_selector
//	3, Used in CLEAR_EVENT (Event id stored), 
//             CLEAR_EVENT_FIFO, 
//             WAIT_FOR_MODE, 
//	4, Used in READ_REG (value stored)
//             Property 6 
//             Property 23 Xenon Flash Required 
//	5, Used in Property 6 
//             Property 23
//             UPDATE_MIN_FRMRATE
//             UPDATE_ISO
//             UPDATE_PHOTO
//             UPDATE_WB
//             Property 10
//	6, Used for burst mode. 0 = OFF,  1 = ON
//	7, JPEG -> draft auto   1 = Done    0 = Not done
//	8, Used for face dectection input, which is stored in reg g, h, i and f.08
//	9, 0:Init  1:ReadyForBurstOutput  2:WaitForEV_RECORD_STATUS  3:BurstOutput
//	a,
//	b, Used in Property 29, BestPic operation
//             seq_pv_verify
//	c, Used to remember ISO setting since one has to change AE_MODE 
//             to "auto" for IS.
//	d, Used to remember LED flash mode (property 23)
//	e, Used for picture readout, 0 => normal, burst 1 => read out pict 1 ...
//	f, Used as 32 flags:
//                  bit 0, Image stabilization,	1 = ON,	    0 = OFF
//                  bit	1, High sensitivity,    1 = ON,     0 = OFF
//                  bit 2, Any draft mode,      1 = YES,    0 = NO		
//                  bit 3, Snapshot format,     1 = JPEG,   0 = YCbCr
//                  bit 4, Xenon flash needed,  1 = Yes,    0 = NO
//                  bit 5, JPEG compression     1 = Normal, 0 = Low compression
//                  bit 6, Flash was used       1 = True,   0 = False
//                  bit 7,
//                  bit 8, Face detection       1 = ON,     0 = OFF
//                  bit 9, Focus range          1 = Full,   0 = Normal
//                  bit A, Photometry spot      1 = ON,     0 = OFF
//									bit B,
//  g, Used for x-coordinate of AF-area
//  h, Used for y-coordinate of AF-area
//  i, Used for width of AF-area
//================================================
//               MACROS
//================================================
// MCB850 UI COMMAND
// Send command   0x3E 0x06 0x02 0x00 0x01 CommandParameter Command
// Command replay 0x3F 0x04 Cause CommandParameter Command
// Polling        0x3E 0x05 0x01 0x00 0x03 0x03
// Receive Event  0x3F 0x04 Cause StatusParameter Status
// Set parameter  0x3E 0x05 0x02 0x00 REG Parameter
// Read parameter 0x3E 0x05 0x01 0x00 REG 0x01
//                0x3F 0x02 Parameter
// Set INT_RELEASE Register  0x3E 0x05 0x02 0x00 0x06 0x01
//================================================

// Sets register to value SET_REG(REG,VAL)
SET_REG = 05 02 00 !0 !1 $f $r2 01 $d0002; 

// Reads register READ_REG(REG,$r2 01)
READ_REG  = 05 01 00 !0 01 $f !1 ;

CLEAR_EVENT =         											// Clears event register. FIFO is not cleared
  						05 01 00 03 03 $f   					// Packet length, access code, id number, reg to read (int source), req packet length
  						$r4 1 123 $d0002    					// Put Int_source in reg 1, Event_info in reg 2 and Event_id in reg 3
  						$c3 00              					// If internal register 3 holds 0 (means the queue was empty)
    						$"CAMDRIVER0: Queue_was_empty"
  						$cl
    						$"CAMDRIVER0: Cleared_Int_Source_%1_Event_Info_%2_Event_ID_%3"   
  						$cx
  						#SET_REG(06,03)     					// Clears the event     
  						;

CLEAR_EVENT_FIFO =    								// Clears the event FIFO
  								$"CAMDRIVER0: Clear_event_fifo"
  								$s0 01              // Set internal register 0 to 0x01 (otherwise the loop won't even start)
  								[ 0 ff              // Loop 0xff times or quit looping when internal register 0 holds 0
    								#CLEAR_EVENT      // Read the event and clear it
    								$c3 00            // If internal register 3 holds 00 (= if EVENT_ID equals 00, meaning the queue is empty)
      								$s0 00          // Set internal register 0 to 0x00 in order to exit the loop
    								$cx
  								]
  								;

WAIT_FOR_TRIG =       													// Listen to TRIG APP GPIO_02=GPIO_82
  						 $h 0 82 5 1000      							// Listen to trig on Application GPIO_02 = TRIG
  						 $c0 00                
    						 $"CAMDRIVER0: TRIG_Timeout"    // No event occured
  						 $cl
    						 $"CAMDRIVER0: TRIG_Recieved"   // Event occured
  						 $cx
  						 ;

// Only send command, no reply is read out
COMMAND  = 06 02 00 01 !1 !0 $f $r3 012 $d0002; // Change delay time from 5ms to 2ms.

// Waits for signal on TRIG, and clear the event register when it has arrived
CAPTURE_EVENT = 
							 #WAIT_FOR_TRIG
               #CLEAR_EVENT
               ;

// This sends a command and waits for reply
// In most cases this is the command that should be used, isn't it?
COM_EVENT = 
						#CLEAR_EVENT_FIFO
            #COMMAND(!0,!1)
            #WAIT_FOR_TRIG
            #CLEAR_EVENT
            ;

// Use poll instead of TRIG. It is difficult to use TRIG if reply
// and mode transfer comes to close
// Reads and clears events until the specified event occurs. 
WAIT_FOR_MODE =       							// Syntax: WAIT_FOR_MODE($s4 Event_Identification)											
  							$"CAMDRIVER0: Wait_for_mode"
  							!0                  // "Execute" the first parameter
  							$s0 01              // Set internal register 0 to 0x01 (otherwise the loop won't even start)
  							[ 0 ff              // Loop 0xff times or quit looping when internal register 0 holds 0
    							#CLEAR_EVENT      // Clear event. If the event id (which the CLEAR_EVENT-makro will store in
                      							// internal register 2) is equal to 0xea (= EV_MODE_CHANGED)
    							$-3 r4            // Subtract the contents of internal register 4 from the contents of register 3 (EVENT_ID)
                      							// and store the result in internal register 3
    							$c3 00            // If internal register 3 holds 0
      							$"CAMDRIVER0: Successfully_acknowledged_Event_ID_%4"
      							$s0 00          // Set internal register 0 to 0x00 in order to exit the loop
    							$cx               // End if
  							]
  							;
  
WAIT_FOR_MODE_A =       // Syntax: WAIT_FOR_MODE($s4 Event_Identification)											
  							$"CAMDRIVER0: Wait_for_mode"
  							!0                  // "Execute" the first parameter
  							$s0 01              // Set internal register 0 to 0x01 (otherwise the loop won't even start)
  							[ 0 05              // Loop 0x05 times or quit looping when internal register 0 holds 0
    							#CLEAR_EVENT      // Clear event. If the event id (which the CLEAR_EVENT-makro will store in
                      // internal register 2) is equal to 0xea (= EV_MODE_CHANGED)
    							$-3 r4            // Subtract the contents of internal register 4 from the contents of register 3 (EVENT_ID)
                      // and store the result in internal register 3
    							$c3 00            // If internal register 3 holds 0
      							$"CAMDRIVER0: Successfully_acknowledged_Event_ID_%4"
      							$s0 00          // Set internal register 0 to 0x00 in order to exit the loop
    							$cx               // End if
  							]
  							;

// Used to change mode, TRIG is not used, instead event register is polled.
CHANGE_MODE   = 
								#CLEAR_EVENT_FIFO
                #SET_REG(06,03)
                #COMMAND(!0,!1)
                #WAIT_FOR_MODE($s4 ea)
                #SET_REG(06,03)
                ;

CHANGE_MODE_A   = 
								#CLEAR_EVENT_FIFO				//Only used for Burst mode (4 times taking picture)
                #SET_REG(06,03)
                #COMMAND(!0,!1)
                #WAIT_FOR_MODE_A($s4 ea)  // Using 5 times loop to avoid long time waiting for 0xEA events.
                #SET_REG(06,03)
    						;


// Used where HALF_RELEASE should be done 
HALF_RELEASE  = 
                $"CAMDRIVER0_Half-release"
                #CLEAR_EVENT_FIFO
                #SET_REG(06,03)
                #COMMAND(31,03)                //No AF, AE hold, ACC locked
                #WAIT_FOR_MODE($s4 e9)				 //Wait for half release
                #SET_REG(06,03)
                ;

READ_AF_STATUS=
								05 01 00 03 03 $f $r4 4 4 4 5
                $c5 E9												//Use halfrelease do AF operation, so change E6 -> E9 
                $cl 
                   $s4 03 
                $cx
                ; 		            

// Used in scene selection
UPDATE_WB = 
						$p5 01
  					$c5 00							// WB is auto?	
						$cl
	  					$d0032						// Delay 50 milliseconds
	  					$u01							// Update WB
						$cx
						;

UPDATE_PHOTO =        						// Updates photo metering
  						$p5 16
  						$c5 00							// Photo metering is not spot?
  						$cl
    						$u16							// Update photo metering => spot
  						$cx
  						;
  
UPDATE_MIN_FRMRATE =  									// Updates minimum framerate
  									$p5 10
  									$c5 03 
    									#SET_REG(08,04)   // DRAFT_MIN_FRMRATE 2 fps
  									$cl
    									#SET_REG(08,0A)   // DRAFT_MIN_FRMRATE 5 fps
  									$cx
  									;

UPDATE_ISO =          					// Updates ISO
  					$p5 11
  					$c5 00							// ISO is auto
  					$cl
    					$u11							// Update ISO
  					$cx
  					;    

	            
CMD_END=$f $d0002;						// Change delay time form 5ms to 2ms.
 

DOC_MODE =            				// Updates special doc scene settings 
  				#COM_EVENT(55,02)	  // Increase contrast to 2
  				#COM_EVENT(56,08)	  // Increase sharpness to max (8)
  				#COM_EVENT(06,02)	  // Increase exposure to 2
  				#SET_REG(2B,04)     // Setting AF range to Macro
  				#COM_EVENT(05,00)
  				;

NOT_DOC_MODE =        						// Reverses special doc scene settings
  						#COM_EVENT(02,00)   // AE_AUTO
  						#COM_EVENT(55,00)	  // Reset contrast
  						#COM_EVENT(56,00)	  // Reset sharpness
  						#COM_EVENT(06,00)	  // Reset exposure
  						#SET_REG(2B,00)     // Reset AF range to Normal
  						#COM_EVENT(05,00)   // Set ISO to Auto.
  						;
                                    
TO_DRAFT =                     		// Changes to draft (but not on display)
  				$cf.02 0                // If not draft       
    				$sf.02 1              // Set draft flag to 1
  				$cl
  				$cx
  				;  
  
DISP_REG =
  				$"CAMDRIVER0: REG00_%0_REG01_%1_REG02_%2_REG03_%3" 
  				$"CAMDRIVER0: REG04_%4_REG05_%5_REG06_%6_REG07_%7" 
  				$"CAMDRIVER0: REG08_%8_REG09_%9_REG0A_%A_REG0B_%B" 
  				$"CAMDRIVER0: REG0C_%C_REG0D_%D_REG0E_%E_REG0F_%F" 
  				;
  
DISP_GET_REG = //#COM_EVENT(72,00)		    // Update the registers, INFO_GET_DATA
		             #READ_REG(0E,$r2 3 3)		// Put shutter(H, MSB) in reg 3
		             #READ_REG(0F,$r2 2 2)		// Put shutter(L, LSB) in reg 2
		             #READ_REG(10,$r2 1 1)		// Put ISO(H, MSB) in reg 1
		             #READ_REG(11,$r2 0 0)		// Put ISO(L, LSB) in reg 0
		             $"CAMDRIVER0_GetEXIF1_%3_%2_%1_%0"
		             ;
		             
AUTO_AE_SETTING =   #COMMAND(09,01)							//Set AE_SPEED High.
        						#COMMAND(14,01)							//Set CC_SPEED High.
										#COM_EVENT(03,00)		  			// Auto operation for AE
										#COMMAND(04,00)
										#COMMAND(05,00)
										;		             

//---------------------------------------------------------
//These two lines controls the locked frame rate in VR.
//Use them to test different settings!
//The value entered is the desired frame rate * 2.
//Example: 14 means 0x14 = 20 => frame rate 20 / 2 = 10 fps

VR_30_FR=3C;							// 30 fps
VR_15_FR=1E;							// 15 fps
VR_12_FR=18;							// 12 fps
VR_10_FR=14;							// 10 fps
VR_7_5_FR=0F;						  // 7.5fps

//================================================
//               OTHER SEQ
//================================================

seq_init= 	 // $d0014 
        $sf 00                      // Set all flags to zero
  			$sf.05 1                    // Normal JPEG compression
  			$sf.02 1                    // Set draft flag to YES	  
        $s7 01                      // Quick start
  			$se 00                      // Normal snapshot operation
  			$sd 00                      // Flash mode "auto"
        $s6 00                      // Not in burst mode
        
        
      	$"CAMDRIVER0_CAMDRIVER0_init"
      	#CAPTURE_EVENT              // e1 EV_CAM_READY
      	#CAPTURE_EVENT              // ec EV_MUTE_OFF
      
      	#SET_REG(19,00)             //JPEG continuos mode infinite
      	#SET_REG(0C,D0)
      	#SET_REG(0D,07)             //JPEG retry time max 2 sec

        #COMMAND(09,01)							//Set AE_SPEED High.
        #COMMAND(14,01)							//Set CC_SPEED High.
     		;

seq_ping=;

//================================================
//              PROPERTIES
//================================================
//
//Properties: 
//            	0 = Exposure			            Set  				Implemented
//            	1 = White balance		          Set  				Implemented
//         	    2 = Flicker Mode	            Set  				Implemented
//		          3 = Vertical mirror		        Set  				Implemented
//            	4 = Horisontal mirror		      Set  				Implemented
//            	5 = JPEG Compression level	  Set  				Implemented
//		          6 = Zoom			                Set/Get			Implemented
//		          7 = Night mode 			          Set  				Implemented
//		          8 = Effects			              Set  				Implemented
//		          9 = Focus mode			          Set  				Implemented
//	         a 10 = Focus operation		        Set/Get			Implemented
//	         b 11 = Get Exif information 1	  Get  				Implemented
//	         c 12 = Get Exif information 2	  Get  				Implemented
//	         d 13 = LED support 		          Set  				Implemented    
//	         e 14 = Xenon Flash support	      Set  				NOT VALID FOR MCB 850 
//	         f 15 = Optical zoom  		        Set/Get			NOT VALID FOR MCB 850 
//	        10 16 = Scenes			              Set  				Implemented
//	        11 17 = ISO			                  Set  				Implemented
//	        12 18 = Low Framerate Mode        Set  				Implemented
//	        13 19 = Get face det.AF	          Set/Get			Not Implemented		
//	        14 20 = Set AF area		            Set  				Implemented
//	        15 21 =           			              				
//	        16 22 = Photo Metering 	          Set  				Implemented
//	        17 23 = Xenon Flash Required	    Get  				NOT VALID FOR MCB 850 
//	        18 24 = Image Stabilization       Set  				NOT VALID FOR MCB 850 
//	        19 25 = Continuous Zoom		        Set      		Implemented
//	        1a 26 = Get zoom value		        Get  				Implemented
//	        1b 27 = Snapshot operation		    Set  				NOT VALID FOR MCB 850 
//	        1c 28 = 								          
//          1d 29 = Burst (BestPIC) Operation Set  				NOT VALID FOR MCB 850 
//          1e 30 = ITP test (Test Pattern)		Set					Implemented
//									2,3 for FD test and 4 for temp test.
//          1f 31 = ITP test
//          20 32 = ITP test (Spot)
//================================================

sup_properties = 
								 0[3,f,9], 1[0,6,0],  2[0,3,0],  3[0,3,0],  4[0,3,0],
		             5[0,9,0], 6[a,28,a], 7[0,1,0],  8[0,4,0],  9[0,4,0],
		             a[0,2,0], b[0,0,0],  c[0,0,0],  d[0,1,0],  e[0,4,0],
                 f[0,1,0],10[0,7,0], 11[0,9,0], 12[0,ff,0],
                14[0,FFFFFFFF,0],15[0,11,8],16[0,1,0],17[0,0,0],19[0,2,0],1c[0,1,0], 
                1d[0,3,0],1e[0,3,0], 1f[0,1,0],20[0,7,0]
                ;
                
//************************************************ 
//		Property 0  Exposure                     ***
//************************************************
//--------------------------------------------------
//  3 => -2 EV,   9 => -(0) EV ....    f => 2 EV
//---------------------------------------------------
//TBD
seq_set_prop_0 = 
		 						#TO_DRAFT
		 						$s5 %0 
		 						$-5 09 
		 						#COM_EVENT(06,$w5)
		 						;
 
//************************************************ 
//		Property 1  White balance                ***
//************************************************
//---------------------------------------------------
//  0 => Auto         1 => Tungsten     2 => Fluorescent 
//  3 => Outdoor clear sky    4 => Outdoor cloudy
//  5 => All pull-in  
//---------------------------------------------------
//TBD
seq_set_prop_1_0 = #TO_DRAFT #COM_EVENT(11,00);
seq_set_prop_1_1 = #TO_DRAFT #COM_EVENT(11,03);
seq_set_prop_1_2 = #TO_DRAFT #COM_EVENT(11,04);
seq_set_prop_1_3 = #TO_DRAFT #COM_EVENT(11,05);
seq_set_prop_1_4 = #TO_DRAFT #COM_EVENT(11,06);
seq_set_prop_1_5 = #TO_DRAFT #COM_EVENT(11,02);

//**************************************************** 
//		Property 2      Flicker correction,          ***
//****************************************************

//  0 => auto,  1 => 50 Hz, 2 => 60 Hz, 3 => disable 
//
//---------------------------------------------------

seq_set_prop_2_0= #COM_EVENT(21,01);		//Auto detect
seq_set_prop_2_1= #COM_EVENT(21,02);		//50Hz detect
seq_set_prop_2_2= #COM_EVENT(21,03);		//60Hz detect
seq_set_prop_2_3= #COM_EVENT(21,00);		//Disable

//***************************************************
// 		Property 3    Vertical mirror,              ***
//***************************************************
// 0->OFF,       1->ON
//---------------------------------------------------

seq_set_prop_3_0 = #COM_EVENT(52,00);		// OFF 0b00000000 Capt/draft
seq_set_prop_3_1 = #COM_EVENT(52,0A);		// ON  0b00001010 Capt/draft

//***************************************************
//		Property 4  Horizontal mirror               ***
//***************************************************
// 0->OFF,       1->ON
//---------------------------------------------------

seq_set_prop_4_0 = #COM_EVENT(52,00);		// OFF 0b00000000 Capt/draft
seq_set_prop_4_1 = #COM_EVENT(52,05);		// ON  0b00000101 Capt/draft

//***************************************************
//    Property 5 JPEG compression                 ***
//***************************************************
//  0 => normal (High compression) 
//	1 => fine 	(Low  compression)
//
//---------------------------------------------------

seq_set_prop_5_0 = $sf.05 1;     // Normal compression
seq_set_prop_5_1 = $sf.05 0;     // Low compression


//*********************************************************
//		Property 6    Zoom                                ***
//*********************************************************
// 10 => 1.0 x zoom, 11 => 1.1 x zoom, ... 22 => 2.2 x zoom
//---------------------------------------------------------
// TBD
            
seq_set_prop_6 =                	 
		 						#TO_DRAFT
		 						#SET_REG(32,01)									// ZM_SMTH_INTERVAL = 1
 		 						$s4 %0  
 		 						$"CAMDRIVER0_Cam_mag_R4_%4"
// 		 						$ma 4 											 // Set zoom level  y = -15x/11 + 77  
//  	 						$*4 0F  $/4 0B           
//  	 						$s5 4D  $-5 r4  

							 $c4 0A $s5 3F $cl $cx	        // Use searching table replace formula.
		 					 $c4 0B $s5 3E $cl $cx	
		 					 $c4 0C $s5 3C $cl $cx	
		  				 $c4 0D $s5 3A $cl $cx
		 					 $c4 0E $s5 39 $cl $cx	
		 					 $c4 0F $s5 37 $cl $cx	
		 					 $c4 10 $s5 36 $cl $cx	
		 					 $c4 11 $s5 34 $cl $cx	
		 					 $c4 12 $s5 33 $cl $cx	
		           $c4 13 $s5 32 $cl $cx	
		           $c4 14 $s5 31 $cl $cx	
		           $c4 15 $s5 30 $cl $cx	
		           $c4 16 $s5 30 $cl $cx
		 
		 		 		   $"CAMDRIVER0_Cam_mag_value_%5"
		 					 #SET_REG(32,3C)        					// ZM_SMTH_STEP = 60 		 			   
		 					 #COM_EVENT(61,$w5)	
  	           ;

seq_get_prop_6 = 
  							#TO_DRAFT
  							#READ_REG(31,$r2 4 4)   				// Get zoom level x = -11y/15 + 56, TBD
//  							$*4 0B  $/4 0F  $s0 38
//  							$-0 r4  
               $c4 40 $s0 0A $cl $cx						// Use seraching table replace formula.
		 					 $c4 3F $s0 0A $cl $cx	
		 					 $c4 3E $s0 0B $cl $cx	
		  				 $c4 3D $s0 0B $cl $cx
		 					 $c4 3C $s0 0C $cl $cx	
		 					 $c4 3B $s0 0C $cl $cx	
		 					 $c4 3A $s0 0D $cl $cx	
		 					 $c4 39 $s0 0E $cl $cx	
		 					 $c4 38 $s0 0E $cl $cx	
		           $c4 37 $s0 0F $cl $cx	
		           $c4 36 $s0 10 $cl $cx	
		           $c4 35 $s0 10 $cl $cx	
		           $c4 34 $s0 11 $cl $cx
               $c4 33 $s0 12 $cl $cx	
		           $c4 32 $s0 13 $cl $cx	
		           $c4 31 $s0 14 $cl $cx	
		           $c4 30 $s0 15 $cl $cx	
		           $c4 2F $s0 15 $cl $cx 
                
               $s1 00  $s2 00  $s3 00
  						 $"CAMDRIVER0_Read_mag_value_%0"
  						 ;		 


//******************************************
//		Property 7        Night mode,      ***
//******************************************
// TBD		   
seq_set_prop_7_0=
                 $"CAMDRIVER0_property_7_0"
                 ;
                                  
seq_set_prop_7_1=
                 $"CAMDRIVER0_property_7_1"
								 ;

//***************************************************
//		Property 8     Effects  		                ***
//***************************************************
//
//  0 => normal,  1 => negative,  2 => solarize
//  3 => sepia,   4 => black&white, //inverted sepia and negative B&W
//---------------------------------------------------
//TBD
seq_set_prop_8 = 
								#TO_DRAFT 
								#COM_EVENT(53,%0)
								;


//*********************************************
//		Property 9   Focus setting,           ***
//*********************************************
//  0--Nomal
//  1--Full range
//  4--Macro
// TBD
seq_set_prop_9 = 
								#TO_DRAFT 
								#SET_REG(2B,%0)
								;


//************************************************
//		Property 10  Focus operation,            ***
//************************************************
//------------------------------------------------
//   0 => Stop AF scan and hold position
//   1 => Start AF scan 
//   2 => Stop AF and go to infinity

//   Return values:
//   3 <= Focus ongoing
//   4 <= Focus operation success
//   5 <= Focus operation failure
//-------------------------------------------------

seq_set_prop_a_0=
  								$"CAMDRIVER0: Stop_AF"
  								$cf.02 0                     // If not in draft mode 
      						  #CHANGE_MODE(34,01)        // MODE_DRAFT
      						  $sf.02 1                   // Set draft flag to 1
      							#COM_EVENT(43,FF)          // MANUAL_FOCUS = FF, Infinity
    							$cx
									;     								
seq_set_prop_a_1=
  								$"CAMDRIVER0: Start_AF"
  								$cd 01
  									$d01F4
  								$cl
  								$cx
  								$"CAMDRIVER0: Start_AF_Delay_End"
  								$sf.02 0                     // Not in draft mode
  								#COMMAND(31,07)              // AF, AE hold, No ACC locked
									;
seq_set_prop_a_2=
        					$"CAMDRIVER0: Stop_AF_Infinity"
        					#COMMAND(31,03)          		 // Half-release with focus set to inf
        				  $sf.02 0                     // Not in draft mode
									;

seq_get_prop_a=
								05 01 00 03 03 $f $r4 4 4 4 5
								$"CAMDRIVER0: Focus_REG5_%5_REG4_%4"
                $c5 E9												 //Use halfrelease do AF operation, so change E6 -> E9 
    								$b4 00 4 1        				 //Remove the flash notification bit
    								$c4 00
      								$"CAMDRIVER0: Focus_operation_succeded"
      								$s0 04
    								$cl
      								$"CAMDRIVER0: Focus_operation_failed"
      								$s0 05          
    								$cx
                $cl 
                   $"CAMDRIVER0: Focus_operation_not_finnished"
                   $s0 03 
                $cx
								;

//*****************************************************
//		Property 11         Get EXIF information 1,   ***
//*****************************************************

seq_get_prop_b = 
								 #COM_EVENT(72,00)		    // Update the registers, INFO_GET_DATA
		             #READ_REG(51,$r2 3 3)		// Put shutter(H, MSB) in reg 3
		             #READ_REG(50,$r2 2 2)		// Put shutter(L, LSB) in reg 2
		             #READ_REG(4F,$r2 1 1)		// Put ISO(H, MSB) in reg 1
		             #READ_REG(4E,$r2 0 0)		// Put ISO(L, LSB) in reg 0
		             $"CAMDRIVER0_EXIF1_%3_%2_%1_%0"
		             ;
		             
//*****************************************************
//		Property 12      Get EXIF information 2,      ***
//*****************************************************

seq_get_prop_c =  
									#COM_EVENT(72,00)		     // Udate registers, INFO_GET_DATA
		              #READ_REG(52,$r2 0 0)		 // Put WB in reg 0
		              $c0 00				           // reg 0 = 00 ?
		   				                             // Do nothing
		              $cl
		                  $-0 02			         // Subtract 2 from reg 0
		              $cx
		              #READ_REG(53,$r2 1 1)		 // Put distance in reg 1
		              #READ_REG(1C,$r2 3 3)		 // Put q-factor (JPEG_HOST_QUALITY) in reg 3
		              $s2 00                    // set reg2 value to 0. 
                  $"CAMDRIVER0_EXIF2_%3_%2_%1_%0"
                  ;

//*********************************************************************
//	Property 13  LED flash                                          ***
//*********************************************************************
//  Set to 1 if the camera should expect LED support
// 
//  If white balance is set to auto - change to cloudy when using LED
//---------------------------------------------------------------------
//TBD


seq_set_prop_d= $"CAMDRIVER0: Property_13"
								$s8 00
                $s8 %0 
                $c8 00
                  $"CAMDRIVER0: Property_13_0_REG8=_%8"
                $cl
                  $"CAMDRIVER0: Property_13_1_REG8=_%8"
                $cx
								;


//****************************************************
//	property 14    Xenon Flash Support             ***
//****************************************************
//  Set to 1 if the camera should expect flash support
//---------------------------------------------------
//TBD
seq_set_prop_e_0= ;     //Off
seq_set_prop_e_1= ;     //Force LED Fill Light Mode
seq_set_prop_e_2= ;     //Automatic LED Fill Light Mode
seq_set_prop_e_3= ;     //Forced Xenon Fill Light Mode
seq_set_prop_e_4= ;     //Automatic Xenon Fill Light Mode

//************************************************
//        Property 15    Optical zoom      ***
//************************************************
//
//
//---------------------------------------------------
seq_set_prop_f_0= ;
seq_set_prop_f_1= ;

//********************************************************************
//  Property 16, 0x10      Scenes                                  ***
//********************************************************************
// Input value:
//  0 => normal        1 => Portrait       2 => Landscape
//  3 => Night         4 => Party          5 => Beach/Snow  
//  6 => Sport
// Gives sensor value:
//  0 => normal        1 => Portrait       2 => Beach/Snow  
//  3 => Party         4 => Night          5 => Sport  
//  6 => Landscape     7 => Documents (Added by SEMC)
//
//  0	=> Normal
//  1	=> Portrait
//  2	=> Landscape
//  3	=> Night scene
//  4	=> Night portrait (Custom scene)
//  5	=> Beach & snow
//  6	=> Sports
//  7	=> Document (Custom scene)
//  8	=> Night mode

//--------------------------------------------------------------------

seq_set_prop_10_0 =        									 // Normal
  									#TO_DRAFT
  									#COM_EVENT(51,00)        // Auto scene
  									#UPDATE_WB
  									#UPDATE_PHOTO
  									#NOT_DOC_MODE            // Must be called before UPDATE_ISO
  									#UPDATE_ISO  
  									;   

seq_set_prop_10_1 =        									 // Portrait
  									#TO_DRAFT
  									#COM_EVENT(51,01)        // Portrait scene
  									#UPDATE_WB
  									#NOT_DOC_MODE
  									;   
	
seq_set_prop_10_2 =        									 // Landscape
  									#TO_DRAFT
  									#COM_EVENT(51,06)        // Landscape scene
  									#UPDATE_WB
  									#NOT_DOC_MODE
  									;

seq_set_prop_10_3 =        									 // Night
  									#TO_DRAFT
  									#COM_EVENT(51,04)        // Night scene   
  									#UPDATE_WB
  									#NOT_DOC_MODE
  									;

seq_set_prop_10_4 =        									 // Night portrait. TBD
  									#TO_DRAFT
  									#COM_EVENT(51,03)        // Party scene   
  									#UPDATE_WB
  									#NOT_DOC_MODE;

seq_set_prop_10_5 =        									 // Beach & snow
  									#TO_DRAFT
  									#COM_EVENT(51,02)        // Beach & snow scene
  									#UPDATE_WB
  									#NOT_DOC_MODE
  									;
	      
seq_set_prop_10_6 =        									 // Sports
  									#TO_DRAFT
  									#COM_EVENT(51,05)        // Sports scene
  									#UPDATE_WB
  									#NOT_DOC_MODE
  									;   
	  
seq_set_prop_10_7 =        									 // Document
  									$"CAMDRIVER0: Documents settings"
  									#TO_DRAFT
  									#COM_EVENT(04,00)        // AE Auto
  									#COM_EVENT(51,07)        // Custom scene   
  									#UPDATE_WB
  									#DOC_MODE
  									;


//************************************************
//		Property 17   ISO,                       ***
//************************************************
//
//  0 => Auto     1 => 100     
//  2 => 200      3 => 400       
//
//
//---------------------------------------------------

seq_set_prop_11_0 =     										 // Auto
  									#TO_DRAFT
  									$sc 00
  									#COM_EVENT(05,00)
										;
		
seq_set_prop_11_1 =     										 // ISO 100
  									#TO_DRAFT
  									$sc 01 
  									#COM_EVENT(05,01)
  									;
		
seq_set_prop_11_2 =     										 // ISO 200
  									#TO_DRAFT
  									$sc 04 
  									#COM_EVENT(05,04)
  									;
		
seq_set_prop_11_3 =     										 // ISO 400
  									#TO_DRAFT
  									$sc 07  
  									#COM_EVENT(05,07)
  									;

//************************************************
//		 Property 18  Low Framerate Mode         ***
//************************************************
//  0 => off   1=> on 
//------------------------------------------------

seq_set_prop_12_0 =        									 // Restore framerate 
  									$z5                      // Put res id in reg 5
  									$c5 29                   // If res id 0x29
    									#SET_REG(08,#VR_10_FR) // DRAFT_FRMRATE 10 fps
  									$cl $cx
  									$c5 2c                   // If res id 0x2c
    									#SET_REG(08,#VR_7_5_FR)// DRAFT_FRMRATE 7.5 fps
  									$cl $cx
  									$c5 25                   // If res id 0x25
    									#SET_REG(08,#VR_12_FR) // DRAFT_FRMRATE 12 fps
  									$cl $cx
  									$c5 26                   // If res id 0x26
    									#SET_REG(08,#VR_12_FR) // DRAFT_FRMRATE 12 fps
  									$cl $cx
  									$c5 2b                   // If res id 0x2b
    									#SET_REG(08,#VR_15_FR) // DRAFT_FRMRATE 15 fps
  									$cl                      // Else
    									#SET_REG(08,#VR_30_FR) // DRAFT_FRMRATE 30 fps
  									$cx

  									#CHANGE_MODE(34,01)
  									;

seq_set_prop_12_1 =        									 // Decrease framerate
  									#SET_REG(08,#VR_7_5_FR)  // DRAFT_MAX_FRMRATE 7,5 fps
  									#CHANGE_MODE(34,01)
  									;


//************************************************
//		 Property 19    Get Face Detection Info  ***
//************************************************
//
//  
//
//---------------------------------------------------
seq_get_prop_13= ;

//************************************************
//		 Property 20  Set Autofocus area         ***
//************************************************
//
// 
//
//---------------------------------------------------

seq_set_prop_14 =          // Set AF window
//  $"CAMDRIVER0: Property_20_start"
  $s8 00
  $s8 %0 $mg 8             // Put H-position in reg g
  $s8 %1 $mh 8             // Put V-position in reg h
  $s8 %2 $mi 8             // Put Witdth and height of AE in reg i
  $s8 %3                   // Put FD ON/OFF 
  $c8 00                   // FD Off?
    #SET_REG(42,00)        // SCAN_AF_AREA_OFFSET_H
    #SET_REG(43,00)        // SCAN_AF_AREA_OFFSET_V
    #COMMAND(02,00)        // AE_MODE = 0x00
  $cl                      // Else FD ON
    $cf.0a 1               // Spot ON?
      #SET_REG(42,00)      // SCAN_AF_AREA_OFFSET_H
      #SET_REG(43,00)      // SCAN_AF_AREA_OFFSET_V
     	#COMMAND(02,00)    	 // AE_MODE = 0x00
    $cl
//      #SET_REG(8D,01)      // Open AE Window, For debug
//      #COM_EVENT(34,01)

      #SET_REG(42,$wg)     // SCAN_AF_AREA_OFFSET_H
      #SET_REG(43,$wh)     // SCAN_AF_AREA_OFFSET_V
      #SET_REG(44,$wi)     // AE_AREA_HALF_SIZE_H
      #SET_REG(45,$wi)     // AE_AREA_HALF_SIZE_V
			#COMMAND(02,01)      // AE_MODE = 0x01 (Start arbitrary frame mode)         
    $cx
  $cx
//  $"CAMDRIVER0: Property_20_stop"
  ;

//************************************************
//		Property 21                              ***
//************************************************
//
//  
//
//---------------------------------------------------

seq_set_prop_15 = ;

//**************************************************
//		 Property 22  Photo metering               ***
//**************************************************
//  0 => Multi Mode            1 => Spot Mode
//--------------------------------------------------

seq_set_prop_16_0 = 
  #TO_DRAFT
  #COM_EVENT(08,00)
  $sf.0A 0             			// Spot flag OFF
  ;   											// Multimode
  
  
seq_set_prop_16_1 = 
  #TO_DRAFT
  #COM_EVENT(08,01)
  $sf.0A 1             			// Spot flag ON
  ;   											// Spot

//**************************************************
//		Property 23 Xenon Flash Required 
//**************************************************
// This property also changes scenes when flash is used.
// Return values: 0 = No flash, 1 = flash 
seq_get_prop_17 =
  								$"CAMDRIVER0: Start ---- Check if flash is needed"  
  								#AUTO_AE_SETTING
  								$s0 00                  // Initialize flash return value to No flash.
  								$sf.06 0               	// Initialize flash flag 
  								#COM_EVENT(72,00)      	// Update the registers
		    					#READ_REG(29,$r2 4 4) 	// Read AE-value (LSB)in camera reg 29
		    					#READ_REG(2a,$r2 5 5)   // Rdad AE-value (MSM)in camera reg 2a
		    					$"CAMDRIVER0:AE_LEVEL_%5_%4_h"
		    					$cg5 23
                  	#COM_EVENT(13,00)     //Turn off cc_offset.	 	    						
                  	#SET_REG(3A,00)				//AE_LED_Offset set to 0.
                  	#SET_REG(3B,00)                  	
                    #COM_EVENT(5A,00)			//Force LED Fill Light Mode                 	
		    						$s0 00								// Return 0, no need flash
                    $sd 00
		    					$cl
		    						$cs4 55
                  		#SET_REG(3A,00)				//AE_LED_Offset set to 04.
                  		#SET_REG(3B,04)		    							
// 											#COM_EVENT(13,01)     //Turn on cc_offset
                  		#SET_REG(3c,2D)				//CC_R_Offset & CC_B_Offset
                  		#SET_REG(3d,54)
                  		#COM_EVENT(5A,01)			//Force LED Fill Light Mode                 		
		    							#COM_EVENT(03,00)	  // Auto operation for AE
											#COMMAND(04,1C)		  // Exposure time 1/10

			    						$s0 01							// Return 1, need flash
		    							$sd 01										// Exposure adjustment, Scense change
		    						$cx
		    					$cx
		    					$s1 00 $s2 00 $s3 00
  								$"CAMDRIVER0: End ----- Check if flash needed:_returned:_%0"
		    					;



//**************************************************
//		Property 24   Image stabilization          ***
//**************************************************
// 0 => off      1=> on
//--------------------------------------------------
seq_set_prop_18_0 =;

seq_set_prop_18_1 =; 

//***************************************************
//		property 25 	Continuous Zoom               ***
//***************************************************
//	0 =>Stop continuous zoom
// 	1 =>Start continuous zoom in	
//  2 =>Start continuous zoom out
//---------------------------------------------------

seq_set_prop_19_0 =      										// Stop
  									$"CAMDRIVER0: Property_19_0"
  									#TO_DRAFT
  									#COM_EVENT(61,44)
  									;
seq_set_prop_19_1 =      										// Zoom in
  									$"CAMDRIVER0: Property_19_1"
  									#TO_DRAFT
  									#SET_REG(32,01)        	// ZM_SMTH_STEP = 1 
  									#COM_EVENT(61,2F)			 	// Fix to 2.13x 
  									;     
seq_set_prop_19_2 =      										// Zoom out
  									$"CAMDRIVER0: Property_19_2"
  									#TO_DRAFT
  									#SET_REG(32,01)         // ZM_SMTH_SPEED = 1 
  									#COM_EVENT(61,3F)
  									;     


//***************************************************
//	 property 26 	Continuous zoom level           ***
//***************************************************

seq_get_prop_1a = 
//  								#TO_DRAFT
//  								#READ_REG(31,$r2 4 4)   // Get zoom level in percent 1-100
//  								$s0 63  $*0 40  $/0 r4  $-0 54
//  								$/0 0F  $s3 00  $s2 00 $s1 00
  								;


//**************************************************
//	property 27 Snapshot operation               ***
//**************************************************
//   0 = Still Capture mode/IS Still Capture mode
//   1 = Burst output. Read out picture 1
//   	.
//	.
//   9 = Burst output. Read out picture 9
//--------------------------------------------------

seq_set_prop_1b =; 


//**************************************************
// 		property 28  BestPic image size            ***
//**************************************************
//
//--------------------------------------------------
seq_set_prop_1c =;		    


//**************************************************
//		property 29   Burst(BestPic Operation)     ***
//**************************************************

//**************************************************
//		Test pattern, property 30	****
//**************************************************
//	0 => Reset	1 => test pattern  2...4 => temp test
//--------------------------------------------------

seq_set_prop_1e_0 = $gr 1				   // Reset
		    $d0014
		    $gr 0
		    $d0140;				            // Delay 320 ms

seq_set_prop_1e_1 = 03 55 AA $f $r2 01 $d0005			// Testpattern
		    08 04 80 0C 04 00 01 00 $f $r2 01 $d0005
		    08 04 82 0C 04 00 05 00 $f $r2 01 $d0005;
		    
seq_set_prop_1e_2 =    // Test face detection ON
  $sg 74               // Put H-position in reg g 137
  $sh 48               // Put V-position in reg h 73
  $si 05               // Put Witdth and height of AE in reg i
  $sj 01               // Put FD ON/OFF in reg j
  $cj 00
    $sf.08 0           // FD OFF
  $cl
    $sf.08 1           // FD ON
  $cx
  $"CAMDRIVER0: H=_%g_V=_%h_AE=_%i_Flag=_%j"
  #SET_REG(42,$wg)           // SCAN_AF_AREA_OFFSET_H
  #SET_REG(43,$wh)           // SCAN_AF_AREA_OFFSET_V
  #SET_REG(44,$wi)           // AE_AREA_HALF_SIZE_H
  #SET_REG(45,$wi)           // AE_AREA_HALF_SIZE_V
  #COM_EVENT(02,01)          // AE_MODE = 0x1 (Start arbitrary frame mode.) 
//  #COM_EVENT(02,00)          // AE_MODE = 0x0 (End arbitrary frame mode.)                 
  ;

seq_set_prop_1e_3 =    // Face detection OFF
  $sf.08 0             // FD OFF
  #COM_EVENT(02,00)    // AE_MODE = auto
  ;		    


//***************************************************
//		Property 31, only for tests
//***************************************************

seq_set_prop_1f_0 = 
  								$"CAMDRIVER0: Start ---- Check if flash is needed"  
  								$s0 00                  // Initialize flash return value to No flash.
  								$sf.06 0               	// Initialize flash flag 
  								#COM_EVENT(72,00)      	// Update the registers
		    					#READ_REG(29,$r2 4 4) 	// Read AE-value (LSB)in camera reg 29
		    					#READ_REG(2a,$r2 5 5)   // Rdad AE-value (MSM)in camera reg 2a
		    					$"CAMDRIVER0:AE_LEVEL_%5_%4_h"
		    					$cg5 23
		    						$s0 00								// Return 0, no need flash
		    					$cl
		    						$cs4 55
		    							$s0 01							// Return 1, need flash
		    																	// Exposure adjustment, Scense change
		    						$cx
		    					$cx
		    					$s1 00 $s2 00 $s3 00
  								$"CAMDRIVER0: End ----- Check if flash needed:_returned:_%0"
		    					;

seq_set_prop_1f_1 = 
									$go 10 1								// AppGPIO_08 = GPIO_10
									$d1000
									$go 10 0
									;
		
//***************************************
//		Spot, property 32     ***
//***************************************  
seq_set_prop_20=; //TBD


//================================================
//=============== SIZE CONFIGS ===================
//================================================

LOCK_30_FPS= #SET_REG(08,#VR_30_FR);      							// Draft mode frame rate max x fps
																				               	// Transition to draft mode at half rate => x/2 fps
           
LOCK_15_FPS= #SET_REG(08,#VR_15_FR);      							// Draft mode frame rate max x fps
																				              	// Transition to draft mode at half rate => x/2 fps
                
LOCK_12_FPS= #SET_REG(08,#VR_12_FR);      							// Draft mode frame rate max x fps
																			                	// Transition to draft mode at half rate => x/2 fps
                
LOCK_10_FPS= #SET_REG(08,#VR_10_FR);      							// Draft mode frame rate max x fps
																			                	// Transition to draft mode at half rate => x/2 fps
                
LOCK_7_5_FPS= #SET_REG(08,#VR_7_5_FR);      						// Draft mode frame rate max x fps
																				               	// Transition to draft mode at half rate => x/2 fps                                                
            
RELEASE_LOCK_FPS=
                 $"CAMDRIVER0_Lock_release"
                 $u07;                								// Set draft mode frame rate and do
                                      								// transition to draft mode according to property 7

VF_TRANSITION_DELAY=$d00c8;


//=========================================================
//  Normal quality settings:
//                 MIN     MAX       TARGET      COMPRESSION for initial, average and last quality
//  
//  640 x 480:      10     150         55        		75  
// 1280 x 960:      60     400        200       		75  
// 1632 x1224:     150     600        400       		75
// 2048 x 1536     400 		 800				600						75	
//
//=========================================================
//---------------------------------------------------
//=========================================================
//  Fine quality settings:
//                 MIN     MAX       TARGET      COMPRESSION for initial, average and last quality
//  
//  640 x 480:      10     150         80        		90  
// 1280 x 960:     150     400        300       		90  
// 1632 x1224:     400     600        500       		90
// 2048 x 1536     600 		 900				800						90	
//
//=========================================================

seq_ss_config_1 =
  $sf.03 1             // JPEG flag to 1
  #SET_REG(1A,09)      // 640 x 480 JPEG and JPEG IMST
  $cf.05 1             // If normal compression
    $"CAMDRIVER0: VGA NORMAL COMPRESSION"
    0D 02 00 0E        // Start sending 13 bytes at adress 0E
    96 00	             // JPEG_MAX_CODE_SIZE    = 150d  	
   	0A 00	             // JPEG_MIN_CODE_SIZE    =  10d
    37 00              // JPEG_TARGET_CODE_SIZE =  55d
    46                 // JPEG_INIT_QUALITY     =  70d
    3C                 // JPEG_FIRST_QUALITY    =  60d
    32                 // JPEG_LAST_QUALITY     =  50d
    $f $ra 1111111111 $d0002
  $cl                  // Else low compression
    $"CAMDRIVER0: VGA LOW COMPRESSION"
    0D 02 00 0E        // Start sending 13 bytes at adress 0E
    96 00	             // JPEG_MAX_CODE_SIZE    = 150d  	
   	32 00	             // JPEG_MIN_CODE_SIZE    =  50d
    50 00              // JPEG_TARGET_CODE_SIZE =  80d
    50                 // JPEG_INIT_QUALITY     =  80d
    46                 // JPEG_FIRST_QUALITY    =  70d
    3C                 // JPEG_LAST_QUALITY     =  60d    
    $f $ra 1111111111 $d0002
  $cx
  ;

seq_ss_config_2 =
  $sf.03 1             // JPEG flag to 1
  #SET_REG(1A,06)      // 1280 x 960 JPEG and JPEG IMST
  $cf.05 1             // If normal compression
    $"CAMDRIVER0: 1M NORMAL COMPRESSION"
    0D 02 00 0E        // Start sending 13 bytes at adress 0E
    90 01	             // JPEG_MAX_CODE_SIZE    = 400d  	
   	3C 00	             // JPEG_MIN_CODE_SIZE    =  60d
    C8 00              // JPEG_TARGET_CODE_SIZE = 200d
    46                 // JPEG_INIT_QUALITY     =  70d
    3C                 // JPEG_FIRST_QUALITY    =  60d
    32                 // JPEG_LAST_QUALITY     =  50d
    $f $ra 1111111111 $d0002
  $cl                  // Else low compression
    $"CAMDRIVER0: 1M LOW COMPRESSION"
    0D 02 00 0E        // Start sending 13 bytes at adress 0E
    90 01	             // JPEG_MAX_CODE_SIZE    = 400d  	
   	64 00	             // JPEG_MIN_CODE_SIZE    = 100d
    2C 01              // JPEG_TARGET_CODE_SIZE = 300d
    50                 // JPEG_INIT_QUALITY     =  80d
    46                 // JPEG_FIRST_QUALITY    =  70d
    3C                 // JPEG_LAST_QUALITY     =  60d    
    $f $ra 1111111111 $d0002 
  $cx
  ;

seq_ss_config_4 =
  $sf.03 1             // JPEG flag to 1
  #SET_REG(1A,04)      // 1632 x 1224 JPEG and JPEG IMST 
  $cf.05 1             // If normal compression
    $"CAMDRIVER0: 2M NORMAL COMPRESSION"
    0D 02 00 0E        // Start sending 13 bytes at adress 0E
    58 02	             // JPEG_MAX_CODE_SIZE    = 600d  	
   	96 00	             // JPEG_MIN_CODE_SIZE    = 150d
    90 01              // JPEG_TARGET_CODE_SIZE = 400d
    46                 // JPEG_INIT_QUALITY     =  70d
    3C                 // JPEG_FIRST_QUALITY    =  60d
    32                 // JPEG_LAST_QUALITY     =  50d
    $f $ra 1111111111 $d0002
  $cl                  // Else low compression
    $"CAMDRIVER0: 2M LOW COMPRESSION"
    0D 02 00 0E        // Start sending 13 bytes at adress 0E
    58 02	             // JPEG_MAX_CODE_SIZE    = 600d  	
   	90 01	             // JPEG_MIN_CODE_SIZE    = 400d
    F4 01              // JPEG_TARGET_CODE_SIZE = 500d
    50                 // JPEG_INIT_QUALITY     =  80d
    46                 // JPEG_FIRST_QUALITY    =  70d
    3C                 // JPEG_LAST_QUALITY     =  60d    
    $f $ra 1111111111 $d0002
  $cx
  ;

seq_ss_config_5 =
  $sf.03 1             // JPEG output
  #SET_REG(1A,00)      // 2048 x 1536 JPEG and JPEG IMST 
  $cf.05 1             // If normal compression
    $"CAMDRIVER0: 3M NORMAL COMPRESSION"
    0D 02 00 0E        // Start sending 13 bytes at adress 0E
    20 03	             // JPEG_MAX_CODE_SIZE    = 800d  	
   	90 01	             // JPEG_MIN_CODE_SIZE    = 400d
    58 02              // JPEG_TARGET_CODE_SIZE = 600d
    46                 // JPEG_INIT_QUALITY     =  70d
    3C                 // JPEG_FIRST_QUALITY    =  60d
    32                 // JPEG_LAST_QUALITY     =  50d
    $f $ra 1111111111 $d0002
  $cl                  // Else low compression
    $"CAMDRIVER0: 3M LOW COMPRESSION"
    0D 02 00 0E        // Start sending 13 bytes at adress 0E
    84 03	             // JPEG_MAX_CODE_SIZE    = 900d  	
   	58 02	             // JPEG_MIN_CODE_SIZE    = 600d
    52 03              // JPEG_TARGET_CODE_SIZE = 850d
    50                 // JPEG_INIT_QUALITY     =  80d
    46                 // JPEG_FIRST_QUALITY    =  70d
    3C                 // JPEG_LAST_QUALITY     =  60d    
    $f $ra 1111111111 $d0002
  $cx
  ;


seq_ss_config_10 =
  $sf.03 0             // YCbCr output
  #SET_REG(09,08)      // 320 x 240 YCbCr and YCbCr IMST 
  ;

seq_ss_config_11 =
  $sf.03 0             // YCbCr output
  #SET_REG(09,04)      // 640 x 480 YCbCr and YCbCr IMST 
  ;  



seq_vf_config_20=
									$"CAMDRIVER0 vf20" 
									#VF_TRANSITION_DELAY 
									#SET_REG(07,05) 
									#LOCK_30_FPS
									#COM_EVENT(03,00)		    // Auto operation for AE
									#COMMAND(04,00)
									#COMMAND(05,00)
									;
seq_vf_config_25=
									$"CAMDRIVER0 vf25" 
									#VF_TRANSITION_DELAY 
									#SET_REG(07,0E) 
									#LOCK_12_FPS
									#COM_EVENT(03,00)		    // Auto operation for AE
									#COMMAND(04,00)
									#COMMAND(05,00)
									$cf.02 0             	 // If not in any draft mode 
    								$sf.02 1             // Set draft flag to 1
  								$cl
    								#CHANGE_MODE(34,01)  // normal draft
  								$cx	
									;
seq_vf_config_26=
									$"CAMDRIVER0 vf26" 
									#VF_TRANSITION_DELAY 
									#SET_REG(07,0C) 
									#LOCK_12_FPS
									#COM_EVENT(03,00)		   // Auto operation for AE									
									#COMMAND(04,00)
									#COMMAND(05,00)									
									$cf.02 0             	 // If not in any draft mode 
    								$sf.02 1             // Set draft flag to 1
  								$cl
    								#CHANGE_MODE(34,01)  // normal draft
  								$cx	
									;
seq_vf_config_29=
									$"CAMDRIVER0 vf29" 
									#VF_TRANSITION_DELAY 
									#SET_REG(07,0C) 
									#LOCK_10_FPS
									#COM_EVENT(03,00)		  // Auto operation for AE
									#COMMAND(04,00)
									#COMMAND(05,00)
									$cf.02 0             	 // If not in any draft mode 
    								$sf.02 1             // Set draft flag to 1
  								$cl
    								#CHANGE_MODE(34,01)  // normal draft
  								$cx										
									;
seq_vf_config_2a=
									$"CAMDRIVER0 vf2a" 
									#VF_TRANSITION_DELAY 
									#SET_REG(07,05) 
									#COMMAND(04,00)
									#COMMAND(05,00)
								  #SET_REG(08,3C)                   // 30fps => Normal mode
								  #COM_EVENT(03,3C)		  // 30 fps, AE_SLOW_SHUTTER
//									#COMMAND(04,17)
									;
seq_vf_config_2b=
									$"CAMDRIVER0 vf2b" 
									#VF_TRANSITION_DELAY 
									#SET_REG(07,05) 
									#LOCK_15_FPS          // 15fps,
									#COM_EVENT(03,00)		  // Auto operation for AE
									#COMMAND(04,00)
									#COMMAND(05,00)									
									;
seq_vf_config_2c=
									$"CAMDRIVER0 vf2c" 
									#VF_TRANSITION_DELAY 
									#SET_REG(07,05) 
									#SET_REG(08,0F)        // 7.5fps, Dark mode
//                  #COM_EVENT(03,0F) 	   // 7.5fps, AE_SLOW_SHUTTER
									#COM_EVENT(03,0F)		  // AE, 7.5fps 
// 									#COMMAND(04,00)        // Fix for about 8fps
//									#COMMAND(05,00)
									;
seq_vf_config_2f=
									$"CAMDRIVER0 vf2f" 
									#VF_TRANSITION_DELAY 
									#SET_REG(07,05) 
									#LOCK_30_FPS
									#COM_EVENT(03,00)		  // Auto operation for AE
									#COMMAND(04,00)
									#COMMAND(05,00)
									;

seq_ss_config_30=$"CAMDRIVER0_ss_conf" 05 02 00 07 06 $f 06 02 00 01 01 34 $f $d0200
03 55 AA $f
08 04 12 80 00 05 AA 55 $se 30 $d0100;


 
//===============================================
// Rotation of viewfinder and video images
//===============================================

//================================================
//============ STATE TRANSITIONS =================
//================================================
seq_vf_start=$"CAMDRIVER0_draft" 		
             $c7 01
             $cl
             		$cf.02	0                    	 // If not in any draft mode 
    								#CHANGE_MODE(34,01)        // Draft mode
    								#COM_EVENT(43,00)          // MANUAL_FOCUS = 00, Infinity    
        						$sf.02 1                   // Set draft flag to 1
    								$se 00                     // Set snapshot operation to normal
  					 		$cl
    								#CHANGE_MODE(34,01)
             		$cx
             		$s6 00
    			   		$"CAMDRIVER0_DRAFT_INIT_REG06_%6"								
             $cx
             $s7 00
             ;

seq_vf_stop = ; 
 
seq_ss_start =  
		$"CAMDRIVER0_SS_Start"
		$cf.02 1                       // If draft mode?
      #COMMAND(31,03)          		 // Half-release with focus set to inf
    	$sf.02 0                     // Not in draft mode
  	$cl                            // Do nothing.							                     
  	$cx 
  	
    $z1 
    $c1 01
    	$s6 01											//  Burst mode
    $cl
    	$s6 00											//  Normal mode
    $cx

  	$c6 01
				$"CAMDRIVER0_SS_BURST"
				$cf.03 1                   		// IF JPEG 
		  		$cd 01
  					$d0032
  				$cl
  				$cx
		  		#CHANGE_MODE_A(32,01)				// JPEG
		  		#CAPTURE_EVENT		    			// Capture EV_CAPTURE_STATUS, 02 E4
    		$cl                           // Else IMST OFF       
		  		#CHANGE_MODE(33,01) 				// YCbCr
    		$cx
    $cl
    		$"CAMDRIVER0_SS_NO_BURST"
    		$cf.03 1                   		// IF JPEG 
		  		#CHANGE_MODE(32,01)					// JPEG
	    		#CAPTURE_EVENT		    			// Capture EV_CAPTURE_STATUS, 02 E4
    		$cl                           // Else IMST OFF       
		  		#CHANGE_MODE(33,01) 				// YCbCr
    		$cx
//    		$s6 01
    $cx  
  	$"CAMDRIVER0_SS_Start_06_07_0F_%6_%7_%f"
  	;
    

// Take only waits for status = 0
seq_ss_take = 
			$"CAMDRIVER0_SS_TAKE"
	    ;  
               
// Verify should be modified to something that actually verifies
// the image.

seq_ss_verify = $"CAMDRIVER0_ss_verify"
                #CAPTURE_EVENT   // Capture EV_CAPTURE_STATUS, 01 E4
  							;

seq_ss_stop  = 
						$"CAMDRIVER0: SEQ_SS_STOP!"
            $c6 00
  						$"CAMDRIVER0: SEQ_SS_STOP!_NoBurst"
  						$cf.03 1
    						$ce 00
      						#CHANGE_MODE(34,01)
      						#COM_EVENT(43,00)          // MANUAL_FOCUS = 00, Infinity    
      						$s7 00
    						$cx
  						$cx
						$cl
							$"CAMDRIVER0: SEQ_SS_STOP!_Burst"
						$cx
						;

// Functions for synchronized viewfinder images in burst mode. 

seq_pv_start = ;
 	
seq_pv_stop = ;

seq_pv_verify = ; 


//================================================
//============ JPEG HEADER CREATION ==============
//================================================
// 
// Same header as in clara with the difference that 
// restart is added.
//
jpeg_qtable_selector_0=$s2 00 #READ_REG(1C, $r2 0 0); //Change from MCB750 0x1B
jpeg_qtable_selector_1=$s2 01 #READ_REG(1C, $r2 0 0); 

jpeg_qtable_0=10 0B 0C 0E 0C 0A 10 0E 
              0D 0E 12 11 10 13 18 28 
              1A 18 16 16 18 31 23 25 
              1D 28 3A 33 3D 3C 39 33 
              38 37 40 48 5C 4E 40 44 
              57 45 37 38 50 6D 51 57 
              5F 62 67 68 67 3E 4D 71
              79 70 64 78 5C 65 67 63;

jpeg_qtable_1=11 12 12 18 15 18 2F 1A 
              1A 2F 63 42 38 42 63 63 
              63 63 63 63 63 63 63 63 
              63 63 63 63 63 63 63 63 
              63 63 63 63 63 63 63 63 
              63 63 63 63 63 63 63 63 
              63 63 63 63 63 63 63 63 
              63 63 63 63 63 63 63 63; 
            
            
jpeg_qtable_factors=0,320100,190000,10AB00,C8000,A0000,85500,72500,64000,58E00,50000
,48C00,42B00,3D900,39200,35500,32000,2F100,2C700,2A200,28000
,26200,24600,22D00,21500,20000,1EC00,1DA00,1C900,1B900,1AB00
,19D00,19000,18400,17800,16E00,16400,15A00,15100,14800,14000
,13800,13100,12A00,12300,11C00,11600,11000,10B00,10500,10000
,FB00,F600,F100,EC00,E600,E100,DC00,D700,D200,CD00
,C800,C300,BD00,B800,B300,AE00,A900,A400,9F00,9A00
,9400,8F00,8A00,8500,8000,7B00,7600,7100,6C00,6600
,6100,5C00,5700,5200,4D00,4800,4300,3D00,3800,3300
,2E00,2900,2400,1F00,1A00,1400,F00,A00,500,100;

jpeg_header= FF D8
             FF E0 00 10 4A 46 49 46 00 01 01 00 00 01 00 01 00 00
             FF DB 00 84 00 $qt0  01 $qt1                             
             FF C4 01 A2 00 00 01 05 01 01 01 01 01 01 00 00 00 00 00 00 00 
                            00 01 02 03 04 05 06 07 08 09 0A 0B
                         01 00 03 01 01 01 01 01 01 01 01 01 00 00 00 00 00 
                            00 01 02 03 04 05 06 07 08 09 0A 0B
                         10 00 02 01 03 03 02 04 03 05 05 04 04 00 00 01 7D
                            01 02 03 00 04 11 05 12 21 31 41 06 13 51 61 07 
                            22 71 14 32 81 91 a1 08 23 42 b1 c1 15 52 d1 f0 
                            24 33 62 72 82 09 0a 16 17 18 19 1a 25 26 27 28 
                            29 2a 34 35 36 37 38 39 3a 43 44 45 46 47 48 49 
                            4a 53 54 55 56 57 58 59 5a 63 64 65 66 67 68 69 
                            6a 73 74 75 76 77 78 79 7a 83 84 85 86 87 88 89 
                            8a 92 93 94 95 96 97 98 99 9a a2 a3 a4 a5 a6 a7 
                            a8 a9 aa b2 b3 b4 b5 b6 b7 b8 b9 ba c2 c3 c4 c5 
                            c6 c7 c8 c9 ca d2 d3 d4 d5 d6 d7 d8 d9 da e1 e2
                            e3 e4 e5 e6 e7 e8 e9 ea f1 f2 f3 f4 f5 f6 f7 f8 
                            f9 fa
                         11 00 02 01 02 04 04 03 04 07 05 04 04 00 01 02 77
                            00 01 02 03 11 04 05 21 31 06 12 41 51 07 61 71 
                            13 22 32 81 08 14 42 91 a1 b1 c1 09 23 33 52 f0 
                            15 62 72 d1 0a 16 24 34 e1 25 f1 17 18 19 1a 26 
                            27 28 29 2a 35 36 37 38 39 3a 43 44 45 46 47 48 
                            49 4a 53 54 55 56 57 58 59 5a 63 64 65 66 67 68 
                            69 6a 73 74 75 76 77 78 79 7a 82 83 84 85 86 87 
                            88 89 8a 92 93 94 95 96 97 98 99 9a a2 a3 a4 a5 
                            a6 a7 a8 a9 aa b2 b3 b4 b5 b6 b7 b8 b9 ba c2 c3 
                            c4 c5 c6 c7 c8 c9 ca d2 d3 d4 d5 d6 d7 d8 d9 da
                            e2 e3 e4 e5 e6 e7 e8 e9 ea f2 f3 f4 f5 f6 f7 f8 
                            f9 fa             
             FF DD 00 04 00 00 
             FF C0 00 11 08 $h $w 03 01 21 00 02 11 01 03 11 01
             FF DA 00 0C 03 01 00 02 11 03 11 00 3F 00;
