root/platform/sx510hs/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. vid_get_bitmap_fb
  7. get_flash_params_count
  8. debug_led
  9. camera_set_led
  10. vid_get_viewport_fb
  11. vid_get_viewport_fb_d
  12. vid_get_viewport_live_fb
  13. vid_get_viewport_yscale
  14. vid_get_viewport_width
  15. vid_get_viewport_fulllscreen_width
  16. vid_get_viewport_height
  17. vid_get_viewport_display_xoffset
  18. vid_get_viewport_display_xoffset_proper
  19. vid_get_viewport_display_yoffset_proper
  20. vid_get_viewport_height_proper
  21. vid_get_viewport_fullscreen_height
  22. vid_get_palette_type
  23. vid_get_palette_size
  24. vid_get_bitmap_active_palette
  25. load_chdk_palette
  26. JogDial_CW
  27. JogDial_CCW

   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 _ScreenLock();
  28     extern void _ScreenUnlock();
  29 
  30     full_screen_refresh |= 3;
  31     _ScreenLock();
  32     _ScreenUnlock();
  33 }
  34 
  35 #define LED_PR 0xC022302C
  36 #define AF_LED 0xC0223030
  37 void shutdown()
  38 {
  39     extern void _TurnOffE1(void);
  40     _TurnOffE1();
  41     while(1);
  42 }
  43 
  44 void *vid_get_bitmap_fb()        { return (void*)0x406f1000; }             // Found @0xff049118
  45 int get_flash_params_count(void) { return 0x99; }                          // Found @0xff1eb3e4
  46 
  47 
  48 void debug_led(int state)
  49 {
  50     volatile long *p=(void*)LED_PR;
  51     if (state)
  52         p[0]=0x46;
  53     else
  54         p[0]=0x44;
  55 }
  56 
  57 void camera_set_led(int led, int state, int bright) {
  58     static char led_table[]={0,12}; // status, AF
  59     _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  60 }
  61 
  62 extern char active_viewport_buffer;
  63 extern void* viewport_buffers[];
  64 
  65 void *vid_get_viewport_fb()
  66 {
  67     // Return first viewport buffer - for case when vid_get_viewport_live_fb not defined
  68     return viewport_buffers[0];
  69 }
  70 
  71 void *vid_get_viewport_fb_d()
  72 {
  73     extern char *viewport_fb_d;
  74     return viewport_fb_d;
  75 }
  76 
  77 void *vid_get_viewport_live_fb()
  78 {
  79     if (MODE_IS_VIDEO(mode_get()) || is_video_recording())
  80         return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
  81 
  82     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
  83     // verified -1 gives best response
  84     return viewport_buffers[(active_viewport_buffer-1)&3];
  85 }
  86 
  87 // Y multiplier for cameras with 480 pixel high viewports (CHDK code assumes 240)
  88 int vid_get_viewport_yscale() {
  89     return 2;
  90 }
  91 
  92 int vid_get_viewport_width()
  93 {
  94     if (camera_info.state.mode_play)
  95     {
  96         return 360;
  97     }
  98     extern int _GetVRAMHPixelsSize();
  99     return _GetVRAMHPixelsSize() >> 1;
 100 }
 101 
 102 int vid_get_viewport_fulllscreen_width()
 103 {
 104     return 720;
 105 }
 106 
 107 long vid_get_viewport_height()
 108 {
 109 
 110     int m = mode_get();
 111     int aspect_ratio=shooting_get_prop(PROPCASE_ASPECT_RATIO);
 112 
 113     if (MODE_IS_VIDEO(m) || is_video_recording())
 114         return 240;
 115 
 116     if ((m & MODE_MASK) != MODE_PLAY) 
 117     {
 118         // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 119         if (aspect_ratio==1 || aspect_ratio==2)
 120             return 240;
 121     }
 122     extern int _GetVRAMVPixelsSize();    
 123     return ((m & MODE_MASK) == MODE_PLAY)?240:_GetVRAMVPixelsSize()>>1;
 124 }
 125 
 126 // viewport width offset table for each aspect ratio
 127 // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 128 static long vp_xo[4] = { 0, 0, 0, 44 };        // should all be even values for edge overlay
 129 
 130 int vid_get_viewport_display_xoffset()
 131 {
 132     int m = mode_get();
 133     int aspect_ratio=shooting_get_prop(PROPCASE_ASPECT_RATIO);
 134 
 135     if ((m & MODE_MASK) != MODE_PLAY) {
 136         return (vp_xo[aspect_ratio]);
 137     }
 138     else
 139         return 0;
 140 }
 141 
 142 int vid_get_viewport_display_xoffset_proper()   { return vid_get_viewport_display_xoffset()<<1; }
 143 int vid_get_viewport_display_yoffset_proper()   { return vid_get_viewport_display_yoffset()<<1; }
 144 int vid_get_viewport_height_proper()            { return vid_get_viewport_height() * 2; }
 145 int vid_get_viewport_fullscreen_height()        { return 480; }
 146 int vid_get_palette_type()                      { return 3; }
 147 int vid_get_palette_size()                      { return 256 * 4; }
 148 
 149 
 150 #ifdef CAM_LOAD_CUSTOM_COLORS
 151 void *vid_get_bitmap_active_palette()
 152 {
 153     extern int active_palette_buffer;
 154     extern int** palette_buffer_ptr;
 155     int *p = palette_buffer_ptr[active_palette_buffer];
 156     // active_palette_buffer can point at null when
 157     // func and menu are opened for the first time
 158     if(!p) {
 159         p = palette_buffer_ptr[0]; // rec mode buffer appears to always be initialized
 160     }
 161     return (p+1);
 162 }
 163 
 164 // Function to load CHDK custom colors into active Canon palette
 165 void load_chdk_palette()
 166 {
 167     extern int active_palette_buffer;
 168     // Only load for the standard record and playback palettes
 169     if ((active_palette_buffer == 0) || (active_palette_buffer == 5))
 170     {
 171         int *pal = (int*)vid_get_bitmap_active_palette();
 172         if (pal[CHDK_COLOR_BASE+0] != 0x3F3ADF62)
 173         {
 174             pal[CHDK_COLOR_BASE+0]  = 0x3F3ADF62;  // Red
 175             pal[CHDK_COLOR_BASE+1]  = 0x3F26EA40;  // Dark Red
 176             pal[CHDK_COLOR_BASE+2]  = 0x3F4CD57F;  // Light Red
 177             pal[CHDK_COLOR_BASE+5]  = 0x3F73BFAE;  // Green
 178             pal[CHDK_COLOR_BASE+6]  = 0x3F4BD6CA;  // Dark Green
 179             pal[CHDK_COLOR_BASE+7]  = 0x3F95AB95;  // Light Green
 180             pal[CHDK_COLOR_BASE+8]  = 0x3F4766F0;  // Blue
 181             pal[CHDK_COLOR_BASE+9]  = 0x3F1250F3;  // Dark Blue
 182             pal[CHDK_COLOR_BASE+10] = 0x3F7F408F;  // Cyan
 183             pal[CHDK_COLOR_BASE+11] = 0x3F512D5B;  // Magenta
 184             pal[CHDK_COLOR_BASE+12] = 0x3FA9A917;  // Yellow
 185             pal[CHDK_COLOR_BASE+13] = 0x3F819137;  // Dark Yellow
 186             pal[CHDK_COLOR_BASE+14] = 0x3FDED115;  // Light Yellow
 187 
 188             extern char palette_control;
 189             palette_control = 1;
 190             vid_bitmap_refresh();
 191         }
 192     }
 193 }
 194 #endif
 195 
 196 void JogDial_CW(void)
 197 {
 198     _PostLogicalEventToUI(0x872, 1);  // RotateJogDialRight (in table @ ????, fw 1.01a)
 199 }
 200 
 201 void JogDial_CCW(void)
 202 {
 203     _PostLogicalEventToUI(0x873, 1);  // RotateJogDialLeft (in table @ ???, fw 1.01a)
 204 }

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