root/platform/sx710hs/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. shutdown_soft
  6. get_flash_params_count
  7. JogDial_CW
  8. JogDial_CCW
  9. hook_raw_image_addr
  10. vid_get_viewport_fb
  11. vid_get_viewport_fb_d
  12. vid_get_viewport_live_fb
  13. vid_get_viewport_width
  14. vid_get_viewport_height
  15. vid_get_viewport_yoffset
  16. vid_get_viewport_display_xoffset
  17. vid_get_viewport_display_yoffset
  18. vid_get_bitmap_fb
  19. vid_get_viewport_byte_width
  20. vid_get_viewport_display_xoffset_proper
  21. vid_get_viewport_display_yoffset_proper
  22. vid_get_viewport_fullscreen_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
  28. update_screen_dimensions
  29. camera_jpeg_count_str

   1 #include "platform.h"
   2 #include "lolevel.h"
   3 #include "live_view.h"
   4 
   5 extern int active_bitmap_buffer;
   6 
   7 void vid_bitmap_refresh() {
   8     // https://chdk.setepontos.com/index.php?topic=12788.msg133958#msg133958
   9     extern void _transfer_src_overlay(int);
  10 // works in most cases but can cause "ghosting" in auto mode when canon UI constantly updates
  11 //  _transfer_src_overlay(active_bitmap_buffer);
  12     _transfer_src_overlay(0);
  13     _transfer_src_overlay(1);
  14 }
  15 
  16 void shutdown() {
  17 //***TODO***
  18 /*
  19     volatile long *p = (void*)0xC022001C;
  20 
  21     asm(
  22         "MRS     R1, CPSR\n"
  23         "AND     R0, R1, #0x80\n"
  24         "ORR     R1, R1, #0x80\n"
  25         "MSR     CPSR_cf, R1\n"
  26         :::"r1","r0"
  27     );
  28 
  29     *p = 0x44;  // power off.
  30 */
  31     while(1);
  32 }
  33 
  34 #define LED_PR 0xd20b0994 // green LED on the back
  35 
  36 void debug_led(int state) {
  37     volatile long *p = (void*)LED_PR;
  38     *p = ((state) ? 0x4d0002 : 0x4c0003);
  39 }
  40 
  41 // Power Led = first entry in table (led 0)
  42 // AF Assist Lamp = second entry in table (led 1)
  43 void camera_set_led(int led, int state, int bright) {
  44     static char led_table[2]={0,4};
  45     _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  46 }
  47 
  48 void shutdown_soft() {
  49     _PostLogicalEventForNotPowerType(0x1005,0); // PressOffButton
  50 }
  51 
  52 int get_flash_params_count(void) {
  53     return 0xe5; // @fc066f98 GetParameterData
  54 }
  55 
  56 void JogDial_CW(void) {
  57     _PostLogicalEventToUI(0x872, 1);    //RotateJogDialRight
  58 }
  59 
  60 void JogDial_CCW(void) {
  61     _PostLogicalEventToUI(0x873, 1);    //RotateJogDialLeft
  62 }
  63 
  64 // updated by using function in capt_seq, valid between shot start and raw hook end
  65 extern  char*   current_raw_addr;
  66 char *hook_raw_image_addr()
  67 {
  68     if(current_raw_addr) {
  69         return current_raw_addr;
  70     }
  71     // TODO fallback if current_raw_addr not set. Would be better to fail, but calling code doesn't check
  72     return  (char *)0x41574352; // CRAW BUF = *fc56898c
  73 }
  74 
  75 // TODO - camera has at least 3 raw buffers
  76 /*
  77 0x42f69e00
  78 0x44da0100
  79 0x46bd6400
  80 */
  81 /*
  82 char *hook_alt_raw_image_addr()
  83 {
  84     return raw_buffers[((active_raw_buffer&1)^1)];
  85 }
  86 */
  87 
  88 void *vid_get_viewport_fb() {
  89     return (void*)0x42cafe00; // "first" viewport adr, "VRAM Address  : %p", contains d6 uyvy
  90 }
  91 /*
  92 playback viewport
  93 */
  94 void *vid_get_viewport_fb_d()    {
  95     // based on suggestion from 62ndidiot in https://chdk.setepontos.com/index.php?topic=12532.msg129914#msg129914
  96     extern void *current_fb_d;
  97     return current_fb_d;
  98 } 
  99 
 100 extern void* viewport_buffers[];
 101 /*
 102 four viewport buffers @0xfc5befd8
 103 0x42cafe00
 104 0x42d5e600
 105 0x42e0ce00
 106 0x42ebb600
 107 */
 108 
 109 extern void *current_viewport_buffer;
 110 void *vid_get_viewport_live_fb()
 111 {
 112 // current_viewport_buffer assummed not most recent, like g7x
 113     int i;
 114     for(i=0;i<4;i++) {
 115         if(current_viewport_buffer == viewport_buffers[i]) {
 116             return viewport_buffers[(i+1)&3];
 117         }
 118     }
 119     return 0;
 120 }
 121 
 122 int vid_get_viewport_width() {
 123     extern int _GetVRAMHPixelsSize();
 124     if (camera_info.state.mode_play)
 125     {
 126         return 640;
 127     }
 128 // TODO: currently using actual width rather than half width used on pre d6
 129 // pixel format is uyvy (16bpp)
 130     return _GetVRAMHPixelsSize();
 131 }
 132 
 133 long vid_get_viewport_height() {
 134     extern int _GetVRAMVPixelsSize();
 135     if (camera_info.state.mode_play)
 136     {
 137         return 480;
 138     }
 139 // TODO: currently using actual height rather than 240 used on pre d6
 140     return _GetVRAMVPixelsSize();
 141 }
 142 
 143 int vid_get_viewport_yoffset() {
 144     // this seems to be always 0, buffer always begins with actual display data (widescreen or not)
 145     return 0;
 146 }
 147 // TODO
 148 // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 149 static long vp_xo[4] = { 0, 0, 0, 80 };                         // should all be even values for edge overlay
 150 
 151 int vid_get_viewport_display_xoffset() {
 152     if (camera_info.state.mode_play)
 153     {
 154         return 0;
 155     }
 156     // video, ignore still res propcase
 157     if(camera_info.state.mode_video || is_video_recording()) {
 158         return 0; //neither 4:3 nor 16:9 video have x offset
 159     }
 160     return vp_xo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 161 }
 162 
 163 // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 164 static long vp_yo[4] = { 0, 60, 28, 0 };
 165 
 166 int vid_get_viewport_display_yoffset() {
 167     if (camera_info.state.mode_play)
 168     {
 169         return 0;
 170     }
 171     // video, ignore still res propcase
 172     if(camera_info.state.mode_video || is_video_recording()) {
 173         if(shooting_get_prop(PROPCASE_VIDEO_RESOLUTION) == 2) {
 174             return 0; // 4:3 video, no Y offset
 175         } else {
 176             return 60; // 16:9 video
 177         }
 178     }
 179     return vp_yo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 180 }
 181 
 182 extern char* bitmap_buffer[];
 183 
 184 void *vid_get_bitmap_fb() {
 185     return (void *)0x5ff02e00; // from sub_fc1632ba, alt 5fe05c00, based on searching for "BmpDDev.c" similar to g7x
 186 }
 187 
 188 int vid_get_viewport_byte_width() {
 189     return 640*2;
 190 }
 191 
 192 // Functions for PTP Live View system
 193 int vid_get_viewport_display_xoffset_proper()   { return vid_get_viewport_display_xoffset(); }
 194 int vid_get_viewport_display_yoffset_proper()   { return vid_get_viewport_display_yoffset(); }
 195 int vid_get_viewport_fullscreen_width()         { return 640; }
 196 int vid_get_viewport_fullscreen_height()        { return 480; }
 197 int vid_get_viewport_buffer_width_proper()      { return 640; }
 198 int vid_get_viewport_type()                     { return LV_FB_YUV8B; }
 199 
 200 void *vid_get_bitmap_active_buffer() {
 201     return bitmap_buffer[active_bitmap_buffer&1];
 202 }
 203 
 204 // the opacity buffer defines opacity for the bitmap overlay's pixels
 205 // fc1631ee, similar to g7x fc0f7b52, BmpDDev.c assert + switch
 206 volatile char *opacity_buffer[2] = {(char*)0x5fd87300, (void*)0x5fd08a00};
 207 
 208 // 0x10108 also appears to contain the active buffer
 209 void *vid_get_opacity_active_buffer() {
 210     return (void *)opacity_buffer[active_bitmap_buffer&1];
 211 }
 212 
 213 // TODO sx280 c&p
 214 #if 0
 215 #ifdef CAM_SUPPORT_BITMAP_RES_CHANGE
 216 /*
 217  * needed because bitmap buffer resolutions change when an external display is used
 218  * an extra screen erase doesn't seem to be needed
 219  */
 220 void update_screen_dimensions() {
 221     // see sub_fc18618a in 102b and 102c for the values
 222     extern int displaytype;
 223     static int old_displaytype = -1;
 224 
 225     if (old_displaytype == displaytype) {
 226         return;
 227     }
 228     old_displaytype = displaytype;
 229 
 230     switch(displaytype) {
 231         case 0:
 232         case 3:
 233         case 4:
 234         case 5:
 235             // lcd
 236             camera_screen.width = camera_screen.physical_width = camera_screen.buffer_width = 640;
 237             camera_screen.height = camera_screen.buffer_height = 480;
 238             camera_screen.size = camera_screen.buffer_size = 640*480;
 239             break;
 240         case 1:
 241         case 2:
 242         case 8:
 243         case 9:
 244             // tv-out
 245             camera_screen.width = 720;
 246             camera_screen.physical_width = camera_screen.buffer_width = 736;
 247             camera_screen.height = camera_screen.buffer_height = 480;
 248             camera_screen.size = 720*480;
 249             camera_screen.buffer_size = 736*480;
 250             break;
 251         case 6:
 252         case 7:
 253             // hdmi
 254             camera_screen.width = camera_screen.physical_width = camera_screen.buffer_width = 960;
 255             camera_screen.height = camera_screen.buffer_height = 540;
 256             camera_screen.size = camera_screen.buffer_size = 960*540;
 257             break;
 258     }
 259 }
 260 #endif
 261 #endif
 262 
 263 char *camera_jpeg_count_str()
 264 {
 265     extern char jpeg_count_str[];
 266         return jpeg_count_str;
 267 }

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