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

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