root/platform/n/lib.c

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

DEFINITIONS

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

   1 // Powershot N
   2 
   3 #include "platform.h"
   4 #include "platform_palette.h"
   5 #include "lolevel.h"
   6 
   7 extern  int     active_raw_buffer;
   8 extern  char*   raw_buffers[];
   9 
  10 char *camera_jpeg_count_str()    { return (char*)0x00220c20; }             // Found @0xff2c1778
  11 int get_flash_params_count(void) { return 0x91; }                          // Found @0xff25006c
  12 
  13 char *hook_raw_image_addr()
  14 {
  15     return raw_buffers[active_raw_buffer];
  16 }
  17 
  18 char *hook_alt_raw_image_addr()
  19 {
  20     return raw_buffers[(active_raw_buffer^1)];
  21 }
  22 
  23 void vid_bitmap_refresh()
  24 {
  25     extern int full_screen_refresh;
  26     extern void _ScreenUnlock();
  27     extern void _ScreenLock();
  28 
  29     full_screen_refresh |= 3;
  30     _ScreenLock();
  31     _ScreenUnlock();
  32 }
  33 
  34 void shutdown()
  35 {
  36     extern void _TurnOffE1(void);
  37     _TurnOffE1();
  38     while(1);
  39 }
  40 
  41 // powershot N has only one LED - on the power button
  42 void debug_led(int state) 
  43 {
  44     if ( state == 1 ) *(int*)0xc022c30c = ( (*(int*)0xc022c30c) & 0xffffffcf ) | 0x20 ;
  45     else              *(int*)0xc022c30c = ( (*(int*)0xc022c30c) & 0xffffffcf )        ;
  46 }
  47 
  48 // powershot N has one LED - on the power button - and a focus assist / camera lamp on the front of the camera
  49 void camera_set_led(int led, int state, int bright)
  50 {
  51     static char led_table[3]={0,6,11};  // 0=green power button LED, 6=focus assist lamp (dim), 11=flash LED (bright)
  52     _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  53 }
  54 
  55 // Bitmap values 
  56 void *vid_get_bitmap_fb()   { return (void*)0x406c5000; }        // Found @0xff08d5d8
  57 void *vid_get_viewport_fb() { return (void*)0x4081ab80; }        // Found @0xff4b7ba4
  58 
  59 void *vid_get_viewport_fb_d()                                    // buffer used in playback mode & fallback if vid_get_viewport_live_fb returns null
  60 {
  61     extern char *viewport_fb_d;
  62     return viewport_fb_d;
  63 }
  64 
  65 void *vid_get_viewport_live_fb()                                 // live buffer used in record mode
  66 { 
  67     extern char active_viewport_buffer;
  68     extern void* viewport_buffers[];
  69 
  70     if (MODE_IS_VIDEO(mode_get()) || (get_movie_status()==VIDEO_RECORD_IN_PROGRESS))
  71         return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
  72    
  73     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
  74     // -1 used for best MD response - TODO verify this
  75     return viewport_buffers[(active_viewport_buffer-7)&7];  // -7 tested best with fudgey's HTML motion detector
  76 }
  77 
  78 
  79 
  80 // Y multiplier for cameras with 480 pixel high viewports (CHDK code assumes 240)
  81 int vid_get_viewport_yscale() {
  82         return 2;              
  83 }
  84 
  85 int vid_get_viewport_width()
  86 {
  87     if ((mode_get() & MODE_MASK) == MODE_PLAY)
  88     {
  89         return 360;
  90     }
  91     extern int _GetVRAMHPixelsSize();
  92     return _GetVRAMHPixelsSize() >> 1;    
  93 }
  94 
  95 long vid_get_viewport_height()
  96 {
  97   if ((mode_get() & MODE_MASK) == MODE_PLAY)
  98   {
  99        return 240;
 100   }
 101   extern int _GetVRAMVPixelsSize();
 102   return _GetVRAMVPixelsSize() >> 1;
 103 
 104 }
 105 
 106 // Functions for PTP Live View system & Cuatom Palette Colors
 107 
 108 extern int active_palette_buffer;
 109 extern int** palette_buffer_ptr;
 110 extern char palette_control;
 111 
 112 int vid_get_viewport_display_xoffset_proper()   { return vid_get_viewport_display_xoffset() * 2; }
 113 int vid_get_palette_type()                      { return 3; }
 114 int vid_get_palette_size()                      { return 256 * 4; }
 115 int vid_get_aspect_ratio()                      { return 1; }
 116 
 117 void *vid_get_bitmap_active_palette() {
 118     unsigned char theme;
 119     get_parameter_data(20, &theme, 1);
 120     return  palette_buffer_ptr[active_palette_buffer+theme] + 1;
 121 }
 122 
 123 void * vid_get_bitmap_active_buffer()
 124 {
 125     return (void*)(*(int*)(0x7510+0x18)); //found Powershot N @ loc_FF1BDFEC (from A1400 example)
 126 }
 127 
 128 #ifdef CAM_LOAD_CUSTOM_COLORS
 129 
 130 // Function to load CHDK custom colors into active Canon palette
 131 
 132 void load_chdk_palette()
 133 {
 134     unsigned char theme;
 135  
 136     // active_palette_buffer values
 137     //  0x00:shooting, 0x04:camera modes menu, 0x0C:func menu, 0x10:playback, 0x14:shooting setup menu, 0x18:wifi menu
 138     
 139     if (    (active_palette_buffer == 0x00) 
 140          || (active_palette_buffer == 0x10))
 141     {
 142         get_parameter_data(20, &theme, 1);   
 143         if (palette_buffer_ptr[active_palette_buffer+theme] !=0)
 144         {
 145             int* pal = palette_buffer_ptr[active_palette_buffer+theme] + 1; 
 146             // check that palette_buffer != null and palette transparent & black colors are correct before overwriting palette)
 147             if (    (pal!=0) 
 148                  && (pal[CHDK_COLOR_BASE+0] != 0x3F3ADF62) 
 149                  && (pal[0x00]==0x00FF0000) 
 150                  && (pal[0xFF]==0x3F000000) )
 151             {
 152                 pal[CHDK_COLOR_BASE+0]  = 0x3F3ADF62;  // Red
 153                 pal[CHDK_COLOR_BASE+1]  = 0x3F26EA40;  // Dark Red
 154                 pal[CHDK_COLOR_BASE+2]  = 0x3F4CD57F;  // Light Red
 155                 pal[CHDK_COLOR_BASE+3]  = 0x3F73BFAE;  // Green
 156                 pal[CHDK_COLOR_BASE+4]  = 0x3F4BD6CA;  // Dark Green
 157                 pal[CHDK_COLOR_BASE+5]  = 0x3F95AB95;  // Light Green
 158                 pal[CHDK_COLOR_BASE+6]  = 0x3F4766F0;  // Blue
 159                 pal[CHDK_COLOR_BASE+7]  = 0x3F1250F3;  // Dark Blue
 160                 pal[CHDK_COLOR_BASE+8]  = 0x3F7F408F;  // Cyan
 161                 pal[CHDK_COLOR_BASE+9]  = 0x3F512D5B;  // Magenta
 162                 pal[CHDK_COLOR_BASE+10] = 0x3FA9A917;  // Yellow
 163                 pal[CHDK_COLOR_BASE+11] = 0x3F819137;  // Dark Yellow
 164                 pal[CHDK_COLOR_BASE+12] = 0x3FDED115;  // Light Yellow
 165                 pal[CHDK_COLOR_BASE+13] = 0x1F0A0000;  // Transparent dark grey               
 166  
 167                 palette_control = 1; // note appears to be a bitmask, 2nd bit is also used for something ?
 168                 
 169                 vid_bitmap_refresh();
 170             }
 171         }
 172     }
 173 }
 174 #endif

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