root/platform/a495/lib.c

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

DEFINITIONS

This source file includes following definitions.
  1. hook_raw_image_addr
  2. shutdown
  3. debug_led
  4. camera_set_led
  5. camera_jpeg_count_str
  6. vid_bitmap_refresh
  7. get_flash_params_count
  8. _GetBatteryTemperature
  9. vid_get_bitmap_active_palette
  10. vid_get_palette_type
  11. vid_get_palette_size
  12. vid_get_bitmap_active_buffer
  13. vid_get_viewport_fb
  14. vid_get_viewport_live_fb
  15. vid_get_viewport_fb_d
  16. vid_get_bitmap_fb
  17. vid_get_viewport_yoffset
  18. vid_get_viewport_width
  19. vid_get_viewport_width_proper
  20. vid_get_viewport_height
  21. vid_get_viewport_height_proper
  22. vid_get_viewport_fullscreen_height
  23. vid_get_viewport_display_xoffset_proper
  24. vid_get_viewport_display_yoffset_proper

   1 #include "platform.h"
   2 #include "lolevel.h"
   3 
   4 char *hook_raw_image_addr()
   5 {
   6     return (char*) 0x10E52420;
   7 }
   8 
   9 /*long hook_raw_size() {
  10     //CAM_RAW_ROWS * ((CAM_RAW_ROWPIX*CAM_SENSOR_BITS_PER_PIXEL)/8)
  11     return 0x00ec04f0;
  12 }*/
  13 
  14 // only two LEDs in A495:
  15 #define LED_PR 0xC0220088  // green LED
  16 #define LED_AF 0xC0220080  // orange AF LED
  17 
  18 
  19 void shutdown()
  20 {
  21     volatile long *p = (void*)LED_PR;    // Green LED
  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     *p = 0x44;  // power off.
  31 
  32     while(1);
  33 }
  34 
  35 
  36 void debug_led(int state)
  37 {
  38     *(int*)LED_PR=state ? 0x46 : 0x44;
  39 }
  40 
  41 // A495 has 2 led values
  42 // 0/7 - Power LED Green
  43 // 1/9 - AF LED Orange
  44 void camera_set_led(int led, int state, int bright) {
  45     static char led_table[2]={7,9};
  46     if(state<=1) _LEDDrive(led_table[led%sizeof(led_table)], (!state)&1);
  47 }
  48 
  49 char *camera_jpeg_count_str()
  50 {
  51     extern char jpeg_count_str[];
  52     return jpeg_count_str;
  53 }
  54 
  55 
  56 void vid_bitmap_refresh() {
  57     extern int enabled_refresh_physical_screen;
  58     extern int full_screen_refresh;
  59 
  60     // asm1989: i've tried refreshphysical screen (screen unlock) and that caused the canon and
  61     // function menu to not display at all. This seems to work and is called in a similar
  62     // way in other places where original OSD should be refreshed.
  63     extern void _ScreenLock();
  64     extern void _ScreenUnlock();
  65 
  66     _ScreenLock();
  67 
  68     enabled_refresh_physical_screen=1;
  69     full_screen_refresh=3;   // found in ScreenUnlock underneath a CameraLog.c call
  70 
  71     _ScreenUnlock();
  72 }
  73 
  74 
  75 int get_flash_params_count(void){
  76     return 0x94;  //found by finsig
  77 }
  78 
  79 
  80 // This camera crashes if GetBatteryTemperature is called, override auto detected stub
  81 int _GetBatteryTemperature()
  82 {
  83       return -99;
  84 }
  85 
  86 // Functions for PTP Live View system
  87 
  88 void *vid_get_bitmap_active_palette() {
  89         return (void*)(*(int*)(0x4970+0x20));  //Found @ 0xffcd1e80 a495 100f
  90 }
  91 
  92 // 64 entry palette based on 100f 0xffcd1e80
  93 int vid_get_palette_type()                      { return 4; }
  94 int vid_get_palette_size()                      { return 16*4; }
  95 
  96 void *vid_get_bitmap_active_buffer()
  97 {
  98     return (void*)(*(int*)(0x4970+0xC)); //found @ 0xffcd1f3c a495 100f
  99 }
 100 
 101 
 102 // Viewport and Bitmap values that shouldn't change across firmware versions.
 103 // Values that may change are in lib.c for each firmware version.
 104 
 105 // Defined in stubs_min.S
 106 extern char active_viewport_buffer;
 107 extern void* viewport_buffers[];
 108 
 109 void *vid_get_viewport_fb()
 110 {
 111     // Return first viewport buffer - for case when vid_get_viewport_live_fb not defined
 112     return viewport_buffers[0];
 113 }
 114 
 115 void *vid_get_viewport_live_fb()
 116 {
 117     if (MODE_IS_VIDEO(mode_get()) || is_video_recording())
 118         return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
 119 
 120     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
 121     return viewport_buffers[(active_viewport_buffer)&3];
 122 }
 123 
 124 void *vid_get_viewport_fb_d()
 125 {
 126     extern char *viewport_fb_d;
 127     return viewport_fb_d;
 128 }
 129 
 130 void *vid_get_bitmap_fb(){
 131     return (void*)0x10361000; // Found @0xffc3f020
 132 }
 133 
 134 int vid_get_viewport_yoffset() {
 135     return 0;
 136 }
 137 
 138 extern int _GetVRAMHPixelsSize();
 139 extern int _GetVRAMVPixelsSize();
 140 
 141 int vid_get_viewport_width() {
 142     return 360;
 143 }
 144 
 145 int vid_get_viewport_width_proper() {
 146     return ((mode_get()&MODE_MASK) == MODE_PLAY)?720:_GetVRAMHPixelsSize();
 147 }
 148 
 149 long vid_get_viewport_height() {
 150     return 240;
 151 }
 152 
 153 int vid_get_viewport_height_proper() {
 154     int m = mode_get();
 155     // special case: W resolution
 156     if ((m&MODE_MASK) != MODE_PLAY && shooting_get_prop(PROPCASE_RESOLUTION) == 8) {
 157         return 240;
 158     }
 159     return ((mode_get()&MODE_MASK) == MODE_PLAY)?240:_GetVRAMVPixelsSize();
 160 }
 161 
 162 int vid_get_viewport_fullscreen_height() {
 163     int m = mode_get();
 164     // special case: W resolution
 165     if ((m&MODE_MASK) != MODE_PLAY && shooting_get_prop(PROPCASE_RESOLUTION) == 8) {
 166         return 120;
 167     }
 168     return ((mode_get()&MODE_MASK) == MODE_PLAY)?240:_GetVRAMVPixelsSize();
 169 }
 170 
 171 int vid_get_viewport_display_xoffset_proper()   { return vid_get_viewport_display_xoffset(); }
 172 int vid_get_viewport_display_yoffset_proper()   { return vid_get_viewport_display_yoffset(); }
 173 

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