root/platform/s100/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. JogDial_CW
  7. JogDial_CCW
  8. vid_get_viewport_live_fb
  9. vid_get_viewport_yscale
  10. vid_get_viewport_width
  11. vid_get_viewport_xoffset
  12. vid_get_viewport_display_xoffset
  13. vid_get_viewport_height
  14. vp_yoffset
  15. vid_get_viewport_yoffset
  16. vid_get_viewport_display_yoffset
  17. vid_get_viewport_display_xoffset_proper
  18. vid_get_viewport_display_yoffset_proper
  19. vid_get_viewport_height_proper
  20. vid_get_viewport_fullscreen_height
  21. vid_get_palette_type
  22. vid_get_palette_size
  23. vid_get_bitmap_active_buffer
  24. vid_get_bitmap_active_palette
  25. load_chdk_palette

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 void vid_bitmap_refresh()
   6 {
   7         extern int full_screen_refresh;
   8         extern void _ScreenUnlock();
   9         extern void _ScreenLock();
  10 
  11         full_screen_refresh |= 3;
  12         _ScreenLock();
  13         _ScreenUnlock();
  14 }
  15 
  16 void shutdown()
  17 {
  18         volatile long *p = (void*)0xC022001C;
  19 
  20         asm(
  21                 "MRS     R1, CPSR\n"
  22                 "AND     R0, R1, #0x80\n"
  23                 "ORR     R1, R1, #0x80\n"
  24                 "MSR     CPSR_cf, R1\n"
  25                 :::"r1","r0");
  26 
  27         *p = 0x44;  // power off.
  28 
  29         while(1);
  30 }
  31 
  32 #define LED_PR 0xC022C30C       // Power LED (@FF15B178 & @FF15B1CC)
  33 
  34 void debug_led(int state)
  35 {
  36         // using power LED, which defaults to on
  37         // for debugging turn LED off if state is 1 and on for state = 0
  38         // leaves LED on at end of debugging
  39     volatile long *p = (void*)LED_PR;
  40     *p = (*p & 0xFFFFFFCF) | ((state) ? 0x00 : 0x20);
  41 }
  42 
  43 // S100 has two 'lights' - Power LED, and AF assist lamp
  44 // Power Led = first entry in table (led 0)
  45 // AF Assist Lamp = second entry in table (led 1)
  46 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
  47  static char led_table[2]={7,10};
  48  _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  49 }
  50 
  51 void shutdown_soft()
  52 {
  53    _PostLogicalEventForNotPowerType(0x1005,0);
  54 }
  55 
  56 void JogDial_CW(void){
  57         _PostLogicalEventToUI(0x872, 1);  // RotateJogDialRight (levent_table)
  58 }
  59 
  60 void JogDial_CCW(void){
  61         _PostLogicalEventToUI(0x873, 1);  // RotateJogDialLeft (levent_table)
  62 }
  63 
  64 void *vid_get_viewport_live_fb() // use sigfinder's address
  65 {
  66     return vid_get_viewport_fb();
  67 }
  68 
  69 // Defined in stubs_min.S
  70 extern int active_bitmap_buffer;
  71 extern char* bitmap_buffer[];
  72 
  73 // Y multiplier for cameras with 480 pixel high viewports (CHDK code assumes 240)
  74 int vid_get_viewport_yscale() {
  75         return 2;
  76 }
  77 
  78 int vid_get_viewport_width()
  79 {
  80     if ((mode_get() & MODE_MASK) == MODE_PLAY)
  81     {
  82         return 360;
  83     }
  84     extern int _GetVRAMHPixelsSize();
  85     return _GetVRAMHPixelsSize() >> 1;
  86 }
  87 
  88 // viewport width offset table for each image size
  89 // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1, 4 = 4:5
  90 static long vp_xo[5] = { 0, 0, 0, 44, 72 };                             // should all be even values for edge overlay
  91 
  92 int vid_get_viewport_xoffset()
  93 {
  94     if ((mode_get() & MODE_MASK) == MODE_PLAY)
  95     {
  96         return 0;
  97     }
  98     else if (shooting_get_prop(PROPCASE_SHOOTING_MODE) == 16909) // Stitch mode
  99     {
 100         return 0;
 101     }
 102     else
 103     {
 104         return vp_xo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 105     }
 106 }
 107 
 108 int vid_get_viewport_display_xoffset()
 109 {
 110     if ((mode_get() & MODE_MASK) == MODE_PLAY)
 111     {
 112         return 0;
 113     }
 114     else if (shooting_get_prop(PROPCASE_SHOOTING_MODE) == 16909) // Stitch mode
 115     {
 116         if (shooting_get_prop(PROPCASE_STITCH_DIRECTION) == 0)      // Direction check
 117             if (shooting_get_prop(PROPCASE_STITCH_SEQUENCE) == 0)   // Shot already taken?
 118                 return 40;
 119             else
 120                 return 140;
 121         else
 122             if (shooting_get_prop(PROPCASE_STITCH_SEQUENCE) == 0)   // Shot already taken?
 123                 return 140;
 124             else
 125                 return 40;
 126     }
 127     else
 128     {
 129         return vp_xo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 130     }
 131 }
 132 
 133 long vid_get_viewport_height()
 134 {
 135     if ((mode_get() & MODE_MASK) == MODE_PLAY)
 136     {
 137         return 240;
 138     }
 139     extern int _GetVRAMVPixelsSize();
 140     return _GetVRAMVPixelsSize() >> 1;
 141 }
 142 
 143 static int vp_yoffset(int stitch)
 144 {
 145     // viewport height offset table for each image size
 146     // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1, 4 = 4:5
 147     static long vp_yo[5] = { 0, 30, 13, 0, 0 };
 148 
 149     int m = mode_get();
 150     if ((m & MODE_MASK) == MODE_PLAY)
 151     {
 152         return 0;
 153     }
 154     else if (shooting_get_prop(PROPCASE_SHOOTING_MODE) == 16908) // Stitch mode
 155     {
 156         return stitch;
 157     }
 158     else if (mode_is_video(m))
 159     {
 160         return 30;
 161     }
 162     else
 163     {
 164             return vp_yo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 165     }
 166 }
 167 
 168 int vid_get_viewport_yoffset()
 169 {
 170     return vp_yoffset(0);
 171 }
 172 
 173 int vid_get_viewport_display_yoffset()
 174 {
 175     return vp_yoffset(72);
 176 }
 177 
 178 // Functions for PTP Live View system
 179 int vid_get_viewport_display_xoffset_proper()   { return vid_get_viewport_display_xoffset() * 2; }
 180 int vid_get_viewport_display_yoffset_proper()   { return vid_get_viewport_display_yoffset() * 2; }
 181 int vid_get_viewport_height_proper()            { return vid_get_viewport_height() * 2; }
 182 int vid_get_viewport_fullscreen_height()        { return 480; }
 183 int vid_get_palette_type()                      { return 5; }
 184 int vid_get_palette_size()                      { return 256 * 4; }
 185 
 186 void *vid_get_bitmap_active_buffer()
 187 {
 188     return bitmap_buffer[active_bitmap_buffer];
 189 }
 190 
 191 void *vid_get_bitmap_active_palette()
 192 {
 193     extern int active_palette_buffer;
 194     extern char* palette_buffer[];
 195     void* p = palette_buffer[active_palette_buffer];
 196     // Don't add offset if value is 0
 197     if (p) p += 4;
 198     return p;
 199 }
 200 
 201 // Function to load CHDK custom colors into active Canon palette
 202 void load_chdk_palette()
 203 {
 204     extern int active_palette_buffer;
 205     // Only load for the standard record and playback palettes
 206     if ((active_palette_buffer == 0) || (active_palette_buffer == 3))
 207     {
 208         int *pal = (int*)vid_get_bitmap_active_palette();
 209         if (pal && pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
 210         {
 211             pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
 212             pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
 213             pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
 214             pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
 215             pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
 216             pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
 217             pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
 218             pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
 219             pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
 220             pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
 221             pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
 222             pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
 223             pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
 224             pal[CHDK_COLOR_BASE+13] = 0x0090000;  // Transparent dark grey
 225 
 226             extern char palette_control;
 227             palette_control = 1;
 228             vid_bitmap_refresh();
 229         }
 230     }
 231 }

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