root/platform/sx500is/lib.c

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

DEFINITIONS

This source file includes following definitions.
  1. camera_jpeg_count_str
  2. shutdown
  3. debug_led
  4. camera_set_led
  5. get_flash_params_count
  6. JogDial_CW
  7. JogDial_CCW
  8. vid_get_viewport_width
  9. vid_get_viewport_height
  10. vid_get_viewport_fb
  11. vid_get_viewport_live_fb
  12. vid_get_viewport_fb_d
  13. vid_get_bitmap_fb
  14. vid_bitmap_refresh
  15. vid_get_bitmap_active_palette
  16. vid_get_bitmap_active_buffer
  17. load_chdk_palette
  18. vid_get_palette_type
  19. vid_get_palette_size

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 
   6 char *camera_jpeg_count_str()
   7 {
   8     extern char jpeg_count_str[];
   9     return jpeg_count_str;
  10 }
  11 
  12 //To do: Check this address
  13 #define LED_PR 0xC0220120
  14 
  15 void shutdown()
  16 {
  17     volatile long *p = (void*)LED_PR;
  18 
  19     asm(
  20         "MRS     R1, CPSR\n"
  21         "AND     R0, R1, #0x80\n"
  22         "ORR     R1, R1, #0x80\n"
  23         "MSR     CPSR_cf, R1\n"
  24         :::"r1","r0");
  25 
  26     *p = 0x44;  // power off.
  27 
  28     while(1);
  29 }
  30 
  31 void debug_led(int state)
  32 {
  33         // using power LED, which defaults to on
  34         // for debugging turn LED off if state is 1 and on for state = 0
  35      *(int*)LED_PR=state ? 0x46 : 0x44;
  36 }
  37 
  38 //To do: Check this function
  39 // SX500 IS has two 'lights' - Power LED, and AF assist lamp
  40 // Power Led = first entry in table (led 0)
  41 // AF Assist Lamp = second entry in table (led 1)
  42 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
  43     static char led_table[2]={0,4};
  44     if(state<=1) _LEDDrive(led_table[led%sizeof(led_table)], (!state)&1);
  45 }
  46 
  47 int get_flash_params_count(void) 
  48 {
  49     return 0xA6;
  50 }
  51 
  52 void JogDial_CW(void)
  53 {
  54     _PostLogicalEventForNotPowerType(0x872, 1);  // RotateJogDialRight (in table @ ???)
  55 }
  56 
  57 void JogDial_CCW(void)
  58 {
  59     _PostLogicalEventForNotPowerType(0x873, 1);  // RotateJogDialLeft (in table @ ???)
  60 }
  61 
  62 int vid_get_viewport_width()
  63 {
  64     if ((mode_get() & MODE_MASK) == MODE_PLAY)
  65     {
  66         return 360;
  67     }
  68     extern int _GetVRAMHPixelsSize();
  69     return _GetVRAMHPixelsSize() >> 1;
  70 }
  71 
  72 long vid_get_viewport_height()
  73 {
  74     if ((mode_get() & MODE_MASK) == MODE_PLAY)
  75     {
  76         return 240;
  77     }
  78     extern int _GetVRAMVPixelsSize();
  79     return _GetVRAMVPixelsSize();
  80 
  81 }
  82 
  83 // Viewport and Bitmap values that shouldn't change across firmware versions.
  84 // Values that may change are in lib.c for each firmware version.
  85 extern char active_viewport_buffer;
  86 extern void* viewport_buffers[];
  87 
  88 void *vid_get_viewport_fb() 
  89 {
  90     // Return first viewport buffer - for case when vid_get_viewport_live_fb not defined
  91     return viewport_buffers[0];
  92 }
  93 
  94 void *vid_get_viewport_live_fb() 
  95 {
  96     if (MODE_IS_VIDEO(mode_get()) || is_video_recording())
  97         return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
  98 
  99     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
 100     return viewport_buffers[(active_viewport_buffer-1)&3];
 101 }
 102 
 103 void *vid_get_viewport_fb_d()
 104 {
 105     extern char *viewport_fb_d;
 106     return viewport_fb_d;
 107 }
 108 
 109 
 110 extern int active_bitmap_buffer;
 111 extern char* bitmap_buffer[];
 112 
 113 void *vid_get_bitmap_fb() 
 114 {
 115     // Return first bitmap buffer address
 116     return bitmap_buffer[0];
 117 }
 118 
 119 
 120 void vid_bitmap_refresh() 
 121 {
 122     extern int full_screen_refresh;
 123     extern void _ScreenLock();
 124     extern void _ScreenUnlock();
 125 
 126     full_screen_refresh |= 3;
 127     _ScreenLock();
 128     _ScreenUnlock();
 129 }
 130 
 131 void *vid_get_bitmap_active_palette() 
 132 {
 133     extern int active_palette_buffer;
 134     extern char* palette_buffer[];
 135     void* p = palette_buffer[active_palette_buffer];
 136     // Don't add offset if value is 0
 137     if (p) p += 4;
 138     return p;
 139 }
 140 
 141 void *vid_get_bitmap_active_buffer()
 142 {
 143     return bitmap_buffer[active_bitmap_buffer];
 144 }
 145 
 146 #ifdef CAM_LOAD_CUSTOM_COLORS
 147 // Function to load CHDK custom colors into active Canon palette
 148  
 149 void load_chdk_palette() 
 150 {
 151         extern int active_palette_buffer;
 152         // Only load for the standard record and playback palettes
 153         if ((active_palette_buffer == 0) || (active_palette_buffer == 5))
 154         {
 155                 int *pal = (int*)vid_get_bitmap_active_palette();
 156                 if (pal && pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
 157                 {
 158                         pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
 159                         pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
 160                         pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
 161                         pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
 162                         pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
 163                         pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
 164                         pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
 165                         pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
 166                         pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
 167                         pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
 168                         pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
 169                         pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
 170                         pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
 171 
 172                         extern char palette_control;
 173                         palette_control = 1;
 174                         vid_bitmap_refresh();
 175         }
 176     }
 177 }
 178 #endif
 179 
 180 // Functions for PTP Live View system
 181 int vid_get_palette_type()                      { return 3; }
 182 int vid_get_palette_size()                      { return 256 * 4; }

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