root/platform/g7x2/lib.c

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

DEFINITIONS

This source file includes following definitions.
  1. vid_bitmap_refresh
  2. vid_get_bitmap_fb
  3. vid_get_bitmap_active_buffer
  4. vid_get_opacity_active_buffer
  5. camera_jpeg_count_str
  6. shutdown
  7. debug_led
  8. camera_set_led
  9. shutdown_soft
  10. get_flash_params_count
  11. JogDial_CW
  12. JogDial_CCW
  13. hook_raw_image_addr
  14. hook_alt_raw_image_addr
  15. vid_get_viewport_fb_d
  16. vid_get_viewport_fb
  17. vid_get_viewport_live_fb
  18. vid_get_viewport_width
  19. vid_get_viewport_height
  20. vid_get_viewport_byte_width
  21. vid_get_viewport_display_xoffset
  22. vid_get_viewport_display_yoffset
  23. vid_get_viewport_display_xoffset_proper
  24. vid_get_viewport_display_yoffset_proper
  25. vid_get_viewport_fullscreen_width
  26. vid_get_viewport_fullscreen_height
  27. vid_get_viewport_buffer_width_proper
  28. vid_get_viewport_type
  29. vid_get_aspect_ratio
  30. update_ui

   1 
   2 #include "platform.h"
   3 #include "lolevel.h"
   4 #include "live_view.h"
   5 #include "levent.h"
   6 
   7 // Dummy variable - actual zoom_status not found
   8 int zoom_status;
   9 
  10 extern int active_bitmap_buffer;
  11 extern char* bitmap_buffer[];
  12 
  13 void vid_bitmap_refresh()
  14 {
  15     extern void _transfer_src_overlay(int);
  16     extern void _VTMLock();
  17     extern void _VTMUnlock();
  18     _VTMLock();
  19     int n = active_bitmap_buffer;
  20     _transfer_src_overlay(n^1);
  21     _transfer_src_overlay(n);
  22     _VTMUnlock();
  23 }
  24 
  25 void *vid_get_bitmap_fb()
  26 {
  27     // For live view send YUV instead of RGBA
  28     return bitmap_buffer[0];
  29 }
  30 
  31 void *vid_get_bitmap_active_buffer()
  32 {
  33     // For live view send YUV instead of RGBA
  34     return bitmap_buffer[active_bitmap_buffer];
  35 }
  36 
  37 // the opacity buffer defines opacity for the bitmap overlay's pixels
  38 // found near BmpDDev.c
  39 void *opacity_buffer[2] = { (void*)0x7FC40000, (void*)0x7FB80000 };
  40 
  41 void *vid_get_opacity_active_buffer()
  42 {
  43     return opacity_buffer[active_bitmap_buffer];
  44 }
  45 
  46 char *camera_jpeg_count_str()
  47 {
  48     extern char jpeg_count_str[];
  49     return jpeg_count_str;
  50 }
  51 
  52 void shutdown()
  53 {
  54     debug_led(1);
  55     PostLogicalEventForNotPowerType(levent_id_for_name("PressPowerButton"),0);
  56     while(1) msleep(100);
  57 }
  58 
  59 #define LED_PR 0xD20801E4   // green LED on the back
  60 
  61 void debug_led(int state)
  62 {
  63     volatile long *p = (void*) LED_PR;
  64     *p = ((state) ? 0x24D0002 : 0x24C0003);
  65 }
  66 
  67 // Power Led = first entry in table (led 0)
  68 // AF Assist Lamp = second entry in table (led 1)
  69 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
  70     static char led_table[2] = { 0, 4 };
  71     _LEDDrive(led_table[led % sizeof(led_table)], state <= 1 ? !state : state);
  72 }
  73 
  74 void shutdown_soft()
  75 {
  76     _PostLogicalEventForNotPowerType(0x1005, 0);
  77 }
  78 
  79 int get_flash_params_count(void)
  80 {
  81     return 241;
  82 }
  83 
  84 void JogDial_CW(void)
  85 {
  86     _PostLogicalEventToUI(0x872, 1);    //RotateJogDialRight
  87 }
  88 
  89 void JogDial_CCW(void)
  90 {
  91     _PostLogicalEventToUI(0x873, 1);    //RotateJogDialLeft
  92 }
  93 
  94 // updated by using function in capt_seq, valid between shot start and raw hook end
  95 char *hook_raw_image_addr()
  96 {
  97     extern char* current_raw_addr;
  98     return current_raw_addr;
  99 }
 100 
 101 char *hook_alt_raw_image_addr()
 102 {
 103     extern char* current_raw_alt_addr;
 104     return current_raw_alt_addr;
 105 }
 106 
 107 extern void* _GetActiveViewportBuffer();
 108 
 109 void *vid_get_viewport_fb_d()
 110 {
 111     return _GetActiveViewportBuffer();
 112 }
 113 
 114 void *vid_get_viewport_fb()
 115 {
 116     return _GetActiveViewportBuffer();
 117 }
 118 
 119 void *vid_get_viewport_live_fb()
 120 {
 121     return _GetActiveViewportBuffer();
 122 }
 123 
 124 extern int displaytype;
 125 #define hdmi_out ((displaytype == 6) || (displaytype == 7))
 126 
 127 int vid_get_viewport_width() {
 128     if (camera_info.state.mode_play)
 129     {
 130         if (hdmi_out) return 1920;
 131         return 720;
 132     }
 133     extern int _GetVRAMHPixelsSize();
 134     return _GetVRAMHPixelsSize();
 135 }
 136 
 137 long vid_get_viewport_height() {
 138     if (camera_info.state.mode_play)
 139     {
 140         if (hdmi_out) return 1080;
 141         return 480;
 142     }
 143     extern int _GetVRAMVPixelsSize();
 144     return _GetVRAMVPixelsSize();
 145 }
 146 
 147 int vid_get_viewport_byte_width()
 148 {
 149     return vid_get_viewport_buffer_width_proper()*2;
 150 }
 151 
 152 int vid_get_viewport_display_xoffset()
 153 {
 154     // viewport width offset table for each image size
 155     // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 156     static long vp_xo[5] = { 40, 0, 0, 120};        // should all be even values for edge overlay
 157     static long vp_xo_hdmi[5] = { 240, 0, 150, 420};   // should all be even values for edge overlay
 158 
 159     if (camera_info.state.mode_play)
 160     {
 161         return 0;
 162     }
 163     else if (camera_info.state.mode_video)
 164     {
 165         if (shooting_get_prop(PROPCASE_VIDEO_RESOLUTION) == 2)  // VGA
 166         {
 167             if (hdmi_out) return 240;
 168             return 40;
 169         }
 170         return 0;
 171     }
 172     else
 173     {
 174         if (hdmi_out)
 175             return vp_xo_hdmi[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 176         return vp_xo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 177     }
 178 }
 179 
 180 int vid_get_viewport_display_yoffset()
 181 {
 182     // viewport height offset table for each image size
 183     // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 184     static long vp_yo[5] = { 0, 38, 0, 0 };
 185 
 186     if (camera_info.state.mode_play)
 187     {
 188         return 0;
 189     }
 190     else if (camera_info.state.mode_video)
 191     {
 192         if (shooting_get_prop(PROPCASE_VIDEO_RESOLUTION) == 2) // VGA
 193             return 0;
 194         return 38;
 195     }
 196     else
 197     {
 198         if (hdmi_out)
 199             return 0;
 200         return vp_yo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 201     }
 202 }
 203 
 204 // Functions for PTP Live View system
 205 int vid_get_viewport_display_xoffset_proper()   { return vid_get_viewport_display_xoffset(); }
 206 int vid_get_viewport_display_yoffset_proper()   { return vid_get_viewport_display_yoffset(); }
 207 int vid_get_viewport_fullscreen_width()         { if (hdmi_out) return 1920; else return 720; }
 208 int vid_get_viewport_fullscreen_height()        { if (hdmi_out) return 1080; else return 480; }
 209 int vid_get_viewport_buffer_width_proper()      { if (hdmi_out) return 1920; else return 736; }
 210 int vid_get_viewport_type()                     { return LV_FB_YUV8B; }
 211 int vid_get_aspect_ratio()                      { if (hdmi_out) return LV_ASPECT_16_9; else return LV_ASPECT_3_2; }
 212 
 213 int display_needs_refresh = 0;
 214 
 215 // Ximr layer
 216 typedef struct {
 217     unsigned short  unk1[6];
 218     unsigned short  color_type;
 219     unsigned short  visibility;
 220     unsigned short  unk2;
 221     unsigned short  src_y;
 222     unsigned short  src_x;
 223     unsigned short  src_h;
 224     unsigned short  src_w;
 225     unsigned short  dst_y;
 226     unsigned short  dst_x;
 227     unsigned short  enabled;
 228     unsigned int    marv_sig;
 229     unsigned int    bitmap;
 230     unsigned int    opacity;
 231     unsigned int    color;
 232     unsigned int    width;
 233     unsigned int    height;
 234     unsigned int    unk3;
 235 } ximr_layer;
 236 
 237 // Ximr context
 238 typedef struct {
 239     unsigned int    unk1[14];
 240     int             buffer_width;
 241     int             buffer_height;
 242     unsigned int    unk2[2];
 243     ximr_layer      layers[8];
 244     unsigned int    unk3[26];
 245     short           width;
 246     short           height;
 247     unsigned int    unk4[27];
 248 } ximr_context;
 249 
 250 /*
 251  * Called when Canon is updating UI, via dry_memcpy patch.
 252  * Sets flag for CHDK to update it's UI.
 253  * Also needed because bitmap buffer resolution changes when using HDMI
 254  * LCD = 720 x 480
 255  * HDMI = 960 x 540
 256  * TODO: This does not reset the OSD positions of things on screen
 257  *       If user has customised OSD layout how should this be handled?
 258  */
 259 void update_ui(ximr_context* ximr)
 260 {
 261     // Make sure we are updating the correct layer - skip redundant updates for HDMI out
 262     extern unsigned char* hdmi_buffer_check_adr;
 263     if ((ximr->layers[0].color_type == 0x0500) || (ximr->layers[0].bitmap == (unsigned int)&hdmi_buffer_check_adr))
 264     {
 265         // Update screen dimensions
 266         if (camera_screen.buffer_width != ximr->buffer_width)
 267         {
 268             camera_screen.width = ximr->width;
 269             camera_screen.height = ximr->height;
 270             camera_screen.buffer_width = ximr->buffer_width;
 271             camera_screen.buffer_height = ximr->buffer_height;
 272 
 273             // Reset OSD offset and width
 274             camera_screen.disp_right = camera_screen.width - 1;
 275             camera_screen.disp_width = camera_screen.width;
 276 
 277             // Update other values
 278             camera_screen.physical_width = camera_screen.width;
 279             camera_screen.size = camera_screen.width * camera_screen.height;
 280             camera_screen.buffer_size = camera_screen.buffer_width * camera_screen.buffer_height;
 281         }
 282 
 283         // Tell CHDK UI that display needs update
 284         display_needs_refresh = 1;
 285     }
 286 }

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