root/platform/sx700hs/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. hook_alt_raw_image_addr
  11. vid_get_viewport_fb
  12. vid_get_viewport_fb_d
  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_byte_width
  21. vid_get_viewport_display_xoffset_proper
  22. vid_get_viewport_display_yoffset_proper
  23. vid_get_viewport_fullscreen_width
  24. vid_get_viewport_fullscreen_height
  25. vid_get_viewport_buffer_width_proper
  26. vid_get_viewport_type
  27. vid_get_bitmap_active_buffer
  28. vid_get_opacity_active_buffer
  29. update_screen_dimensions
  30. 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, __attribute__ ((unused))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 0xa6; // @fc0bbe8a GetParameterData FFTM
  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 
  65 // Copied from sx280
  66 extern  int     active_raw_buffer;
  67 extern  char *  raw_buffers[];
  68 
  69 char *hook_raw_image_addr()
  70 {
  71     return raw_buffers[(active_raw_buffer&1)];
  72 }
  73 
  74 char *hook_alt_raw_image_addr()
  75 {
  76     return raw_buffers[((active_raw_buffer&1)^1)];
  77 }
  78 
  79 
  80 
  81 // ***  Viewport buffer handling ***
  82 
  83 extern void* viewport_buffers[];
  84 extern void *current_viewport_buffer;
  85 
  86 void *vid_get_viewport_fb() {
  87     //return viewport_buffers[0];      // From G16 copy
  88     return (void*)0x43312300; // sx700v100e "first" viewport adr, "VRAM Address  : %p", contains d6 uyvy
  89 }
  90 
  91 /*
  92 playback viewport
  93 */
  94 
  95 void *vid_get_viewport_fb_d()    {
  96     // based on suggestion from 62ndidiot in https://chdk.setepontos.com/index.php?topic=12532.msg129914#msg129914
  97     extern void *current_fb_d;
  98     return current_fb_d;
  99 }
 100 
 101 /* Below numbers for sx700v100e
 102 four viewport buffers @0xfc568a64
 103 rmem 0xfc568a64 4 -i32
 104 0xfc568a64 16
 105 0xfc568a64: 0x43312300 0x433c0b00 0x4346f300 0x4351db00
 106 */
 107 
 108 
 109 void *vid_get_viewport_live_fb()
 110 {
 111 // current_viewport_buffer assummed not most recent, like g7x
 112     int i;
 113     for(i=0;i<4;i++) {
 114         if(current_viewport_buffer == viewport_buffers[i]) {
 115             return viewport_buffers[(i+1)&3];
 116         }
 117     }
 118     return 0;
 119 }
 120 
 121 int vid_get_viewport_width() {
 122     extern int _GetVRAMHPixelsSize();
 123     if (camera_info.state.mode_play)
 124     {
 125         return 640;
 126     }
 127 // TODO: currently using actual width rather than half width used on pre d6
 128 // pixel format is uyvy (16bpp)
 129     return _GetVRAMHPixelsSize();
 130 }
 131 
 132 long vid_get_viewport_height() {
 133     extern int _GetVRAMVPixelsSize();
 134     if (camera_info.state.mode_play)
 135     {
 136         return 480;
 137     }
 138 // TODO: currently using actual height rather than 240 used on pre d6
 139     return _GetVRAMVPixelsSize();
 140 }
 141 
 142 int vid_get_viewport_yoffset() {
 143     // this seems to be always 0, buffer always begins with actual display data (widescreen or not)
 144     return 0;
 145 }
 146 // TODO
 147 // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 148 static long vp_xo[4] = { 0, 0, 0, 80 };                         // should all be even values for edge overlay
 149 
 150 int vid_get_viewport_display_xoffset() {
 151     if (camera_info.state.mode_play)
 152     {
 153         return 0;
 154     }
 155     // video, ignore still res propcase
 156     if(camera_info.state.mode_video || is_video_recording()) {
 157         return 0; //neither 4:3 nor 16:9 video have x offset
 158     }
 159     return vp_xo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 160 }
 161 
 162 // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 163 static long vp_yo[4] = { 0, 60, 28, 0 };
 164 
 165 int vid_get_viewport_display_yoffset() {
 166     if (camera_info.state.mode_play)
 167     {
 168         return 0;
 169     }
 170     // video, ignore still res propcase
 171     if(camera_info.state.mode_video || is_video_recording()) {
 172         if(shooting_get_prop(PROPCASE_VIDEO_RESOLUTION) == 2) {
 173             return 0; // 4:3 video, no Y offset
 174         } else {
 175             return 60; // 16:9 video
 176         }
 177     }
 178     return vp_yo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 179 }
 180 
 181 extern char* bitmap_buffer[];
 182 
 183 void *vid_get_bitmap_fb() {
 184 //    return (void *)0x5ff02e00; // from sub_fc1632ba, alt 5fe05c00, based on searching for "BmpDDev.c" similar to g7x
 185       return bitmap_buffer[0];
 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 // FFTM fc0e3c8c
 207 volatile char *opacity_buffer[2] = {(char*)0x4161b400, (void*)0x41699d00};
 208 
 209 // 0x10108 also appears to contain the active buffer
 210 void *vid_get_opacity_active_buffer() {
 211     return (void *)opacity_buffer[active_bitmap_buffer&1];
 212 }
 213 
 214 
 215 // TODO sx280 c&p
 216 //#if 0
 217 #ifdef CAM_SUPPORT_BITMAP_RES_CHANGE
 218 /*
 219  * needed because bitmap buffer resolutions change when an external display is used
 220  * an extra screen erase doesn't seem to be needed
 221  */
 222 void update_screen_dimensions() {
 223     // see sub_fc18618a in 102b and 102c for the values
 224     extern int displaytype;
 225     static int old_displaytype = -1;
 226 
 227     if (old_displaytype == displaytype) {
 228         return;
 229     }
 230     old_displaytype = displaytype;
 231 
 232     switch(displaytype) {
 233         case 0:
 234         case 3:
 235         case 4:
 236         case 5:
 237             // lcd
 238             camera_screen.width = camera_screen.physical_width = camera_screen.buffer_width = 640;
 239             camera_screen.height = camera_screen.buffer_height = 480;
 240             camera_screen.size = camera_screen.buffer_size = 640*480;
 241             break;
 242         case 1:
 243         case 2:
 244         case 8:
 245         case 9:
 246             // tv-out
 247             camera_screen.width = 720;
 248             camera_screen.physical_width = camera_screen.buffer_width = 736;
 249             camera_screen.height = camera_screen.buffer_height = 480;
 250             camera_screen.size = 720*480;
 251             camera_screen.buffer_size = 736*480;
 252             break;
 253         case 6:
 254         case 7:
 255             // hdmi
 256             camera_screen.width = camera_screen.physical_width = camera_screen.buffer_width = 960;
 257             camera_screen.height = camera_screen.buffer_height = 540;
 258             camera_screen.size = camera_screen.buffer_size = 960*540;
 259             break;
 260     }
 261 }
 262 #endif
 263 //#endif
 264 
 265 char *camera_jpeg_count_str()
 266 {
 267     extern char jpeg_count_str[];
 268         return jpeg_count_str;
 269 }

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