root/platform/a540/sub/100b/lib.c

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

DEFINITIONS

This source file includes following definitions.
  1. hook_raw_image_addr
  2. hook_yuv_shooting_buf_addr
  3. hook_yuv_shooting_buf_width
  4. hook_yuv_shooting_buf_height
  5. vid_get_bitmap_fb
  6. vid_get_viewport_fb
  7. vid_get_viewport_fb_d
  8. vid_get_viewport_width_proper
  9. vid_get_viewport_width
  10. vid_get_viewport_height_proper
  11. vid_get_viewport_height
  12. review_fullscreen_mode
  13. postreview_fullscreen_mode
  14. raw_shoot_avail
  15. mf_slider_active
  16. vid_get_viewport_live_fb
  17. camera_jpeg_count_str
  18. vid_get_palette_type
  19. vid_get_palette_size
  20. vid_get_bitmap_active_palette
  21. vid_get_bitmap_active_buffer
  22. vid_get_viewport_fullscreen_height
  23. vid_get_viewport_fullscreen_width
  24. vid_get_viewport_display_xoffset
  25. vid_get_viewport_xoffset
  26. vid_get_viewport_display_yoffset
  27. vid_get_viewport_yoffset

   1 #include "platform.h"
   2 #include "keyboard.h"
   3 #include "stdlib.h"
   4 
   5 char *hook_raw_image_addr()
   6 {
   7     return (char*)0x105B8AC0; // OK (find on ".crw")
   8     
   9 }
  10 
  11 /*
  12 YUV buffer created in jpeg processing for < full size jpeg
  13 not currently used, kept for future reference
  14 */
  15 #if 0
  16 /*
  17 buffer that holds the uncompressed yuv source of the fresh jpeg
  18 not used for L or W picture size
  19 */
  20 char *hook_yuv_shooting_buf_addr() {
  21     return (char*)0x105599A0; // based on proximity to viewport_fb in ROM table at FFEF8370, by comparison to a410
  22 }
  23 
  24 /*
  25 via sub_FFCA2CC8, after EnableEngineClocks
  26 note these update during shooting, may hold incorrect values after resolution changes
  27 invalid for L or Wide (continues to hold previous value)
  28 */
  29 int hook_yuv_shooting_buf_width() {
  30     if (shooting_get_resolution() !=0 && shooting_get_resolution() !=8)
  31         return *(int*)0x33394; //FFCB1D50
  32     return 0;
  33 }
  34 
  35 int hook_yuv_shooting_buf_height() {
  36     if (shooting_get_resolution() !=0 && shooting_get_resolution() !=8)
  37         return *(int*)0x33398; //FFCB1D54
  38     return 0;
  39 }
  40 #endif
  41 
  42 void *vid_get_bitmap_fb()
  43 {
  44     return (void*)0x103C79A0; // OK (find in _CreatePhysicalVram)
  45 }
  46 
  47 void *vid_get_viewport_fb()
  48 {
  49     return (void*)0x105F17A0; // OK (find on "VRAM Address  : %p")
  50 }
  51 
  52 void *vid_get_viewport_fb_d()
  53 {
  54 // from ewavr 
  55   int x=(*(int*)0x63AD0); // found in sub_FFD25770
  56   return (void *)x;
  57 // if we start camera in PB mode with movie on display, this pointer will be NULL
  58 // _fb isn't valid data, but at least it doesn't crash
  59 //  return (void*) (x ? (void *)x : vid_get_viewport_fb()) ;
  60 }
  61 
  62 extern int _GetVRAMHPixelsSize();
  63 extern int _GetVRAMVPixelsSize();
  64 
  65 // for testing only, to simulate cameras with variable aspect
  66 // MODE_PORTRAIT uses 1:1 ( 528x240 ) and MODE_LANDSCAPE 16:9 (704x180)
  67 // no need to implement this on other cameras unless you are doing development
  68 //#define FAKE_ASPECT 1
  69 
  70 int vid_get_viewport_width_proper() {
  71     int m = mode_get();
  72     if((m&MODE_MASK) == MODE_PLAY) {
  73         return 704;
  74     }
  75 #ifdef FAKE_ASPECT
  76     // fake 1:1 mode
  77     if((m&MODE_SHOOTING_MASK) == MODE_PORTRAIT) {
  78         return 528;
  79     }
  80 #endif
  81     // return hard coded width since mode doesn't update at the same time as GetVRAMHPixelsSize
  82     if((m&MODE_SHOOTING_MASK) == MODE_STITCH) {
  83         return 352;
  84     }
  85     return _GetVRAMHPixelsSize();
  86 }
  87 
  88 int vid_get_viewport_width() {
  89     return vid_get_viewport_width_proper()>>1;
  90 }
  91 
  92 int vid_get_viewport_height_proper() {
  93     int m = mode_get();
  94     // TODO not correct if TV out connected
  95     if((m&MODE_MASK) == MODE_PLAY) {
  96         return 240;
  97     }
  98 #ifdef FAKE_ASPECT
  99     // fake 16:9 mode
 100     if((m&MODE_SHOOTING_MASK) == MODE_LANDSCAPE) {
 101         return 180; 
 102     }
 103 #endif
 104     // return hard coded width since mode doesn't update at the same time as GetVRAMHPixelsSize
 105     if((m&MODE_SHOOTING_MASK) == MODE_STITCH) {
 106         return 120; 
 107     }
 108     return _GetVRAMVPixelsSize();
 109 }
 110 
 111 long vid_get_viewport_height() {
 112     return vid_get_viewport_height_proper();
 113 }
 114 
 115 // the following aren't used, kept for informational purposes
 116 #if 0
 117 int review_fullscreen_mode(){ //from 710 added
 118  char r;
 119  get_parameter_data(53, &r, 1);
 120  return  r==0;
 121 }
 122 
 123 int postreview_fullscreen_mode(){ //from 710 added
 124  char r;
 125  get_parameter_data(54, &r, 1);
 126  return  r==0;
 127 }
 128 
 129 
 130 static int file_size_table[3][5]={{3110,2562,1666,1057,288},
 131                                   {1954,1441, 928, 608,176},
 132                                   {960,  736, 480, 320,112}};  // in KB   // from 710 added
 133                                         
 134                                   
 135 long raw_shoot_avail(){ // from 710 added
 136  long jpegs,size,quality;
 137  jpegs=atoi((char*)0x6E8D0); // orig.0x7BD98 find -> a9999
 138  get_property_case(23, (void *)&quality, 4);
 139  get_property_case(24, (void *)&size, 4);
 140  if ((size>4) || (quality>2)) return 0; 
 141  return (file_size_table[quality][size]*jpegs)/(file_size_table[quality][size]+(hook_raw_size()>>10));
 142 }
 143 
 144 
 145 int mf_slider_active() // from 710 added
 146 {
 147  return *(long*)0x6C8B0==0x100; // orig.0x798F0  found in "ControlSwitcher.c"
 148 }
 149 #endif
 150 
 151 void *vid_get_viewport_live_fb() // from 710 added
 152 {
 153     void **fb=(void **)0x5288;
 154     unsigned char buff = *((unsigned char*)0x5298);
 155     if (buff == 0) {
 156         buff = 2;
 157     }
 158     else {
 159         buff--;
 160     }
 161     return fb[buff];
 162 }
 163 
 164 
 165 char *camera_jpeg_count_str()
 166 {
 167     return (char*)0x6E8D0 ; // from 700 added orig. 0x78688
 168 }
 169 
 170 // PTP display stuff
 171 int vid_get_palette_type() { return 1; }
 172 int vid_get_palette_size() { return 16*4; }
 173 
 174 void *vid_get_bitmap_active_palette() {
 175     return (void *)0x634E0; // GetPaletteFromPhysicalScreen
 176 }
 177 
 178 void *vid_get_bitmap_active_buffer()
 179 {
 180     return (void*)(*(int*)0x5ED0); // FFD23420 DisplayPhysicalScreenWithYUVPalette
 181 }
 182 
 183 int vid_get_viewport_fullscreen_height() {
 184     // except for stitch, always full screen
 185     int m = mode_get();
 186     if((m&MODE_MASK) != MODE_PLAY && ((m&MODE_SHOOTING_MASK) == MODE_STITCH
 187 #ifdef FAKE_ASPECT
 188          || (m&MODE_SHOOTING_MASK) == MODE_LANDSCAPE
 189 #endif
 190          )) {
 191         return 240;
 192     }
 193     return vid_get_viewport_height_proper();
 194 }
 195 int vid_get_viewport_fullscreen_width() {
 196     // except for stitch, always full screen
 197     int m = mode_get();
 198     if((m&MODE_MASK) != MODE_PLAY && ((m&MODE_SHOOTING_MASK) == MODE_STITCH
 199 #ifdef FAKE_ASPECT
 200          || (m&MODE_SHOOTING_MASK) == MODE_PORTRAIT
 201 #endif
 202     )) {
 203         return 704;
 204     }
 205     return vid_get_viewport_width_proper();
 206 }
 207 
 208 int vid_get_viewport_display_xoffset() {
 209     int m = mode_get();
 210     if((m&MODE_MASK) == MODE_PLAY) {
 211         return 0;
 212     } else if((m&MODE_SHOOTING_MASK) == MODE_STITCH) {
 213         short dir=0;
 214         short seq=0;
 215         get_property_case(PROPCASE_STITCH_DIRECTION,&dir,sizeof(dir));
 216         get_property_case(PROPCASE_STITCH_SEQUENCE,&seq,sizeof(seq));
 217         // overall stitch window is 3/4 screen width, centered
 218         // live part is 1/2, so margin is either 1/8th or 3/8th
 219         if(dir==0) {
 220             return seq?132:44;
 221         } else {
 222             return seq?44:132;
 223         }
 224 #ifdef FAKE_ASPECT
 225     } else if((m&MODE_SHOOTING_MASK) == MODE_PORTRAIT) {
 226         return 44;
 227 #endif
 228     }
 229     return 0;
 230 }
 231 
 232 #ifdef FAKE_ASPECT
 233 int vid_get_viewport_xoffset() {
 234     int m = mode_get();
 235     if((m&MODE_MASK) != MODE_PLAY && (m&MODE_SHOOTING_MASK) == MODE_PORTRAIT) {
 236        return 44;
 237     }
 238     return 0;
 239 }
 240 #endif
 241 
 242 int vid_get_viewport_display_yoffset() {
 243     int m = mode_get();
 244     if((m&MODE_MASK) == MODE_PLAY) {
 245         return 0;
 246     }
 247 #ifdef FAKE_ASPECT
 248     if((m&MODE_SHOOTING_MASK) == MODE_LANDSCAPE) {
 249        return 30;
 250     }
 251 #endif
 252     return ((m&MODE_SHOOTING_MASK) == MODE_STITCH)?60:0; // window is 120, centered in 240 screen
 253 }
 254 
 255 #ifdef FAKE_ASPECT
 256 int vid_get_viewport_yoffset() {
 257     int m = mode_get();
 258     if((m&MODE_MASK) != MODE_PLAY && (m&MODE_SHOOTING_MASK) == MODE_LANDSCAPE) {
 259        return 30;
 260     }
 261     return 0;
 262 }
 263 #endif

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