K850 Profesinal Camera v8.5

Features:
  • New night mode without noise
  • New auto mode
  • New sports mode
  • New document mode
  • New ISO values
  • Variable maximum buffer 2.5 MB
  • 2 new modes: high colors and normal

Date: 05.01.2009.
Author: Elitek550
Nationality: Brazilian
download
//K850 Profesinal Camera 8.5

SHOT_SPEED=         1D;       
SHOT_NIGHT=         24;       

EXPOSURE=$-5         09;               

CONTRAST=             00;         
SARPNESS=               01;        
SATURATION=        05;        

info_name=MCB991;
info_vendor=TopSony;
info_major_ver=8;
info_minor_ver=5;

cam_power_on_0 = 5, 2, 31, 0, 05;   
cam_power_on_1 = 5, 2, 20, 1, 05;   
cam_power_on_2 = 5, 2, 33, 1, 00;  
cam_power_on_3 = 5, 2, 30, 1, 05;   
cam_power_on_4 = 5, 3,  9, 6590,05; 
cam_power_on_5 = 5, 2, 31, 1, 05;   

cam_power_off_0 = 5, 2, 31, 0, 05;  
cam_power_off_1 = 5, 3,  9, 0, 05; 
cam_power_off_2 = 5, 2, 30, 0, 20;  
cam_power_off_3 = 5, 2, 33, 0, 05;  
cam_power_off_4 = 5, 2, 20, 0, 05;  

cam_i2c_address = 1F;
cam_i2c_clock   =;                    
cam_vf_clock_freq = 9, 6590;  
cam_ss_clock_freq = 9, 6590;  

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_post_processing_20 = 1;   
cam_post_processing_25 = 1;   
cam_post_processing_26 = 1;   
cam_post_processing_29 = 1;   

cam_ss_jpeg_buf_size_1 = 25800; 
cam_ss_jpeg_buf_size_2 = 64000; 
cam_ss_jpeg_buf_size_4 = 96000; 
cam_ss_jpeg_buf_size_5 = 177000;
cam_ss_jpeg_buf_size_6 = 270000;             

sup_sizes = 
  1[280,1E0,0],         //  SS 640  x 480  JPEG   
  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
  6[A20,798,0],   // SS 2592 x 1944 JPEG 5M

  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
  21[140,F0,5DC],       //  VF  320 x 240  YCbCr 15 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

sup_properties = 
  0[3,f,9],     // Exposure 
  1[0,4,0],     // White balance  
  2[0,3,0],     // Flicker  
  3[0,1,0],     // Vertical mirroring  
  4[0,1,0],     // Horisontal mirroring
  5[0,1,0],     // JPEG compression
  6[A,A0,A],    // Step zoom 
  7[0,1,0],     // Night mode, HS ON/OFF
  8[0,4,0],     // Effects  
  9[0,1,0],     // Focus mode
  A[0,2,0],     // Focus operation
  B[0,0,0],     // EXIF info 1
  C[0,0,0],     // EXIF info 2
//D[0,0,0],     // 
  E[0,4,0],     // Xenon flash support
//F[0,0,0],     //
  10[0,7,0],    // Scenes    
  11[0,4,0],    // ISO
  12[0,1,0],    // Framerate adjustments for GUI speed
//13[0,0,0],    //
//14[0,0,0],    //
//15[0,0,0],    //
  16[0,1,0],    // Photo metering
  17[0,0,0],    // Xenon flash required
  18[0,1,0],    // Image stabilization
  19[0,2,0],    // Continuous zoom
  1A[0,0,0],    // Get zoom level in percentage
  1B[0,9,0],    // Snapshot operation
  1C[0,3,0],    // BestPic picture size
  1D[0,4,0],    // BestPic Operation
  1E[0,1,0];     // Reset and Test pattern 

SET= 05 02 00 !0 !1 $f  $r2 1 1 $d0002;         // Sets register to value 
                                                                         // Syntax: SET(REG,VAL)
 
READ= 05 01 00 !0 01 $f $r2 4 4 $d0002;        // Read from camera and put result in platf. reg 4
                                                                               // Syntax: READ(REG)  // Result saved in reg 4.
                                                               
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(06,03);     // Clears the event     

CLEAR_EVENT_FIFO =    // Clears the 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 ];
 
COMMAND=06 02 00 01 !1 !0 $f $r3 111 $d0002;            // Only send command, no reply is read out
                                                                                                 // Syntax: COMMAND(REG,VALUE)
  
WAIT_FOR_TRIG =       // Listen to TRIG
  $h 0 02 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;
                      // Reads and clears events until the specified event occurs. 
POLL_EVENT_ID =       // Syntax: POLL_EVENT_ID($s4 Event Identification)        
  !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     

CAPTURE_EVENT =#WAIT_FOR_TRIG #CLEAR_EVENT;

CHANGE_MODE =#CLEAR_EVENT_FIFO   // Syntax: CHANGE_MODE(command, value)  // Clear the fifo
                                    #COMMAND(!0,!1)                    // Send command                                                           
                                    #POLL_EVENT_ID($s4 ea)        // Wait for EV_mode_changed (0xea)
                                    #SET(06,03);  
 
CMD= #CLEAR_EVENT_FIFO          // Syntax: CMD(command, value)
             #COMMAND(!0,!1)
             #WAIT_FOR_TRIG  
             #CLEAR_EVENT;

UPDATE_WB =           // Updates white balance if necessary
  $p5 01
  $c5 00  // WB is auto?
  $cl 
    $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;

WB_ISO100 =           // Correct WB for ISO100 xenon  
  #SET(98,25)    // FLASH_CC_R = 0x25 (colour temperature of 7000 K for flash)
  #SET(99,73);    // FLASH_CC_B = 0x73 (colour temperature of 7000 K for flash)

WB_ISO200 =           // Correct WB for ISO200 xenon
  #SET(98,27)    // FLASH_CC_R = 0x27 (colour temperature of 6000 K for flash)
  #SET(99,6D);    // FLASH_CC_B = 0x6D (colour temperature of 6000 K for flash)
  
WB_ISO400 =           // Correct WB for ISO400 xenon
  #SET(98,28)    // FLASH_CC_R = 0x28 (colour temperature of 5700 K for flash)
  #SET(99,6A);    // FLASH_CC_B = 0x6A (colour temperature of 5700 K for flash)

FLASH_LIMIT_ISO100 =  
  #SET(A2,C8) #SET(A3,25)
  #SET(A4,D0) #SET(A5,25);

FLASH_LIMIT_ISO200 = 
  #SET(A2,C7) #SET(A3,21) 
  #SET(A4,D0) #SET(A5,21);

FLASH_LIMIT_ISO400 =  
  #SET(A2,C6) #SET(A3,1D) 
  #SET(A4,D0) #SET(A5,1D);

