root/platform/sx280hs/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_d
  12. vid_get_viewport_fb
  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_display_xoffset_proper
  21. vid_get_viewport_display_yoffset_proper
  22. vid_get_viewport_fullscreen_height
  23. vid_get_viewport_buffer_width_proper
  24. vid_get_viewport_byte_width
  25. vid_get_viewport_type
  26. vid_get_bitmap_active_buffer
  27. vid_get_opacity_active_buffer
  28. update_screen_dimensions

   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);
  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     _PostLogicalEventForNotPowerType(0x1005,0);
  45 }
  46 
  47 int get_flash_params_count(void) {
  48     return 0x91;
  49 }
  50 
  51 void JogDial_CW(void) {
  52     _PostLogicalEventToUI(0x872, 1);    //RotateJogDialRight
  53 }
  54 
  55 void JogDial_CCW(void) {
  56     _PostLogicalEventToUI(0x873, 1);    //RotateJogDialLeft
  57 }
  58 
  59 extern  int     active_raw_buffer;
  60 extern  char*   raw_buffers[];
  61 
  62 char *hook_raw_image_addr()
  63 {
  64     return raw_buffers[(active_raw_buffer&1)];
  65 }
  66 
  67 char *hook_alt_raw_image_addr()
  68 {
  69     return raw_buffers[((active_raw_buffer&1)^1)];
  70 }
  71 
  72 /*
  73     Playback mode framebuffers (uyvy_d6)
  74     resolution according to output device (HDMI case unknown, there's space for full HD)
  75     0x4eb68000, 0x4ef68000, 0x4f368000
  76     @ 0xfc937e04 (0080364F 01000000 00000000 0080F64E 01000000 00000000 0080B64E 01000000 00000000)
  77     aka 0xd990 in RAM (102b)
  78 */
  79 void *vid_get_viewport_fb_d() {
  80     extern void *current_fb_d;
  81     return current_fb_d;    // method from the sx60 and g7x ports
  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     //return (void*)0x4b25fc00; // uyvy buffers (more than 4), pixel format compatible with earlier DIGIC uyvy
  91 }
  92 
  93 void *vid_get_viewport_live_fb() {
  94     /*
  95     1)  4 live buffers starting @ 0x43115100, change dimensions when changing output device, uyvy_d6
  96         size of 1 buffer is 0xae800 bytes (not enough for HDMI 960x540, but there's no live view through HDMI anyway)
  97         address list @ 0xfc4d3568 (102b)
  98     2)  8 live buffers starting @ 0x4B25FC00, fixed 640x480, old uyvy
  99         size of 1 buffer is 0x96000 bytes (640*480*2)
 100         address list @ 0xfc4d3578, listed in reverse order (102b)
 101     3)  3 live buffers (probably only active when half shooting) starting @ 0x4B70FC00, 1280x960, old uyvy
 102         size of 1 buffer is 0x26ac00 bytes (1280x990)
 103         address list @ 0xfc4d35d8, listed in reverse order (102b)
 104     */
 105 
 106     // implementation is from the g7x port, including the comment
 107 
 108     // current_viewport_buffer doesn't seem to be most recent
 109     int i;
 110     for(i=0;i<4;i++) {
 111         if(current_viewport_buffer == viewport_buffers[i]) {
 112             return viewport_buffers[(i+1)&3];
 113         }
 114     }
 115     return 0;
 116 }
 117 
 118 int vid_get_viewport_width() {
 119 /*
 120 loc_fc134980: ; 4 refs (GetVRAMHPixelsSize)
 121 fc134980:   487d        ldr r0, [pc, #500]  ; 0xfc134b78: (0002ca18) 
 122 fc134982:   f8d0 00ac   ldr.w   r0, [r0, #172]  ; 0xac
 123 fc134986:   4770        bx  lr
 124 */
 125     extern int _GetVRAMHPixelsSize();
 126 // TODO: this is the actual width, pixel format is uyvy (16bpp)
 127     if (camera_info.state.mode_play)
 128         return camera_screen.physical_width;
 129     return _GetVRAMHPixelsSize();
 130 }
 131 
 132 long vid_get_viewport_height() {
 133 /*
 134 loc_fc134988: ; 3 refs (GetVRAMVPixelsSize)
 135 fc134988:   487b        ldr r0, [pc, #492]  ; 0xfc134b78: (0002ca18) 
 136 fc13498a:   f8d0 00b0   ldr.w   r0, [r0, #176]  ; 0xb0
 137 fc13498e:   4770        bx  lr
 138 */
 139     extern int _GetVRAMVPixelsSize();
 140 // return half height
 141     if (camera_info.state.mode_play)
 142         return camera_screen.buffer_height;
 143     return _GetVRAMVPixelsSize();
 144 }
 145 
 146 int vid_get_viewport_yoffset() {
 147     // this seems to be always 0, buffer always begins with actual display data (widescreen or not)
 148     return 0;
 149 }
 150 
 151 int vid_get_viewport_display_xoffset() {
 152     return 0;
 153 }
 154 
 155 int vid_get_viewport_display_yoffset() {
 156     return 0;
 157 }
 158 
 159 extern int active_bitmap_buffer;
 160 extern char* bitmap_buffer[];
 161 
 162 void *vid_get_bitmap_fb() {
 163     // Return first bitmap buffer address
 164     return bitmap_buffer[0];
 165 }
 166 
 167 // Functions for PTP Live View system
 168 int vid_get_viewport_display_xoffset_proper()   { return vid_get_viewport_display_xoffset(); }
 169 int vid_get_viewport_display_yoffset_proper()   { return vid_get_viewport_display_yoffset(); }
 170 int vid_get_viewport_fullscreen_height()        { return camera_screen.height; } // may not be always ok
 171 int vid_get_viewport_buffer_width_proper()      { return camera_screen.buffer_width; } // may not be always ok
 172 int vid_get_viewport_byte_width()               { return camera_screen.buffer_width * 2; } // may not be always ok
 173 
 174 int vid_get_viewport_type() {
 175     /*
 176     // no longer needed, other viewports are used instead
 177     if (camera_info.state.mode_play)
 178         return LV_FB_YUV8B;
 179     */
 180     return LV_FB_YUV8B;
 181 }
 182 
 183 void *vid_get_bitmap_active_buffer() {
 184     return bitmap_buffer[active_bitmap_buffer&1];
 185 }
 186 
 187 // the opacity buffer defines opacity for the bitmap overlay's pixels
 188 volatile char *opacity_buffer[2] = {(char*)0x41718600, (char*)0x41796f00};
 189 
 190 void *vid_get_opacity_active_buffer() {
 191     return (void *)opacity_buffer[active_bitmap_buffer&1];
 192 }
 193 
 194 #ifdef CAM_SUPPORT_BITMAP_RES_CHANGE
 195 /*
 196  * needed because bitmap buffer resolutions change when an external display is used
 197  * an extra screen erase doesn't seem to be needed
 198  */
 199 void update_screen_dimensions() {
 200     // see sub_fc18618a in 102b and 102c for the values
 201     extern int displaytype;
 202     static int old_displaytype = -1;
 203 
 204     if (old_displaytype == displaytype) {
 205         return;
 206     }
 207     old_displaytype = displaytype;
 208 
 209     switch(displaytype) {
 210         case 0:
 211         case 3:
 212         case 4:
 213         case 5:
 214             // lcd
 215             camera_screen.width = camera_screen.physical_width = camera_screen.buffer_width = 640;
 216             camera_screen.height = camera_screen.buffer_height = 480;
 217             camera_screen.size = camera_screen.buffer_size = 640*480;
 218             break;
 219         case 1:
 220         case 2:
 221         case 8:
 222         case 9:
 223             // tv-out
 224             camera_screen.width = 720;
 225             camera_screen.physical_width = camera_screen.buffer_width = 736;
 226             camera_screen.height = camera_screen.buffer_height = 480;
 227             camera_screen.size = 720*480;
 228             camera_screen.buffer_size = 736*480;
 229             break;
 230         case 6:
 231         case 7:
 232             // hdmi
 233             camera_screen.width = camera_screen.physical_width = camera_screen.buffer_width = 960;
 234             camera_screen.height = camera_screen.buffer_height = 540;
 235             camera_screen.size = camera_screen.buffer_size = 960*540;
 236             break;
 237     }
 238 }
 239 #endif
 240 

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