root/platform/ixus155_elph150/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 // IXUS155_ELPH150 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 @0xff9ab2f0 ixus155 100b
  49 char *hook_raw_image_addr()      {return (char*) 0x43717e20;}   // (Found @0xffb55ee0)
  50 
  51 
  52 extern int _GetVRAMHPixelsSize();
  53 extern int _GetVRAMVPixelsSize();
  54 
  55 int vid_get_viewport_width()
  56 {
  57     if (camera_info.state.mode_play)
  58     {
  59         return 360;
  60     }
  61     return _GetVRAMHPixelsSize() >> 1;
  62 }
  63 
  64 long vid_get_viewport_height()
  65 {
  66     extern int _GetVideoOutType(void);
  67     int vot = _GetVideoOutType();
  68     if (camera_info.state.mode_play)
  69     {
  70         if(vot == 2) { // PAL
  71             return 288; // 576
  72         }
  73         return 240;
  74     }
  75     return _GetVRAMVPixelsSize();
  76 }
  77 
  78 
  79 // Viewport and Bitmap values that shouldn't change across firmware versions.
  80 // Values that may change are in lib.c for each firmware version.
  81 //void *vid_get_bitmap_fb()        { return (void*)0x40431000; } // Found @0xff85cf34
  82 // OSD buffer
  83 
  84 void *vid_get_bitmap_fb()        { return (void*)0x406f1000; }             // Found @0xff86306c
  85 
  86 //void *vid_get_viewport_fb()      { return (void*)0x40586b80; } // Found @0xffb17000
  87 // Live picture buffer (shoot half-pressed)
  88 
  89 void *vid_get_viewport_fb()      { return (void*)0x40846b80; }             // Found @0xffb544c8
  90 
  91 void *vid_get_viewport_fb_d()
  92 {
  93     extern char *viewport_fb_d;
  94     return viewport_fb_d;
  95 }
  96 
  97 void *vid_get_viewport_live_fb()
  98 {
  99     extern char active_viewport_buffer;
 100     extern void* viewport_buffers[];
 101 
 102     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
 103     return viewport_buffers[(active_viewport_buffer-1)&3];
 104 }
 105 
 106 int vid_get_palette_type()                      { return 3; }
 107 int vid_get_palette_size()                      { return 256 * 4; }
 108 
 109 void *vid_get_bitmap_active_buffer()
 110 {
 111     return vid_get_bitmap_fb();
 112 }
 113 
 114 void *vid_get_bitmap_active_palette()
 115 {
 116     extern int active_palette_buffer;
 117     extern int** palette_buffer_ptr;
 118     int *p = palette_buffer_ptr[active_palette_buffer];
 119     // active_palette_buffer can point at null when
 120     // func and menu are opened for the first time
 121     if(!p) {
 122         p = palette_buffer_ptr[0]; // rec mode buffer normally initialized
 123         if(!p) { // but may be null on video out switch
 124             return (void *)0;
 125         }
 126     }
 127     return (p+1);
 128 }
 129 
 130 // Function to load CHDK custom colors into active Canon palette
 131 void load_chdk_palette()
 132 {
 133     extern int active_palette_buffer;
 134     // Only load for the standard record and playback palettes
 135     // 0 = rec, 4 = func menu, 5 = playback, 6 = menu (play or rec),
 136     if ((active_palette_buffer == 0) || (active_palette_buffer == 5))
 137     {
 138         int *pal = (int*)vid_get_bitmap_active_palette();
 139         if (pal && pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
 140         {
 141             pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
 142             pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
 143             pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
 144             pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
 145             pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
 146             pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
 147             pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
 148             pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
 149             pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
 150             pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
 151             pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
 152             pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
 153             pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
 154             pal[CHDK_COLOR_BASE+13] = 0x1F0A0000;  // Transparent dark grey
 155 
 156             extern char palette_control;
 157             palette_control = 1; // note appears to be a bitmask, bit 2 is also used
 158             vid_bitmap_refresh();
 159         }
 160     }
 161 }
 162 

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