// ISO MACROS
ISO_A  =   #COM_EVENT(05,00);
ISO100 =   #COM_EVENT(05,01);
ISO125 =   #COM_EVENT(05,02);
ISO160 =   #COM_EVENT(05,03); 
ISO200 =   #COM_EVENT(05,04);
ISO3000 =  #COM_EVENT(05,0g);
ISO320 =   #COM_EVENT(05,06) #ISO_A #COM_EVENT(05,06) #COM_EVENT(56,FF) #COM_EVENT(55,FF);
ISO400 =   #COM_EVENT(05,07) #ISO_A #COM_EVENT(05,07) #COM_EVENT(56,FE) #COM_EVENT(55,FF);


// Night Mode
STATIC_MODE =       #COM_EVENT(03,07) 
                                #COM_EVENT(55,01) 
                                #COM_EVENT(06,00) 
                                #COM_EVENT(05,05)
                                #COM_EVENT(56,00);       




TWLGT_LNDSCP =  #COM_EVENT(51,04) 
                #COM_EVENT(43,04) 
                #COM_EVENT(03,04)                                 
                #COM_EVENT(56,FD) 
                #COM_EVENT(55,FF) 
                #COM_EVENT(58,FE)                                        
                #UPDATE_FLICK
                #UPDATE_WB;

// Advanced-Camera™ Mode
A_ADVANCE_ENABLE =   #COM_EVENT(55,16)
                   #COM_EVENT(56,08) 
                   #COM_EVENT(03,14); 

DAY_MODE      = #COM_EVENT(55,00) 
                #COM_EVENT(56,FF) 
                #COM_EVENT(06,00) 
                #COM_EVENT(04,00)       
  #SET_REG(40,05)  
      #SET_REG(43,2A)  
  #SET_REG(44,70); 

NORM_MODE     = #COM_EVENT(55,01) 
                #COM_EVENT(56,06) 
                #COM_EVENT(06,00) 
                #COM_EVENT(04,00)       
  #SET_REG(40,06)  
      #SET_REG(43,32)  
  #SET_REG(44,82); 



A_MACRO_ENABLE =  #COM_EVENT(55,01) 
                  #COM_EVENT(06,00) 
                  #COM_EVENT(05,01) 
                  #COM_EVENT(56,08) 
                  #COM_EVENT(03,14);          
                                        

       


SPORT_MODE    = #COM_EVENT(55,01) 
                #COM_EVENT(56,05) 
                #COM_EVENT(06,00) 
                #COM_EVENT(04,00)       
  #SET_REG(44,82)  
                #SET_REG(40,07); 


TEXT_MODE     =  #COM_EVENT(03,14)  
                 #COM_EVENT(56,06) 
                 #COM_EVENT(55,03)  
                 #COM_EVENT(06,01)  
   #SET_REG(40,01); 


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

//UPDATE_COLOR=
  $p5 08              // Put effect property value in reg 5
  $c5 00 
  #CMD(58,07)
  $cl
  #CMD(58,00) 
  $cx;  

DOC_MODE =            // Updates special doc scene settings 
  #CMD(55,02)   // Increase contrast to 2
  #CMD(56,08)   // Increase sharpness to max (8)
  #CMD(06,02)   // Increase exposure to 2
  #SET(95,01)     // Set flash ISO to 100 
  #WB_ISO100
  #FLASH_LIMIT_ISO100;

 NOT_DOC_MODE = // Reverses special doc scene settings 
  #CMD(06,00)   // Reset exposure
  #CMD(55,00)           // Reset contrast
  #CMD(56,02)   // Reset sharpness
  #SET(95,04)               // Set flash ISO to default 200 
  #WB_ISO200
  #FLASH_LIMIT_ISO200;

UPDATE_MIN_FRMRATE =  // Updates minimum framerate
  $p5 10
  $c5 03 
    #SET(22,04)             // DRAFT_MIN_FRMRATE 2 fps
  $cl
    #SET(22,0A)            // DRAFT_MIN_FRMRATE 5 fps
  $cx;

FLASH_SETTINGS =
  #SET(92,00)            // FLASH_MSHUT_MODE = 0
  #SET(A0,02)          // FLASH_REDEYE_NUM = 2
  #SET(A1,07)          // FLASH_REDEYE_TWAIT = 7
  #SET(96,00)           // FLASH_EXPOSING_OFFSET = 0x0400
  #SET(97,04)           // Low byte of FLASH_EXPOSING_OFFSET
  #SET(9A,F0)     // CC_FLASH_OFFSET_MAX_RATIO
  #SET(9B,A0)     // CC_FLASH_OFFSET_MIN_RATIO
  #SET(9C,0D)     // CC_FLASH_OFFSET_DARK
  #SET(9D,2B);     // CC_FLASH_OFFSET_BRIGHT 

TO_DRAFT =                            // Changes to draft (but not on display)
  $cf.02 0                                      // If not draft       
   #CHANGE_MODE(33,00)        // MODE_MAIN
    $sf.02 1                                     // Set draft flag to 1
  $cl
  $cx;

seq_init =                // This sequence is run after power_on
  $sf 00                      // Set all flags to zero
  $sf.05 1                    //NORMAL JPEG compression
  $sf.02 1                    // Set draft flag to YES   
  $s8 00                      // Video HS OFF
  $sa 09                      // EV = 0
  $sc 00                      // Set iso to auto
  $se 00                      // Normal snapshot operation
  $sd 00                       // Flash mode "auto"
  $s6 e9 $s7 00 
  #CAPTURE_EVENT              // EV_CAM_READY 
  #CAPTURE_EVENT              // EV_MUTE_OFF
  #SET(29,01)                                // STILL_OUT_REPEAT = 1  
  #SET(3B,02)            
  #SET(3A,BC)                      // JPEG_RETRY_LIMIT = 700d = 0x02BC 
  #SET(6B,06)                          // SCANAF_MODE_1
  #SET(6C,01)                         // SCANAF_AF_ILLUMI
  #SET(6F,3C)                            // SCANAF_MAX_FRMRATE = 30 fps
  #SET(70,1E)                             // SCANAF_MIN_FRMRATE = 15 fps
  #SET(64,#SHOT_SPEED)     // SCENE_SLOW_SHUTTER = 29, 1/8
  #SET(22,0A)                             // DRAFT_MIN_FRMRATE 5 fps
  #SET(95,04)                             // Default ISO 200
  #WB_ISO200                           // Correct xenon WB
  #FLASH_LIMIT_ISO200   
  #CMD(5A,01)                         // FLASH_INFO = 1
  #CMD(55,#CONTRAST)               //  Adjust Contrast        
  #CMD(56,#SARPNESS)              // Adjust Sharpness
  #CMD(58,#SATURATION);         // Adjust Saturation                       

seq_ping = ;

// Property 0, Exposure

