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, 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 //To do
 100 void *vid_get_viewport_live_fb()
 101 {
 102     extern char active_viewport_buffer;
 103     extern void* viewport_buffers[];
 104 
 105     if (MODE_IS_VIDEO(mode_get()) || is_video_recording())
 106         return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
 107 
 108     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
 109     return viewport_buffers[(active_viewport_buffer-1)&3]; //After a while MD Last 190 / Min 70 / Max 198 / Avg 179
 110 }
 111 
 112 int vid_get_palette_type()                      { return 3; }
 113 int vid_get_palette_size()                      { return 256 * 4; }
 114 
 115 void *vid_get_bitmap_active_buffer()
 116 {
 117     return vid_get_bitmap_fb();
 118 }
 119 
 120 void *vid_get_bitmap_active_palette() // from ixus140_elph130
 121 {
 122     extern int active_palette_buffer;
 123     extern int** palette_buffer_ptr;
 124     int *p = palette_buffer_ptr[active_palette_buffer];
 125     // active_palette_buffer can point at null when
 126     // func and menu are opened for the first time
 127     if(!p) {
 128         p = palette_buffer_ptr[0]; // rec mode buffer appears to always be initialized
 129     }
 130     return (p+1);
 131 }
 132 
 133 // Function to load CHDK custom colors into active Canon palette
 134 
 135 void load_chdk_palette() {
 136 
 137     extern int active_palette_buffer;
 138     // Only load for the standard record(0) and playback palettes(5)
 139     if ((active_palette_buffer == 0) || (active_palette_buffer == 5))
 140     {
 141         int *pal = (int*)vid_get_bitmap_active_palette();
 142         if (pal[CHDK_COLOR_BASE+0] != 0x3F3ADF62)
 143         {
 144             pal[CHDK_COLOR_BASE+0]  = 0x3F3ADF62;  // Red
 145             pal[CHDK_COLOR_BASE+1]  = 0x3F26EA40;  // Dark Red
 146             pal[CHDK_COLOR_BASE+2]  = 0x3F4CD57F;  // Light Red
 147             pal[CHDK_COLOR_BASE+3]  = 0x3F73BFAE;  // Green
 148             pal[CHDK_COLOR_BASE+4]  = 0x3F4BD6CA;  // Dark Green
 149             pal[CHDK_COLOR_BASE+5]  = 0x3F95AB95;  // Light Green
 150             pal[CHDK_COLOR_BASE+6]  = 0x3F4766F0;  // Blue
 151             pal[CHDK_COLOR_BASE+7]  = 0x3F1250F3;  // Dark Blue
 152             pal[CHDK_COLOR_BASE+8]  = 0x3F7F408F;  // Cyan
 153             pal[CHDK_COLOR_BASE+9]  = 0x3F512D5B;  // Magenta
 154             pal[CHDK_COLOR_BASE+10] = 0x3FA9A917;  // Yellow
 155             pal[CHDK_COLOR_BASE+11] = 0x3F819137;  // Dark Yellow
 156             pal[CHDK_COLOR_BASE+12] = 0x3FDED115;  // Light Yellow
 157             pal[CHDK_COLOR_BASE+13] = 0x1F0A0000;  // Transparent dark grey
 158 
 159             extern char palette_control;
 160             palette_control = 1;
 161             vid_bitmap_refresh();
 162         }
 163     }
 164 }
 165 

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