source: trunk/include/platform.h @ 657

Revision 657, 18.5 KB checked in by msl, 2 years ago (diff)

Skript-Befehle fuer Multipartition-Untetstuetzung

+ get_partitionInfo() Liefert eine Tabelle mit folgenden Einträgen:

info["count"] Liefert die Anzahl der Partitionen auf der SD-Karte
info["active"]
Gibt die aktive Partitionsnummer zurück. (Beginnend bei "1" und nicht bei "0")
info["type"] Gibt den Partitionstyp der aktiven Partition zurück.
info["size"]
Gibt den Größe in MB der aktiven Partition zurück.
swap_partition(nr) Wechselt auf die angegebene Partition. (Neustart notwendig!)
swap_partition()
swap_partition() ohne Parameter wechselt auf die nächste Partition auf der Karte.

  • Property svn:eol-style set to native
Line 
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// this is nasty, but not as nasty as checking each of the flags all over the place
19#define MODE_IS_VIDEO(m)   (((m)&MODE_SHOOTING_MASK)==MODE_VIDEO_STD || \
20                            ((m)&MODE_SHOOTING_MASK)==MODE_VIDEO_SPEED ||  \
21                            ((m)&MODE_SHOOTING_MASK)==MODE_VIDEO_COMPACT || \
22                            ((m)&MODE_SHOOTING_MASK)==MODE_VIDEO_MY_COLORS || \
23                            ((m)&MODE_SHOOTING_MASK)==MODE_VIDEO_COLOR_ACCENT || \
24                            ((m)&MODE_SHOOTING_MASK)==MODE_VIDEO_COLOR_SWAP || \
25                            ((m)&MODE_SHOOTING_MASK)==MODE_VIDEO_TIME_LAPSE || \
26                            ((m)&MODE_SHOOTING_MASK)==MODE_VIDEO_PORTRAIT || \
27                            ((m)&MODE_SHOOTING_MASK)==MODE_VIDEO_NIGHT || \
28                            ((m)&MODE_SHOOTING_MASK)==MODE_VIDEO_INDOOR || \
29                            ((m)&MODE_SHOOTING_MASK)==MODE_VIDEO_FOLIAGE || \
30                            ((m)&MODE_SHOOTING_MASK)==MODE_VIDEO_SNOW  || \
31                            ((m)&MODE_SHOOTING_MASK)==MODE_VIDEO_BEACH || \
32                            ((m)&MODE_SHOOTING_MASK)==MODE_VIDEO_AQUARIUM || \
33                            ((m)&MODE_SHOOTING_MASK)==MODE_VIDEO_SUPER_MACRO || \
34                            ((m)&MODE_SHOOTING_MASK)==MODE_VIDEO_STITCH || \
35                            ((m)&MODE_SHOOTING_MASK)==MODE_VIDEO_MANUAL)
36/* propcase ID constants. These are in their own header files for easier sed processing */
37#if CAM_PROPSET == 4
38    #include "propset4.h"
39#elif CAM_PROPSET == 3
40    #include "propset3.h"
41#elif CAM_PROPSET == 2      // most digic3 cameras
42    #include "propset2.h"
43#elif CAM_PROPSET == 1      // most digic2 cameras
44    #include "propset1.h"
45#else
46    #error unknown camera processor
47#endif
48
49
50#define MAX_DIST 65535
51
52//********************
53//char * get_debug();
54//********************
55
56#define MODE_SCREEN_MASK            0x0C00
57#define MODE_SCREEN_OPENED          0x0400
58#define MODE_SCREEN_ROTATED         0x0800
59#define AS_SIZE (sizeof(aperture_sizes_table)/sizeof(aperture_sizes_table[0]))
60#define ASID_MIN (aperture_sizes_table[0].id)
61#define ASID_MAX (aperture_sizes_table[AS_SIZE-1].id)
62
63/* Keyboard repeat and initial delays */
64#define KBD_REPEAT_DELAY  140
65#define KBD_INITIAL_DELAY 300
66
67// Video recording current status constants, see movie_status variable
68#define VIDEO_RECORD_NEVER_STARTED  0 
69#define VIDEO_RECORD_STOPPED        1 
70#define VIDEO_RECORD_IN_PROGRESS    4
71
72//Optical & digital zoom status constants, see zoom_status variable
73#define ZOOM_OPTICAL_MIN            1
74#define ZOOM_OPTICAL_MAX            2
75#define ZOOM_OPTICAL_MEDIUM         3
76#define ZOOM_OPTICAL_IN             4
77#define ZOOM_OPTICAL_OUT            5
78#define ZOOM_OPTICAL_REACHED_MIN    7
79
80#define ZOOM_DIGITAL_MAX            9
81#define ZOOM_DIGITAL_MEDIUM         10
82#define ZOOM_DIGITAL_IN             11
83#define ZOOM_DIGITAL_OUT            12
84#define ZOOM_DIGITAL_REACHED_MAX    13
85
86typedef struct {
87    int hackmode;   // platform independent mode values from MODE_xxx enum
88    int canonmode;  // PROPCASE_SHOOTING_MODE value
89} CapturemodeMap;
90
91typedef struct {
92    short id;       // hacks id
93    short prop_id;  // Canons id
94    char name[8];
95    short shutter_dfs_value; // shutter speed to use dark frame substraction
96} ISOTable;
97
98typedef struct {
99    short id;       // hacks id
100    short prop_id;  // Canons id
101    char name[8];
102    long usec;
103} ShutterSpeed;
104
105typedef struct {
106    short id;       // hacks id
107    short prop_id;  // Canons id
108    char name[8];
109} ApertureSize;
110
111typedef struct {
112    short av96;
113    short dav96;
114    short av96_step;
115    short tv96;
116    short dtv96;
117    short tv96_step;
118    short sv96;
119    short dsv96;
120    short sv96_step;
121    short iso;
122    short diso;
123    short iso_step;
124    short subj_dist;
125    short dsubj_dist;
126    short subj_dist_step;
127    short shoot_counter;
128    short type;
129} EXPO_BRACKETING_VALUES;
130
131#define SET_NOW      1
132#define SET_LATER    0
133
134#define SHOW_ALWAYS    1
135#define SHOW_HALF      2
136
137
138typedef struct {
139    short av96;
140    short tv96;
141    short sv96;
142    short subj_dist;
143    short nd_filter;
144} PHOTO_PARAM;
145
146typedef struct {
147    short hyperfocal_valid;
148    short distance_valid;
149    int   hyperfocal_distance_1e3;
150    int   aperture_value;
151    int   focal_length;
152    int   subject_distance;
153    int   near_limit;
154    int   far_limit;
155    int   hyperfocal_distance;
156    int   depth_of_field;
157    int   min_stack_distance;
158} DOF_TYPE;
159
160extern DOF_TYPE dof_values;
161
162typedef struct {
163    short av96;
164    short tv96;
165    short sv96;
166    short iso;
167    short sv96_market;
168    short iso_market;
169    short bv96_measured;
170    short bv96_seted;       //Ev96_internal-Sv96
171    short ev96_seted;       //Tv96+Av96
172    short ev96_measured;    //Bv96+Sv96
173    short dev96;            // Ev96_external-Ev96_internal
174    short dev96_canon;      // Canon OverExposure
175    int b;                  //average scene luminance
176} EXPO_TYPE;
177
178typedef struct {
179    float value;
180    char fraction[10];
181} shutter_speed;
182
183
184/******************************************************************/
185
186int get_focal_length(int zp);
187int get_effective_focal_length(int zp);
188int get_zoom_x(int zp);
189
190/******************************************************************/
191
192long get_tick_count();
193
194void remount_filesystem();
195void mark_filesystem_bootable();
196
197/******************************************************************/
198
199long get_parameter_data(long id, void *buf, long bufsize);
200long set_parameter_data(long id, void *buf, long bufsize);
201
202long get_property_case(long id, void *buf, long bufsize);
203long set_property_case(long id, void *buf, long bufsize);
204
205long get_file_counter();
206long get_exposure_counter();
207long get_file_next_counter();
208#if defined(CAM_DATE_FOLDER_NAMING)
209    void get_target_dir_name(char*);
210#else
211    long get_target_dir_num();
212#endif
213long get_target_file_num();
214
215/******************************************************************/
216
217void kbd_key_press(long key);
218void kbd_key_release(long key);
219void kbd_key_release_all();
220long kbd_is_key_pressed(long key);
221long kbd_is_key_clicked(long key);
222long kbd_get_pressed_key();
223long kbd_get_clicked_key();
224long kbd_get_autoclicked_key();
225void kbd_reset_autoclicked_key();
226long kbd_use_zoom_as_mf();
227long kbd_use_up_down_left_right_as_fast_switch();
228void kbd_set_alt_mode_key_mask(long key);
229int get_usb_power(int edge);
230long get_jogdial_direction(void);
231/******************************************************************/
232
233long vid_is_bitmap_shown();
234void *vid_get_bitmap_fb();
235long vid_get_bitmap_screen_width();
236long vid_get_bitmap_screen_height();
237long vid_get_bitmap_buffer_width();
238long vid_get_bitmap_buffer_height();
239void *vid_get_viewport_fb();
240void *vid_get_viewport_fb_d();
241void *vid_get_viewport_live_fb();
242void vid_bitmap_refresh();
243long vid_get_viewport_height();
244int vid_get_viewport_width();
245int vid_get_viewport_buffer_width();
246int vid_get_viewport_xoffset();
247int vid_get_viewport_yoffset();
248int vid_get_viewport_image_offset();
249int vid_get_viewport_row_offset();
250void vid_turn_off_updates();
251void vid_turn_on_updates();
252
253/******************************************************************/
254
255void *hook_raw_fptr();
256void *hook_raw_ret_addr();
257char *hook_raw_image_addr();
258char *hook_alt_raw_image_addr();
259long hook_raw_size();
260void hook_raw_install();
261void hook_raw_save_complete();
262
263/******************************************************************/
264
265long lens_get_zoom_pos();
266void lens_set_zoom_pos(long newpos);
267long lens_get_zoom_point();
268void lens_set_zoom_point(long newpt);
269void lens_set_zoom_speed(long newspd); //for S-series
270long lens_get_focus_pos();
271long lens_get_focus_pos_from_lens();
272void lens_set_focus_pos(long newpos);
273long lens_get_target_distance();
274
275/******************************************************************/
276
277int shooting_in_progress();
278int shooting_is_flash();
279int shooting_is_flash_ready();
280short shooting_get_flash_mode();
281
282
283/******************************************************************/
284int shooting_get_user_tv_id();
285char* shooting_get_tv_str();
286short shooting_get_tv96_from_shutter_speed(float t);
287short shooting_get_tv96();
288void shooting_set_tv96(short v, short is_now);
289void shooting_set_tv96_direct(short v, short is_now);
290void shooting_set_shutter_speed_ubasic(int t, short is_now);
291short shooting_get_user_tv96();
292void shooting_set_user_tv96(short v);
293float shooting_get_shutter_speed_from_tv96(short tv);
294float shooting_get_shutter_speed_override_value();
295const char * shooting_get_tv_override_value();
296const char * shooting_get_tv_bracket_value();
297const char * shooting_get_bracket_type();
298void shooting_set_user_tv_by_id(int v);
299void shooting_set_user_tv_by_id_rel(int v);
300const ShutterSpeed *shooting_get_tv_line();
301/******************************************************************/
302short shooting_get_aperture_sizes_table_size();
303short shooting_get_aperture_sizes_table_prop_id(short i);
304short shooting_get_max_aperture_sizes_table_prop_id();
305short shooting_get_aperture_from_av96(short av96);
306int shooting_get_user_av_id();
307char* shooting_get_av_str();
308void shooting_set_user_av_by_id(int v);
309short shooting_get_av96();
310void shooting_set_av96(short v,short is_now);
311void shooting_set_av96_direct(short v, short is_now);
312short shooting_get_user_av96();
313void shooting_set_user_av96(short v);
314void shooting_set_user_av_by_id_rel(int v);
315short shooting_get_real_aperture();
316short shooting_get_min_real_aperture();
317short shooting_get_av96_override_value();
318const char * shooting_get_av_bracket_value();
319void shooting_set_nd_filter_state(short v, short is_now);
320/******************************************************************/
321int shooting_get_day_seconds();
322int shooting_get_tick_count();
323/******************************************************************/
324void shooting_set_prop(int id, int v);
325int shooting_get_prop(int id);
326/******************************************************************/
327extern int circle_of_confusion;
328/******************************************************************/
329extern const int zoom_points;
330int shooting_get_zoom();
331void shooting_set_zoom(int v);
332void shooting_set_zoom_rel(int v);
333void shooting_set_zoom_speed(int v);
334/******************************************************************/
335int shooting_get_focus();
336void shooting_set_focus(int v, short is_now);
337short shooting_get_focus_mode();
338short shooting_get_real_focus_mode();
339short shooting_get_focus_state();
340short shooting_get_focus_ok();
341void shooting_update_dof_values();
342int shooting_get_hyperfocal_distance();
343int shooting_get_hyperfocal_distance_1e3_f(int av, int fl);
344int shooting_get_near_limit_of_acceptable_sharpness();
345int shooting_get_far_limit_of_acceptable_sharpness();
346int shooting_get_depth_of_field();
347int shooting_get_min_stack_distance();
348int shooting_get_subject_distance();
349int shooting_get_subject_distance_override_value();
350int shooting_get_subject_distance_bracket_value();
351int shooting_get_subject_distance_override_koef();
352int shooting_get_lens_to_focal_plane_width();
353short shooting_get_drive_mode();
354short shooting_can_focus();
355short shooting_get_common_focus_mode();
356/******************************************************************/
357int shooting_get_iso_mode();
358void shooting_set_iso_mode(int v);
359short shooting_get_sv96();
360short shooting_get_svm96();
361short shooting_get_iso_market();
362short shooting_get_iso_real();
363void shooting_set_iso_real(short iso, short is_now);
364//void shooting_set_iso_market(short isom);
365//void shooting_set_iso_real_delta_from_base(short diso);
366void shooting_set_sv96(short sv96, short is_now);
367short shooting_get_iso_override_value();
368short shooting_get_iso_bracket_value();
369/******************************************************************/
370short shooting_get_canon_overexposure_value();
371short shooting_get_bv96();
372int shooting_get_luminance();
373//const char* shooting_get_flash_light_value();
374/******************************************************************/
375int shooting_get_canon_subject_distance();
376int shooting_get_exif_subject_dist();
377/******************************************************************/
378void shooting_expo_param_override();
379void shooting_bracketing(void);
380
381void shooting_video_bitrate_change(int v);
382extern int auto_started;
383void shooting_tv_bracketing();
384void shooting_av_bracketing();
385void shooting_iso_bracketing();
386/******************************************************************/
387// capture mode functions
388// return a CHDK mode enum for a PROPCASE_SHOOTING_MODE value, or 0 if not found
389int shooting_mode_canon2chdk(int canonmode);
390// 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.
391int shooting_mode_chdk2canon(int hackmode);
392// set capture mode from CHDK mode, returns 0 if mode not found or not in rec, otherwise 1
393int shooting_set_mode_chdk(int mode);
394// set capture mode from PROPCASE_SHOOTING_MODE value. return 0 if not in rec or mode is -1, otherwise 1
395int shooting_set_mode_canon(int mode);
396
397// returns 0 if in play, nonzero if rec
398int rec_mode_active(void);
399
400// not used. Right now this is just to preserve code from earlier version of mode_get()
401// in case we want to check play/rec switch state in the future.
402// WARNING: it isn't known if all variants of this check the switch state or some other bit.
403// should return 0 is switch is in play position, non-zero otherwise
404//int rec_switch_state(void);
405
406// swivel screen state.
407#ifdef CAM_SWIVEL_SCREEN
408// 0 not open, non-zero open
409int screen_opened(void);
410// 0 not rotated, non-zero rotated
411int screen_rotated(void);
412#endif
413
414/******************************************************************/
415void clear_values();
416/******************************************************************/
417
418int mode_get();
419
420/******************************************************************/
421
422long stat_get_vbatt();
423int get_ccd_temp();
424int get_optical_temp();
425int get_battery_temp();
426long get_vbatt_min();
427long get_vbatt_max();
428void play_sound(unsigned sound);
429void camera_set_raw(int mode);
430void camera_set_nr(int mode);
431int camera_get_nr();
432int camera_get_script_autostart();
433void camera_set_script_autostart();
434void enter_alt();
435void exit_alt();
436void camera_shutdown_in_a_second(void);
437
438void disable_shutdown();
439void enable_shutdown();
440
441void JogDial_CW(void);
442void JogDial_CCW(void);
443void change_video_tables(int a, int b);
444int get_flash_params_count(void);
445
446/******************************************************************/
447void __attribute__((noreturn)) shutdown();
448void camera_set_led(int led, int state, int bright);
449void debug_led(int state);
450/****************************************/
451extern int canon_menu_active;
452extern char canon_shoot_menu_active;
453extern int recreview_hold;
454
455extern int movie_status;
456unsigned int movie_reset;
457unsigned int GetFreeCardSpaceKb(void);
458unsigned int GetTotalCardSpaceKb(void);
459
460
461
462int swap_partitions(int new_partition);
463unsigned char get_active_partition(void);
464int get_part_type(void);
465int get_part_count(void);
466int is_partition_changed(void);
467void create_partitions(void);
468extern char * camera_jpeg_count_str();
469
470unsigned int GetJpgCount(void);
471unsigned int GetRawCount(void);
472
473void MakeAFScan(void);
474extern int movie_status;
475extern int zoom_status;
476void EnterToCompensationEVF(void);
477void ExitFromCompensationEVF(void);
478
479void TurnOnBackLight(void);
480void TurnOffBackLight(void);
481
482void wait_until_remote_button_is_released(void);
483short shooting_get_ev_correction1();
484
485//image_quality_override
486void shooting_set_image_quality(int imq);
487
488int get_ev_video_avail(void);
489void set_ev_video_avail(int);
490int get_ev_video(void);
491void set_ev_video(int);
492//dng related
493// new version to support DNG double buffer
494void reverse_bytes_order2(char* from, char* to, int count);
495// convert old version calls to new version (to minimise code changes)
496#define reverse_bytes_order(start, count)   reverse_bytes_order2(start,start,count)
497void save_ext_for_dng(void);
498void change_ext_to_dng(void);
499void change_ext_to_default(void);
500
501void DoAFLock(void);
502void UnlockAF(void);
503
504void drv_self_hide(void);
505void drv_self_unhide(void);
506
507void  PostLogicalEventForNotPowerType(unsigned event, unsigned unk);
508void  PostLogicalEventToUI(unsigned event, unsigned unk);
509void  SetLogicalEventActive(unsigned event, unsigned state);
510void SetScriptMode(unsigned mode);
511/*
512 call C function with argument list created at runtime.
513 See lib/armutil/callfunc.S for documentation
514*/
515unsigned call_func_ptr(void *func, const unsigned *args, unsigned n_args);
516
517/*
518 reboot, optionally loading a different binary
519 see lib/armutil/reboot.c for documentation
520*/
521int reboot(const char *bootfile);
522
523#define started() debug_led(1)
524#define finished() debug_led(0)
525
526#ifdef CAM_CHDK_PTP
527
528typedef struct {
529    int code;
530    int sess_id;
531    int trans_id;
532    int num_param;
533    int param1;
534    int param2;
535    int param3;
536    int param4;
537    int param5;
538} PTPContainer;
539
540typedef struct {
541    int handle;
542    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
543    int (*recv_data)(int handle, char *buf, int size, int, int); // (0xFF9F5500)
544    int (*send_resp)(int handle, PTPContainer *resp); // (0xFF9F5688)
545    int (*get_data_size)(int handle); // (0xFF9F5830)
546    int (*send_err_resp)(int handle, PTPContainer *resp); // (0xFF9F5784)
547    int unknown1; // ???
548    int (*f2)(); // ??? (0xFF8D5B24)
549    int (*f3)(); // ??? (0xFF8D5B5C)
550    // more??
551} ptp_data;
552
553typedef int (*ptp_handler)(int, ptp_data*, int, int, int, int, int, int, int, int);
554
555int add_ptp_handler(int opcode, ptp_handler handler, int unknown);
556
557void init_chdk_ptp();
558void init_chdk_ptp_task();
559
560typedef struct {
561    unsigned size;
562    unsigned script_id; // id of script message is to/from
563    unsigned type;
564    unsigned subtype;
565    char data[];
566} ptp_script_msg;
567int ptp_script_write_msg(ptp_script_msg *msg);
568ptp_script_msg* ptp_script_read_msg(void);
569ptp_script_msg* ptp_script_create_msg(unsigned type, unsigned subtype, unsigned datasize, const void *data);
570int ptp_script_write_error_msg(unsigned errtype, const char *err);
571
572#endif // CAM_CHDK_PTP
573
574int switch_mode_usb(int mode); // 0 = playback, 1 = record; return indicates success
575                               // N.B.: switch_mode only supported when USB is connected
576
577void ExitTask();
578
579#ifdef OPT_EXMEM_MALLOC
580    void exmem_malloc_init(void);
581#endif
582
583unsigned char SetFileAttributes(const char* fn, unsigned char attr);
584
585#endif
Note: See TracBrowser for help on using the repository browser.