seq_set_prop_0 =#TO_DRAFT $s5 %0 #EXPOSURE #CMD(06,$w5);    

seq_get_prop_0 =$s3 00 $s2 00 $s1 00 $m0 a;

// Property 1, White balance

seq_set_prop_1_0 =#TO_DRAFT $m0 f $>0 7 $b0 00 1 7 #CMD(11,00);     // Auto 
seq_set_prop_1_1 =#TO_DRAFT #CMD(11,03);         
seq_set_prop_1_2 =#COM_EVENT(58,13);       
seq_set_prop_1_3 =#COM_EVENT(11,06);       
seq_set_prop_1_4 =#TO_DRAFT #CMD(11,06);     

// Property 2, Flicker mode

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

// Property 3, Vertical mirroring

seq_set_prop_3_0 = #CMD(52,00);   // Off 
seq_set_prop_3_1 = #CMD(52,0A);   // On

// Property 4, Horizontal mirroring

seq_set_prop_4_0 = #CMD(52,00);   // Off
seq_set_prop_4_1 = #CMD(52,05);   // On

// Property 5, JPEG compression

seq_set_prop_5_0 = #SET_REG(19,5F) // JPEG_INIT_QUALITY = 0x5F = 95d
     #SET_REG(13,84) #SET_REG(14,03)
                #SET_REG(17,20) #SET_REG(18,03) 
     #SET_REG(15,58) #SET_REG(16,02);

seq_set_prop_5_1 = #SET_REG(19,64) // JPEG_INIT_QUALITY = 0x64 = 100d
     #SET_REG(13,64) #SET_REG(14,03)
                #SET_REG(17,64) #SET_REG(18,03) 
     #SET_REG(15,64) #SET_REG(16,03);

seq_set_prop_5_2 = $"VGA_High_comp"
     #SET_REG(19,5F) // JPEG_INIT_QUALITY = 0x5F = 95d       
     #SET_REG(13,96) #SET_REG(14,00)
     #SET_REG(17,50) #SET_REG(18,00)
     #SET_REG(15,0a) #SET_REG(16,00);
     
seq_set_prop_5_3 = $"VGA_low_comp"
     #SET_REG(19,64) // JPEG_INIT_QUALITY = 0x64 = 100d
     #SET_REG(13,64) #SET_REG(14,03)
     #SET_REG(17,64) #SET_REG(18,03) 
     #SET_REG(15,64) #SET_REG(16,03);  

seq_set_prop_5_4 = $"1M_High_comp"
     #SET_REG(19,5F) // JPEG_INIT_QUALITY = 0x5F = 95d 
     #SET_REG(13,90) #SET_REG(14,01) 
     #SET_REG(17,2C) #SET_REG(18,01) 
     #SET_REG(15,96) #SET_REG(16,00); 
 
seq_set_prop_5_5 = $"1M_low_comp"
     #SET_REG(19,64) // JPEG_INIT_QUALITY = 0x64 = 100d 
     #SET_REG(13,64) #SET_REG(14,03)  
     #SET_REG(17,64) #SET_REG(18,03)  
     #SET_REG(15,64) #SET_REG(16,03);

seq_set_prop_5_6 = $"2M_High_comp"
     #SET_REG(19,5F) // JPEG_INIT_QUALITY = 0x5F = 95d   
     #SET_REG(13,58) #SET_REG(14,02) 
     #SET_REG(17,F4) #SET_REG(18,01)
     #SET_REG(15,90) #SET_REG(16,01);
     
seq_set_prop_5_7 = $"2M_low_comp"
     #SET_REG(19,64) // JPEG_INIT_QUALITY = 0x64 = 100d  
     #SET_REG(13,64) #SET_REG(14,03)
     #SET_REG(17,64) #SET_REG(18,03) 
     #SET_REG(15,64) #SET_REG(16,03);

seq_set_prop_5_8 = $"3M_High_comp"
     #SET_REG(19,5F) // JPEG_INIT_QUALITY = 0x5F = 95d  
     #SET_REG(13,84) #SET_REG(14,03)
     #SET_REG(17,20) #SET_REG(18,03) 
     #SET_REG(15,58) #SET_REG(16,02);

seq_set_prop_5_9 = $"3M_low_comp"
     #SET_REG(19,64) // JPEG_INIT_QUALITY = 0x64 = 100d
     #SET_REG(13,64) #SET_REG(14,03)
     #SET_REG(17,64) #SET_REG(18,03) 
     #SET_REG(15,64) #SET_REG(16,03);

// Property 6, Zoom

seq_set_prop_6 =                 // Set zoom level  y = -60x/150 + 68    
  #TO_DRAFT
  $s4 %0  $ma 4 
  $*4 3C  $/4 96  
  $s5 44  $-5 r4  
  #SET(67,3C)                // ZM_SMTH_SPEED = 60 
  #CMD(61,$w5);            // Send value to camera  

seq_get_prop_6 = 
  #TO_DRAFT
  #READ(69)   // Get zoom level x = -150y/60 + 170
  $*4 96  $/4 3C  $s0 AA
  $-0 r4  $s1 00  $s2 00  $s3 00;

// Property 7, Night mode 

seq_set_prop_7_0 = ;        // Normal mode

seq_set_prop_7_1 = ;        // HS mode ON

// Property 8, Effects

// 0 => normal, 1 => negative, 2 => solarize, 3 => sepia
// 4 => black&white

seq_set_prop_8 = #TO_DRAFT $s5 %0 #CMD(53,$w5);   

// Property 9, Focus mode  

seq_set_prop_9_0 =#TO_DRAFT #SET(6A,00);       // Normal range
seq_set_prop_9_1 =#TO_DRAFT #SET(6A,01);      // Full range

// Property 10, Focus operation    

seq_set_prop_a_0 =             // Stop AF 
  $cf.02 0                     // If not in draft mode 
    #CHANGE_MODE(33,00)        // MODE_MAIN
    $sf.02 1                   // Set draft flag to 1
    #CMD(43,00)          // MANUAL_FOCUS = 00, Infinity
    #CMD(5A,01)          // FLASH_INFO = 01
  $cx;

seq_set_prop_a_1 =             // Start AF
  #CHANGE_MODE(31,06)          // Half-release
  $sf.02 0;                     // Not in draft mode

seq_set_prop_a_2 =             // Go to infinity, do not autofocus!
  #CHANGE_MODE(31,02)          // Half-release
  $sf.02 0;                     // Not in draft mode

