root/platform/d30/lib.c

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

DEFINITIONS

This source file includes following definitions.
  1. hook_raw_image_addr
  2. hook_alt_raw_image_addr
  3. camera_jpeg_count_str
  4. vid_bitmap_refresh
  5. shutdown
  6. debug_led
  7. camera_set_led
  8. get_flash_params_count
  9. vid_get_viewport_fb
  10. vid_get_viewport_fb_d
  11. vid_get_viewport_live_fb
  12. vid_get_viewport_yscale
  13. vid_get_viewport_width
  14. vid_get_viewport_width_proper
  15. vid_get_viewport_fulllscreen_width
  16. vid_get_viewport_height
  17. vid_get_viewport_height_proper
  18. vid_get_viewport_fullscreen_height
  19. vid_get_viewport_display_xoffset
  20. vid_get_viewport_display_xoffset_proper
  21. vid_get_viewport_display_yoffset_proper
  22. vid_get_palette_type
  23. vid_get_palette_size
  24. vid_get_bitmap_fb
  25. vid_get_bitmap_active_buffer
  26. vid_get_bitmap_active_palette
  27. load_chdk_palette
  28. camera_jpeg_current_filename
  29. camera_jpeg_current_gps

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 extern  int     active_raw_buffer;
   6 extern  char*   raw_buffers[];
   7 
   8 char *hook_raw_image_addr()
   9 {
  10     return raw_buffers[active_raw_buffer];
  11 }
  12 
  13 char *hook_alt_raw_image_addr()
  14 {
  15     return raw_buffers[active_raw_buffer^1];
  16 }
  17 
  18 char *camera_jpeg_count_str()
  19 {
  20     extern char jpeg_count_str[];
  21     return jpeg_count_str;
  22 }
  23 
  24 void vid_bitmap_refresh()
  25 {
  26     extern int full_screen_refresh;
  27     extern void _ScreenUnlock();
  28     extern void _ScreenLock();
  29 
  30     _ScreenLock();
  31     full_screen_refresh |= 3;
  32     _ScreenUnlock();
  33 }
  34 
  35 #define GREEN_LED 0xC0220130
  36 #define AF_LED 0xC0223030
  37 void shutdown()
  38 {
  39     extern void _TurnOffE1(void);
  40     _TurnOffE1();
  41     while(1);
  42 }
  43 
  44 
  45 void debug_led(int state) {
  46     // using power LED, which defaults to on
  47     // for debugging turn LED off if state is 1 and on for state = 0
  48     // leaves LED on at end of debugging
  49      *(int*)GREEN_LED=state ? 0x46 : 0x44;
  50 }
  51 
  52 //TODO:
  53 // D30 has two 'lights' - Power LED, and AF assist lamp
  54 // Power Led = first entry in table (led ??)
  55 // AF Assist Lamp = second entry in table (led ??)
  56 void camera_set_led(int led, int state, int bright) {
  57     static char led_table[]={0,4}; // status, AF
  58     _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  59 }
  60 
  61 int get_flash_params_count(void) {
  62     return 0xA6;
  63 }
  64 
  65 // Viewport and Bitmap values that shouldn't change across firmware versions.
  66 // Values that may change are in lib.c for each firmware version.
  67 
  68 // Defined in stubs_entry.S
  69 extern char active_viewport_buffer;
  70 extern void* viewport_buffers[];
  71 
  72 void *vid_get_viewport_fb()
  73 {
  74     // Return first viewport buffer - for case when vid_get_viewport_live_fb not defined
  75     return viewport_buffers[0];
  76 }
  77 
  78 void *vid_get_viewport_fb_d()
  79 {
  80     extern char *viewport_fb_d;
  81     return viewport_fb_d;
  82 }
  83 
  84 void *vid_get_viewport_live_fb()
  85 {
  86     if (MODE_IS_VIDEO(mode_get()))
  87         return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
  88 
  89     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
  90     return viewport_buffers[(active_viewport_buffer-1)&3];
  91 }
  92 
  93 // Y multiplier for cameras with 480 pixel high viewports (CHDK code assumes 240)
  94 int vid_get_viewport_yscale() {
  95     return 2;
  96 }
  97 
  98 extern int _GetVRAMHPixelsSize();
  99 extern int _GetVRAMVPixelsSize();
 100 
 101 int vid_get_viewport_width()
 102 {
 103         return 720;
 104 }
 105 
 106 int vid_get_viewport_width_proper() {
 107     return ((mode_get()&MODE_MASK) == MODE_PLAY)?720:_GetVRAMHPixelsSize();
 108 }
 109 
 110 int vid_get_viewport_fulllscreen_width()
 111 {
 112     return 720;
 113 }
 114 
 115 long vid_get_viewport_height()
 116 {
 117     return 480;
 118 }
 119 
 120 int vid_get_viewport_height_proper()
 121 {
 122     int m = mode_get();
 123     int aspect_ratio=shooting_get_prop(PROPCASE_ASPECT_RATIO);
 124 
 125     if (MODE_IS_VIDEO(m) || is_video_recording())
 126         return 240;
 127 
 128     if ((m & MODE_MASK) != MODE_PLAY) {
 129 // This mode causes problems to liveview, see notes.txt
 130 //        if((m&MODE_SHOOTING_MASK) == MODE_VIDEO_MOVIE_DIGEST)
 131 //            return 480;
 132 
 133         // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 134         if (aspect_ratio==1 || aspect_ratio==2)
 135             return 480;
 136     }
 137     return ((m & MODE_MASK) == MODE_PLAY)?480:_GetVRAMVPixelsSize();
 138 }
 139 
 140 int vid_get_viewport_fullscreen_height()
 141 {
 142     return vid_get_viewport_height_proper();
 143 }
 144 
 145 // viewport width offset table for each aspect ratio
 146 // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 147 static long vp_xo[4] = { 0, 0, 0, 44 };        // should all be even values for edge overlay
 148 
 149 int vid_get_viewport_display_xoffset()
 150 {
 151     int m = mode_get();
 152     int aspect_ratio=shooting_get_prop(PROPCASE_ASPECT_RATIO);
 153 
 154     if ((m & MODE_MASK) != MODE_PLAY) {
 155         return (vp_xo[aspect_ratio]);
 156     }
 157     else
 158         return 0;
 159 }
 160 
 161 // Functions for PTP Live View system
 162 int vid_get_viewport_display_xoffset_proper()   { return vid_get_viewport_display_xoffset()<<1; }
 163 int vid_get_viewport_display_yoffset_proper()   { return vid_get_viewport_display_yoffset()<<1; }
 164 
 165 int vid_get_palette_type()                      { return 3; }
 166 int vid_get_palette_size()                      { return 256 * 4; }
 167 
 168 extern int active_bitmap_buffer;
 169 extern char* bitmap_buffer[];
 170 
 171 void *vid_get_bitmap_fb() {
 172     // Return first bitmap buffer address
 173     return bitmap_buffer[0];
 174 }
 175 
 176 void *vid_get_bitmap_active_buffer() {
 177     return bitmap_buffer[active_bitmap_buffer];
 178 }
 179 
 180 #ifdef CAM_LOAD_CUSTOM_COLORS
 181 void *vid_get_bitmap_active_palette() {
 182     extern int active_palette_buffer;
 183     extern char* palette_buffer[];
 184     return (palette_buffer[active_palette_buffer]+4);
 185 }
 186 
 187 // Function to load CHDK custom colors into active Canon palette
 188 void load_chdk_palette()
 189 {
 190     extern int active_palette_buffer;
 191     // Only load for the standard record and playback palettes
 192     //rec=0, set menu=, play=, menu=
 193     if ((active_palette_buffer == 0) || (active_palette_buffer == 5))
 194     {
 195         int *pal = (int*)vid_get_bitmap_active_palette();
 196         if (pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
 197         {
 198             pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
 199             pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
 200             pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
 201             pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
 202             pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
 203             pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
 204             pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
 205             pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
 206             pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
 207             pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
 208             pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
 209             pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
 210             pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
 211 
 212             extern char palette_control;
 213             palette_control = 1;
 214             vid_bitmap_refresh();
 215         }
 216     }
 217 }
 218 #endif
 219 
 220 //Unchecked, copied from D20
 221 char *camera_jpeg_current_filename() {
 222      return (void*)0xBD06C;                 //0xFF1E2E88 search for  "%03d-%04d"
 223 }
 224 
 225 char *camera_jpeg_current_gps() {
 226     return (void*)0xBD0E0;
 227 }

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