| 1 | #ifndef PLATFORM_H |
|---|
| 2 | #define PLATFORM_H |
|---|
| 3 | |
|---|
| 4 | #include "camera.h" |
|---|
| 5 | |
|---|
| 6 | #define SSID_INVALID (-32767) |
|---|
| 7 | #define ASID_INVALID (-32767) |
|---|
| 8 | |
|---|
| 9 | #define MODE_MASK 0x0300 |
|---|
| 10 | #define MODE_REC 0x0100 |
|---|
| 11 | #define MODE_PLAY 0x0200 |
|---|
| 12 | |
|---|
| 13 | #define MODE_SHOOTING_MASK 0x00FF |
|---|
| 14 | |
|---|
| 15 | /* capture mode constants. These are in their own header for easier sed processing*/ |
|---|
| 16 | #include "modelist.h" |
|---|
| 17 | |
|---|
| 18 | // converted large macro to function in platform/generic/shooting.c (philmoz July 2011) |
|---|
| 19 | extern int mode_is_video(int); |
|---|
| 20 | #define MODE_IS_VIDEO(m) mode_is_video(m) |
|---|
| 21 | |
|---|
| 22 | /* propcase ID constants. These are in their own header files for easier sed processing */ |
|---|
| 23 | #if CAM_PROPSET == 4 |
|---|
| 24 | #include "propset4.h" |
|---|
| 25 | #elif CAM_PROPSET == 3 |
|---|
| 26 | #include "propset3.h" |
|---|
| 27 | #elif CAM_PROPSET == 2 // most digic3 cameras |
|---|
| 28 | #include "propset2.h" |
|---|
| 29 | #elif CAM_PROPSET == 1 // most digic2 cameras |
|---|
| 30 | #include "propset1.h" |
|---|
| 31 | #else |
|---|
| 32 | #error unknown camera processor |
|---|
| 33 | #endif |
|---|
| 34 | |
|---|
| 35 | #define MIN_DIST CAMERA_MIN_DIST // Defined in camera.h (can be overridden in platform_camera.h) |
|---|
| 36 | #define MAX_DIST CAMERA_MAX_DIST // Defined in camera.h (can be overridden in platform_camera.h) |
|---|
| 37 | #define INFINITY_DIST 0xFFFFFFFF // Value to send to firmware to select 'infinity' focus |
|---|
| 38 | |
|---|
| 39 | //******************** |
|---|
| 40 | //char * get_debug(); |
|---|
| 41 | //******************** |
|---|
| 42 | |
|---|
| 43 | #define MODE_SCREEN_MASK 0x0C00 |
|---|
| 44 | #define MODE_SCREEN_OPENED 0x0400 |
|---|
| 45 | #define MODE_SCREEN_ROTATED 0x0800 |
|---|
| 46 | |
|---|
| 47 | /* Keyboard repeat and initial delays */ |
|---|
| 48 | #define KBD_REPEAT_DELAY 140 |
|---|
| 49 | #define KBD_INITIAL_DELAY 300 |
|---|
| 50 | |
|---|
| 51 | // Video recording current status constants, see movie_status variable |
|---|
| 52 | #define VIDEO_RECORD_NEVER_STARTED 0 |
|---|
| 53 | #define VIDEO_RECORD_STOPPED 1 |
|---|
| 54 | #define VIDEO_RECORD_IN_PROGRESS 4 |
|---|
| 55 | |
|---|
| 56 | //Optical & digital zoom status constants, see zoom_status variable |
|---|
| 57 | #define ZOOM_OPTICAL_MIN 1 |
|---|
| 58 | #define ZOOM_OPTICAL_MAX 2 |
|---|
| 59 | #define ZOOM_OPTICAL_MEDIUM 3 |
|---|
| 60 | #define ZOOM_OPTICAL_IN 4 |
|---|
| 61 | #define ZOOM_OPTICAL_OUT 5 |
|---|
| 62 | #define ZOOM_OPTICAL_REACHED_MIN 7 |
|---|
| 63 | |
|---|
| 64 | #define ZOOM_DIGITAL_MAX 9 |
|---|
| 65 | #define ZOOM_DIGITAL_MEDIUM 10 |
|---|
| 66 | #define ZOOM_DIGITAL_IN 11 |
|---|
| 67 | #define ZOOM_DIGITAL_OUT 12 |
|---|
| 68 | #define ZOOM_DIGITAL_REACHED_MAX 13 |
|---|
| 69 | |
|---|
| 70 | typedef struct { |
|---|
| 71 | unsigned short hackmode; // platform independent mode values from MODE_xxx enum |
|---|
| 72 | unsigned short canonmode; // PROPCASE_SHOOTING_MODE value |
|---|
| 73 | } CapturemodeMap; |
|---|
| 74 | |
|---|
| 75 | typedef struct { |
|---|
| 76 | short id; // hacks id |
|---|
| 77 | short prop_id; // Canons id |
|---|
| 78 | char name[8]; |
|---|
| 79 | short shutter_dfs_value; // shutter speed to use dark frame substraction |
|---|
| 80 | } ISOTable; |
|---|
| 81 | |
|---|
| 82 | typedef struct { |
|---|
| 83 | short id; // hacks id |
|---|
| 84 | short prop_id; // Canons id |
|---|
| 85 | char name[8]; |
|---|
| 86 | long usec; |
|---|
| 87 | } ShutterSpeed; |
|---|
| 88 | |
|---|
| 89 | typedef struct { |
|---|
| 90 | short id; // hacks id |
|---|
| 91 | short prop_id; // Canons id |
|---|
| 92 | char name[8]; |
|---|
| 93 | } ApertureSize; |
|---|
| 94 | |
|---|
| 95 | typedef struct { |
|---|
| 96 | short av96; |
|---|
| 97 | short dav96; |
|---|
| 98 | short av96_step; |
|---|
| 99 | short tv96; |
|---|
| 100 | short dtv96; |
|---|
| 101 | short tv96_step; |
|---|
| 102 | short sv96; |
|---|
| 103 | short dsv96; |
|---|
| 104 | short sv96_step; |
|---|
| 105 | short iso; |
|---|
| 106 | short diso; |
|---|
| 107 | short iso_step; |
|---|
| 108 | short subj_dist; |
|---|
| 109 | short dsubj_dist; |
|---|
| 110 | short subj_dist_step; |
|---|
| 111 | short shoot_counter; |
|---|
| 112 | short type; |
|---|
| 113 | } EXPO_BRACKETING_VALUES; |
|---|
| 114 | |
|---|
| 115 | #define SET_NOW 1 |
|---|
| 116 | #define SET_LATER 0 |
|---|
| 117 | |
|---|
| 118 | #define SHOW_ALWAYS 1 |
|---|
| 119 | #define SHOW_HALF 2 |
|---|
| 120 | |
|---|
| 121 | |
|---|
| 122 | typedef struct { |
|---|
| 123 | short av96; |
|---|
| 124 | short tv96; |
|---|
| 125 | short sv96; |
|---|
| 126 | short subj_dist; |
|---|
| 127 | short nd_filter; |
|---|
| 128 | } PHOTO_PARAM; |
|---|
| 129 | |
|---|
| 130 | typedef struct { |
|---|
| 131 | short hyperfocal_valid; |
|---|
| 132 | short distance_valid; |
|---|
| 133 | int hyperfocal_distance_1e3; |
|---|
| 134 | int aperture_value; |
|---|
| 135 | int focal_length; |
|---|
| 136 | int subject_distance; |
|---|
| 137 | int near_limit; |
|---|
| 138 | int far_limit; |
|---|
| 139 | int hyperfocal_distance; |
|---|
| 140 | int depth_of_field; |
|---|
| 141 | int min_stack_distance; |
|---|
| 142 | } DOF_TYPE; |
|---|
| 143 | |
|---|
| 144 | extern DOF_TYPE dof_values; |
|---|
| 145 | |
|---|
| 146 | typedef struct { |
|---|
| 147 | short av96; |
|---|
| 148 | short tv96; |
|---|
| 149 | short sv96; |
|---|
| 150 | short iso; |
|---|
| 151 | short sv96_market; |
|---|
| 152 | short iso_market; |
|---|
| 153 | short bv96_measured; |
|---|
| 154 | short bv96_seted; //Ev96_internal-Sv96 |
|---|
| 155 | short ev96_seted; //Tv96+Av96 |
|---|
| 156 | short ev96_measured; //Bv96+Sv96 |
|---|
| 157 | short dev96; // Ev96_external-Ev96_internal |
|---|
| 158 | short dev96_canon; // Canon OverExposure |
|---|
| 159 | int b; //average scene luminance |
|---|
| 160 | } EXPO_TYPE; |
|---|
| 161 | |
|---|
| 162 | typedef struct { |
|---|
| 163 | float value; |
|---|
| 164 | char fraction[10]; |
|---|
| 165 | } shutter_speed; |
|---|
| 166 | |
|---|
| 167 | |
|---|
| 168 | /******************************************************************/ |
|---|
| 169 | |
|---|
| 170 | int get_focal_length(int zp); |
|---|
| 171 | int get_effective_focal_length(int zp); |
|---|
| 172 | int get_zoom_x(int zp); |
|---|
| 173 | |
|---|
| 174 | /******************************************************************/ |
|---|
| 175 | |
|---|
| 176 | long get_tick_count(); |
|---|
| 177 | |
|---|
| 178 | void remount_filesystem(); |
|---|
| 179 | void mark_filesystem_bootable(); |
|---|
| 180 | |
|---|
| 181 | /******************************************************************/ |
|---|
| 182 | |
|---|
| 183 | long get_parameter_data(long id, void *buf, long bufsize); |
|---|
| 184 | long set_parameter_data(long id, void *buf, long bufsize); |
|---|
| 185 | |
|---|
| 186 | long get_property_case(long id, void *buf, long bufsize); |
|---|
| 187 | long set_property_case(long id, void *buf, long bufsize); |
|---|
| 188 | |
|---|
| 189 | long get_file_counter(); |
|---|
| 190 | long get_exposure_counter(); |
|---|
| 191 | long get_file_next_counter(); |
|---|
| 192 | #if defined(CAM_DATE_FOLDER_NAMING) |
|---|
| 193 | void get_target_dir_name(char*); |
|---|
| 194 | #else |
|---|
| 195 | long get_target_dir_num(); |
|---|
| 196 | #endif |
|---|
| 197 | long get_target_file_num(); |
|---|
| 198 | |
|---|
| 199 | /******************************************************************/ |
|---|
| 200 | |
|---|
| 201 | void kbd_key_press(long key); |
|---|
| 202 | void kbd_key_release(long key); |
|---|
| 203 | void kbd_key_release_all(); |
|---|
| 204 | long kbd_is_key_pressed(long key); |
|---|
| 205 | long kbd_is_key_clicked(long key); |
|---|
| 206 | long kbd_get_pressed_key(); |
|---|
| 207 | long kbd_get_clicked_key(); |
|---|
| 208 | long kbd_get_autoclicked_key(); |
|---|
| 209 | void kbd_reset_autoclicked_key(); |
|---|
| 210 | long kbd_use_zoom_as_mf(); |
|---|
| 211 | long kbd_use_up_down_left_right_as_fast_switch(); |
|---|
| 212 | void kbd_set_alt_mode_key_mask(long key); |
|---|
| 213 | int get_usb_power(int edge); |
|---|
| 214 | long get_jogdial_direction(void); |
|---|
| 215 | /******************************************************************/ |
|---|
| 216 | |
|---|
| 217 | long vid_is_bitmap_shown(); |
|---|
| 218 | void *vid_get_bitmap_fb(); |
|---|
| 219 | |
|---|
| 220 | void *vid_get_viewport_fb(); |
|---|
| 221 | void *vid_get_viewport_fb_d(); |
|---|
| 222 | void *vid_get_viewport_live_fb(); |
|---|
| 223 | |
|---|
| 224 | void vid_bitmap_refresh(); |
|---|
| 225 | void vid_turn_off_updates(); |
|---|
| 226 | void vid_turn_on_updates(); |
|---|
| 227 | |
|---|
| 228 | // These define the viewport dimensions both physically and in terms of the CHDK co-ordinate system |
|---|
| 229 | // CHDK works in a 360x240 screen dimension / co-ordinate system |
|---|
| 230 | extern long vid_get_viewport_height(); // Viewport height in CHDK screen pixels |
|---|
| 231 | extern int vid_get_viewport_width(); // Viewport width in CHDK screen pixels |
|---|
| 232 | extern int vid_get_viewport_xoffset(); // X offset of viewport edge relative to the viewport buffer (in CHDK screen pixels) |
|---|
| 233 | extern int vid_get_viewport_yoffset(); // Y offset of viewport top relative to the viewport buffer (in CHDK screen pixels) |
|---|
| 234 | extern int vid_get_viewport_display_xoffset(); // X offset of viewport edge relative to LCD screen (in CHDK screen pixels) |
|---|
| 235 | extern int vid_get_viewport_display_yoffset(); // Y offset of viewport top relative to LCD screen (in CHDK screen pixels) |
|---|
| 236 | extern int vid_get_viewport_byte_width(); // Physical width of viewport row in bytes |
|---|
| 237 | extern int vid_get_viewport_yscale(); // Y multiplier for cameras with 480 pixel high viewports (CHDK code assumes 240) |
|---|
| 238 | extern int vid_get_viewport_image_offset(); // Byte offset from start of viewport memory to first displayed pixel |
|---|
| 239 | extern int vid_get_viewport_row_offset(); // Difference between physical width of viewport and displayed width (in bytes) |
|---|
| 240 | |
|---|
| 241 | |
|---|
| 242 | // PTP Live View functions |
|---|
| 243 | // These functions return actual size/offset in pixels of the viewport and bitmap buffers |
|---|
| 244 | extern int vid_get_viewport_display_xoffset_proper(); // X Offset (for variable image size) |
|---|
| 245 | extern int vid_get_viewport_display_yoffset_proper(); // Y Offset (for variable image size) |
|---|
| 246 | extern int vid_get_viewport_width_proper(); // Visible viewport width (for variable image size) |
|---|
| 247 | extern int vid_get_viewport_height_proper(); // Visible viewport height (for variable image size) |
|---|
| 248 | extern int vid_get_viewport_max_width(); // Max visible viewport width in pixels |
|---|
| 249 | extern int vid_get_viewport_max_height(); // Max visible viewport height in pixels |
|---|
| 250 | extern int vid_get_viewport_logical_width(); |
|---|
| 251 | extern int vid_get_viewport_logical_height(); |
|---|
| 252 | extern int vid_get_viewport_buffer_width_proper(); // Physical viewport buffer width in pixels |
|---|
| 253 | extern int vid_get_palette_type(); // Palette type (0 - 3) |
|---|
| 254 | extern int vid_get_palette_size(); // Palette size (in bytes) |
|---|
| 255 | extern int vid_get_aspect_ratio(); // LCD aspect ratio (0 = 4:3 or 1 = 16:9) |
|---|
| 256 | |
|---|
| 257 | extern void *vid_get_viewport_active_buffer(); // Return active live viewport memory address |
|---|
| 258 | extern void *vid_get_bitmap_active_buffer(); // Return current active bitmap memory address |
|---|
| 259 | extern void *vid_get_bitmap_active_palette(); // Return current palette memory address |
|---|
| 260 | |
|---|
| 261 | #ifdef CAM_LOAD_CUSTOM_COLORS |
|---|
| 262 | // Color palette function |
|---|
| 263 | extern void load_chdk_palette(); |
|---|
| 264 | #endif |
|---|
| 265 | /******************************************************************/ |
|---|
| 266 | |
|---|
| 267 | void *hook_raw_fptr(); |
|---|
| 268 | void *hook_raw_ret_addr(); |
|---|
| 269 | char *hook_raw_image_addr(); |
|---|
| 270 | char *hook_alt_raw_image_addr(); |
|---|
| 271 | long hook_raw_size(); |
|---|
| 272 | void hook_raw_install(); |
|---|
| 273 | void hook_raw_save_complete(); |
|---|
| 274 | |
|---|
| 275 | /******************************************************************/ |
|---|
| 276 | |
|---|
| 277 | long lens_get_zoom_pos(); |
|---|
| 278 | void lens_set_zoom_pos(long newpos); |
|---|
| 279 | long lens_get_zoom_point(); |
|---|
| 280 | void lens_set_zoom_point(long newpt); |
|---|
| 281 | void lens_set_zoom_speed(long newspd); //for S-series |
|---|
| 282 | long lens_get_focus_pos(); |
|---|
| 283 | long lens_get_focus_pos_from_lens(); |
|---|
| 284 | void lens_set_focus_pos(long newpos); |
|---|
| 285 | long lens_get_target_distance(); |
|---|
| 286 | |
|---|
| 287 | /******************************************************************/ |
|---|
| 288 | |
|---|
| 289 | int shooting_in_progress(); |
|---|
| 290 | int shooting_is_flash(); |
|---|
| 291 | int shooting_is_flash_ready(); |
|---|
| 292 | short shooting_get_flash_mode(); |
|---|
| 293 | |
|---|
| 294 | |
|---|
| 295 | /******************************************************************/ |
|---|
| 296 | int shooting_get_user_tv_id(); |
|---|
| 297 | #if defined(CAM_DRAW_EXPOSITION) |
|---|
| 298 | char* shooting_get_tv_str(); |
|---|
| 299 | #endif |
|---|
| 300 | short shooting_get_tv96_from_shutter_speed(float t); |
|---|
| 301 | short shooting_get_tv96(); |
|---|
| 302 | void shooting_set_tv96(short v, short is_now); |
|---|
| 303 | void shooting_set_tv96_direct(short v, short is_now); |
|---|
| 304 | void shooting_set_shutter_speed_ubasic(int t, short is_now); |
|---|
| 305 | short shooting_get_user_tv96(); |
|---|
| 306 | void shooting_set_user_tv96(short v); |
|---|
| 307 | float shooting_get_shutter_speed_from_tv96(short tv); |
|---|
| 308 | float shooting_get_shutter_speed_override_value(); |
|---|
| 309 | const char * shooting_get_tv_override_value(); |
|---|
| 310 | const char * shooting_get_tv_bracket_value(); |
|---|
| 311 | const char * shooting_get_bracket_type(); |
|---|
| 312 | void shooting_set_user_tv_by_id(int v); |
|---|
| 313 | void shooting_set_user_tv_by_id_rel(int v); |
|---|
| 314 | const ShutterSpeed *shooting_get_tv_line(); |
|---|
| 315 | /******************************************************************/ |
|---|
| 316 | short shooting_get_aperture_sizes_table_size(); |
|---|
| 317 | short shooting_get_max_aperture_sizes_table_prop_id(); |
|---|
| 318 | short shooting_get_aperture_from_av96(short av96); |
|---|
| 319 | int shooting_get_user_av_id(); |
|---|
| 320 | #if defined(CAM_DRAW_EXPOSITION) |
|---|
| 321 | char* shooting_get_av_str(); |
|---|
| 322 | #endif |
|---|
| 323 | void shooting_set_user_av_by_id(int v); |
|---|
| 324 | short shooting_get_av96(); |
|---|
| 325 | void shooting_set_av96(short v,short is_now); |
|---|
| 326 | void shooting_set_av96_direct(short v, short is_now); |
|---|
| 327 | short shooting_get_user_av96(); |
|---|
| 328 | void shooting_set_user_av96(short v); |
|---|
| 329 | void shooting_set_user_av_by_id_rel(int v); |
|---|
| 330 | short shooting_get_real_aperture(); |
|---|
| 331 | short shooting_get_min_real_aperture(); |
|---|
| 332 | short shooting_get_av96_override_value(); |
|---|
| 333 | const char * shooting_get_av_bracket_value(); |
|---|
| 334 | void shooting_set_nd_filter_state(short v, short is_now); |
|---|
| 335 | /******************************************************************/ |
|---|
| 336 | int shooting_get_day_seconds(); |
|---|
| 337 | int shooting_get_tick_count(); |
|---|
| 338 | /******************************************************************/ |
|---|
| 339 | void shooting_set_prop(int id, int v); |
|---|
| 340 | int shooting_get_prop(int id); |
|---|
| 341 | /******************************************************************/ |
|---|
| 342 | extern int circle_of_confusion; |
|---|
| 343 | /******************************************************************/ |
|---|
| 344 | extern short shooting_get_is_mode(); |
|---|
| 345 | extern short shooting_get_resolution(); |
|---|
| 346 | extern short shooting_get_display_mode(); |
|---|
| 347 | /******************************************************************/ |
|---|
| 348 | extern const int zoom_points; |
|---|
| 349 | int shooting_get_zoom(); |
|---|
| 350 | void shooting_set_zoom(int v); |
|---|
| 351 | void shooting_set_zoom_rel(int v); |
|---|
| 352 | void shooting_set_zoom_speed(int v); |
|---|
| 353 | /******************************************************************/ |
|---|
| 354 | void shooting_set_focus(int v, short is_now); |
|---|
| 355 | short shooting_get_focus_mode(); |
|---|
| 356 | short shooting_get_real_focus_mode(); |
|---|
| 357 | short shooting_get_focus_state(); |
|---|
| 358 | short shooting_get_focus_ok(); |
|---|
| 359 | void shooting_update_dof_values(); |
|---|
| 360 | int shooting_get_hyperfocal_distance(); |
|---|
| 361 | int shooting_get_hyperfocal_distance_1e3_f(int av, int fl); |
|---|
| 362 | int shooting_get_near_limit_of_acceptable_sharpness(); |
|---|
| 363 | int shooting_get_far_limit_of_acceptable_sharpness(); |
|---|
| 364 | int shooting_get_depth_of_field(); |
|---|
| 365 | int shooting_get_min_stack_distance(); |
|---|
| 366 | int shooting_get_subject_distance(); |
|---|
| 367 | int shooting_get_subject_distance_override_value(); |
|---|
| 368 | int shooting_get_subject_distance_bracket_value(); |
|---|
| 369 | int shooting_get_subject_distance_override_koef(); |
|---|
| 370 | int shooting_get_lens_to_focal_plane_width(); |
|---|
| 371 | short shooting_get_drive_mode(); |
|---|
| 372 | short shooting_can_focus(); |
|---|
| 373 | short shooting_get_common_focus_mode(); |
|---|
| 374 | short shooting_is_infinity_distance(); |
|---|
| 375 | /******************************************************************/ |
|---|
| 376 | int shooting_get_iso_mode(); |
|---|
| 377 | void shooting_set_iso_mode(int v); |
|---|
| 378 | short shooting_get_sv96(); |
|---|
| 379 | short shooting_get_svm96(); |
|---|
| 380 | short shooting_get_iso_market(); |
|---|
| 381 | short shooting_get_iso_real(); |
|---|
| 382 | void shooting_set_iso_real(short iso, short is_now); |
|---|
| 383 | //void shooting_set_iso_market(short isom); |
|---|
| 384 | //void shooting_set_iso_real_delta_from_base(short diso); |
|---|
| 385 | void shooting_set_sv96(short sv96, short is_now); |
|---|
| 386 | short shooting_get_iso_override_value(); |
|---|
| 387 | short shooting_get_iso_bracket_value(); |
|---|
| 388 | /******************************************************************/ |
|---|
| 389 | short shooting_get_canon_overexposure_value(); |
|---|
| 390 | short shooting_get_bv96(); |
|---|
| 391 | int shooting_get_luminance(); |
|---|
| 392 | //const char* shooting_get_flash_light_value(); |
|---|
| 393 | /******************************************************************/ |
|---|
| 394 | int shooting_get_canon_subject_distance(); |
|---|
| 395 | int shooting_get_exif_subject_dist(); |
|---|
| 396 | /******************************************************************/ |
|---|
| 397 | void shooting_expo_param_override(); |
|---|
| 398 | void shooting_bracketing(void); |
|---|
| 399 | |
|---|
| 400 | void shooting_video_bitrate_change(int v); |
|---|
| 401 | extern int auto_started; |
|---|
| 402 | void shooting_tv_bracketing(); |
|---|
| 403 | void shooting_av_bracketing(); |
|---|
| 404 | /******************************************************************/ |
|---|
| 405 | // capture mode functions |
|---|
| 406 | // return a CHDK mode enum for a PROPCASE_SHOOTING_MODE value, or 0 if not found |
|---|
| 407 | int shooting_mode_canon2chdk(int canonmode); |
|---|
| 408 | // return a PROPCASE_SHOOTING_MODE value for a CHDK mode enum value, or -1 if not found. 0 is a valid mode on some cameras. |
|---|
| 409 | int shooting_mode_chdk2canon(int hackmode); |
|---|
| 410 | // set capture mode from CHDK mode, returns 0 if mode not found or not in rec, otherwise 1 |
|---|
| 411 | int shooting_set_mode_chdk(int mode); |
|---|
| 412 | // set capture mode from PROPCASE_SHOOTING_MODE value. return 0 if not in rec or mode is -1, otherwise 1 |
|---|
| 413 | int shooting_set_mode_canon(int mode); |
|---|
| 414 | |
|---|
| 415 | // returns 0 if in play, nonzero if rec |
|---|
| 416 | int rec_mode_active(void); |
|---|
| 417 | |
|---|
| 418 | // not used. Right now this is just to preserve code from earlier version of mode_get() |
|---|
| 419 | // in case we want to check play/rec switch state in the future. |
|---|
| 420 | // WARNING: it isn't known if all variants of this check the switch state or some other bit. |
|---|
| 421 | // should return 0 is switch is in play position, non-zero otherwise |
|---|
| 422 | //int rec_switch_state(void); |
|---|
| 423 | |
|---|
| 424 | // swivel screen state. |
|---|
| 425 | #ifdef CAM_SWIVEL_SCREEN |
|---|
| 426 | // 0 not open, non-zero open |
|---|
| 427 | int screen_opened(void); |
|---|
| 428 | // 0 not rotated, non-zero rotated |
|---|
| 429 | int screen_rotated(void); |
|---|
| 430 | #endif |
|---|
| 431 | |
|---|
| 432 | /******************************************************************/ |
|---|
| 433 | void clear_values(); |
|---|
| 434 | /******************************************************************/ |
|---|
| 435 | |
|---|
| 436 | int mode_get(); |
|---|
| 437 | |
|---|
| 438 | /******************************************************************/ |
|---|
| 439 | |
|---|
| 440 | long stat_get_vbatt(); |
|---|
| 441 | int get_ccd_temp(); |
|---|
| 442 | int get_optical_temp(); |
|---|
| 443 | int get_battery_temp(); |
|---|
| 444 | long get_vbatt_min(); |
|---|
| 445 | long get_vbatt_max(); |
|---|
| 446 | void play_sound(unsigned sound); |
|---|
| 447 | void camera_set_raw(int mode); |
|---|
| 448 | void camera_set_nr(int mode); |
|---|
| 449 | int camera_get_nr(); |
|---|
| 450 | int camera_get_script_autostart(); |
|---|
| 451 | void camera_set_script_autostart(); |
|---|
| 452 | void enter_alt(); |
|---|
| 453 | void exit_alt(); |
|---|
| 454 | void camera_shutdown_in_a_second(void); |
|---|
| 455 | |
|---|
| 456 | void disable_shutdown(); |
|---|
| 457 | void enable_shutdown(); |
|---|
| 458 | |
|---|
| 459 | void JogDial_CW(void); |
|---|
| 460 | void JogDial_CCW(void); |
|---|
| 461 | void change_video_tables(int a, int b); |
|---|
| 462 | int get_flash_params_count(void); |
|---|
| 463 | |
|---|
| 464 | /******************************************************************/ |
|---|
| 465 | void __attribute__((noreturn)) shutdown(); |
|---|
| 466 | void camera_set_led(int led, int state, int bright); |
|---|
| 467 | void debug_led(int state); |
|---|
| 468 | /****************************************/ |
|---|
| 469 | extern int canon_menu_active; |
|---|
| 470 | extern char canon_shoot_menu_active; |
|---|
| 471 | extern int recreview_hold; |
|---|
| 472 | |
|---|
| 473 | extern int movie_status; |
|---|
| 474 | unsigned int movie_reset; |
|---|
| 475 | unsigned int GetFreeCardSpaceKb(void); |
|---|
| 476 | unsigned int GetTotalCardSpaceKb(void); |
|---|
| 477 | |
|---|
| 478 | |
|---|
| 479 | |
|---|
| 480 | int swap_partitions(int new_partition); |
|---|
| 481 | unsigned char get_active_partition(void); |
|---|
| 482 | int get_part_type(void); |
|---|
| 483 | int get_part_count(void); |
|---|
| 484 | int is_partition_changed(void); |
|---|
| 485 | void create_partitions(void); |
|---|
| 486 | extern char * camera_jpeg_count_str(); |
|---|
| 487 | |
|---|
| 488 | unsigned int GetJpgCount(void); |
|---|
| 489 | unsigned int GetRawCount(void); |
|---|
| 490 | |
|---|
| 491 | void MakeAFScan(void); |
|---|
| 492 | extern int movie_status; |
|---|
| 493 | extern int zoom_status; |
|---|
| 494 | void EnterToCompensationEVF(void); |
|---|
| 495 | void ExitFromCompensationEVF(void); |
|---|
| 496 | |
|---|
| 497 | extern void PutInNdFilter(); |
|---|
| 498 | extern void PutOutNdFilter(); |
|---|
| 499 | extern long GetCurrentAvValue(); |
|---|
| 500 | extern long IsStrobeChargeCompleted(); |
|---|
| 501 | extern void SetCurrentCaptureModeType(); |
|---|
| 502 | #if CAM_CAN_UNLOCK_OPTICAL_ZOOM_IN_VIDEO |
|---|
| 503 | extern void UnsetZoomForMovie(); |
|---|
| 504 | #endif |
|---|
| 505 | #ifdef CAM_AV_OVERRIDE_IRIS_FIX |
|---|
| 506 | extern int MoveIrisWithAv(short*); |
|---|
| 507 | #endif |
|---|
| 508 | #if CAM_EV_IN_VIDEO |
|---|
| 509 | extern void ExpCtrlTool_StartContiAE(int, int); |
|---|
| 510 | extern void ExpCtrlTool_StopContiAE(int, int); |
|---|
| 511 | extern short SetAE_ShutterSpeed(short* tv); |
|---|
| 512 | #endif |
|---|
| 513 | |
|---|
| 514 | void TurnOnBackLight(void); |
|---|
| 515 | void TurnOffBackLight(void); |
|---|
| 516 | |
|---|
| 517 | void wait_until_remote_button_is_released(void); |
|---|
| 518 | short shooting_get_ev_correction1(); |
|---|
| 519 | short shooting_get_ev_correction2(); |
|---|
| 520 | |
|---|
| 521 | //image_quality_override |
|---|
| 522 | void shooting_set_image_quality(int imq); |
|---|
| 523 | |
|---|
| 524 | int get_ev_video_avail(void); |
|---|
| 525 | void set_ev_video_avail(int); |
|---|
| 526 | int get_ev_video(void); |
|---|
| 527 | void set_ev_video(int); |
|---|
| 528 | //dng related |
|---|
| 529 | // new version to support DNG double buffer |
|---|
| 530 | void reverse_bytes_order2(char* from, char* to, int count); |
|---|
| 531 | // convert old version calls to new version (to minimise code changes) |
|---|
| 532 | #define reverse_bytes_order(start, count) reverse_bytes_order2(start,start,count) |
|---|
| 533 | void save_ext_for_dng(void); |
|---|
| 534 | void change_ext_to_dng(void); |
|---|
| 535 | void change_ext_to_default(void); |
|---|
| 536 | |
|---|
| 537 | void DoAFLock(void); |
|---|
| 538 | void UnlockAF(void); |
|---|
| 539 | |
|---|
| 540 | void drv_self_hide(void); |
|---|
| 541 | void drv_self_unhide(void); |
|---|
| 542 | |
|---|
| 543 | void PostLogicalEventForNotPowerType(unsigned event, unsigned unk); |
|---|
| 544 | void PostLogicalEventToUI(unsigned event, unsigned unk); |
|---|
| 545 | void SetLogicalEventActive(unsigned event, unsigned state); |
|---|
| 546 | void SetScriptMode(unsigned mode); |
|---|
| 547 | /* |
|---|
| 548 | call C function with argument list created at runtime. |
|---|
| 549 | See lib/armutil/callfunc.S for documentation |
|---|
| 550 | */ |
|---|
| 551 | unsigned call_func_ptr(void *func, const unsigned *args, unsigned n_args); |
|---|
| 552 | |
|---|
| 553 | /* |
|---|
| 554 | reboot, optionally loading a different binary |
|---|
| 555 | see lib/armutil/reboot.c for documentation |
|---|
| 556 | */ |
|---|
| 557 | int reboot(const char *bootfile); |
|---|
| 558 | |
|---|
| 559 | #define started() debug_led(1) |
|---|
| 560 | #define finished() debug_led(0) |
|---|
| 561 | |
|---|
| 562 | #ifdef CAM_CHDK_PTP |
|---|
| 563 | |
|---|
| 564 | typedef struct { |
|---|
| 565 | int code; |
|---|
| 566 | int sess_id; |
|---|
| 567 | int trans_id; |
|---|
| 568 | int num_param; |
|---|
| 569 | int param1; |
|---|
| 570 | int param2; |
|---|
| 571 | int param3; |
|---|
| 572 | int param4; |
|---|
| 573 | int param5; |
|---|
| 574 | } PTPContainer; |
|---|
| 575 | |
|---|
| 576 | typedef struct { |
|---|
| 577 | int handle; |
|---|
| 578 | int (*send_data)(int handle, const char *buf, int part_size, int total_size, int, int, int); // (0xFF9F525C), total_size should be 0 except for the first call |
|---|
| 579 | int (*recv_data)(int handle, char *buf, int size, int, int); // (0xFF9F5500) |
|---|
| 580 | int (*send_resp)(int handle, PTPContainer *resp); // (0xFF9F5688) |
|---|
| 581 | int (*get_data_size)(int handle); // (0xFF9F5830) |
|---|
| 582 | int (*send_err_resp)(int handle, PTPContainer *resp); // (0xFF9F5784) |
|---|
| 583 | int unknown1; // ??? |
|---|
| 584 | int (*f2)(); // ??? (0xFF8D5B24) |
|---|
| 585 | int (*f3)(); // ??? (0xFF8D5B5C) |
|---|
| 586 | // more?? |
|---|
| 587 | } ptp_data; |
|---|
| 588 | |
|---|
| 589 | typedef int (*ptp_handler)(int, ptp_data*, int, int, int, int, int, int, int, int); |
|---|
| 590 | |
|---|
| 591 | int add_ptp_handler(int opcode, ptp_handler handler, int unknown); |
|---|
| 592 | |
|---|
| 593 | void init_chdk_ptp(); |
|---|
| 594 | void init_chdk_ptp_task(); |
|---|
| 595 | |
|---|
| 596 | typedef struct { |
|---|
| 597 | unsigned size; |
|---|
| 598 | unsigned script_id; // id of script message is to/from |
|---|
| 599 | unsigned type; |
|---|
| 600 | unsigned subtype; |
|---|
| 601 | char data[]; |
|---|
| 602 | } ptp_script_msg; |
|---|
| 603 | int ptp_script_write_msg(ptp_script_msg *msg); |
|---|
| 604 | ptp_script_msg* ptp_script_read_msg(void); |
|---|
| 605 | ptp_script_msg* ptp_script_create_msg(unsigned type, unsigned subtype, unsigned datasize, const void *data); |
|---|
| 606 | int ptp_script_write_error_msg(unsigned errtype, const char *err); |
|---|
| 607 | |
|---|
| 608 | #endif // CAM_CHDK_PTP |
|---|
| 609 | |
|---|
| 610 | int switch_mode_usb(int mode); // 0 = playback, 1 = record; return indicates success |
|---|
| 611 | // N.B.: switch_mode only supported when USB is connected |
|---|
| 612 | |
|---|
| 613 | void ExitTask(); |
|---|
| 614 | |
|---|
| 615 | // Data returned from GetMemInfo & GetExMemInfo functions stored in this data structure |
|---|
| 616 | typedef struct { |
|---|
| 617 | int start_address; |
|---|
| 618 | int end_address; |
|---|
| 619 | int total_size; |
|---|
| 620 | int allocated_size; |
|---|
| 621 | int allocated_peak; |
|---|
| 622 | int allocated_count; |
|---|
| 623 | int free_size; |
|---|
| 624 | int free_block_max_size; |
|---|
| 625 | int free_block_count; |
|---|
| 626 | } cam_meminfo; |
|---|
| 627 | |
|---|
| 628 | // Always included for module_inspector |
|---|
| 629 | extern void GetMemInfo(cam_meminfo*); |
|---|
| 630 | extern int GetExMemInfo(cam_meminfo*); |
|---|
| 631 | |
|---|
| 632 | #ifdef OPT_EXMEM_MALLOC |
|---|
| 633 | extern void exmem_malloc_init(void); |
|---|
| 634 | #endif |
|---|
| 635 | |
|---|
| 636 | #ifdef CAM_TOUCHSCREEN_UI |
|---|
| 637 | extern unsigned short touch_screen_x, touch_screen_y; |
|---|
| 638 | extern int touch_screen_active; |
|---|
| 639 | #endif |
|---|
| 640 | |
|---|
| 641 | unsigned char SetFileAttributes(const char* fn, unsigned char attr); |
|---|
| 642 | |
|---|
| 643 | #ifdef CAM_HAS_GPS |
|---|
| 644 | void GPS_UpdateData(); |
|---|
| 645 | extern char * camera_jpeg_current_filename(); |
|---|
| 646 | extern char * camera_jpeg_current_latitude(); |
|---|
| 647 | extern char * camera_jpeg_current_longitude(); |
|---|
| 648 | extern char * camera_jpeg_current_height(); |
|---|
| 649 | #endif |
|---|
| 650 | |
|---|
| 651 | // debug logging function - see generic wrappers.c to adjust destination |
|---|
| 652 | // WARNING fixed length buffer |
|---|
| 653 | extern void dbg_printf(char *fmt,...); |
|---|
| 654 | |
|---|
| 655 | //#define DEBUG_LOGGING |
|---|
| 656 | // debug with timestamp |
|---|
| 657 | #ifdef DEBUG_LOGGING |
|---|
| 658 | #define DBGPRINTF(fmt,args...) dbg_printf("%08d DBG:" fmt,get_tick_count(), ##args) |
|---|
| 659 | #else |
|---|
| 660 | #define DBGPRINTF(...) |
|---|
| 661 | #endif |
|---|
| 662 | |
|---|
| 663 | #endif |
|---|
| 664 | |
|---|