seq_get_prop_a =      // Status of focus operation
  05 01 00 03 03 $f   // Packet length, access code, id number, reg to read (int source), req packet length
  $r4 1 123 $d0005    // Put Int_source in reg 0, Event_info in reg 2 and Event_id in reg 3
  $c3 e9              // If EV_HALF_REL, e9
    $b2 00 4 1        // Remove the flash notification bit
    $c2 00
      $"CAMDRIVER0: Focus_operation_succeded"
      $s0 04
    $cl
      $"CAMDRIVER0: Focus_operation_failed"
      $s0 05          
    $cx
    $"CAMDRIVER0: Received_and_cleared_Int_Source_%0_Event_Info_%2_Event_ID_%3"
    #SET(06,03)                 // Clears the event
  $cl
    $"CAMDRIVER0: Focus_operation_not_finnished"
    $s0 03         
  $cx         
  $s1 00  $s2 00  $s3 00; 

// Property 11, EXIF 1    

seq_get_prop_b = 
  #CMD(72,00)        // INFO_GET_DATA 
  05 01 00 B0 04 $f        // Read 4 bytes from adress B0
  $r5 0 0 1 2 3 $d0002;     // ISO r0 r1, Shutter r2 r3

// Property 12, EXIF 2

seq_get_prop_c =
  #CMD(72,00)        // INFO_GET_DATA 
  05 01 00 B4 02 $f        // Read 2 bytes from adress B4
  $r3 0 0 1 $d0002         // CC r0, Distance r1
  $cf.06 1
    $ce 00                 // If not BestPic
      $s2 01               // Flash
    $cl
      $s2 00               // BestPic, no flash used even if  
    $cx                    //          it was dark 
  $cl
    $s2 00                 // No flash
  $cx
  #READ(4A) $m3 4;      // Q-value

// Property 14, Xenon flash support    

seq_set_prop_e_0 = $sd 00 #SET(91,00);    // Off   // FLASH_XENON_MODE = 0 

seq_set_prop_e_1 = $sd 01;

seq_set_prop_e_2 = $sd 02  #FLASH_SETTINGS;         // Auto internal flash
  
seq_set_prop_e_3 = 
  $sd 03                   // Auto red-eye
  #FLASH_SETTINGS;

seq_set_prop_e_4 =         // Forced on
  $sd 04
  #SET(91,03);   

// Property 16, Scenes    

seq_set_prop_10_0=#COM_EVENT(51,00)
                   #UPDATE_WB_IF_NECESSARY; 


seq_set_prop_10_1= #COM_EVENT(51,00)
                                #STATIC_MODE
                                #UPDATE_WB_IF_NECESSARY;

seq_set_prop_10_2= #COM_EVENT(51,00)
                               #A_ADVANCE_ENABLE
                               #UPDATE_WB_IF_NECESSARY;

seq_set_prop_10_3= #TWLGT_LNDSCP;

seq_set_prop_10_4= #COM_EVENT(51,00)
                               #A_MACRO_ENABLE
                               #UPDATE_WB_IF_NECESSARY;


seq_set_prop_10_5=  $"Normal_scene"  // IS disabled
      $sc 00   // Sensor scene
      #COM_EVENT(03,12)  // 9 fps AE_SLOW_SHUTTER
      #COM_EVENT(51,00)  // Sensor scene "Auto 00"
      #UPDATE_WB_IF_NECESSARY
      #DAY_MODE
      $u16;   // Update property 16: photometry
                    #COM_EVENT(02,00)  // AE_MODE = Auto
      $se 01;   // On, set reg e to 01


seq_set_prop_10_6= $"Sport_scene"  // Flash and IS disabled
      $sc 05   // Sensor scene
      #COM_EVENT(51,05)  // Sensor scene "Sports 05"
       #COM_EVENT(03,78)  // 60 fps AE_SLOW_SHUTTER
                   #UPDATE_WB_IF_NECESSARY
                   #SPORT_MODE
                   #COM_EVENT(02,00)  // AE_MODE = Auto
      $se 01;   // On, set reg e to 01

   
seq_set_prop_10_7 =        // Document
  $sa 0B                   // EV=+2/3
  #TO_DRAFT
  #SET(64,#SHOT_SPEED)       // SCENE_SLOW_SHUTTER = 29, 1/8
  #SET(22,0A)          // DRAFT_MIN_FRMRATE 5 fps
  #CMD(02,00)        // AE Auto
  #CMD(51,08)        // Custom scene 
  #UPDATE_WB  
  #DOC_MODE
  #CHANGE_MODE(34,00)
  #CMD(5A,01)        // FLASH_INFO = 1
  $cf.00 1                 // If imst mode
    #CHANGE_MODE(35,00)    // IS_DRAFT mode
  $cl $cx;                     // Not in IS

// Property 17, ISO    

seq_set_prop_11_0 =     // Auto
  #TO_DRAFT
  $sc 00
  #SET(95,04)       // Default ISO 200
  #CMD(02,00)
  #WB_ISO200
  #FLASH_LIMIT_ISO200
  #CMD(5A,01);     // FLASH_INFO = 1
  
seq_set_prop_11_1 =     // ISO 100
  #TO_DRAFT
  $sc 01 
  #SET(61,01) 
  #SET(95,01)
  #CMD(02,04)
  #WB_ISO100
  #FLASH_LIMIT_ISO100  
  #CMD(5A,01);     // FLASH_INFO = 1
  
seq_set_prop_11_2 =     // ISO 200
  #TO_DRAFT
  $sc 04 
  #SET(61,04)
  #SET(95,04) 
  #CMD(02,04)
  #WB_ISO200
  #FLASH_LIMIT_ISO200
  #CMD(5A,01);     // FLASH_INFO = 1
  
seq_set_prop_11_3 =     // ISO 400
  #TO_DRAFT
  $sc 07  
  #SET(61,07) 
  #SET(95,07)
  #CMD(02,04)
  #WB_ISO400
  #FLASH_LIMIT_ISO400
  #CMD(5A,01);     // FLASH_INFO = 1

// Property 18, Framerate reduction/restoration for GUI speed

