root/platform/ixus240_elph320hs/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. get_flash_params_count
  5. vid_bitmap_refresh
  6. shutdown
  7. debug_led
  8. camera_set_led
  9. vid_get_viewport_fb
  10. vid_get_viewport_live_fb
  11. vid_get_viewport_fb_d
  12. vid_get_bitmap_fb
  13. vid_get_viewport_width
  14. vid_get_viewport_height
  15. vid_get_viewport_display_xoffset_proper
  16. vid_get_viewport_height_proper
  17. vid_get_viewport_buffer_width_proper
  18. vid_get_viewport_fullscreen_height
  19. vid_get_palette_type
  20. vid_get_palette_size
  21. vid_get_aspect_ratio
  22. vid_get_bitmap_active_buffer
  23. vid_get_bitmap_active_palette
  24. load_chdk_palette

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

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