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(0x872, 1);    //RotateJogDialRight
  55 }
  56 
  57 void JogDial_CCW(void) {
  58     _PostLogicalEventToUI(0x873, 1);    //RotateJogDialLeft
  59 }
  60 
  61 extern  int     active_raw_buffer;
  62 extern  char*   raw_buffers[];
  63 extern char* raw_buffers_canon_raw[];
  64 extern char* raw_buffers_jpeg[];
  65 
  66 char *hook_raw_image_addr()
  67 {
  68     // todo: untested
  69     int i=active_raw_buffer&3;
  70     if(i>2) i=0;
  71     return raw_buffers[i];
  72 }
  73 
  74 void *vid_get_viewport_fb_d() {
  75     extern void *current_fb_d;
  76     return current_fb_d;    // method from the sx60 and g7x ports
  77 }
  78 
  79 
  80 extern void* viewport_buffers[];
  81 extern void *current_viewport_buffer;
  82 
  83 void *vid_get_viewport_fb() {
  84     // Return first viewport buffer - for case when vid_get_viewport_live_fb not defined
  85     return viewport_buffers[0]; // 1st of 4 uyvy_d6 buffers
  86 }
  87 
  88 void *vid_get_viewport_live_fb()
  89 {
  90 // current_viewport_buffer doesn't seem to be most recent
  91     int i;
  92     for(i=0;i<4;i++) {
  93         if(current_viewport_buffer == viewport_buffers[i]) {
  94             return viewport_buffers[(i+1)&3];
  95         }
  96     }
  97     return 0;
  98 }
  99 
 100 int vid_get_viewport_width() {
 101     extern int _GetVRAMHPixelsSize();
 102     if (camera_info.state.mode_play)
 103     {
 104         return 720;
 105     }
 106 // TODO: currently using actual width rather than half width used on pre d6
 107 // pixel format is uyvy (16bpp)
 108     return _GetVRAMHPixelsSize();
 109 }
 110 
 111 long vid_get_viewport_height() {
 112     extern int _GetVRAMVPixelsSize();
 113     if (camera_info.state.mode_play)
 114     {
 115         return 480;
 116     }
 117         return _GetVRAMVPixelsSize();
 118 }
 119 
 120 int vid_get_viewport_yoffset() {
 121     // this seems to be always 0, buffer always begins with actual display data (widescreen or not)
 122     return 0;
 123 }
 124 
 125 // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1, 4 = 4:5
 126 static long vp_xo[5] = { 40, 0, 0, 120, 168 };                          // should all be even values for edge overlay
 127 
 128 int vid_get_viewport_display_xoffset() {
 129     if (camera_info.state.mode_play)
 130     {
 131         return 0;
 132     }
 133     // video, ignore still res propcase
 134     if(camera_info.state.mode_video || is_video_recording()) {
 135         if(shooting_get_prop(PROPCASE_VIDEO_RESOLUTION) == 2) {
 136             return 40;// 4:3 video
 137         } else {
 138             return 0; // 16:9 video, no x offset
 139         }
 140     }
 141     return vp_xo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 142 }
 143 
 144 int vid_get_viewport_display_yoffset() {
 145     if (camera_info.state.mode_play)
 146     {
 147         return 0;
 148     }
 149     // video, ignore still res propcase
 150     if(camera_info.state.mode_video || is_video_recording()) {
 151         if(shooting_get_prop(PROPCASE_VIDEO_RESOLUTION) == 2) {
 152             return 0; // 4:3 video, no Y offset
 153         } else {
 154             return 36; // 16:9 video
 155         }
 156     }
 157     if (shooting_get_prop(PROPCASE_ASPECT_RATIO) == 1)
 158     {
 159         return 36;
 160     }
 161     return 0;
 162 }
 163 
 164 extern int active_bitmap_buffer;
 165 extern char* bitmap_buffer[];
 166 
 167 int vid_get_viewport_type() {
 168 //    if (camera_info.state.mode_play)
 169         return LV_FB_YUV8B;
 170 //    return LV_FB_YUV8C;
 171 }
 172 
 173 
 174 void *vid_get_bitmap_fb() {
 175     // Return first bitmap buffer address
 176     return bitmap_buffer[0];
 177 }
 178 
 179 // Functions for PTP Live View system
 180 int vid_get_viewport_display_xoffset_proper()   { return vid_get_viewport_display_xoffset() ; }
 181 int vid_get_viewport_display_yoffset_proper()   { return vid_get_viewport_display_yoffset() ; }
 182 int vid_get_viewport_buffer_width_proper()              { return camera_screen.buffer_width ; }
 183 int vid_get_viewport_fullscreen_width()                 { return camera_screen.width; }
 184 int vid_get_viewport_byte_width()                               { return (camera_screen.buffer_width * 2); }
 185 
 186 int vid_get_viewport_fullscreen_height()        { return 480; }
 187 int vid_get_aspect_ratio()                      { return LV_ASPECT_3_2; }
 188 
 189 
 190 
 191 // the opacity buffer defines opacity for the bitmap overlay's pixels
 192 volatile char *opacity_buffer[2] = {(char*)0x5FD87300, (void*)0x5FD08A00};
 193 
 194 void *vid_get_bitmap_active_buffer() {
 195     return bitmap_buffer[active_bitmap_buffer&1];
 196 }
 197 
 198 void *vid_get_opacity_active_buffer() {
 199     return (void *)opacity_buffer[active_bitmap_buffer&1];
 200 }
 201 
 202 
 203 #ifdef CAM_SUPPORT_BITMAP_RES_CHANGE
 204 /*
 205  * needed because bitmap buffer resolutions change when an external display is used
 206  * an extra screen erase doesn't seem to be needed
 207  */
 208 void update_screen_dimensions() {
 209     // see sub_fc177316 in 110d for the values
 210     extern int displaytype;
 211     static int old_displaytype = -1;
 212 
 213     if (old_displaytype == displaytype) {
 214         return;
 215     }
 216     old_displaytype = displaytype;
 217 
 218     switch(displaytype) {
 219         case 0:
 220         case 3:
 221         case 4:
 222         case 5:
 223             // ?
 224             camera_screen.width = camera_screen.physical_width = camera_screen.buffer_width = 640;
 225             camera_screen.height = camera_screen.buffer_height = 480;
 226             camera_screen.size = camera_screen.buffer_size = 640*480;
 227             break;
 228         case 1:
 229         case 2:
 230         case 8:
 231         case 9:
 232             // tv-out (not implemented in hw)
 233             camera_screen.physical_width = camera_screen.width = 720;
 234             camera_screen.buffer_width = 736;
 235             camera_screen.height = camera_screen.buffer_height = 480;
 236             camera_screen.size = 720*480;
 237             camera_screen.buffer_size = 736*480;
 238             break;
 239         case 6:
 240         case 7:
 241             // hdmi
 242             camera_screen.width = camera_screen.physical_width = camera_screen.buffer_width = 960;
 243             camera_screen.height = camera_screen.buffer_height = 540;
 244             camera_screen.size = camera_screen.buffer_size = 960*540;
 245             break;
 246         case 10:
 247             // lcd (the real one)
 248             camera_screen.physical_width = camera_screen.width = 720;
 249             camera_screen.buffer_width = 736;
 250             camera_screen.height = camera_screen.buffer_height = 480;
 251             camera_screen.size = 720*480;
 252             camera_screen.buffer_size = 736*480;
 253             break;
 254         case 11:
 255             // lcd ? (invalid, buffer would overflow)
 256             camera_screen.width = camera_screen.physical_width = camera_screen.buffer_width = 1024;
 257             camera_screen.height = camera_screen.buffer_height = 768;
 258             camera_screen.size = camera_screen.buffer_size = 1024*768;
 259             break;
 260         case 12:
 261             // lcd ? (invalid, buffer would overflow)
 262             camera_screen.physical_width = camera_screen.width = 900;
 263             camera_screen.buffer_width = 928;
 264             camera_screen.height = camera_screen.buffer_height = 600;
 265             camera_screen.size = 900*600;
 266             camera_screen.buffer_size = 928*600;
 267             break;
 268     }
 269 }
 270 #endif
 271 
 272 char *camera_jpeg_count_str()
 273 {
 274     extern char jpeg_count_str[];
 275     return jpeg_count_str;
 276 }

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