seq_set_prop_12_0 =        // Restore framerate
  $"CAMDRIVER0: Restore framerate" 
  $sf.07 0                 // Set flag to "not in menu"
  $z5                      // Put res id in reg 5
  $c5 20                   // If res id 0x20
    $p6 10                 // Put scene value in reg 6
    $c6 03          // Scene is night?
      #SET(22,02)      // DRAFT_MIN_FRMRATE 1 fps
    $cl
      #SET(22,0A)      // DRAFT_MIN_FRMRATE 5 fps
      #SET(25,0A)      // HS_DRAFT_MIN_FRMRATE 5 fps
    $cx
    #SET(21,3C)        // DRAFT_MAX_FRMRATE 30 fps
    #SET(24,3C)        // HS_DRAFT_MAX_FRMRATE 30 fps      
  $cx
  $c5 2f                   // If res id 0x2f
    $p6 10                 // Put scene value in reg 6
    $c6 03          // Scene is night?
      #SET(22,02)      // DRAFT_MIN_FRMRATE 1 fps
    $cl
      #SET(22,0A)      // DRAFT_MIN_FRMRATE 5 fps
      #SET(25,0A)      // HS_DRAFT_MIN_FRMRATE 5 fps
    $cx
    #SET(21,3C)        // DRAFT_MAX_FRMRATE 30 fps
    #SET(24,3C)        // HS_DRAFT_MAX_FRMRATE 30 fps      
  $cx
  $c5 21                   // If res id 0x21
    #SET(22,0A)        // DRAFT_MIN_FRMRATE 5 fps
    #SET(25,0A)        // HS_DRAFT_MIN_FRMRATE 5 fps
    #SET(21,3C)        // DRAFT_MAX_FRMRATE 30 fps
    #SET(24,3C)        // HS_DRAFT_MAX_FRMRATE 30 fps      
  $cx
  $c5 25                   // If res id 0x25
    #SET(22,18)        // DRAFT_MIN_FRMRATE 12 fps
    #SET(25,18)        // HS_DRAFT_MIN_FRMRATE 12 fps
    #SET(21,18)        // DRAFT_MAX_FRMRATE 12 fps
    #SET(24,18)        // HS_DRAFT_MAX_FRMRATE 12 fps      
  $cx
  $c5 26                   // If res id 0x26
    #SET(22,18)        // DRAFT_MIN_FRMRATE 12 fps
    #SET(25,18)        // HS_DRAFT_MIN_FRMRATE 12 fps
    #SET(21,18)        // DRAFT_MAX_FRMRATE 12 fps
    #SET(24,18)        // HS_DRAFT_MAX_FRMRATE 12 fps      
  $cx
  $c5 29                   // If res id 0x29
    #SET(22,14)        // DRAFT_MIN_FRMRATE 10 fps
    #SET(25,14)        // HS_DRAFT_MIN_FRMRATE 10 fps
    #SET(21,14)        // DRAFT_MAX_FRMRATE 10 fps
    #SET(24,14)        // HS_DRAFT_MAX_FRMRATE 10 fps      
  $cx
  $c5 2a                   // If res id 0x2a
    #SET(22,3B)        // DRAFT_MIN_FRMRATE 29.5 fps
    #SET(25,3B)        // HS_DRAFT_MIN_FRMRATE 29.5 fps
    #SET(21,3C)        // DRAFT_MAX_FRMRATE 30 fps
    #SET(24,3C)        // HS_DRAFT_MAX_FRMRATE 30 fps      
  $cx
  $c5 2b                   // If res id 0x2b
    #SET(22,1E)        // DRAFT_MIN_FRMRATE 15 fps
    #SET(25,1E)        // HS_DRAFT_MIN_FRMRATE 15 fps
    #SET(21,1E)        // DRAFT_MAX_FRMRATE 15 fps
    #SET(24,1E)        // HS_DRAFT_MAX_FRMRATE 15 fps      
  $cx
  $c5 2c                   // If res id 0x2c
    #SET(22,0F)        // DRAFT_MIN_FRMRATE 7,5 fps
    #SET(25,0F)        // HS_DRAFT_MIN_FRMRATE 7,5 fps
    #SET(21,0F)        // DRAFT_MAX_FRMRATE 7,5 fps
    #SET(24,0F)        // HS_DRAFT_MAX_FRMRATE 7,5 fps      
  $cl $cx
  #CHANGE_MODE(34,00)
  #CMD(5A,01)          // FLASH_INFO = 1
  $cf.00 1                   // If imst mode
    #CHANGE_MODE(35,00)      // IS_DRAFT mode
    $cf.01 1                 // If (IS) HS mode 
      #CHANGE_MODE(38,00)    // Mode IS HS draft
    $cl 
    $cx 
  $cl                        // Not in IS
    $cf.01 1                 // If HS mode
      #CHANGE_MODE(37,00)    // Mode HS draft
    $cl 
    $cx  
  $cx;

seq_set_prop_12_1 =        // Decrease framerate
  $"CAMDRIVER0: Decrease framerate"
  $sf.07 1                 // Set flag to "menu" mode
  #SET(22,0F)          // DRAFT_MIN_FRMRATE 7,5 fps
  #SET(25,0F)          // HS_DRAFT_MIN_FRMRATE 7,5 fps
  #SET(21,0F)          // DRAFT_MAX_FRMRATE 7,5 fps
  #SET(24,0F)          // HS_DRAFT_MAX_FRMRATE 7,5 fps  
  #CHANGE_MODE(34,00);

// Property 22, Photo metering    

seq_set_prop_16_0 = 
  #TO_DRAFT
  #CMD(08,00);   // Multimode
seq_set_prop_16_1 = 
  #TO_DRAFT
  #CMD(08,01);   // Spot

// Property 23, Xenon flash required   

seq_get_prop_17 =        // 0 = no flash, 1 = flash
  #READ(93)          // FLASH_INFO_STATUS
  $-4 02 $m0 4 
  $sf.06 0               // Set flash flag to FALSE     
  $cd 02                 // Auto setting?
    #SET(9E,0E)      // FLASH_MSHUT_LONG = 1/250 sec
    $c0 01               // If use flash?
      $sf.06 1           // Set flash flag to TRUE                  
      $p5 10             // Put value of Scene in reg 5
      $c5 04             // If scene = night portrait
        #SET(9E,1D)  // FLASH_MSHUT_LONG = 1/8 sec 
        #SET(91,23)  // FLASH_XENON_MODE = 0b00100011, slow sync 
     $cl
        #SET(91,03)  // FLASH_XENON_MODE = 0b00000011, autoflash ON 
      $cx    
    $cl                  // Else not use
      #SET(91,00)    // FLASH_XENON_MODE = 0, autoflash OFF   
    $cx
  $cl 
  $cx
  $cd 03                 // Auto RER setting?
    #SET(9E,0E)      // FLASH_MSHUT_LONG = 1/250 sec
    $c0 01               // If use flash? 
      $sf.06 1           // Set flash flag to TRUE                      
      $p5 10             // Put value of Scene in reg 5
      $c5 04             // If scene = night portrait
        #SET(9E,1D)  // FLASH_MSHUT_LONG = 1/8 sec 
        #SET(91,13)  // FLASH_XENON_MODE = 0b00010011, slow sync RER 
     $cl
        #SET(91,13)  // FLASH_XENON_MODE = 0b00010011, autoflash ON, RER 
      $cx
    $cl                  // Else not use
      #SET(91,00)    // FLASH_XENON_MODE = 0, autoflash OFF, RER   
    $cx
  $cl
  $cx
  $s1 00 $s2 00 $s3 00;                    

// Property 24, Image stabilization 

