root/platform/sx60hs/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_display_xoffset_proper
  20. vid_get_viewport_display_yoffset_proper
  21. vid_get_viewport_byte_width
  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. camera_jpeg_count_str
  29. update_screen_dimensions

   1 #include "platform.h"
   2 #include "lolevel.h"
   3 #include "live_view.h"
   4 
   5 extern int displaytype;
   6 extern void _LogCameraEvent(int id, const char *fmt,...);
   7 extern int active_bitmap_buffer;
   8 extern void* bitmap_buffer[];
   9 extern char* raw_buffers_canon_raw[];
  10 extern char* raw_buffers_jpeg[];
  11 
  12 void vid_bitmap_refresh() {
  13 
  14     extern void _transfer_src_overlay(int);
  15     _transfer_src_overlay(0);
  16     _transfer_src_overlay(1);
  17 }
  18 
  19 void shutdown() {
  20 /*
  21     volatile long *p = (void*)0xC022001C;
  22 
  23     asm(
  24         "MRS     R1, CPSR\n"
  25         "AND     R0, R1, #0x80\n"
  26         "ORR     R1, R1, #0x80\n"
  27         "MSR     CPSR_cf, R1\n"
  28         :::"r1","r0"
  29     );
  30 
  31     *p = 0x44;  // power off.
  32 */
  33     while(1);
  34 }
  35 
  36 #define LED_PR 0xd20b0994 // green LED on the back
  37 
  38 void debug_led(int state) {
  39     volatile long *p = (void*)LED_PR;
  40     *p = ((state) ? 0x4d0002 : 0x4c0003);
  41 }
  42 
  43 // Power Led = first entry in table (led 0)
  44 // AF Assist Lamp = second entry in table (led 1)
  45 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
  46     static char led_table[2]={0,4};
  47     _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  48 }
  49 
  50 void shutdown_soft() {
  51     _PostLogicalEventForNotPowerType(0x1005,0); // PressOffButton
  52 }
  53 
  54 int get_flash_params_count(void) {
  55     return 0xde; // @0xfc0afeb8
  56 }
  57 
  58 void JogDial_CW(void) {
  59     _PostLogicalEventToUI(0x8ad, 1);    //RotateJogDialRight 
  60 }
  61 
  62 void JogDial_CCW(void) {
  63     _PostLogicalEventToUI(0x8ae, 1);    //RotateJogDialLeft
  64 }
  65 
  66 extern  int     active_raw_buffer;
  67 extern  char*   current_raw_addr;
  68 //extern  char*   raw_buffers[];
  69 char *hook_raw_image_addr()
  70 {
  71     if (current_raw_addr) {
  72          return current_raw_addr;
  73     }
  74 // fall back to old code which will be wrong in many cases.....
  75     // observed values 0-2, 3 would index something that doesn't look like a raw fb in the jpeg case
  76     int i=active_raw_buffer&3;
  77 /*
  78     _LogCameraEvent(0x20,"lc: hria: %i %i %08x %i",i, camera_info.state.mode_shooting,
  79                                               camera_info.state.mode_shooting,
  80                                               shooting_get_prop(PROPCASE_IMAGE_FORMAT));
  81 */ 
  82     if(i>2) {
  83         i=0;
  84     }
  85     if( camera_info.state.mode_shooting == MODE_AUTO) {
  86         // AUTO mode (canon raw can't be enabled in AUTO)
  87         return (char *)0x435ee300; // TODO unclear if this is only buffer, or if used in all AUTO sub modes
  88     }else if(shooting_get_prop(PROPCASE_IMAGE_FORMAT) == 1) {
  89     // canon raw disabled - uses up to 3 raw buffers
  90         return raw_buffers_jpeg[i];
  91     } else {
  92         // canon raw enabled - different address, not clear if it ever uses multiple buffers
  93         return raw_buffers_canon_raw[i];
  94     }
  95     // TODO most scene modes seem to use different addresse(s)
  96 }
  97 
  98 /* 
  99 char *hook_raw_image_addr()
 100 {
 101       return raw_buffers_jpeg[(active_raw_buffer&1)];
 102 }
 103 
 104 char *hook_alt_raw_image_addr()
 105 {
 106     return raw_buffers_jpeg[((active_raw_buffer&1)^1)];
 107 }
 108 */
 109 
 110 
 111 
 112 
 113 
 114 void *vid_get_viewport_fb() {
 115     return (void*)0x43334300; // same as g7x "first" viewport adr, "VRAM Address  : %p", contains d6 uyvy
 116 // TODO sx280 values
 117     // Return first viewport buffer - for case when vid_get_viewport_live_fb not defined
 118     //return (void*)0x43115100; // uyvy buffers with signed(?) chroma components
 119     // return (void*)0x4b25fc00; // uyvy buffers (more than 4), pixel format compatible with earlier DIGIC uyvy
 120 }
 121 
 122 //void *vid_get_viewport_fb_d()    { return (void*)0x5e878000; } //by comparison with g7x
 123 void *vid_get_viewport_fb_d()    { 
 124   extern void *current_fb_d;
 125   return current_fb_d;
 126  } 
 127 //void *vid_get_viewport_fb_d()    { return (void*)0x43334300; } 
 128 //void *vid_get_viewport_fb_d()    { return (void*)0x465ebb40; } 
 129 /* live buffers the list is found at 0xfc5cf054 on 100f and at 0xfc5cf040 on 100b
 130   first at 0x43334000 
 131 strangely these increment like the g7x (by 0xae800)  case which has higher rez
 132   640*2*480 = 0x96000 + 0x18800 ae800
 133  0x43334300
 134  0x433e2b00
 135  0x43491300
 136  0x4353fb00
 137 */
 138 extern void* viewport_buffers[];
 139 extern void *current_viewport_buffer;
 140 
 141 void *vid_get_viewport_live_fb()
 142 {
 143 // current_viewport_buffer doesn't seem to be most recent
 144     int i;
 145     for(i=0;i<4;i++) {
 146         if(current_viewport_buffer == viewport_buffers[i]) {
 147             return viewport_buffers[(i+1)&3];
 148         }
 149     }
 150     return 0;
 151 }
 152 
 153 
 154 int vid_get_viewport_width() {
 155 /*
 156 loc_fc134980: ; 4 refs (GetVRAMHPixelsSize)
 157 fc134980:   487d        ldr r0, [pc, #500]  ; 0xfc134b78: (0002ca18) 
 158 fc134982:   f8d0 00ac   ldr.w   r0, [r0, #172]  ; 0xac
 159 fc134986:   4770        bx  lr
 160 */
 161    if (camera_info.state.mode_play)
 162    { 
 163        return camera_screen.physical_width; 
 164 //     return 360; //todo
 165    }
 166     extern int _GetVRAMHPixelsSize();
 167     return _GetVRAMHPixelsSize();
 168 }
 169 
 170 long vid_get_viewport_height() {
 171 /*
 172 loc_fc134988: ; 3 refs (GetVRAMVPixelsSize)
 173 fc134988:   487b        ldr r0, [pc, #492]  ; 0xfc134b78: (0002ca18) 
 174 fc13498a:   f8d0 00b0   ldr.w   r0, [r0, #176]  ; 0xb0
 175 fc13498e:   4770        bx  lr
 176 */
 177 /*
 178     int m = mode_get();
 179     int aspect_ratio=shooting_get_prop(PROPCASE_ASPECT_RATIO);
 180 
 181     if (MODE_IS_VIDEO(m) || is_video_recording())
 182         return 480;
 183 
 184     if ((m & MODE_MASK) != MODE_PLAY)
 185     {
 186         // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 187         if (aspect_ratio==1 || aspect_ratio==2)
 188             return 480;
 189     }
 190     
 191     extern int _GetVRAMVPixelsSize();
 192     return ((m & MODE_MASK) == MODE_PLAY)?480:_GetVRAMVPixelsSize();
 193 */
 194        extern int _GetVRAMVPixelsSize();
 195 // return half height
 196     if (camera_info.state.mode_play)
 197         return camera_screen.buffer_height;
 198     return _GetVRAMVPixelsSize();
 199 }
 200 
 201 // viewport width offset table for each aspect ratio
 202 // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1 4 = 4:5
 203 static long vp_xo[5] = { 0, 0, 0, 80, 128 };// should all be even values for edge overlay
 204 static long vp_yo[5] = {0, 60, 28, 0, 0};
 205 
 206 int vid_get_viewport_yoffset() {
 207 //     int aspect_ratio=shooting_get_prop(PROPCASE_ASPECT_RATIO);
 208 
 209         return 0;
 210 }
 211 
 212 
 213 int vid_get_viewport_display_xoffset() {
 214 
 215     if (camera_info.state.mode_play) {
 216         return 0;
 217     }
 218     // video, ignore still res propcase
 219     if(camera_info.state.mode_video || is_video_recording()) {
 220             return 0; //all video modes for now
 221     }
 222     return vp_xo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 223 
 224 }
 225 
 226 int vid_get_viewport_display_yoffset() {
 227     if (camera_info.state.mode_play) {
 228         return 0;
 229     }
 230     else {
 231         if(camera_info.state.mode_video || is_video_recording()) {
 232                 return 0; //all video modes
 233         }
 234     } 
 235     return (vp_yo[shooting_get_prop(PROPCASE_ASPECT_RATIO)]);
 236 
 237 }
 238 
 239 
 240 //extern int active_bitmap_buffer;
 241 //int active_bitmap_buffer = 0;
 242 //extern char* bitmap_buffer[];
 243 
 244 void *vid_get_bitmap_fb() {
 245 //    return (void *)0x41441000; //  from sub_fc0f8804, alt 4153e200
 246       return bitmap_buffer[0];
 247 }
 248 
 249 // TODO
 250 // Functions for PTP Live View system
 251 int vid_get_viewport_display_xoffset_proper()   { return vid_get_viewport_display_xoffset() ; }
 252 int vid_get_viewport_display_yoffset_proper()   { return vid_get_viewport_display_yoffset() ; }
 253 int vid_get_viewport_byte_width() {
 254 // digic 6 uYvY    2 pixels per 4 bytes
 255   return (640 * 2);
 256 }
 257 int vid_get_viewport_fullscreen_width()         { return camera_screen.width; }
 258 int vid_get_viewport_fullscreen_height()        { return camera_screen.height; }
 259 int vid_get_viewport_buffer_width_proper()      { return camera_screen.buffer_width; } // may not be always ok
 260 int vid_get_viewport_type()                     { return LV_FB_YUV8B; }
 261 
 262 void *vid_get_bitmap_active_buffer() {
 263     return bitmap_buffer[active_bitmap_buffer&1];
 264 }
 265 
 266 // the opacity buffer defines opacity for the bitmap overlay's pixels
 267 // found near BmpDDev.c line 215 assert fc0f873c
 268 volatile char *opacity_buffer[2] = {(char*)0x4163b400, (void*)0x416b9d00};
 269 void *vid_get_opacity_active_buffer() {
 270     return (void *)opacity_buffer[active_bitmap_buffer&1];
 271 }
 272 // now in platform_palette.c
 273 //void *vid_get_bitmap_active_palette() {
 274 //    return (void*)0x8000; // just to return something valid, no palette needed on this cam
 275 //}
 276 char *camera_jpeg_count_str()
 277 {
 278     extern char jpeg_count_str[];
 279         return jpeg_count_str;
 280 }
 281 #ifdef CAM_SUPPORT_BITMAP_RES_CHANGE
 282 /*
 283  * needed because bitmap buffer resolutions change when an external display is used
 284  * an extra screen erase doesn't seem to be needed
 285  */
 286 void update_screen_dimensions() {
 287     extern int displaytype;
 288     static int old_displaytype = -1;
 289 
 290     if (old_displaytype == displaytype) {
 291         return;
 292     }
 293  
 294     _LogCameraEvent(0x60,"lc: odt: %d dt: %d csw: %d csh: %d css: %d",
 295                 old_displaytype, displaytype, camera_screen.width,
 296                  camera_screen.height, camera_screen.size);
 297     camera_screen.width = camera_screen.physical_width = camera_screen.buffer_width = 640;
 298     camera_screen.height = camera_screen.buffer_height = 480;
 299     camera_screen.size = camera_screen.buffer_size = 640*480;
 300     old_displaytype = displaytype;
 301     switch(displaytype) {
 302         case 0:
 303         case 3:
 304         case 4:
 305             // lcd
 306             camera_screen.width = camera_screen.physical_width = camera_screen.buffer_width = 640;
 307             camera_screen.height = camera_screen.buffer_height = 480;
 308             camera_screen.size = camera_screen.buffer_size = 640*480;
 309             break;
 310         case 5:
 311         case 1:
 312         case 2:
 313         case 8:
 314         case 9:
 315             // tv-out
 316             camera_screen.width = 720;
 317             camera_screen.physical_width = camera_screen.buffer_width = 736;
 318             camera_screen.height = camera_screen.buffer_height = 480;
 319             camera_screen.size = 720*480;
 320             camera_screen.buffer_size = 736*480;
 321             break;
 322         case 6:
 323             // hdmi
 324             camera_screen.width = camera_screen.physical_width = camera_screen.buffer_width = 960;
 325             camera_screen.height = camera_screen.buffer_height = 540;
 326             camera_screen.size = camera_screen.buffer_size = 960*540;
 327             break;
 328     }
 329 }
 330 #endif
 331 

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