root/platform/ixus160_elph160/lib.c

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

DEFINITIONS

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

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 #define LED_PR 0xc022d1fc
   6 #define LED_AF 0xc022d200
   7 
   8 
   9 void debug_led(int state)
  10 {
  11         *(int*)LED_PR=state ? 0x93d800 : 0x83dc00;
  12 }
  13 
  14 // TODO not really complete, last call from task_Bye
  15 void shutdown()
  16 {
  17     extern void _TurnOffE1(void);
  18     _TurnOffE1();
  19     while(1);
  20 }
  21 
  22 // IXUS160/ELPH160 has two 'lights' - Power LED, and AF assist lamp
  23 // Power Led = first entry in table (led 0)
  24 // AF Assist Lamp = second entry in table (led 1)
  25 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
  26     static char led_table[2]={0,4};
  27     _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);    
  28 }
  29 
  30 void *vid_get_viewport_fb()      { return (void*)0x40866b80; }             // Found @0xffb7af7c
  31 char *camera_jpeg_count_str()    { return (char*)0x000d7868; }             // Found @0xff9ff7f0
  32 int get_flash_params_count(void) { return 0xd4; }                          // Found @0xff9af548
  33 
  34 extern int active_bitmap_buffer;
  35 extern char* bitmap_buffer[];
  36 
  37 void *vid_get_bitmap_fb() {
  38     return bitmap_buffer[0];
  39 }
  40 //void *vid_get_bitmap_fb()        { return (void*)0x40711000; }             // Found @0xff8662d0
  41 
  42 void *vid_get_bitmap_active_buffer() {
  43     return bitmap_buffer[active_bitmap_buffer];
  44 }
  45 
  46 // start palette table FFC062B0?
  47 void *vid_get_bitmap_active_palette()
  48 {
  49     extern int active_palette_buffer;
  50     extern int** palette_buffer_ptr;
  51     int *p = palette_buffer_ptr[active_palette_buffer];
  52     if(!p) {
  53         p = palette_buffer_ptr[0];
  54     }
  55     return (p+1);
  56 }
  57 
  58 extern int _GetVRAMHPixelsSize();
  59 extern int _GetVRAMVPixelsSize();
  60 
  61 //taken from n
  62 int vid_get_viewport_width()
  63 {
  64     if ((mode_get() & MODE_MASK) == MODE_PLAY)
  65     {
  66         return 360;
  67     }
  68     return _GetVRAMHPixelsSize() >> 1;
  69 }
  70 
  71 long vid_get_viewport_height()
  72 {
  73   if ((mode_get() & MODE_MASK) == MODE_PLAY)
  74   {
  75        return 240;
  76   }
  77   return _GetVRAMVPixelsSize();
  78 }
  79 
  80 void *vid_get_viewport_fb_d()
  81 {
  82     extern char *viewport_fb_d;
  83     return viewport_fb_d;
  84 }
  85 
  86 void *vid_get_viewport_live_fb()
  87 {
  88     return 0;
  89 }
  90 
  91 char *hook_raw_image_addr()
  92 {
  93 //FFB7C910 (search for CRAW BUFF)
  94     return (char*) 0x43737E20;
  95 }
  96 
  97 void vid_bitmap_refresh()
  98 {
  99     extern int full_screen_refresh;
 100     extern void _ScreenLock();
 101     extern void _ScreenUnlock();
 102 
 103     full_screen_refresh |= 3;
 104     _ScreenLock();
 105     _ScreenUnlock();
 106 }
 107 
 108 int vid_get_palette_type()   { return 5; }
 109 int vid_get_palette_size()   { return 256 * 4 ; }
 110 
 111 // Function to load CHDK custom colors into active Canon palette
 112 void load_chdk_palette()
 113 {
 114     extern int active_palette_buffer;
 115         // Only load for the standard record and playback palettes
 116         if ((active_palette_buffer == 0) || (active_palette_buffer == 5))
 117     {
 118         int *pal = (int*)vid_get_bitmap_active_palette();
 119 
 120 
 121         if (pal[CHDK_COLOR_BASE+0] != 0x3F3ADF62)
 122         {
 123             pal[CHDK_COLOR_BASE+0]  = 0x3F3ADF62;  // Red
 124             pal[CHDK_COLOR_BASE+1]  = 0x3F26EA40;  // Dark Red
 125             pal[CHDK_COLOR_BASE+2]  = 0x3F4CD57F;  // Light Red
 126             pal[CHDK_COLOR_BASE+3]  = 0x3F73BFAE;  // Green
 127             pal[CHDK_COLOR_BASE+4]  = 0x3F4BD6CA;  // Dark Green
 128             pal[CHDK_COLOR_BASE+5]  = 0x3F95AB95;  // Light Green
 129             pal[CHDK_COLOR_BASE+6]  = 0x3F4766F0;  // Blue
 130             pal[CHDK_COLOR_BASE+7]  = 0x3F1250F3;  // Dark Blue
 131             pal[CHDK_COLOR_BASE+8]  = 0x3F7F408F;  // Cyan
 132             pal[CHDK_COLOR_BASE+9]  = 0x3F512D5B;  // Magenta
 133             pal[CHDK_COLOR_BASE+10] = 0x3FA9A917;  // Yellow
 134             pal[CHDK_COLOR_BASE+11] = 0x3F819137;  // Dark Yellow
 135             pal[CHDK_COLOR_BASE+12] = 0x3FDED115;  // Light Yellow
 136             pal[CHDK_COLOR_BASE+13] = 0x00090000;  // Transparent dark grey
 137 
 138             extern char palette_control;
 139             palette_control = 1;
 140             vid_bitmap_refresh();
 141         }
 142     }
 143 }
 144 

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