1 | /* |
2 | * 1394-Based Digital Camera Control Library |
3 | * |
4 | * Generic camera control functions |
5 | * |
6 | * Written by Damien Douxchamps <ddouxchamps@users.sf.net> |
7 | * |
8 | * This library is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU Lesser General Public |
10 | * License as published by the Free Software Foundation; either |
11 | * version 2.1 of the License, or (at your option) any later version. |
12 | * |
13 | * This library is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | * Lesser General Public License for more details. |
17 | * |
18 | * You should have received a copy of the GNU Lesser General Public |
19 | * License along with this library; if not, write to the Free Software |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 | */ |
22 | |
23 | #include <dc1394/log.h> |
24 | |
25 | #ifndef __DC1394_CONTROL_H__ |
26 | #define __DC1394_CONTROL_H__ |
27 | |
28 | /*! \file dc1394/control.h |
29 | \brief Diverse controls of camera features |
30 | \author Gord Peters: main writer |
31 | \author Chris Urmson: some additions |
32 | \author Damien Douxchamps: some additions |
33 | \author Peter Antoniac: documentation maintainer |
34 | \author Rudolf Leitgeb: documentation writer |
35 | |
36 | This is the main include file of the library. It lists most of the library |
37 | functions, enumerations and data structures. |
38 | */ |
39 | |
40 | /** |
41 | * Enumeration of trigger modes |
42 | */ |
43 | typedef enum { |
44 | DC1394_TRIGGER_MODE_0= 384, |
45 | DC1394_TRIGGER_MODE_1, |
46 | DC1394_TRIGGER_MODE_2, |
47 | DC1394_TRIGGER_MODE_3, |
48 | DC1394_TRIGGER_MODE_4, |
49 | DC1394_TRIGGER_MODE_5, |
50 | DC1394_TRIGGER_MODE_14, |
51 | DC1394_TRIGGER_MODE_15 |
52 | } dc1394trigger_mode_t; |
53 | #define DC1394_TRIGGER_MODE_MIN DC1394_TRIGGER_MODE_0 |
54 | #define DC1394_TRIGGER_MODE_MAX DC1394_TRIGGER_MODE_15 |
55 | #define DC1394_TRIGGER_MODE_NUM (DC1394_TRIGGER_MODE_MAX - DC1394_TRIGGER_MODE_MIN + 1) |
56 | |
57 | /** |
58 | * Enumeration of camera features |
59 | */ |
60 | typedef enum { |
61 | DC1394_FEATURE_BRIGHTNESS= 416, |
62 | DC1394_FEATURE_EXPOSURE, |
63 | DC1394_FEATURE_SHARPNESS, |
64 | DC1394_FEATURE_WHITE_BALANCE, |
65 | DC1394_FEATURE_HUE, |
66 | DC1394_FEATURE_SATURATION, |
67 | DC1394_FEATURE_GAMMA, |
68 | DC1394_FEATURE_SHUTTER, |
69 | DC1394_FEATURE_GAIN, |
70 | DC1394_FEATURE_IRIS, |
71 | DC1394_FEATURE_FOCUS, |
72 | DC1394_FEATURE_TEMPERATURE, |
73 | DC1394_FEATURE_TRIGGER, |
74 | DC1394_FEATURE_TRIGGER_DELAY, |
75 | DC1394_FEATURE_WHITE_SHADING, |
76 | DC1394_FEATURE_FRAME_RATE, |
77 | DC1394_FEATURE_ZOOM, |
78 | DC1394_FEATURE_PAN, |
79 | DC1394_FEATURE_TILT, |
80 | DC1394_FEATURE_OPTICAL_FILTER, |
81 | DC1394_FEATURE_CAPTURE_SIZE, |
82 | DC1394_FEATURE_CAPTURE_QUALITY |
83 | } dc1394feature_t; |
84 | #define DC1394_FEATURE_MIN DC1394_FEATURE_BRIGHTNESS |
85 | #define DC1394_FEATURE_MAX DC1394_FEATURE_CAPTURE_QUALITY |
86 | #define DC1394_FEATURE_NUM (DC1394_FEATURE_MAX - DC1394_FEATURE_MIN + 1) |
87 | |
88 | /** |
89 | * Enumeration of trigger sources |
90 | */ |
91 | typedef enum { |
92 | DC1394_TRIGGER_SOURCE_0= 576, |
93 | DC1394_TRIGGER_SOURCE_1, |
94 | DC1394_TRIGGER_SOURCE_2, |
95 | DC1394_TRIGGER_SOURCE_3, |
96 | DC1394_TRIGGER_SOURCE_SOFTWARE |
97 | } dc1394trigger_source_t; |
98 | #define DC1394_TRIGGER_SOURCE_MIN DC1394_TRIGGER_SOURCE_0 |
99 | #define DC1394_TRIGGER_SOURCE_MAX DC1394_TRIGGER_SOURCE_SOFTWARE |
100 | #define DC1394_TRIGGER_SOURCE_NUM (DC1394_TRIGGER_SOURCE_MAX - DC1394_TRIGGER_SOURCE_MIN + 1) |
101 | |
102 | /** |
103 | * External trigger polarity |
104 | */ |
105 | typedef enum { |
106 | DC1394_TRIGGER_ACTIVE_LOW= 704, |
107 | DC1394_TRIGGER_ACTIVE_HIGH |
108 | } dc1394trigger_polarity_t; |
109 | #define DC1394_TRIGGER_ACTIVE_MIN DC1394_TRIGGER_ACTIVE_LOW |
110 | #define DC1394_TRIGGER_ACTIVE_MAX DC1394_TRIGGER_ACTIVE_HIGH |
111 | #define DC1394_TRIGGER_ACTIVE_NUM (DC1394_TRIGGER_ACTIVE_MAX - DC1394_TRIGGER_ACTIVE_MIN + 1) |
112 | |
113 | /** |
114 | * Control modes for a feature (excl. absolute control) |
115 | */ |
116 | typedef enum { |
117 | DC1394_FEATURE_MODE_MANUAL= 736, |
118 | DC1394_FEATURE_MODE_AUTO, |
119 | DC1394_FEATURE_MODE_ONE_PUSH_AUTO |
120 | } dc1394feature_mode_t; |
121 | #define DC1394_FEATURE_MODE_MIN DC1394_FEATURE_MODE_MANUAL |
122 | #define DC1394_FEATURE_MODE_MAX DC1394_FEATURE_MODE_ONE_PUSH_AUTO |
123 | #define DC1394_FEATURE_MODE_NUM (DC1394_FEATURE_MODE_MAX - DC1394_FEATURE_MODE_MIN + 1) |
124 | |
125 | /** |
126 | * List of feature modes |
127 | */ |
128 | typedef struct |
129 | { |
130 | uint32_t num; |
131 | dc1394feature_mode_t modes[DC1394_FEATURE_MODE_NUM]; |
132 | } dc1394feature_modes_t; |
133 | |
134 | /** |
135 | * List of trigger modes |
136 | */ |
137 | typedef struct |
138 | { |
139 | uint32_t num; |
140 | dc1394trigger_mode_t modes[DC1394_TRIGGER_MODE_NUM]; |
141 | } dc1394trigger_modes_t; |
142 | |
143 | /** |
144 | * List of trigger sources |
145 | */ |
146 | typedef struct |
147 | { |
148 | uint32_t num; |
149 | dc1394trigger_source_t sources[DC1394_TRIGGER_SOURCE_NUM]; |
150 | } dc1394trigger_sources_t; |
151 | |
152 | /** |
153 | * A structure containing all information about a feature. |
154 | * |
155 | * Some fields are only valid for some features (e.g. trigger, white balance,...) |
156 | */ |
157 | typedef struct __dc1394feature_info_t_struct |
158 | { |
159 | dc1394feature_t id; |
160 | dc1394bool_t available; |
161 | dc1394bool_t absolute_capable; |
162 | dc1394bool_t readout_capable; |
163 | dc1394bool_t on_off_capable; |
164 | dc1394bool_t polarity_capable; |
165 | dc1394switch_t is_on; |
166 | dc1394feature_mode_t current_mode; |
167 | dc1394feature_modes_t modes; |
168 | dc1394trigger_modes_t trigger_modes; |
169 | dc1394trigger_mode_t trigger_mode; |
170 | dc1394trigger_polarity_t trigger_polarity; |
171 | dc1394trigger_sources_t trigger_sources; |
172 | dc1394trigger_source_t trigger_source; |
173 | uint32_t min; |
174 | uint32_t max; |
175 | uint32_t value; |
176 | uint32_t BU_value; |
177 | uint32_t RV_value; |
178 | uint32_t B_value; |
179 | uint32_t R_value; |
180 | uint32_t G_value; |
181 | uint32_t target_value; |
182 | |
183 | dc1394switch_t abs_control; |
184 | float abs_value; |
185 | float abs_max; |
186 | float abs_min; |
187 | |
188 | } dc1394feature_info_t; |
189 | |
190 | /** |
191 | * The list of features |
192 | */ |
193 | typedef struct __dc1394featureset_t |
194 | { |
195 | dc1394feature_info_t feature[DC1394_FEATURE_NUM]; |
196 | } dc1394featureset_t; |
197 | |
198 | #ifdef __cplusplus |
199 | extern "C" { |
200 | #endif |
201 | |
202 | /*************************************************************************** |
203 | Features |
204 | ***************************************************************************/ |
205 | |
206 | /** |
207 | * Collects the available features for the camera described by node and stores them in features. |
208 | */ |
209 | dc1394error_t dc1394_feature_get_all(dc1394camera_t *camera, dc1394featureset_t *features); |
210 | |
211 | /** |
212 | * Stores the bounds and options associated with the feature described by feature->feature_id |
213 | */ |
214 | dc1394error_t dc1394_feature_get(dc1394camera_t *camera, dc1394feature_info_t *feature); |
215 | |
216 | /** |
217 | * Displays the bounds and options of the given feature |
218 | */ |
219 | dc1394error_t dc1394_feature_print(dc1394feature_info_t *feature, FILE *fd); |
220 | |
221 | /** |
222 | * Displays the bounds and options of every feature supported by the camera |
223 | */ |
224 | dc1394error_t dc1394_feature_print_all(dc1394featureset_t *features, FILE *fd); |
225 | |
226 | /** |
227 | * Gets the whitebalance values |
228 | */ |
229 | dc1394error_t dc1394_feature_whitebalance_get_value(dc1394camera_t *camera, uint32_t *u_b_value, uint32_t *v_r_value); |
230 | |
231 | /** |
232 | * Sets the whitebalance values |
233 | */ |
234 | dc1394error_t dc1394_feature_whitebalance_set_value(dc1394camera_t *camera, uint32_t u_b_value, uint32_t v_r_value); |
235 | |
236 | /** |
237 | * Gets the temperature values (target and current) |
238 | */ |
239 | dc1394error_t dc1394_feature_temperature_get_value(dc1394camera_t *camera, uint32_t *target_temperature, uint32_t *temperature); |
240 | |
241 | /** |
242 | * Sets the temperature values (target only) FIXME: COULD BE DROPPED? already in the standard feature_set_value()? |
243 | */ |
244 | dc1394error_t dc1394_feature_temperature_set_value(dc1394camera_t *camera, uint32_t target_temperature); |
245 | |
246 | /** |
247 | * Gets the white shading values |
248 | */ |
249 | dc1394error_t dc1394_feature_whiteshading_get_value(dc1394camera_t *camera, uint32_t *r_value, uint32_t *g_value, uint32_t *b_value); |
250 | |
251 | /** |
252 | * Sets the white shading values |
253 | */ |
254 | dc1394error_t dc1394_feature_whiteshading_set_value(dc1394camera_t *camera, uint32_t r_value, uint32_t g_value, uint32_t b_value); |
255 | |
256 | /** |
257 | * Gets the value of a feature |
258 | */ |
259 | dc1394error_t dc1394_feature_get_value(dc1394camera_t *camera, dc1394feature_t feature, uint32_t *value); |
260 | |
261 | /** |
262 | * Sets the value of a feature |
263 | */ |
264 | dc1394error_t dc1394_feature_set_value(dc1394camera_t *camera, dc1394feature_t feature, uint32_t value); |
265 | |
266 | /** |
267 | * Tells whether a feature is present or not |
268 | */ |
269 | dc1394error_t dc1394_feature_is_present(dc1394camera_t *camera, dc1394feature_t feature, dc1394bool_t *value); |
270 | |
271 | /** |
272 | * Tells whether a feature is readable or not |
273 | */ |
274 | dc1394error_t dc1394_feature_is_readable(dc1394camera_t *camera, dc1394feature_t feature, dc1394bool_t *value); |
275 | |
276 | /** |
277 | * Gets the boundaries of a feature |
278 | */ |
279 | dc1394error_t dc1394_feature_get_boundaries(dc1394camera_t *camera, dc1394feature_t feature, uint32_t *min, uint32_t *max); |
280 | |
281 | /** |
282 | * Tells whether a feature is switcheable or not (ON/OFF) |
283 | */ |
284 | dc1394error_t dc1394_feature_is_switchable(dc1394camera_t *camera, dc1394feature_t feature, dc1394bool_t *value); |
285 | |
286 | /** |
287 | * Gets the power status of a feature (ON or OFF) |
288 | */ |
289 | dc1394error_t dc1394_feature_get_power(dc1394camera_t *camera, dc1394feature_t feature, dc1394switch_t *pwr); |
290 | |
291 | /** |
292 | * Sets the power status of a feature (ON or OFF) |
293 | */ |
294 | dc1394error_t dc1394_feature_set_power(dc1394camera_t *camera, dc1394feature_t feature, dc1394switch_t pwr); |
295 | |
296 | /** |
297 | * Gets the list of control modes for a feature (manual, auto, etc...) |
298 | */ |
299 | dc1394error_t dc1394_feature_get_modes(dc1394camera_t *camera, dc1394feature_t feature, dc1394feature_modes_t *modes); |
300 | |
301 | /** |
302 | * Gets the current control modes for a feature |
303 | */ |
304 | dc1394error_t dc1394_feature_get_mode(dc1394camera_t *camera, dc1394feature_t feature, dc1394feature_mode_t *mode); |
305 | |
306 | /** |
307 | * Sets the current control modes for a feature |
308 | */ |
309 | dc1394error_t dc1394_feature_set_mode(dc1394camera_t *camera, dc1394feature_t feature, dc1394feature_mode_t mode); |
310 | |
311 | /** |
312 | * Tells whether a feature can be controlled in absolute mode |
313 | */ |
314 | dc1394error_t dc1394_feature_has_absolute_control(dc1394camera_t *camera, dc1394feature_t feature, dc1394bool_t *value); |
315 | |
316 | /** |
317 | * Gets the absolute boundaries of a feature |
318 | */ |
319 | dc1394error_t dc1394_feature_get_absolute_boundaries(dc1394camera_t *camera, dc1394feature_t feature, float *min, float *max); |
320 | |
321 | /** |
322 | * Gets the absolute value of a feature |
323 | */ |
324 | dc1394error_t dc1394_feature_get_absolute_value(dc1394camera_t *camera, dc1394feature_t feature, float *value); |
325 | |
326 | /** |
327 | * Sets the absolute value of a feature |
328 | */ |
329 | dc1394error_t dc1394_feature_set_absolute_value(dc1394camera_t *camera, dc1394feature_t feature, float value); |
330 | |
331 | /** |
332 | * Gets the status of absolute control of a feature |
333 | */ |
334 | dc1394error_t dc1394_feature_get_absolute_control(dc1394camera_t *camera, dc1394feature_t feature, dc1394switch_t *pwr); |
335 | |
336 | /** |
337 | * Sets the feature in absolute control mode (ON/OFF) |
338 | */ |
339 | dc1394error_t dc1394_feature_set_absolute_control(dc1394camera_t *camera, dc1394feature_t feature, dc1394switch_t pwr); |
340 | |
341 | /*************************************************************************** |
342 | Trigger |
343 | ***************************************************************************/ |
344 | |
345 | /** |
346 | * Sets the polarity of the external trigger |
347 | */ |
348 | dc1394error_t dc1394_external_trigger_set_polarity(dc1394camera_t *camera, dc1394trigger_polarity_t polarity); |
349 | |
350 | /** |
351 | * Gets the polarity of the external trigger |
352 | */ |
353 | dc1394error_t dc1394_external_trigger_get_polarity(dc1394camera_t *camera, dc1394trigger_polarity_t *polarity); |
354 | |
355 | /** |
356 | * Tells whether the external trigger can change its polarity or not. |
357 | */ |
358 | dc1394error_t dc1394_external_trigger_has_polarity(dc1394camera_t *camera, dc1394bool_t *polarity_capable); |
359 | |
360 | /** |
361 | * Switch between internal and external trigger |
362 | */ |
363 | dc1394error_t dc1394_external_trigger_set_power(dc1394camera_t *camera, dc1394switch_t pwr); |
364 | |
365 | /** |
366 | * Gets the status of the external trigger |
367 | */ |
368 | dc1394error_t dc1394_external_trigger_get_power(dc1394camera_t *camera, dc1394switch_t *pwr); |
369 | |
370 | /** |
371 | * Sets the external trigger mode |
372 | */ |
373 | dc1394error_t dc1394_external_trigger_set_mode(dc1394camera_t *camera, dc1394trigger_mode_t mode); |
374 | |
375 | /** |
376 | * Gets the external trigger mode |
377 | */ |
378 | dc1394error_t dc1394_external_trigger_get_mode(dc1394camera_t *camera, dc1394trigger_mode_t *mode); |
379 | |
380 | /** |
381 | * Sets the external trigger source |
382 | */ |
383 | dc1394error_t dc1394_external_trigger_set_source(dc1394camera_t *camera, dc1394trigger_source_t source); |
384 | |
385 | /** |
386 | * Gets the external trigger source |
387 | */ |
388 | dc1394error_t dc1394_external_trigger_get_source(dc1394camera_t *camera, dc1394trigger_source_t *source); |
389 | |
390 | /** |
391 | * Gets the list of available external trigger source |
392 | */ |
393 | dc1394error_t dc1394_external_trigger_get_supported_sources(dc1394camera_t *camera, dc1394trigger_sources_t *sources); |
394 | |
395 | /** |
396 | * Turn software trigger on or off |
397 | */ |
398 | dc1394error_t dc1394_software_trigger_set_power(dc1394camera_t *camera, dc1394switch_t pwr); |
399 | |
400 | /** |
401 | * Gets the state of software trigger |
402 | */ |
403 | dc1394error_t dc1394_software_trigger_get_power(dc1394camera_t *camera, dc1394switch_t *pwr); |
404 | |
405 | /*************************************************************************** |
406 | PIO, SIO and Strobe Functions |
407 | ***************************************************************************/ |
408 | |
409 | /** |
410 | * Sends a quadlet on the PIO (output) |
411 | */ |
412 | dc1394error_t dc1394_pio_set(dc1394camera_t *camera, uint32_t value); |
413 | |
414 | /** |
415 | * Gets the current quadlet at the PIO (input) |
416 | */ |
417 | dc1394error_t dc1394_pio_get(dc1394camera_t *camera, uint32_t *value); |
418 | |
419 | /*************************************************************************** |
420 | Other functionalities |
421 | ***************************************************************************/ |
422 | |
423 | /** |
424 | * reset a camera to factory default settings |
425 | */ |
426 | dc1394error_t dc1394_camera_reset(dc1394camera_t *camera); |
427 | |
428 | /** |
429 | * turn a camera on or off |
430 | */ |
431 | dc1394error_t dc1394_camera_set_power(dc1394camera_t *camera, dc1394switch_t pwr); |
432 | |
433 | /** |
434 | * Download a camera setup from the memory. |
435 | */ |
436 | dc1394error_t dc1394_memory_busy(dc1394camera_t *camera, dc1394bool_t *value); |
437 | |
438 | /** |
439 | * Uploads a camera setup in the memory. |
440 | * |
441 | * Note that this operation can only be performed a certain number of |
442 | * times for a given camera, as it requires reprogramming of an EEPROM. |
443 | */ |
444 | dc1394error_t dc1394_memory_save(dc1394camera_t *camera, uint32_t channel); |
445 | |
446 | /** |
447 | * Tells whether the writing of the camera setup in memory is finished or not. |
448 | */ |
449 | dc1394error_t dc1394_memory_load(dc1394camera_t *camera, uint32_t channel); |
450 | |
451 | |
452 | #ifdef __cplusplus |
453 | } |
454 | #endif |
455 | |
456 | #endif /* __DC1394_CONTROL_H__ */ |
457 | |