seq_set_prop_18_0 =      // IS Off
  #TO_DRAFT
  #CHANGE_MODE(34,00)    // DRAFT_MODE
  $sf.00 0  
  $cc 00                 // AE_MODE = auto?
    #CMD(02,00)    // Auto
  $cl
    #CMD(02,04)    // ISO priority
    #SET(61,$wc)     // Change back to last ISO
  $cx
  #CMD(5A,01)      // FLASH_INFO = 1
  $c8 01                 // If (IS) HS video mode 
    #CHANGE_MODE(37,00)  // Mode HS draft
  $cl $cx;
                 
seq_set_prop_18_1 =      // IS On
  #TO_DRAFT
  $sf.00 1     
  #CMD(02,00)      // AE_MODE = Auto
  #CHANGE_MODE(35,00)    // IS_DRAFT mode
  $c8 01                 // If (IS) HS video mode 
    #CHANGE_MODE(38,00)  // Mode IS HS draft
  $cl $cx;

// Property 25, Continuous zoom 

seq_set_prop_19_0 =      // Stop
  #TO_DRAFT
  #CMD(61,84);
seq_set_prop_19_1 =      // Zoom in
  #TO_DRAFT
  #SET(67,01)        // ZM_SMTH_SPEED = 1 
  #CMD(61,04);      
seq_set_prop_19_2 =      // Zoom out
  #TO_DRAFT
  #SET(67,01)        // ZM_SMTH_SPEED = 1 
  #CMD(61,40);     

// Property 26, Get continuous zoom 

seq_get_prop_1a = 
  #TO_DRAFT
  #READ(69)   // 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 

seq_set_prop_1b = $se %0;        // 0 => Normal, Read out pict 1-9 in BestPic

// Property 28, BestPic image size

seq_set_prop_1c_0 =     // 5M
  #SET(2D,01)       // BURST_JPEG_IMAGE_SIZE = 5M
  #SET(42,46)       // JPEG_INIT_QUALITY = 70d, 0x46
  $cf.05 1              // If normal
    #SET(45,5A)     // JPEG_BURST_TARGET_RATE = 90d  850KB
  $cl                   // Else low compr
    #SET(45,5F)     // JPEG_BURST_TARGET_RATE = 95d = 897KB
  $cx;

seq_set_prop_1c_1 =     // 3M
  #SET(2D,03)       // BURST_JPEG_IMAGE_SIZE = 3M   
  #SET(42,40)       // JPEG_INIT_QUALITY = 64d, 0x40
  $cf.05 1              // If normal
    #SET(45,40)     // JPEG_BURST_TARGET_RATE = 64d 605 KB
  $cl                   // Else low compr
    #SET(45,46)     // JPEG_BURST_TARGET_RATE = 70d 662 KB
  $cx;

seq_set_prop_1c_2 =     // 1M
  #SET(2D,06)       // BURST_JPEG_IMAGE_SIZE = SXGA  
  #SET(42,32)       // JPEG_INIT_QUALITY = 50d, 0x32
  $cf.05 1              // If normal
    #SET(45,14)     // JPEG_BURST_TARGET_RATE = 20d 189KB
  $cl                   // Else low compr
    #SET(45,1E)     // JPEG_BURST_TARGET_RATE = 30d 283KB   
  $cx;

seq_set_prop_1c_3 =     // VGA
  #SET(2D,08)       // BURST_JPEG_IMAGE_SIZE = VGA 
  #SET(42,20)       // JPEG_INIT_QUALITY = 32d, 0x20
  $cf.05 1              // If normal
    #SET(45,05)     // JPEG_BURST_TARGET_RATE = 5d 43KB      
  $cl                   // Else low compr
    #SET(45,0A)     // JPEG_BURST_TARGET_RATE = 10d 95KB 
  $cx;


// Property 29, BestPic operation, 

seq_set_prop_1d_0 = $sb 00;     // Normal burst operation
  
seq_set_prop_1d_1 = $sb 01;     // Half speed burst operation
     
seq_set_prop_1d_2 = $sb 02;    // Abort Burst operation     

seq_set_prop_1d_3 =     // Start Burst (only for ITP)
  #CHANGE_MODE(31,02)   // Half-release with focus set to inf
  #CHANGE_MODE(39,04);

seq_set_prop_1d_4 = #CMD(3A,00);    // Stop Burst (only for ITP)
                                                                   // Take picture  

// Reset and test pattern,  property 30

seq_set_prop_1e_0 = 
  $go 31 0             // Reset low
  $d0020
  $go 31 1             // Reset high
  #CAPTURE_EVENT       // EV_CAM_READY 
  #CAPTURE_EVENT       // EV_MUTE_OFF
  #SET(29,01)      // STILL_OUT_REPEAT = 1
  #SET(2B,01);      // VSGATE ON   

seq_set_prop_1e_1 =    // Testpattern
  #SET(81,01) 
  03 55 AA $f $r2 01 $d0003   
  08 04 70 30 00 05 01 00 $f $r3 001 $d0003;

// Viewfinder and snapshot sequences

seq_ss_config_1 =
  $sf.03 1             // JPEG flag to 1
  #SET(26,08)      // 640 x 480 JPEG and JPEG IMST
  $cf.05 1             // If normal compression
    $"CAMDRIVER0: VGA NORMAL COMPRESSION"
    0D 02 00 3C        // Start sending 13 bytes at adress 3C
    96 00              // JPEG_MAX_CODE_SIZE    = 150d   
    A0 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 3C        // Start sending 13 bytes at adress 3C
    96 00              // JPEG_MAX_CODE_SIZE    = 150d   
    A0 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(26,06)      // 1280 x 960 JPEG and JPEG IMST
  $cf.05 1             // If normal compression
    $"CAMDRIVER0: 1M NORMAL COMPRESSION"
    0D 02 00 3C        // Start sending 13 bytes at adress 3C
    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 3C        // Start sending 13 bytes at adress 3C
    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(26,05)      // 1632 x 1224 JPEG and JPEG IMST 
  $cf.05 1             // If normal compression
    $"CAMDRIVER0: 2M NORMAL COMPRESSION"
    0D 02 00 3C        // Start sending 13 bytes at adress 3C
    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 3C        // Start sending 13 bytes at adress 3C
    58 02              // JPEG_MAX_CODE_SIZE    = 600d   
    90 01              // JPEG_MIN_CODE_SIZE    = 400d
    F4 01              // JPEG_TARGET_CODE_SIZE = 500d
    5A                 // JPEG_INIT_QUALITY     =  90d
    50                 // JPEG_FIRST_QUALITY    =  80d
    46                // JPEG_LAST_QUALITY     =  70d    
    $f $ra 1111111111 $d0002
  $cx;

