root/platform/m10/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_d
  11. vid_get_viewport_fb
  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_viewport_type
  19. vid_get_bitmap_fb
  20. vid_get_viewport_display_xoffset_proper
  21. vid_get_viewport_display_yoffset_proper
  22. vid_get_viewport_buffer_width_proper
  23. vid_get_viewport_fullscreen_width
  24. vid_get_viewport_byte_width
  25. vid_get_viewport_fullscreen_height
  26. vid_get_aspect_ratio
  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 void vid_bitmap_refresh() {
   6     extern void _transfer_src_overlay(int);
   7     _transfer_src_overlay(0);
   8     _transfer_src_overlay(1);
   9 }
  10 
  11 void shutdown() {
  12 //***TODO***
  13 /*
  14     volatile long *p = (void*)0xC022001C;
  15 
  16     asm(
  17         "MRS     R1, CPSR\n"
  18         "AND     R0, R1, #0x80\n"
  19         "ORR     R1, R1, #0x80\n"
  20         "MSR     CPSR_cf, R1\n"
  21         :::"r1","r0"
  22     );
  23 
  24     *p = 0x44;  // power off.
  25 */
  26     while(1)   _SleepTask(500);
  27 }
  28 
  29 #define LED_PR 0xd20b0994 // green LED on the back
  30 
  31 void debug_led(int state) {
  32     volatile long *p = (void*)LED_PR;
  33     *p = ((state) ? 0x4d0002 : 0x4c0003);
  34 }
  35 
  36 // Power Led = first entry in table (led 0)
  37 // AF Assist Lamp = second entry in table (led 1)
  38 void camera_set_led(int led, int state, int bright) {
  39     static char led_table[2]={0,4};
  40     _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  41 }
  42 
  43 void shutdown_soft() {
  44 //      *(int*)0xd20b0810  = 0x4d0002;   // Orange Led = on
  45 
  46         _PostLogicalEventForNotPowerType(0x1005,0);
  47 }
  48 
  49 int get_flash_params_count(void) {
  50     return 0xe6; // found @ 0xfc27e6fc (101d)
  51 }
  52 
  53 void JogDial_CW(void) {
  54     _PostLogicalEventToUI(0x1134, 1);
  55     _PostLogicalEventToUI(0x8AF, 1);    //RotateEDialRight
  56     _PostLogicalEventToUI(0x1135, 1);
  57 }
  58 
  59 void JogDial_CCW(void) {
  60     _PostLogicalEventToUI(0x1134, 1);
  61     _PostLogicalEventToUI(0x8B0, 1);    //RotateEDialLeft
  62     _PostLogicalEventToUI(0x1135, 1);
  63 }
  64 
  65 extern  int     active_raw_buffer;
  66 extern  char*   raw_buffers[];
  67 extern char* raw_buffers_canon_raw[];
  68 extern char* raw_buffers_jpeg[];
  69 
  70 char *hook_raw_image_addr()
  71 {
  72     // todo: untested
  73     int i=active_raw_buffer&3;
  74     if(i>2) i=0;
  75     return raw_buffers[i];
  76 }
  77 
  78 void *vid_get_viewport_fb_d() {
  79     extern void *current_fb_d;
  80     return current_fb_d;    // method from the sx60 and g7x ports
  81 }
  82 
  83 
  84 extern void* viewport_buffers[];
  85 extern void *current_viewport_buffer;
  86 
  87 void *vid_get_viewport_fb() {
  88     // Return first viewport buffer - for case when vid_get_viewport_live_fb not defined
  89     return viewport_buffers[0]; // 1st of 4 uyvy_d6 buffers
  90 }
  91 
  92 void *vid_get_viewport_live_fb()
  93 {
  94 // current_viewport_buffer doesn't seem to be most recent
  95     int i;
  96     for(i=0;i<4;i++) {
  97         if(current_viewport_buffer == viewport_buffers[i]) {
  98             return viewport_buffers[(i+1)&3];
  99         }
 100     }
 101     return 0;
 102 }
 103 
 104 int vid_get_viewport_width() {
 105     extern int _GetVRAMHPixelsSize();
 106     if (camera_info.state.mode_play)
 107     {
 108         return 720;
 109     }
 110 // TODO: currently using actual width rather than half width used on pre d6
 111 // pixel format is uyvy (16bpp)
 112     return _GetVRAMHPixelsSize();
 113 }
 114 
 115 long vid_get_viewport_height() {
 116     extern int _GetVRAMVPixelsSize();
 117     if (camera_info.state.mode_play)
 118     {
 119         return 480;
 120     }
 121         return _GetVRAMVPixelsSize();
 122 }
 123 
 124 int vid_get_viewport_yoffset() {
 125     // this seems to be always 0, buffer always begins with actual display data (widescreen or not)
 126     return 0;
 127 }
 128 
 129 // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1, 4 = 4:5
 130 static long vp_xo[5] = { 40, 0, 0, 120, 168 };                          // should all be even values for edge overlay
 131 
 132 int vid_get_viewport_display_xoffset() {
 133     if (camera_info.state.mode_play)
 134     {
 135         return 0;
 136     }
 137     // video, ignore still res propcase
 138     if(camera_info.state.mode_video || is_video_recording()) {
 139         if(shooting_get_prop(PROPCASE_VIDEO_RESOLUTION) == 2) {
 140             return 40;// 4:3 video
 141         } else {
 142             return 0; // 16:9 video, no x offset
 143         }
 144     }
 145     return vp_xo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 146 }
 147 
 148 int vid_get_viewport_display_yoffset() {
 149     if (camera_info.state.mode_play)
 150     {
 151         return 0;
 152     }
 153     // video, ignore still res propcase
 154     if(camera_info.state.mode_video || is_video_recording()) {
 155         if(shooting_get_prop(PROPCASE_VIDEO_RESOLUTION) == 2) {
 156             return 0; // 4:3 video, no Y offset
 157         } else {
 158             return 36; // 16:9 video
 159         }
 160     }
 161     if (shooting_get_prop(PROPCASE_ASPECT_RATIO) == 1)
 162     {
 163         return 36;
 164     }
 165     return 0;
 166 }
 167 
 168 extern int active_bitmap_buffer;
 169 extern char* bitmap_buffer[];
 170 
 171 int vid_get_viewport_type() {
 172 //    if (camera_info.state.mode_play)
 173         return LV_FB_YUV8B;
 174 //    return LV_FB_YUV8C;
 175 }
 176 
 177 
 178 void *vid_get_bitmap_fb() {
 179     // Return first bitmap buffer address
 180     return bitmap_buffer[0];
 181 }
 182 
 183 // Functions for PTP Live View system
 184 int vid_get_viewport_display_xoffset_proper()   { return vid_get_viewport_display_xoffset() ; }
 185 int vid_get_viewport_display_yoffset_proper()   { return vid_get_viewport_display_yoffset() ; }
 186 int vid_get_viewport_buffer_width_proper()              { return camera_screen.buffer_width ; }
 187 int vid_get_viewport_fullscreen_width()                 { return camera_screen.width; }
 188 int vid_get_viewport_byte_width()                               { return (camera_screen.buffer_width * 2); }
 189 
 190 int vid_get_viewport_fullscreen_height()        { return 480; }
 191 int vid_get_aspect_ratio()                      { return LV_ASPECT_3_2; }
 192 
 193 
 194 
 195 // the opacity buffer defines opacity for the bitmap overlay's pixels
 196 volatile char *opacity_buffer[2] = {(char*)0x5FD87300, (void*)0x5FD08A00};
 197 
 198 void *vid_get_bitmap_active_buffer() {
 199     return bitmap_buffer[active_bitmap_buffer&1];
 200 }
 201 
 202 void *vid_get_opacity_active_buffer() {
 203     return (void *)opacity_buffer[active_bitmap_buffer&1];
 204 }
 205 
 206 
 207 #ifdef CAM_SUPPORT_BITMAP_RES_CHANGE
 208 /*
 209  * needed because bitmap buffer resolutions change when an external display is used
 210  * an extra screen erase doesn't seem to be needed
 211  */
 212 void update_screen_dimensions() {
 213     // see sub_fc177316 in 110d for the values
 214     extern int displaytype;
 215     static int old_displaytype = -1;
 216 
 217     if (old_displaytype == displaytype) {
 218         return;
 219     }
 220     old_displaytype = displaytype;
 221 
 222     switch(displaytype) {
 223         case 0:
 224         case 3:
 225         case 4:
 226         case 5:
 227             // ?
 228             camera_screen.width = camera_screen.physical_width = camera_screen.buffer_width = 640;
 229             camera_screen.height = camera_screen.buffer_height = 480;
 230             camera_screen.size = camera_screen.buffer_size = 640*480;
 231             break;
 232         case 1:
 233         case 2:
 234         case 8:
 235         case 9:
 236             // tv-out (not implemented in hw)
 237             camera_screen.physical_width = camera_screen.width = 720;
 238             camera_screen.buffer_width = 736;
 239             camera_screen.height = camera_screen.buffer_height = 480;
 240             camera_screen.size = 720*480;
 241             camera_screen.buffer_size = 736*480;
 242             break;
 243         case 6:
 244         case 7:
 245             // hdmi
 246             camera_screen.width = camera_screen.physical_width = camera_screen.buffer_width = 960;
 247             camera_screen.height = camera_screen.buffer_height = 540;
 248             camera_screen.size = camera_screen.buffer_size = 960*540;
 249             break;
 250         case 10:
 251             // lcd (the real one)
 252             camera_screen.physical_width = camera_screen.width = 720;
 253             camera_screen.buffer_width = 736;
 254             camera_screen.height = camera_screen.buffer_height = 480;
 255             camera_screen.size = 720*480;
 256             camera_screen.buffer_size = 736*480;
 257             break;
 258         case 11:
 259             // lcd ? (invalid, buffer would overflow)
 260             camera_screen.width = camera_screen.physical_width = camera_screen.buffer_width = 1024;
 261             camera_screen.height = camera_screen.buffer_height = 768;
 262             camera_screen.size = camera_screen.buffer_size = 1024*768;
 263             break;
 264         case 12:
 265             // lcd ? (invalid, buffer would overflow)
 266             camera_screen.physical_width = camera_screen.width = 900;
 267             camera_screen.buffer_width = 928;
 268             camera_screen.height = camera_screen.buffer_height = 600;
 269             camera_screen.size = 900*600;
 270             camera_screen.buffer_size = 928*600;
 271             break;
 272     }
 273 }
 274 #endif
 275 
 276 char *camera_jpeg_count_str()
 277 {
 278     extern char jpeg_count_str[];
 279     return jpeg_count_str;
 280 }

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