root/platform/a2200/lib.c

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

DEFINITIONS

This source file includes following definitions.
  1. shutdown
  2. debug_led
  3. camera_set_led
  4. vid_get_viewport_width
  5. vid_get_viewport_height
  6. vid_get_viewport_fb
  7. vid_get_viewport_live_fb
  8. vid_get_viewport_fb_d
  9. vid_bitmap_refresh
  10. vid_get_bitmap_active_palette
  11. load_chdk_palette
  12. vid_get_palette_type
  13. vid_get_palette_size
  14. vid_get_bitmap_active_buffer

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 #define LED_AC     0xC0220130
   6 #define LED_AF     0xC02200AC
   7 
   8 void shutdown() {
   9         
  10         volatile long *p = (void*)LED_AF;
  11 
  12         asm(
  13                 "MRS     R1, CPSR\n"
  14                 "AND     R0, R1, #0x80\n"
  15                 "ORR     R1, R1, #0x80\n"
  16                 "MSR     CPSR_cf, R1\n"
  17                 :::"r1","r0");
  18 
  19         *p = 0x44;  // power off.
  20 
  21         while(1);
  22 }
  23 
  24 void debug_led(int state) {
  25         
  26         *(int*)LED_AC=state ? 0x46 : 0x44;
  27 }
  28 
  29 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
  30         
  31         static char led_table[2]={0,9};
  32         _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  33 }
  34 
  35 int vid_get_viewport_width()
  36 {
  37     return 360;
  38 }
  39 
  40 long vid_get_viewport_height()
  41 {
  42     return 240;
  43 }
  44 
  45 // Defined in stubs_entry.S
  46 extern char active_viewport_buffer;
  47 extern void* viewport_buffers[];
  48 
  49 void *vid_get_viewport_fb()
  50 {
  51     // Return first viewport buffer - for case when vid_get_viewport_live_fb not defined
  52     return viewport_buffers[0];
  53 }
  54 
  55 void *vid_get_viewport_live_fb()
  56 {
  57     if (MODE_IS_VIDEO(mode_get()))
  58         return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
  59 
  60     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
  61     return viewport_buffers[(active_viewport_buffer-1)&3];
  62 }
  63 
  64 void *vid_get_viewport_fb_d()
  65 {
  66     extern char *viewport_fb_d;
  67         return viewport_fb_d;
  68 }
  69 
  70 void vid_bitmap_refresh() {
  71 
  72     extern int full_screen_refresh;
  73     extern void _ScreenLock();
  74     extern void _ScreenUnlock();
  75 
  76     full_screen_refresh |= 3;
  77     _ScreenLock();
  78     _ScreenUnlock();
  79 }
  80 
  81 //// viewport image offset - used when image size != viewport size (zebra, histogram, motion detect & edge overlay)
  82 //// returns the byte offset into the viewport buffer where the image pixels start (to skip any black borders)
  83 //int vid_get_viewport_image_offset() {
  84 //      
  85 //      return (vid_get_viewport_yoffset() * vid_get_viewport_buffer_width() + vid_get_viewport_xoffset()) * 3;
  86 //}
  87 //
  88 //// viewport row offset - used when image size != viewport size (zebra, histogram, motion detect & edge overlay)
  89 //// returns the byte offset to skip at the end of a viewport buffer row to get to the next row.
  90 //int vid_get_viewport_row_offset() {
  91 //      
  92 //      return (vid_get_viewport_buffer_width() - vid_get_viewport_width()) * 3;
  93 //}
  94 
  95 void *vid_get_bitmap_active_palette() {
  96     extern int active_palette_buffer;
  97     extern char* palette_buffer[];
  98     void* p = palette_buffer[active_palette_buffer];
  99     // Don't add offset if value is 0
 100     if (p) p += 8;
 101     return p;
 102 }
 103 
 104 // Function to load CHDK custom colors into active Canon palette
 105 void load_chdk_palette() {
 106         
 107         extern int active_palette_buffer;
 108         // Only load for the standard record and playback palettes
 109         if ((active_palette_buffer == 0) || (active_palette_buffer == 4))
 110         {
 111                 int *pal = (int*)vid_get_bitmap_active_palette();
 112                 if (pal && pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
 113                 {
 114                         pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
 115                         pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
 116                         pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
 117                         pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
 118                         pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
 119                         pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
 120                         pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
 121                         pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
 122                         pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
 123                         pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
 124                         pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
 125                         pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
 126                         pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
 127                         
 128                         extern char palette_control;
 129                         palette_control = 1;
 130                         vid_bitmap_refresh();
 131         }
 132     }
 133 }
 134 
 135 int vid_get_palette_type() {
 136         
 137         return 3;
 138 }
 139 
 140 int vid_get_palette_size() {
 141         
 142         return 256 * 4;
 143 }
 144 
 145 void *vid_get_bitmap_active_buffer()
 146 {
 147 
 148         return (void*)(*(int*)(0x560C+0x18)); // found @ FF912D5C: A2200 100b & 100d
 149 }

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