root/platform/ixus145_elph135/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. camera_jpeg_count_str
  6. get_flash_params_count
  7. hook_raw_image_addr
  8. vid_get_viewport_width
  9. vid_get_viewport_height
  10. vid_get_bitmap_fb
  11. vid_get_viewport_fb
  12. vid_get_viewport_fb_d
  13. vid_get_viewport_live_fb
  14. vid_get_palette_type
  15. vid_get_palette_size
  16. vid_get_bitmap_active_buffer
  17. vid_get_bitmap_active_palette
  18. 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 _ScreenLock();
   9     extern void _ScreenUnlock();
  10 
  11     full_screen_refresh |= 3;
  12     _ScreenLock();
  13     _ScreenUnlock();
  14 }
  15 
  16 //TODO: not really complete, last call from task_Bye
  17 void shutdown()
  18 {
  19     extern void _TurnOffE1(void);
  20     _TurnOffE1();
  21     while(1);
  22 }
  23 
  24 #define LED_PR 0xC022D1FC  // green LED
  25 #define LED_AF 0xC022D200  // orange AF LED
  26 
  27 void debug_led(int state)
  28 {
  29     // using power LED, which defaults to on
  30     // for debugging turn LED off if state is 1 and on for state = 0
  31      *(int*)LED_PR=state ? 0x46 : 0x44;
  32 }
  33 
  34 // IXUS145_ELPH135 has two 'lights' - Power LED, and AF assist lamp
  35 // Power Led = first entry in table (led 0)
  36 // AF Assist Lamp = second entry in table (led 1)
  37 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
  38     static char led_table[2]={0,4}; // green, AF
  39     _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  40 }
  41 
  42 char *camera_jpeg_count_str()
  43 {
  44     extern char jpeg_count_str[];
  45     return jpeg_count_str;
  46 }
  47 
  48 int get_flash_params_count(void) { return 0xa6; }               // Found @0xff9a7ef4 ixus145 100c
  49 char *hook_raw_image_addr()      {return (char*) 0x42f95130;}
  50 
  51 extern int _GetVRAMHPixelsSize();
  52 extern int _GetVRAMVPixelsSize();
  53 
  54 int vid_get_viewport_width()
  55 {
  56     if ((mode_get() & MODE_MASK) == MODE_PLAY)
  57     {
  58         return 360;
  59     }
  60     return _GetVRAMHPixelsSize() >> 1;
  61 }
  62 
  63 long vid_get_viewport_height()
  64 {
  65   if ((mode_get() & MODE_MASK) == MODE_PLAY)
  66   {
  67        return 240;
  68   }
  69   return _GetVRAMVPixelsSize();
  70 }
  71 
  72 
  73 // Viewport and Bitmap values that shouldn't change across firmware versions.
  74 // Values that may change are in lib.c for each firmware version.
  75 //void *vid_get_bitmap_fb()        { return (void*)0x40431000; } // Found @0xff85cf34
  76 // OSD buffer
  77 /*
  78 void *vid_get_bitmap_fb()
  79 {
  80         return (void*)0x40730480;//0x406F1000; // "BmpDDev.c", 0xFF93DAE4       // ixus145
  81 }*/
  82 void *vid_get_bitmap_fb() { return (void*)0x406f1000; }
  83 
  84 //void *vid_get_viewport_fb()      { return (void*)0x40586b80; } // Found @0xffb17000
  85 // Live picture buffer (shoot half-pressed)
  86 /*
  87 void *vid_get_viewport_fb()
  88 {
  89         return (void*)0x40846B80;  // "VRAM Address" sub_FFB66A8C // ixus145
  90 }*/
  91 void *vid_get_viewport_fb() { return (void*)0x40846b80; }
  92 
  93 void *vid_get_viewport_fb_d()
  94 {
  95     extern char *viewport_fb_d;
  96     return viewport_fb_d;
  97 }
  98 
  99 void *vid_get_viewport_live_fb()
 100 {
 101     extern char active_viewport_buffer;
 102     extern void* viewport_buffers[];
 103 
 104     // camera appears to use 4 buffers with in still shooting and video
 105     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
 106     return viewport_buffers[(active_viewport_buffer-1)&3];
 107 }
 108 
 109 int vid_get_palette_type()                      { return 3; }
 110 int vid_get_palette_size()                      { return 256 * 4; }
 111 
 112 void *vid_get_bitmap_active_buffer()
 113 {
 114     return vid_get_bitmap_fb();
 115 }
 116 
 117 void *vid_get_bitmap_active_palette() // from ixus140_elph130
 118 {
 119     extern int active_palette_buffer;
 120     extern int** palette_buffer_ptr;
 121     int *p = palette_buffer_ptr[active_palette_buffer];
 122     // active_palette_buffer can point at null when
 123     // func and menu are opened for the first time
 124     if(!p) {
 125         p = palette_buffer_ptr[0]; // rec mode buffer appears to always be initialized
 126     }
 127     return (p+1);
 128 }
 129 
 130 // Function to load CHDK custom colors into active Canon palette
 131 
 132 void load_chdk_palette() {
 133 
 134     extern int active_palette_buffer;
 135     // Only load for the standard record(0) and playback palettes(5)
 136     if ((active_palette_buffer == 0) || (active_palette_buffer == 5))
 137     {
 138         int *pal = (int*)vid_get_bitmap_active_palette();
 139         if (pal[CHDK_COLOR_BASE+0] != 0x3F3ADF62)
 140         {
 141             pal[CHDK_COLOR_BASE+0]  = 0x3F3ADF62;  // Red
 142             pal[CHDK_COLOR_BASE+1]  = 0x3F26EA40;  // Dark Red
 143             pal[CHDK_COLOR_BASE+2]  = 0x3F4CD57F;  // Light Red
 144             pal[CHDK_COLOR_BASE+3]  = 0x3F73BFAE;  // Green
 145             pal[CHDK_COLOR_BASE+4]  = 0x3F4BD6CA;  // Dark Green
 146             pal[CHDK_COLOR_BASE+5]  = 0x3F95AB95;  // Light Green
 147             pal[CHDK_COLOR_BASE+6]  = 0x3F4766F0;  // Blue
 148             pal[CHDK_COLOR_BASE+7]  = 0x3F1250F3;  // Dark Blue
 149             pal[CHDK_COLOR_BASE+8]  = 0x3F7F408F;  // Cyan
 150             pal[CHDK_COLOR_BASE+9]  = 0x3F512D5B;  // Magenta
 151             pal[CHDK_COLOR_BASE+10] = 0x3FA9A917;  // Yellow
 152             pal[CHDK_COLOR_BASE+11] = 0x3F819137;  // Dark Yellow
 153             pal[CHDK_COLOR_BASE+12] = 0x3FDED115;  // Light Yellow
 154             pal[CHDK_COLOR_BASE+13] = 0x1F0A0000;  // Transparent dark grey
 155 
 156             extern char palette_control;
 157             palette_control = 1;
 158             vid_bitmap_refresh();
 159         }
 160     }
 161 }
 162 

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