root/platform/g16/lib.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. vid_bitmap_refresh
  2. shutdown
  3. debug_led
  4. camera_set_led
  5. get_flash_params_count
  6. camera_jpeg_count_str
  7. JogDial_CW
  8. JogDial_CCW
  9. hook_raw_image_addr
  10. hook_alt_raw_image_addr
  11. vid_get_viewport_fb_d
  12. vid_get_viewport_fb
  13. vid_get_viewport_live_fb
  14. vid_get_viewport_width
  15. vid_get_viewport_height
  16. vid_get_viewport_yoffset
  17. vid_get_viewport_display_xoffset
  18. vid_get_viewport_display_yoffset
  19. vid_get_bitmap_fb
  20. vid_get_viewport_display_xoffset_proper
  21. vid_get_viewport_display_yoffset_proper
  22. vid_get_viewport_byte_width
  23. vid_get_viewport_fullscreen_height
  24. vid_get_viewport_buffer_width_proper
  25. vid_get_viewport_type
  26. vid_get_bitmap_active_buffer
  27. vid_get_opacity_active_buffer

   1 #include "platform.h"
   2 #include "lolevel.h"
   3 #include "live_view.h"
   4 
   5 void vid_bitmap_refresh()
   6 {
   7  // Method 1:
   8  //   extern void _displaybusyonscreen();
   9  //   extern void _undisplaybusyonscreen();
  10  //   _displaybusyonscreen();                 // clears perfectly but blinks and is asynchronous - see SX280hs for more code options
  11  //   _undisplaybusyonscreen();
  12  
  13  // Method 2:
  14  // extern int active_bitmap_buffer;
  15  // extern void _transfer_src_overlay(int);
  16  //   _transfer_src_overlay(active_bitmap_buffer);    
  17     
  18  // Method 3:
  19  // https://chdk.setepontos.com/index.php?topic=12788.msg133958#msg133958
  20  // works in most cases but can cause "ghosting" in auto mode when canon UI constantly updates;
  21     extern void _transfer_src_overlay(int);
  22     _transfer_src_overlay(0);
  23     _transfer_src_overlay(1);    
  24     
  25 }
  26  
  27 void shutdown()
  28 {
  29     // _PostLogicalEventForNotPowerType(0x1005,0);    // Hack : Press the Off Button and wait
  30     // while(1) msleep(100) ;
  31     while(1);    
  32 }
  33 
  34 #define LED_PR 0xd20b0994  // G16 green LED on OVF bezel
  35 
  36 void debug_led(int state)
  37 {
  38     volatile long *p = (void*)LED_PR;
  39     *p = ((state) ? 0x4d0002 : 0x4c0003);
  40 }
  41 
  42 void camera_set_led(int led, int state, __attribute__ ((unused))int bright)
  43 {
  44     static char led_table[4]={0,1,2,4};     // 0=Green OVF, 1=Orange OVF, 2=Power Switch LED, 4=Focus Assist Lamp
  45     _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  46 }
  47 
  48 int get_flash_params_count(void)
  49 {
  50     return 0x9a;         // @0xfc0cce24 - look for compares to #0x4000 in section with PropertyTableManagerCore.c"
  51 }
  52 
  53 char *camera_jpeg_count_str()
  54 {
  55     extern char jpeg_count_str[];
  56     return jpeg_count_str;
  57 }
  58 
  59 void JogDial_CW(void)
  60 {
  61     _PostLogicalEventToUI(0x872, 1);    //RotateJogDialRight
  62 }
  63 
  64 void JogDial_CCW(void) {
  65     _PostLogicalEventToUI(0x873, 1);    //RotateJogDialLeft
  66 }
  67 
  68 
  69 // ***  RAW / DNG handling ***
  70 
  71 extern  int     active_raw_buffer;
  72 extern  char *  raw_buffers[];
  73 extern  char *  raw_buffers_jpeg[];
  74 
  75 char * hook_raw_image_addr()
  76 {
  77     int i=0 ;                               // AUTO mode uses just 1 buffer
  78     if(( camera_info.state.mode_shooting != MODE_AUTO ) &&
  79        ( camera_info.state.mode_shooting != MODE_HYBRID_AUTO ))
  80     {
  81         i=active_raw_buffer&3;              // indexes three buffers
  82 
  83         if(shooting_get_prop(PROPCASE_IMAGE_FORMAT) == 1)
  84         {
  85             return raw_buffers_jpeg[i];     // canon raw disabled
  86         }
  87     }
  88     return raw_buffers[i];                  // canon raw enabled or AUTO mode
  89 
  90     // **FIXME** scene mode addresses might not be right
  91 }
  92 
  93 char *hook_alt_raw_image_addr()
  94 {
  95     int i=0 ;                               // AUTO mode uses just 1 buffer
  96     if(( camera_info.state.mode_shooting != MODE_AUTO ) &&
  97        ( camera_info.state.mode_shooting != MODE_HYBRID_AUTO ))
  98     {
  99         int i = (active_raw_buffer&3)-1;    // indexes three buffers
 100         if (i<0) i=2;
 101 
 102         if(shooting_get_prop(PROPCASE_IMAGE_FORMAT) == 1)
 103         {
 104             return raw_buffers_jpeg[i];     // canon raw disabled
 105         }
 106     }
 107     return raw_buffers[i];
 108 }
 109 
 110 
 111 // ***  Viewport buffer handling ***
 112 
 113 extern void* viewport_buffers[];
 114 extern void *current_viewport_buffer;
 115 
 116 void *vid_get_viewport_fb_d()
 117 {
 118     extern void *current_fb_d;
 119     return current_fb_d;             // same as sx280, sx60, g7x
 120 }
 121 
 122 void *vid_get_viewport_fb()          // Return first viewport buffer - for case when vid_get_viewport_live_fb not defined
 123 {
 124     return viewport_buffers[0];      // ptr in fc571014: (i.e.viewport_buffer[0]) -> 0x43115100
 125     //return  (void *) 0x43115100;   // "first" viewport adr, found before "VRAM Address  : %p", contains d6 uyvy
 126 }
 127 
 128 void *vid_get_viewport_live_fb()
 129 {
 130     int i;
 131     for(i=0;i<4;i++) {
 132         if(current_viewport_buffer == viewport_buffers[i]) {
 133             return viewport_buffers[(i+1)&3];
 134         }
 135     }
 136     return 0;
 137 }
 138 
 139 int vid_get_viewport_width()
 140 {
 141     extern int _GetVRAMHPixelsSize();
 142     if (camera_info.state.mode_play)
 143     {
 144       return camera_screen.physical_width;
 145     }
 146     return _GetVRAMHPixelsSize();
 147 }
 148 
 149 long vid_get_viewport_height()
 150 {
 151     extern int _GetVRAMVPixelsSize();
 152     if (camera_info.state.mode_play)
 153     {
 154        return camera_screen.buffer_height;
 155     }
 156     return _GetVRAMVPixelsSize();
 157 }
 158 
 159 static long vp_xo[5] = { 0, 0,  0,  80, 128 };// should all be even values for edge overlay
 160 static long vp_yo[5] = { 0, 60, 28, 0,  0};
 161 
 162 int vid_get_viewport_yoffset()
 163 {
 164     return 0;       // this seems to be always 0, buffer always begins with actual display data (widescreen or not)
 165 }
 166 
 167 int vid_get_viewport_display_xoffset()
 168 {
 169     if (camera_info.state.mode_play)
 170     {
 171         return 0;
 172     }
 173     if(camera_info.state.mode_video || is_video_recording())
 174     {
 175         return 0;
 176     }
 177     return vp_xo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 178 }
 179 
 180 int vid_get_viewport_display_yoffset()
 181 {
 182     if (camera_info.state.mode_play)
 183     {
 184         return 0;
 185     }
 186     if(camera_info.state.mode_video || is_video_recording())
 187     {
 188         return 0;
 189     }
 190     return (vp_yo[shooting_get_prop(PROPCASE_ASPECT_RATIO)]);
 191 }
 192 
 193 extern int active_bitmap_buffer;
 194 extern char* bitmap_buffer[];
 195 
 196 void *vid_get_bitmap_fb()
 197 {
 198     return bitmap_buffer[0];
 199     //return (void *)0x41421000; // G16 value based on g7x port
 200 }
 201 
 202 // Functions for PTP Live View system
 203 int vid_get_viewport_display_xoffset_proper()   { return vid_get_viewport_display_xoffset(); }
 204 int vid_get_viewport_display_yoffset_proper()   { return vid_get_viewport_display_yoffset(); }
 205 int vid_get_viewport_byte_width()               { return (640 * 2); }
 206 int vid_get_viewport_fullscreen_height()        { return camera_screen.height; }
 207 int vid_get_viewport_buffer_width_proper()      { return camera_screen.buffer_width; }
 208 int vid_get_viewport_type()                     { return LV_FB_YUV8B; }
 209 
 210 void *vid_get_bitmap_active_buffer()
 211 {
 212     return bitmap_buffer[active_bitmap_buffer&1];
 213 }
 214 
 215 // the opacity buffer defines opacity for the bitmap overlay's pixels
 216 // G16 routine @ 0xfc1b3e58 - look for vid_get_bitmap_fb value then values at 0xfc1b3e5e and  0xfc1b3e6c
 217 volatile char *opacity_buffer[2] = { (char*)0x41718600, (void*)0x41796f00 };
 218 
 219 void *vid_get_opacity_active_buffer()
 220 {
 221     return (void *)opacity_buffer[active_bitmap_buffer&1];
 222 }

/* [<][>][^][v][top][bottom][index][help] */