seq_ss_config_5 =
  $sf.03 1             // JPEG output
  #SET(26,03)      // 2048 x 1536 JPEG and JPEG IMST 
  $cf.05 1             // If normal compression
    $"CAMDRIVER0: 3M NORMAL COMPRESSION"
    0D 02 00 3C        // Start sending 13 bytes at adress 3C
    46 05              // JPEG_MAX_CODE_SIZE    = 1350d   
    9E 02              // JPEG_MIN_CODE_SIZE    =  670d
    E8 03              // JPEG_TARGET_CODE_SIZE = 1000d
    5A                // JPEG_INIT_QUALITY     =  90d
    50                 // JPEG_FIRST_QUALITY    =  80d
    46                 // JPEG_LAST_QUALITY     =  70d
    $f $ra 1111111111 $d0002
  $cl                  // Else low compression
    $"CAMDRIVER0: 3M LOW COMPRESSION"
    0D 02 00 3C        // Start sending 13 bytes at adress 3C
    DC 05              // JPEG_MAX_CODE_SIZE    = 1500d   
    B0 04              // JPEG_MIN_CODE_SIZE    = 1200d
    78 05              // JPEG_TARGET_CODE_SIZE = 1400d
    64                 // JPEG_INIT_QUALITY     =  100d
    5A                // JPEG_FIRST_QUALITY    =  90d
    50                // JPEG_LAST_QUALITY     =  80d    
    $f $ra 1111111111 $d0002
    $cx;

seq_ss_config_6 =
  $sf.03 1             // JPEG output
  #SET(26,01)      // 2592 x 1944 JPEG and JPEG IMST 
  $cf.05 1             // If normal compression
    $"CAMDRIVER0: 5M NORMAL COMPRESSION" 
    0D 02 00 3C        // Start sending 13 bytes at adress 3C
    08 07               // JPEG_MAX_CODE_SIZE    = 1800d   
    B0 04              // JPEG_MIN_CODE_SIZE    = 1200d
    DC 05              // JPEG_TARGET_CODE_SIZE = 1500d
    5A                // JPEG_INIT_QUALITY     =  90d
    50                  // JPEG_FIRST_QUALITY    =  80d
    46                 // JPEG_LAST_QUALITY     =  70d
    $f $ra 1111111111 $d0002
  $cl                  // JPEG FINE MODE
    $"CAMDRIVER0: 5M LOW COMPRESSION"
    0D 02 00 3C        // Start sending 13 bytes at adress 3C
    C4 09              // JPEG_MAX_CODE_SIZE    = 2500d   
    DC 05               // JPEG_MIN_CODE_SIZE    = 1500d
    D0 07           // JPEG_TARGET_CODE_SIZE = 2000d
    64                 // JPEG_INIT_QUALITY     =  100d
    5A                 // JPEG_FIRST_QUALITY    =  90d
    50               // JPEG_LAST_QUALITY     =  80d    
    $f $ra 1111111111 $d0002
    $cx;

seq_ss_config_10 =
  $sf.03 0             // YCbCr output
  #SET(26,0C);      // 320 x 240 YCbCr and YCbCr IMST 

seq_ss_config_11 =
  $sf.03 0             // YCbCr output
 #SET(26,08);     // 640 x 480 YCbCr and YCbCr IMST
                                                                                                                                                                                     
seq_vf_config_20 =     // Viewfinder 
  #SET(20,0C)      // DRAFT_IMAGE_SIZE 320x240 
  $cf.07 1             // If in menu mode
                      // do not change max framerate
  $cl
    #SET(21,3C)    // DRAFT_MAX_FRMRATE = 30 (60/2)
  $cx
  #UPDATE_MIN_FRMRATE
  $s8 00;               // No video HS

seq_vf_config_21 =     // Viewfinder for BestPic
  #SET(20,0C)      // DRAFT_IMAGE_SIZE 320x240 
  $cf.07 1             // If in menu mode
                      // do not change max framerate
  $cl
   #SET(21,1E)    // DRAFT_MAX_FRMRATE = 15 (30/2)
  $cx
  #UPDATE_MIN_FRMRATE
  $s8 00;              // No video HS  

seq_vf_config_25 =     // VT
  #SET(20,14)      // DRAFT_IMAGE_SIZE 96x128
  #SET(23,14)      // HS_DRAFT_IMAGE_SIZE 96x128
  $cf.07 1             // If in menu mode
                      // do not change max framerate
  $cl
    #SET(22,14)    // DRAFT_MIN_FRMRATE 10 fps
    #SET(25,14)    // HS_DRAFT_MIN_FRMRATE 10 fps    
    #SET(21,14)    // DRAFT_MAX_FRMRATE 10 fps
    #SET(24,14)    // HS_DRAFT_MAX_FRMRATE 10 fps
  $cx
  $s8 00;               // No video HS

seq_vf_config_26 =     // VT
  #SET(20,12)      // DRAFT_IMAGE_SIZE 144x176
  #SET(23,12)      // HS_DRAFT_IMAGE_SIZE 144x176
  $cf.07 1             // If in menu mode
                      // do not change max framerate
  $cl
    #SET(22,18)    // DRAFT_MIN_FRMRATE 12 fps
    #SET(25,18)    // HS_DRAFT_MIN_FRMRATE 12 fps    
    #SET(21,18)    // DRAFT_MAX_FRMRATE 12 fps
    #SET(24,18)    // HS_DRAFT_MAX_FRMRATE 12 fps  
  $cx
  $s8 00;               // No video HS

seq_vf_config_29 =     // VR
  #SET(20,12)      // DRAFT_IMAGE_SIZE 144x176
  #SET(23,12)      // HS_DRAFT_IMAGE_SIZE 144x176
  $cf.07 1             // If in menu mode
                      // do not change max framerate
  $cl
    #SET(22,14)    // DRAFT_MIN_FRMRATE 10 fps
    #SET(25,14)    // HS_DRAFT_MIN_FRMRATE 10 fps    
    #SET(21,14)    // DRAFT_MAX_FRMRATE 10 fps
    #SET(24,14)    // HS_DRAFT_MAX_FRMRATE 10 fps  
  $cx
  $s8 01;               // Video HS

seq_vf_config_2a =     // VR
  #SET(20,0C)      // DRAFT_IMAGE_SIZE 320x240
  #SET(23,0C)      // HS_DRAFT_IMAGE_SIZE 320x240
  $cf.07 1             // If in menu mode
                      // do not change max framerate
  $cl
    #SET(22,3B)    // DRAFT_MIN_FRMRATE 29.5 fps
    #SET(25,3B)    // HS_DRAFT_MIN_FRMRATE 29.5 fps    
    #SET(24,3C)    // HS_DRAFT_MAX_FRMRATE 30 fps  
    #SET(21,3C)    // DRAFT_MAX_FRMRATE 30 fps
 $cx
  $s8 01;               // Video HS

