-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathpslr_model.h
213 lines (186 loc) · 7.5 KB
/
pslr_model.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/*
pkTriggerCord
Copyright (C) 2011-2019 Andras Salamon <[email protected]>
Remote control of Pentax DSLR cameras.
Support for K200D added by Jens Dreyer <[email protected]> 04/2011
Support for K-r added by Vincenc Podobnik <[email protected]> 06/2011
Support for K-30 added by Camilo Polymeris <[email protected]> 09/2012
Support for K-01 added by Ethan Queen <[email protected]> 01/2013
Support for K-3 added by Tao Wang <[email protected]> 01/2016
based on:
PK-Remote
Remote control of Pentax DSLR cameras.
Copyright (C) 2008 Pontus Lidman <[email protected]>
PK-Remote for Windows
Copyright (C) 2010 Tomasz Kos
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU General Public License
and GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PSLR_MODEL_H
#define PSLR_MODEL_H
#include "pslr_enum.h"
#include "pslr_scsi.h"
#define MAX_RESOLUTION_SIZE 4
#define MAX_STATUS_BUF_SIZE 456
#define SETTINGS_BUFFER_SIZE 1024
#define MAX_SEGMENTS 4
typedef struct ipslr_handle ipslr_handle_t;
typedef struct {
int32_t nom;
int32_t denom;
} pslr_rational_t;
typedef struct {
uint16_t bufmask;
uint32_t current_iso;
pslr_rational_t current_shutter_speed;
pslr_rational_t current_aperture;
pslr_rational_t lens_max_aperture;
pslr_rational_t lens_min_aperture;
pslr_rational_t set_shutter_speed;
pslr_rational_t set_aperture;
pslr_rational_t max_shutter_speed;
uint32_t auto_bracket_mode;
pslr_rational_t auto_bracket_ev;
uint32_t auto_bracket_picture_count;
uint32_t auto_bracket_picture_counter;
uint32_t fixed_iso;
uint32_t jpeg_resolution;
uint32_t jpeg_saturation;
uint32_t jpeg_quality;
uint32_t jpeg_contrast;
uint32_t jpeg_sharpness;
uint32_t jpeg_image_tone;
uint32_t jpeg_hue;
pslr_rational_t zoom;
int32_t focus;
uint32_t image_format;
uint32_t raw_format;
uint32_t light_meter_flags;
pslr_rational_t ec;
uint32_t custom_ev_steps;
uint32_t custom_sensitivity_steps;
uint32_t exposure_mode;
uint32_t scene_mode;
uint32_t user_mode_flag;
uint32_t ae_metering_mode;
uint32_t af_mode;
uint32_t af_point_select;
uint32_t selected_af_point;
uint32_t focused_af_point;
uint32_t auto_iso_min;
uint32_t auto_iso_max;
uint32_t drive_mode;
uint32_t shake_reduction;
uint32_t white_balance_mode;
uint32_t white_balance_adjust_mg;
uint32_t white_balance_adjust_ba;
uint32_t flash_mode;
int32_t flash_exposure_compensation; /* 1/256 */
int32_t manual_mode_ev; /* 1/10 */
uint32_t color_space;
uint32_t lens_id1;
uint32_t lens_id2;
uint32_t battery_1;
uint32_t battery_2;
uint32_t battery_3;
uint32_t battery_4;
} pslr_status;
typedef enum {
PSLR_SETTING_STATUS_UNKNOWN,
PSLR_SETTING_STATUS_READ,
PSLR_SETTING_STATUS_HARDWIRED,
PSLR_SETTING_STATUS_NA
} pslr_setting_status_t;
typedef struct {
pslr_setting_status_t pslr_setting_status;
bool value;
} pslr_bool_setting;
typedef struct {
pslr_setting_status_t pslr_setting_status;
uint16_t value;
} pslr_uint16_setting;
typedef struct {
pslr_bool_setting one_push_bracketing;
pslr_bool_setting bulb_mode_press_press;
pslr_bool_setting bulb_timer;
pslr_uint16_setting bulb_timer_sec;
pslr_bool_setting using_aperture_ring;
pslr_bool_setting shake_reduction;
pslr_bool_setting astrotracer;
pslr_uint16_setting astrotracer_timer_sec;
pslr_bool_setting horizon_correction;
pslr_bool_setting remote_bulb_mode_press_press;
} pslr_settings;
typedef struct {
const char *name;
unsigned long address;
const char *value;
const char *type;
} pslr_setting_def_t;
typedef void (*ipslr_status_parse_t)(ipslr_handle_t *p, pslr_status *status);
pslr_setting_def_t *pslr_find_setting_by_name (pslr_setting_def_t *array, int array_length, char *name);
void ipslr_settings_parser_json(const char *cameraid, ipslr_handle_t *p, pslr_settings *settings);
pslr_setting_def_t *setting_file_process(const char *cameraid, int *def_num);
typedef struct {
uint32_t id; // Pentax model ID
const char *name; // name
bool old_scsi_command; // true for *ist cameras, false for the newer cameras
bool old_bulb_mode; // true for older cameras
bool need_exposure_mode_conversion; // is exposure_mode_conversion required
bool bufmask_command; // true if bufmask determined by calling command 0x02 0x00
bool bufmask_single; // true if buffer cannot handle multiple images
bool is_little_endian; // whether the return value should be parsed as little-endian
int status_buffer_size; // status buffer size in bytes
int max_jpeg_stars; // maximum jpeg stars
int jpeg_resolutions[MAX_RESOLUTION_SIZE]; // jpeg resolution table
int jpeg_property_levels; // 5 [-2, 2] or 7 [-3,3] or 9 [-4,4]
int fastest_shutter_speed; // fastest shutter speed denominator
int base_iso_min; // base iso minimum
int base_iso_max; // base iso maximum
int extended_iso_min; // extended iso minimum
int extended_iso_max; // extended iso maximum
pslr_jpeg_image_tone_t max_supported_image_tone; // last supported jpeg image tone
bool has_jpeg_hue; // camera has jpeg hue setting
int af_point_num; // number of AF points
ipslr_status_parse_t status_parser_function; // parse function for status buffer
} ipslr_model_info_t;
typedef struct {
uint32_t offset;
uint32_t addr;
uint32_t length;
} ipslr_segment_t;
struct ipslr_handle {
FDTYPE fd;
pslr_status status;
pslr_settings settings;
uint32_t id;
ipslr_model_info_t *model;
ipslr_segment_t segments[MAX_SEGMENTS];
uint32_t segment_count;
uint32_t offset;
uint8_t status_buffer[MAX_STATUS_BUF_SIZE];
uint8_t settings_buffer[SETTINGS_BUFFER_SIZE];
};
ipslr_model_info_t *pslr_find_model_by_id( uint32_t id );
int pslr_get_hw_jpeg_quality( ipslr_model_info_t *model, int user_jpeg_stars);
uint32_t get_uint32_be(uint8_t *buf);
uint32_t get_uint32_le(uint8_t *buf);
void set_uint32_be(uint32_t v, uint8_t *buf);
void set_uint32_le(uint32_t v, uint8_t *buf);
typedef uint32_t (*get_uint32_func)(uint8_t *buf);
typedef uint16_t (*get_uint16_func)(const uint8_t *buf);
typedef int32_t (*get_int32_func)(uint8_t *buf);
char *pslr_hexdump(uint8_t *buf, uint32_t bufLen);
void hexdump(uint8_t *buf, uint32_t bufLen);
void hexdump_debug(uint8_t *buf, uint32_t bufLen);
const char* int_to_binary( uint16_t x );
#endif