seq_vf_config_2b =     // VR
  #SET(20,0C)      // DRAFT_IMAGE_SIZE 320x240
  #SET(23,0C)      // HS_DRAFT_IMAGE_SIZE 320x240
  $cf.07 1             // If menu mode
                      // do not change max framerate
  $cl
    #SET(22,1E)    // DRAFT_MIN_FRMRATE 15 fps
    #SET(25,1E)    // HS_DRAFT_MIN_FRMRATE 15 fps    
    #SET(21,1E)    // DRAFT_MAX_FRMRATE 15 fps
    #SET(24,1E)    // HS_DRAFT_MAX_FRMRATE 15 fps  
  $cx
  $s8 01;               // Video HS

seq_vf_config_2c =     // VR
  #SET(20,0C)      // DRAFT_IMAGE_SIZE 320x240
  #SET(23,0C)      // HS_DRAFT_IMAGE_SIZE 320x240
  $cf.07 1             // If in menu mode
                      // do not change max framerate
  $cl
    #SET(22,0F)    // DRAFT_MIN_FRMRATE 7,5 fps
    #SET(25,0F)    // HS_DRAFT_MIN_FRMRATE 7,5 fps
    #SET(21,0F)    // DRAFT_MAX_FRMRATE 7,5 fps
   #SET(24,0F)    // HS_DRAFT_MAX_FRMRATE 7,5 fps  
  $cx 
  $s8 01;               // Video HS

seq_vf_config_2f =     // Viewfinder 
  #SET(20,0C)      // DRAFT_IMAGE_SIZE 320x240 
  $cf.07 1             // If in menu mode
                      // do not change max framerate
  $cl
    #SET(21,3C)    // DRAFT_MAX_FRMRATE = 30 (60/2)
  $cx
  #UPDATE_MIN_FRMRATE
  $s8 00;               // No Video HS

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

seq_vf_start = 
  $cf.02 0                    // If not in any draft mode 
    #CHANGE_MODE(33,00)        // MODE_MAIN
    #CMD(43,00)          // MANUAL_FOCUS = 00, Infinity    
    #CMD(5A,01)          // FLASH_INFO = 1
    $sf.02 1                   // Set draft flag to 1
    $se 00                     // Set snapshot operation to normal     
  $cl
    #CHANGE_MODE(34,00)
    #CMD(5A,01)          // FLASH_INFO = 1
    $cf.00 1                   // If imst mode
      #CHANGE_MODE(35,00)      // IS_DRAFT mode
      $c8 01                   // If (IS) HS video mode 
        #CHANGE_MODE(38,00)    // Mode IS HS draft
      $cl $cx 
    $cl                        // Not in IS
      $c8 01                   // If HS video mode
        #CHANGE_MODE(37,00)    // Mode HS draft
      $cl $cx  
    $cx       
  $cx;     

seq_vf_stop =;

seq_ss_start =
  $cf.02 1                       // If draft mode?
    #CHANGE_MODE(31,02)          // Half-release with focus set to inf
    $sf.02 0                     // Not in draft mode
  $cl
  $cx;

seq_ss_take = 
  $ce 00                         // If not BestPic
    $cf.03 1                   // IF JPEG 
      #CHANGE_MODE(36,80)        // MODE_IMST_STILL_CAPT, JPEG
      #CAPTURE_EVENT             // EV_CAPTURE_STATUS, 02 e4
    $cl                          // Else IMST OFF       
      #CHANGE_MODE(36,00)        // MODE_STILL_CAPT, YCbCr
    $cx 
  $cl                            // Else BestPic mode
    #CHANGE_MODE(3A,$we)         // Read out pict # stored in reg e
  $cx  
  #CAPTURE_EVENT;                 // Capture EV_CAPTURE_STATUS, 00 E4     

seq_ss_verify = #CAPTURE_EVENT   // Capture EV_CAPTURE_STATUS, 01 E4
  $c2 01
    $s0 01
    $"CAMDRVIER0: Image_verified"
  $cl            
    $"CAMDRIVER0: Image_not_verified"
  $cx;

// Functions for synchronized viewfinder images in burst mode.

seq_ss_stop =; 

seq_pv_start =
  $cf.02 1                       // If draft mode?
    #CHANGE_MODE(31,02)          // Half-release with focus set to inf
    $sf.02 0                     // Not in draft mode
  $cl
  $cx  
  $"CAMDRIVER0: seq_pv_start"
  $s9 00                        // BurstStatus -> Init
  $cb 00                        // If normal interval    
    #CHANGE_MODE(39,04)         // Mode burst start, BURST_INTERVAL = 0, BURST_REMAIN = 4
  $cl                           // Else half speed, every 2nd frame 
    #CHANGE_MODE(39,14)         // Mode burst start, BURST_INTERVAL = 1, BURST_REMAIN = 4
  $cx;

seq_pv_stop =
  $c9 01
    $"CAMDRIVER0: seq_pv_stop"
    $s9 03                      // BurstStatus -> BurstOutput
    #CMD(3A,00)           // Take picture
  $cl
    $"CAMDRIVER0: seq_pv_stop is waiting for EV_RECORD_STATUS"
    $s9 02                      // BurstStatus -> WaitForEV_RECORD_STATUS
  $cx;

seq_pv_verify = 
  $h0 02 5 0000                 // Wait for TRIG  
  05 01 00 03 03 $f $r4 0 012   // [source, info, id]
  05 02 00 06 03 $f             // Release interrupt
  $cb 02                        // If Burst operation  = abort? 
    $s0 ff                      // Abort!
  $cl 
    $s0 00
    $c2 e3
      $b1 00 4 4
      $c1 00
        $s0 01                  // Rotate, i.e synch vf-image
        $"CAMDRIVER0: Rotate, synch vf"
      $cl
        $"CAMDRIVER0: Compr_failed_%0_%1_%2"
      $cx
    $cl 
    $cx
    $c2 ea                      // If EVENT_MODE_CHANGED
      $c1 50  
        $s0 ff                  // Done (Burst output)
      $cl
      $cx
    $cl
    $cx
    $c2 ee                      // EV_RECORD_STATUS
      $c9 02
        $"CAMDRIVER0: EV_RECORD_STATUS(completed)"
        $"CAMDRIVER0: Change the mode to BurstOutput"
        $s9 03                  // BurstStatus -> BurstOutput
        #CMD(3A,00)       // Take picture
        $s0 00                  // Reset register 0 to 0
      $cl
        $"CAMDRIVER0: EV_RECORD_STATUS(completed)"
        $s9 01                  // BurstStatus -> ReadyForBurstOutput
      $cx
    $cl
    $cx
  $cx;

// JPEG section
//================================================

jpeg_qtable_selector_0 = 
      $s2 00 #READ(5A)    // JPEG_HOST_QUALITY
      $m0 4 $s1 00
     $"CAMDRIVER0: qtable0=%0" ;   

jpeg_qtable_selector_1 = 
      $s2 01 #READ(5A)    // JPEG_HOST_QUALITY 
      $m0 4 $s1 00
      $"CAMDRIVER0: qtable1=%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;