[camera] Add depth pixel format for depth camera
[platform/core/multimedia/mm-hal-interface.git] / include / camera / tizen-camera.h
1 /*
2  * tizen-camera.h
3  *
4  * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #ifndef __TIZEN_CAMERA_HAL_H__
21 #define __TIZEN_CAMERA_HAL_H__
22
23 #include <stdint.h>
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif /* __cplusplus */
28
29 /**
30  * @file tizen-camera.h
31  * @brief This file contains the Tizen camera HAL API, related structures and enumerations.
32  * @since_tizen 3.0
33  */
34
35 #define BUFFER_PLANE_MAX                    4
36 #define DEVICE_COUNT_MAX                    16
37 #define RESOLUTION_COUNT_MAX                10
38 #define DEVICE_NAME_LENGTH_MAX              16
39 #define DEVICE_NODE_PATH_LENGTH_MAX         16
40
41 /**
42  * @addtogroup TIZEN_CAMERA_HAL_MODULE
43  * @{
44  */
45
46 /**
47  * @brief Enumeration for the camera error.
48  * @since_tizen 3.0
49  */
50 typedef enum camera_error {
51         CAMERA_ERROR_NONE                   = 0,
52         CAMERA_ERROR_INVALID_PARAMETER      = (int32_t)0x80002001,
53         CAMERA_ERROR_INVALID_STATE          = (int32_t)0x80002002,
54         CAMERA_ERROR_PERMISSION_DENIED      = (int32_t)0x80002003,
55         CAMERA_ERROR_OUT_OF_MEMORY          = (int32_t)0x80002004,
56         CAMERA_ERROR_DEVICE_OPEN            = (int32_t)0x80002005,
57         CAMERA_ERROR_DEVICE_NOT_FOUND       = (int32_t)0x80002006,
58         CAMERA_ERROR_DEVICE_UNAVAILABLE     = (int32_t)0x80002007,
59         CAMERA_ERROR_DEVICE_NOT_SUPPORTED   = (int32_t)0x80002008,
60         CAMERA_ERROR_DEVICE_READ            = (int32_t)0x80002009,
61         CAMERA_ERROR_DEVICE_WRITE           = (int32_t)0x8000200a,
62         CAMERA_ERROR_DEVICE_BUSY            = (int32_t)0x8000200b,
63         CAMERA_ERROR_DEVICE_TIME_OUT        = (int32_t)0x8000200c,
64         CAMERA_ERROR_DEVICE_ESD             = (int32_t)0x8000200d,
65         CAMERA_ERROR_INTERNAL               = (int32_t)0x8000200e,
66
67         CAMERA_ERROR_NOT_IMPLEMENTED        = (int32_t)0x80002ffe,
68         CAMERA_ERROR_UNKNOWN                = (int32_t)0x80002fff
69 } camera_error_t;
70
71 /**
72  * @brief Enumeration for the camera state.
73  * @since_tizen 3.0
74  */
75 typedef enum camera_state {
76         CAMERA_STATE_INITIALIZED,
77         CAMERA_STATE_OPENED,
78         CAMERA_STATE_PREVIEWING,
79         CAMERA_STATE_CAPTURING,
80         CAMERA_STATE_RECORDING,
81         CAMERA_STATE_RECORDING_SNAPSHOT
82 } camera_state_t;
83
84 /**
85  * @brief The structure type of the resolution.
86  * @since_tizen 3.0
87  */
88 typedef struct camera_resolution {
89         uint32_t width;
90         uint32_t height;
91 } camera_resolution_t;
92
93 /**
94  * @brief The structure type of the fraction.
95  * @since_tizen 3.0
96  */
97 typedef struct camera_fraction {
98         int numerator;
99         int denominator;
100 } camera_fraction_t;
101
102 /**
103  * @brief The structure type of the rectangle.
104  * @since_tizen 3.0
105  */
106 typedef struct camera_rectangle {
107         int x;
108         int y;
109         uint32_t width;
110         uint32_t height;
111 } camera_rectangle_t;
112
113 /**
114  * @brief Enumeration for the camera pixel format.
115  * @since_tizen 3.0
116  */
117 typedef enum camera_pixel_format {
118         /* YUV */
119         CAMERA_PIXEL_FORMAT_NV12 = 0x0000,
120         CAMERA_PIXEL_FORMAT_NV21,
121         CAMERA_PIXEL_FORMAT_I420,
122         CAMERA_PIXEL_FORMAT_YV12,
123         CAMERA_PIXEL_FORMAT_YUYV,
124         CAMERA_PIXEL_FORMAT_UYVY,
125
126         /* RGB */
127         CAMERA_PIXEL_FORMAT_BGRA8888,
128         CAMERA_PIXEL_FORMAT_ARGB8888,
129
130         /* ENCODED */
131         CAMERA_PIXEL_FORMAT_JPEG,
132         CAMERA_PIXEL_FORMAT_H264,
133
134         /* DEPTH */
135         CAMERA_PIXEL_FORMAT_DEPTH,
136
137         /* MAX */
138         CAMERA_PIXEL_FORMAT_MAX
139 } camera_pixel_format_t;
140
141 /**
142  * @brief The structure type of the camera plane.
143  * @since_tizen 3.0
144  */
145 typedef struct camera_plane {
146         unsigned char *data;
147         uint32_t align_width;
148         uint32_t align_height;
149         uint32_t size;
150 } camera_plane_t;
151
152 /**
153  * @brief The structure type of the camera buffer.
154  * @since_tizen 3.0
155  */
156 typedef struct camera_buffer {
157         int index;
158         camera_pixel_format_t format;
159         camera_resolution_t resolution;
160         uint32_t total_size;
161         uint32_t num_planes;
162         camera_plane_t planes[BUFFER_PLANE_MAX];
163         uint32_t num_bos;
164         void *bos[BUFFER_PLANE_MAX];
165 } camera_buffer_t;
166
167 /**
168  * @brief The structure type of the camera metadata.
169  * @since_tizen 3.0
170  */
171 typedef struct camera_metadata {
172         int is_flashed;
173         camera_fraction_t focal_length;
174         camera_fraction_t aperture_f_number;
175         camera_fraction_t shutter_speed;
176         camera_fraction_t exposure_time;
177         camera_fraction_t brightness;
178         camera_resolution_t exif_image;
179         int iso;
180         int metering_mode;
181         int color_space;
182         int component_configuration;
183         int aperture_in_apex;
184 } camera_metadata_t;
185
186 /**
187  * @brief Enumeration for the focus state.
188  * @since_tizen 3.0
189  */
190 typedef enum camera_focus_state {
191         CAMERA_FOCUS_STATE_RELEASED,
192         CAMERA_FOCUS_STATE_ONGOING,
193         CAMERA_FOCUS_STATE_FOCUSED,
194         CAMERA_FOCUS_STATE_FAILED
195 } camera_focus_state_t;
196
197 /**
198  * @brief Enumeration for the facing direction of camera device.
199  * @since_tizen 3.0
200  */
201 typedef enum camera_facing_direction {
202         CAMERA_FACING_DIRECTION_REAR,
203         CAMERA_FACING_DIRECTION_FRONT,
204         CAMERA_FACING_DIRECTION_EXTERNAL
205 } camera_facing_direction_t;
206
207 /**
208  * @brief Enumeration for the camera rotation.
209  * @since_tizen 3.0
210  */
211 typedef enum camera_rotation {
212         CAMERA_ROTATION_0,
213         CAMERA_ROTATION_90,
214         CAMERA_ROTATION_180,
215         CAMERA_ROTATION_270
216 } camera_rotation_t;
217
218 /**
219  * @brief Enumeration for the camera flip.
220  * @since_tizen 3.0
221  */
222 typedef enum camera_flip {
223         CAMERA_FLIP_NONE,
224         CAMERA_FLIP_HORIZONTAL,
225         CAMERA_FLIP_VERTICAL,
226         CAMERA_FLIP_BOTH
227 } camera_flip_t;
228
229 /**
230  * @brief The structure type of the camera format.
231  * @since_tizen 3.0
232  */
233 typedef struct camera_format {
234         camera_pixel_format_t stream_format;
235         camera_resolution_t stream_resolution;
236         uint32_t stream_fps;
237         camera_rotation_t stream_rotation;
238         camera_pixel_format_t capture_format;
239         camera_resolution_t capture_resolution;
240         uint32_t capture_quality;
241 } camera_format_t;
242
243 /**
244  * @brief Enumeration for the focus mode.
245  * @since_tizen 3.0
246  */
247 typedef enum camera_focus_mode {
248         CAMERA_FOCUS_MODE_NONE,
249         CAMERA_FOCUS_MODE_PAN,
250         CAMERA_FOCUS_MODE_AUTO,
251         CAMERA_FOCUS_MODE_CONTINUOUS_AUTO
252 } camera_focus_mode_t;
253
254 /**
255  * @brief Enumeration for the focus range.
256  * @since_tizen 3.0
257  */
258 typedef enum camera_focus_range {
259         CAMERA_FOCUS_RANGE_NONE,
260         CAMERA_FOCUS_RANGE_NORMAL,
261         CAMERA_FOCUS_RANGE_MACRO,
262         CAMERA_FOCUS_RANGE_FULL
263 } camera_focus_range_t;
264
265 /**
266  * @brief Enumeration for the white balance.
267  * @since_tizen 3.0
268  */
269 typedef enum camera_white_balance {
270         CAMERA_WHITE_BALANCE_AUTO,          /**< Automatic */
271         CAMERA_WHITE_BALANCE_DAYLIGHT,      /**< Daylight */
272         CAMERA_WHITE_BALANCE_CLOUDY,        /**< Cloudy */
273         CAMERA_WHITE_BALANCE_FLUORESCENT,   /**< Fluorescent */
274         CAMERA_WHITE_BALANCE_INCANDESCENT,  /**< Incandescent */
275         CAMERA_WHITE_BALANCE_SHADE,         /**< Shade */
276         CAMERA_WHITE_BALANCE_HORIZON,       /**< Horizon */
277         CAMERA_WHITE_BALANCE_FLASH          /**< Flash */
278 } camera_white_balance_t;
279
280 /**
281  * @brief Enumeration for the effect.
282  * @since_tizen 3.0
283  */
284 typedef enum camera_effect {
285         CAMERA_EFFECT_NONE,                 /**< None */
286         CAMERA_EFFECT_MONO,                 /**< Mono */
287         CAMERA_EFFECT_SEPIA,                /**< Sepia */
288         CAMERA_EFFECT_NEGATIVE,             /**< Negative */
289         CAMERA_EFFECT_RED,                  /**< Red */
290         CAMERA_EFFECT_GREEN,                /**< Green */
291         CAMERA_EFFECT_BLUE,                 /**< Blue */
292         CAMERA_EFFECT_AQUA,                 /**< Aqua */
293         CAMERA_EFFECT_ANTIQUE,              /**< Antique */
294         CAMERA_EFFECT_WARM,                 /**< Warm */
295         CAMERA_EFFECT_EMBOSS,               /**< Emboss */
296         CAMERA_EFFECT_SKETCH,               /**< Sketch */
297         CAMERA_EFFECT_SOLARIZATION,         /**< Solarization */
298         CAMERA_EFFECT_POSTERIZATION,        /**< Posterization */
299         CAMERA_EFFECT_CARTOON               /**< Cartoon */
300 } camera_effect_t;
301
302 /**
303  * @brief Enumeration for the scene mode.
304  * @since_tizen 3.0
305  */
306 typedef enum camera_scene_mode {
307         CAMERA_SCENE_MODE_NORMAL,           /**< Normal */
308         CAMERA_SCENE_MODE_PORTRAIT,         /**< Portrait */
309         CAMERA_SCENE_MODE_LANDSCAPE,        /**< Landscape */
310         CAMERA_SCENE_MODE_SPORTS,           /**< Sports */
311         CAMERA_SCENE_MODE_PARTY_N_INDOOR,   /**< Party & indoor */
312         CAMERA_SCENE_MODE_BEACH_N_INDOOR,   /**< Beach & indoor */
313         CAMERA_SCENE_MODE_SUNSET,           /**< Sunset */
314         CAMERA_SCENE_MODE_DUSK_N_DAWN,      /**< Dusk & dawn */
315         CAMERA_SCENE_MODE_FALL_COLOR,       /**< Fall */
316         CAMERA_SCENE_MODE_NIGHT_SCENE,      /**< Night scene */
317         CAMERA_SCENE_MODE_FIREWORK,         /**< Firework */
318         CAMERA_SCENE_MODE_TEXT,             /**< Text */
319         CAMERA_SCENE_MODE_SHOW_WINDOW,      /**< Show window */
320         CAMERA_SCENE_MODE_CANDLE_LIGHT,     /**< Candle light */
321         CAMERA_SCENE_MODE_BACKLIGHT,        /**< Backlight */
322         CAMERA_SCENE_MODE_AQUA              /**< Aqua */
323 } camera_scene_mode_t;
324
325 /**
326  * @brief Enumeration for the exposure mode.
327  * @since_tizen 3.0
328  */
329 typedef enum camera_exposure_mode {
330         CAMERA_EXPOSURE_MODE_OFF = 0,       /**< Off */
331         CAMERA_EXPOSURE_MODE_ALL,           /**< All mode */
332         CAMERA_EXPOSURE_MODE_CENTER,        /**< Center mode */
333         CAMERA_EXPOSURE_MODE_SPOT,          /**< Spot mode */
334         CAMERA_EXPOSURE_MODE_CUSTOM         /**< Custom mode */
335 } camera_exposure_mode_t;
336
337 /**
338  * @brief Enumeration for the shot mode.
339  * @since_tizen 3.0
340  */
341 typedef enum camera_shot_mode {
342         CAMERA_SHOT_MODE_NORMAL = 0,        /**< Normal */
343         CAMERA_SHOT_MODE_CONTINUOUS,        /**< Continuous */
344         CAMERA_SHOT_MODE_HDR,               /**< HDR */
345         CAMERA_SHOT_MODE_NIGHT              /**< Night */
346 } camera_shot_mode_t;
347
348 /**
349  * @brief Enumeration for the flash mode.
350  * @since_tizen 3.0
351  */
352 typedef enum camera_flash_mode {
353         CAMERA_FLASH_MODE_OFF = 0,          /**< Always off */
354         CAMERA_FLASH_MODE_ON,               /**< Always splashes */
355         CAMERA_FLASH_MODE_AUTO,             /**< Depending on intensity of light, strobe starts to flash */
356         CAMERA_FLASH_MODE_REDEYE_REDUCTION, /**< Red eye reduction. Multiple flash before capturing */
357         CAMERA_FLASH_MODE_SLOW_SYNC,        /**< Slow sync curtain synchronization */
358         CAMERA_FLASH_MODE_FRONT_CURTAIN,    /**< Front curtain synchronization */
359         CAMERA_FLASH_MODE_REAR_CURTAIN,     /**< Rear curtain synchronization */
360         CAMERA_FLASH_MODE_PERMANENT,        /**< Keep turned on until turning off */
361 } camera_flash_mode_t;
362
363 /**
364  * @brief Enumeration for the face detection.
365  * @since_tizen 3.0
366  */
367 typedef enum camera_face_detection {
368         CAMERA_FACE_DETECTION_OFF = 0,      /**< Face detection off */
369         CAMERA_FACE_DETECTION_ON            /**< Face detection on */
370 } camera_face_detection_t;
371
372 /**
373  * @brief Definitions for the camera command.
374  * @since_tizen 3.0
375  */
376 #define CAMERA_COMMAND_BASE                     ((int64_t)1)
377 #define CAMERA_COMMAND_WHITE_BALANCE            ((int64_t)(CAMERA_COMMAND_BASE << 1))
378 #define CAMERA_COMMAND_ISO                      ((int64_t)(CAMERA_COMMAND_BASE << 2))
379 #define CAMERA_COMMAND_CONTRAST                 ((int64_t)(CAMERA_COMMAND_BASE << 3))
380 #define CAMERA_COMMAND_SATURATION               ((int64_t)(CAMERA_COMMAND_BASE << 4))
381 #define CAMERA_COMMAND_HUE                      ((int64_t)(CAMERA_COMMAND_BASE << 5))
382 #define CAMERA_COMMAND_SHARPNESS                ((int64_t)(CAMERA_COMMAND_BASE << 6))
383 #define CAMERA_COMMAND_EFFECT                   ((int64_t)(CAMERA_COMMAND_BASE << 7))
384 #define CAMERA_COMMAND_SCENE_MODE               ((int64_t)(CAMERA_COMMAND_BASE << 8))
385 #define CAMERA_COMMAND_EXPOSURE_MODE            ((int64_t)(CAMERA_COMMAND_BASE << 9))
386 #define CAMERA_COMMAND_EXPOSURE                 ((int64_t)(CAMERA_COMMAND_BASE << 10))
387 #define CAMERA_COMMAND_ROTATION                 ((int64_t)(CAMERA_COMMAND_BASE << 11))
388 #define CAMERA_COMMAND_FLIP                     ((int64_t)(CAMERA_COMMAND_BASE << 12))
389 #define CAMERA_COMMAND_FOCUS_MODE               ((int64_t)(CAMERA_COMMAND_BASE << 13))
390 #define CAMERA_COMMAND_FOCUS_RANGE              ((int64_t)(CAMERA_COMMAND_BASE << 14))
391 #define CAMERA_COMMAND_SHOT_MODE                ((int64_t)(CAMERA_COMMAND_BASE << 15))
392 #define CAMERA_COMMAND_ANTI_SHAKE               ((int64_t)(CAMERA_COMMAND_BASE << 16))
393 #define CAMERA_COMMAND_FOCUS_AREA               ((int64_t)(CAMERA_COMMAND_BASE << 17))
394 #define CAMERA_COMMAND_DIGITAL_ZOOM             ((int64_t)(CAMERA_COMMAND_BASE << 18))
395 #define CAMERA_COMMAND_OPTICAL_ZOOM             ((int64_t)(CAMERA_COMMAND_BASE << 19))
396 #define CAMERA_COMMAND_RECORDING_HINT           ((int64_t)(CAMERA_COMMAND_BASE << 20))
397 #define CAMERA_COMMAND_WDR                      ((int64_t)(CAMERA_COMMAND_BASE << 21))
398 #define CAMERA_COMMAND_SHUTTER_SPEED            ((int64_t)(CAMERA_COMMAND_BASE << 22))
399 #define CAMERA_COMMAND_FLASH_MODE               ((int64_t)(CAMERA_COMMAND_BASE << 23))
400 #define CAMERA_COMMAND_FACE_DETECTION           ((int64_t)(CAMERA_COMMAND_BASE << 24))
401
402
403 typedef struct camera_batch_command_control {
404         /* flag for modified command */
405         int64_t command_set_flag;
406
407         /* value list */
408         camera_white_balance_t white_balance;
409         int iso;
410         int contrast;
411         int saturation;
412         int hue;
413         int sharpness;
414         camera_effect_t effect;
415         camera_scene_mode_t scene_mode;
416         camera_exposure_mode_t exposure_mode;
417         int exposure;
418         camera_rotation_t rotation;
419         camera_flip_t flip;
420         camera_focus_mode_t focus_mode;
421         camera_focus_range_t focus_range;
422         camera_exposure_mode_t shot_mode;
423         int anti_shake;
424         camera_rectangle_t focus_area;
425         int digital_zoom;
426         int optical_zoom;
427         int recording_hint;
428         int wdr;
429         camera_flash_mode_t flash_mode;
430         camera_face_detection_t face_detection;
431 } camera_batch_command_control_t;
432
433 /**
434  * @brief The structure type of the format list.
435  * @since_tizen 3.0
436  */
437 typedef struct camera_pixel_format_list {
438         uint32_t count;
439         camera_pixel_format_t formats[CAMERA_PIXEL_FORMAT_MAX];
440 } camera_format_list_t;
441
442 /**
443  * @brief The structure type of the resolution list.
444  * @since_tizen 3.0
445  */
446 typedef struct camera_resolution_list {
447         uint32_t count;
448         camera_resolution_t resolutions[RESOLUTION_COUNT_MAX];
449 } camera_resolution_list_t;
450
451 /**
452  * @brief The structure type of the camera device information.
453  * @since_tizen 3.0
454  */
455 typedef struct camera_device_info {
456         uint32_t index;
457         char name[DEVICE_NAME_LENGTH_MAX];
458         char node_path[DEVICE_NODE_PATH_LENGTH_MAX];
459         camera_facing_direction_t facing_direction;
460         camera_format_list_t format_list;
461         camera_resolution_list_t preview_list;
462         camera_resolution_list_t capture_list;
463         camera_resolution_list_t video_list;
464 } camera_device_info_t;
465
466 /**
467  * @brief The structure type of the camera device information list.
468  * @since_tizen 3.0
469  */
470 typedef struct camera_device_info_list {
471         uint32_t count;
472         camera_device_info_t device_info[DEVICE_COUNT_MAX];
473 } camera_device_info_list_t;
474
475 /**
476  * @brief Enumeration for the camera message type.
477  * @since_tizen 3.0
478  */
479 typedef enum camera_message_type {
480         CAMERA_MESSAGE_TYPE_FOCUS_CHANGED,
481         CAMERA_MESSAGE_TYPE_CAPTURED,
482         CAMERA_MESSAGE_TYPE_HDR_PROGRESS,
483         CAMERA_MESSAGE_TYPE_ERROR
484 } camera_message_type_t;
485
486 /**
487  * @brief The structure type of the camera message.
488  * @since_tizen 3.0
489  */
490 typedef struct camera_message {
491         camera_message_type_t type;
492         union {
493                 camera_focus_state_t focus_state;
494                 uint32_t hdr_progress;
495                 camera_error_t error_code;
496         };
497 } camera_message_t;
498
499 /**
500  * @brief Callback function for notification from camera HAL.
501  * @since_tizen 3.0
502  * @param[in] message The message from camera HAL
503  * @param[in] user_data The user data for callback
504  * @see camera_add_message_callback()
505  * @see camera_remove_message_callback()
506  */
507 typedef int (*camera_message_cb)(camera_message_t *message, void *user_data);
508
509 /**
510  * @brief Callback function for captured preview frame from camera device.
511  * @since_tizen 3.0
512  * @param[in] buffer The preview buffer
513  * @param[in] meta The meta data for the preview frame
514  * @param[in] user_data The user data for callback
515  * @pre       camera_start_preview() will invoke this callback.
516  * @see camera_start_preview()
517  * @see camera_stop_preview()
518  */
519 typedef int (*camera_preview_frame_cb)(camera_buffer_t *buffer, camera_metadata_t *meta, void *user_data);
520
521 /**
522  * @brief Callback function for captured video frame from camera device.
523  * @since_tizen 3.0
524  * @param[in] buffer The video buffer
525  * @param[in] meta The meta data for the video frame
526  * @param[in] user_data The user data for callback
527  * @pre       camera_start_record() will invoke this callback.
528  * @see camera_start_record()
529  * @see camera_stop_record()
530  */
531 typedef int (*camera_video_frame_cb)(camera_buffer_t *buffer, camera_metadata_t *meta, void *user_data);
532
533 /**
534  * @brief Callback function for captured still image from camera device.
535  * @since_tizen 3.0
536  * @param[in] main The main image data
537  * @param[in] postview The image data of the postview (it could be @c NULL if the available data does not exist)
538  * @param[in] thumbnail The image data of the thumbnail (it could be @c NULL if the available data does not exist)
539  * @param[in] user_data The user data passed from the callback registration function
540  * @pre       camera_start_capture() will invoke this callback function.
541  * @see camera_start_capture()
542  * @see camera_stop_capture()
543  */
544 typedef int (*camera_capture_cb)(camera_buffer_t *main, camera_buffer_t *postview, camera_buffer_t *thumbnail, void *user_data);
545
546 /**
547  * @brief The structure type of the camera interface.
548  * @since_tizen 3.0
549  */
550 typedef struct camera_interface {
551         int (*init)(void **camera_handle);
552         int (*deinit)(void *camera_handle);
553         int (*get_device_info_list)(camera_device_info_list_t *device_info_list);
554         int (*open_device)(void *camera_handle, int device_index);
555         int (*close_device)(void *camera_handle);
556         int (*add_message_callback)(void *camera_handle, camera_message_cb callback, void *user_data, uint32_t *cb_id);
557         int (*remove_message_callback)(void *camera_handle, uint32_t cb_id);
558         int (*set_preview_stream_format)(void *camera_handle, camera_format_t *format);
559         int (*get_preview_stream_format)(void *camera_handle, camera_format_t *format);
560         int (*start_preview)(void *camera_handle, camera_preview_frame_cb callback, void *user_data);
561         int (*release_preview_buffer)(void *camera_handle, int buffer_index);
562         int (*stop_preview)(void *camera_handle);
563         int (*start_auto_focus)(void *camera_handle);
564         int (*stop_auto_focus)(void *camera_handle);
565         int (*start_capture)(void *camera_handle, camera_capture_cb callback, void *user_data);
566         int (*stop_capture)(void *camera_handle);
567         int (*set_video_stream_format)(void *camera_handle, camera_format_t *format);
568         int (*get_video_stream_format)(void *camera_handle, camera_format_t *format);
569         int (*start_record)(void *camera_handle, camera_video_frame_cb callback, void *user_data);
570         int (*release_video_buffer)(void *camera_handle, int buffer_index);
571         int (*stop_record)(void *camera_handle);
572         int (*set_command)(void *camera_handle, int command, void *value);
573         int (*get_command)(void *camera_handle, int command, void **value);
574         int (*set_batch_command)(void *camera_handle, camera_batch_command_control_t *batch_command, int64_t *error_command);
575 } camera_interface_t;
576
577
578 /**
579  * @brief Initializes new handle of camera HAL.
580  * @since_tizen 3.0
581  * @param[out] camera_handle A newly returned handle to the camera HAL
582  * @return @c 0 on success, otherwise a negative error value
583  * @retval #CAMERA_ERROR_NONE Successful
584  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
585  * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
586  * @retval #CAMERA_ERROR_PERMISSION_DENIED The access to the resources can not be granted
587  * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
588  * @post   If it succeeds, the camera state will be #CAMERA_STATE_INITIALIZED.
589  *
590  * @see camera_deinit()
591  */
592 int camera_init(void **camera_handle);
593
594 /**
595  * @brief Deinitializes handle of camera HAL.
596  * @since_tizen 3.0
597  * @param[in] camera_handle The handle to the camera HAL
598  * @return @c 0 on success, otherwise a negative error value
599  * @retval #CAMERA_ERROR_NONE Successful
600  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
601  * @see camera_init()
602  */
603 int camera_deinit(void *camera_handle);
604
605 /**
606  * @brief Gets the device list of camera.
607  * @since_tizen 3.0
608  * @param[out] device_info_list The list of the camera device information
609  * @return @c 0 on success, otherwise a negative error value
610  * @retval #CAMERA_ERROR_NONE Successful
611  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
612  * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
613  * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
614  */
615 int camera_get_device_info_list(camera_device_info_list_t *device_info_list);
616
617 /**
618  * @brief Opens camera device.
619  * @since_tizen 3.0
620  * @param[in] camera_handle The handle to the camera HAL
621  * @param[in] device_index The device index of the camera
622  * @return @c 0 on success, otherwise a negative error value
623  * @retval #CAMERA_ERROR_NONE Successful
624  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
625  * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
626  * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
627  * @retval #CAMERA_ERROR_PERMISSION_DENIED The access to the resources can not be granted
628  * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
629  * @retval #CAMERA_ERROR_DEVICE_NOT_FOUND Failed to find camera device
630  * @retval #CAMERA_ERROR_DEVICE_UNAVAILABLE The camera device is unavailable
631  * @pre    The camera state must be set to #CAMERA_STATE_INITIALIZED.
632  * @post   If it succeeds, the camera state will be #CAMERA_STATE_OPENED.
633  * @see camera_close_device()
634  */
635 int camera_open_device(void *camera_handle, int device_index);
636
637 /**
638  * @brief Closes camera device.
639  * @since_tizen 3.0
640  * @param[in] camera_handle The handle to the camera HAL
641  * @return @c 0 on success, otherwise a negative error value
642  * @retval #CAMERA_ERROR_NONE Successful
643  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
644  * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
645  * @pre    The camera state must be set to #CAMERA_STATE_OPENED.
646  * @post   If it succeeds, the camera state will be #CAMERA_STATE_INITIALIZED.
647  * @see camera_open_device()
648  */
649 int camera_close_device(void *camera_handle);
650
651 /**
652  * @brief Registers a callback function to be called to send a message by camera HAL.
653  * @since_tizen 3.0
654  * @param[in] camera_handle The handle to the camera HAL
655  * @param[in] callback The callback function to be registered
656  * @param[in] user_data The user data to be passed to the callback function
657  * @param[out] cb_id The callback id
658  * @return @c 0 on success, otherwise a negative error value
659  * @retval #CAMERA_ERROR_NONE Successful
660  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
661  * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
662  * @see camera_remove_message_callback()
663  */
664 int camera_add_message_callback(void *camera_handle, camera_message_cb callback, void *user_data, uint32_t *cb_id);
665
666 /**
667  * @brief Unregisters a callback function.
668  * @since_tizen 3.0
669  * @param[in] camera_handle The handle to the camera HAL
670  * @param[in] cb_id The callback id
671  * @return @c 0 on success, otherwise a negative error value
672  * @retval #CAMERA_ERROR_NONE Successful
673  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
674  * @see camera_remove_message_callback()
675  */
676 int camera_remove_message_callback(void *camera_handle, uint32_t cb_id);
677
678 /**
679  * @brief Sets the format of the preview stream.
680  * @since_tizen 3.0
681  * @remarks This function should be called before previewing (see camera_start_preview()).
682  * @param[in] camera_handle The handle to the camera HAL
683  * @param[in] format The format of the preview stream
684  * @return @c 0 on success, otherwise a negative error value
685  * @retval #CAMERA_ERROR_NONE Successful
686  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
687  * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
688  * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
689  * @pre    The camera state must be set to #CAMERA_STATE_OPENED.
690  * @see camera_start_preview()
691  * @see camera_start_capture()
692  * @see camera_get_preview_stream_format()
693  */
694 int camera_set_preview_stream_format(void *camera_handle, camera_format_t *format);
695
696 /**
697  * @brief Gets the format of the preview stream.
698  * @since_tizen 3.0
699  * @param[in] camera_handle The handle to the camera HAL
700  * @param[out] format The format of the preview stream
701  * @return @c 0 on success, otherwise a negative error value
702  * @retval #CAMERA_ERROR_NONE Successful
703  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
704  * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
705  * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
706  * @see camera_start_preview()
707  * @see camera_start_capture()
708  * @see camera_set_preview_stream_format()
709  * @see camera_foreach_supported_preview_format()
710  */
711 int camera_get_preview_stream_format(void *camera_handle, camera_format_t *format);
712
713 /**
714  * @brief Starts preview frames on the screen.
715  * @since_tizen 3.0
716  * @param[in] camera_handle The handle to the camera HAL
717  * @param[in] callback The callback for preview frame
718  * @param[in] user_data The user data for callback
719  * @return @c 0 on success, otherwise a negative error value
720  * @retval #CAMERA_ERROR_NONE Successful
721  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
722  * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
723  * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
724  * @retval #CAMERA_ERROR_DEVICE_BUSY The device is being used in another application or is performing other operations
725  * @retval #CAMERA_ERROR_PERMISSION_DENIED The access to the resources can not be granted
726  * @pre    The camera state must be set to #CAMERA_STATE_OPENED.
727  * @post   If it succeeds, the camera state will be #CAMERA_STATE_PREVIEWING.
728  * @see camera_stop_preview()
729  */
730 int camera_start_preview(void *camera_handle, camera_preview_frame_cb callback, void *user_data);
731
732 /**
733  * @brief Release the preview buffer.
734  * @since_tizen 3.0
735  * @remarks The preview buffer should be released with this function after use it.
736  * @param[in] camera_handle The handle to the camera HAL
737  * @param[in] buffer_index The index of preview buffer
738  * @return @c 0 on success, otherwise a negative error value
739  * @retval #CAMERA_ERROR_NONE Successful
740  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
741  * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
742  * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
743  * @see camera_start_preview()
744  */
745 int camera_release_preview_buffer(void *camera_handle, int buffer_index);
746
747 /**
748  * @brief Stops preview frames.
749  * @since_tizen 3.0
750  * @param[in] camera_handle The handle to the camera HAL
751  * @return @c 0 on success, otherwise a negative error value
752  * @retval #CAMERA_ERROR_NONE Successful
753  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
754  * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
755  * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
756  * @pre    The camera state must be set to #CAMERA_STATE_PREVIEWING.
757  * @post   The camera state will be #CAMERA_STATE_OPENED.
758  * @see camera_start_preview()
759  */
760 int camera_stop_preview(void *camera_handle);
761
762 /**
763  * @brief Starts camera auto focusing operation.
764  * @since_tizen 3.0
765  * @param[in] camera_handle The handle to the camera HAL
766  * @return @c 0 on success, otherwise a negative error value
767  * @retval #CAMERA_ERROR_NONE Successful
768  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
769  * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
770  * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
771  * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
772  * @pre    The camera state must be set to #CAMERA_STATE_PREVIEWING or #CAMERA_STATE_RECORDING.
773  * @post   The camera focus state will be #CAMERA_FOCUS_STATE_ONGOING.
774  * @see camera_stop_auto_focus()
775  * @see camera_add_message_callback()
776  * @see camera_message_cb()
777  * @see camera_set_command()
778  */
779 int camera_start_auto_focus(void *camera_handle);
780
781 /**
782  * @brief Stops camera auto focusing operation.
783  * @since_tizen 3.0
784  * @param[in] camera_handle The handle to the camera HAL
785  * @return @c 0 on success, otherwise a negative error value
786  * @retval #CAMERA_ERROR_NONE Successful
787  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
788  * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
789  * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
790  * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
791  * @pre    The camera state must be set to #CAMERA_STATE_PREVIEWING or #CAMERA_STATE_RECORDING.
792  * @post   The camera focus state will be #CAMERA_FOCUS_STATE_ONGOING.
793  * @see camera_start_auto_focus()
794  * @see camera_add_message_callback()
795  * @see camera_message_cb()
796  */
797 int camera_stop_auto_focus(void *camera_handle);
798
799 /**
800  * @brief Starts capturing of still images.
801  * @since_tizen 3.0
802  * @remarks In case of zero shutter lag capture, preview frame won't be stopped while capturing.
803  * @param[in] camera_handle The handle to the camera HAL
804  * @param[in] callback The callback for captured data
805  * @param[in] user_data The user data for callback
806  * @return @c 0 on success, otherwise a negative error value
807  * @retval #CAMERA_ERROR_NONE Successful
808  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
809  * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
810  * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
811  * @pre    The camera state must be set to #CAMERA_STATE_PREVIEWING or #CAMERA_STATE_RECORDING.
812  * @post   If it succeeds the camera state will be #CAMERA_STATE_CAPTURING or #CAMERA_STATE_RECORDING_SNAPSHOT.
813  * @see camera_start_preview()
814  * @see camera_start_record()
815  * @see camera_set_preview_stream_format()
816  * @see camera_get_preview_stream_format()
817  */
818 int camera_start_capture(void *camera_handle, camera_capture_cb callback, void *user_data);
819
820 /**
821  * @brief Stops capturing of still images.
822  * @since_tizen 3.0
823  * @remarks In case of zero shutter lag, this function will changes only the state of camera HAL \n
824  *          from #CAMERA_STATE_PREVIEWING or #CAMERA_STATE_RECORDING to #CAMERA_STATE_PREVIEWING or #CAMERA_STATE_RECORDING.\n
825  *          Otherwise, preview frame will be restarted.
826  * @param[in] camera_handle The handle to the camera HAL
827  * @param[in] callback The callback for captured data
828  * @param[in] user_data The user data
829  * @return @c 0 on success, otherwise a negative error value
830  * @retval #CAMERA_ERROR_NONE Successful
831  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
832  * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
833  * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
834  * @pre    The camera state must be set to #CAMERA_STATE_CAPTURING or #CAMERA_STATE_RECORDING_SNAPSHOT.
835  * @post   If it succeeds the camera state will be #CAMERA_STATE_PREVIEWING or #CAMERA_STATE_RECORDING.
836  * @see camera_start_capture()
837  * @see camera_start_record()
838  * @see camera_set_preview_stream_format()
839  * @see camera_get_preview_stream_format()
840  * @see camera_set_video_stream_format()
841  * @see camera_get_video_stream_format()
842  */
843 int camera_stop_capture(void *camera_handle);
844
845 /**
846  * @brief Sets the format of the video stream for recording.
847  * @since_tizen 3.0
848  * @remarks This function should be called before recording (see camera_start_record()).
849  * @param[in] camera_handle The handle to the camera HAL
850  * @param[in] format The format of the video stream
851  * @return @c 0 on success, otherwise a negative error value
852  * @retval #CAMERA_ERROR_NONE Successful
853  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
854  * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
855  * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
856  * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
857  * @pre    The camera state must be set to #CAMERA_STATE_OPENED.
858  * @see camera_start_record()
859  * @see camera_start_capture()
860  * @see camera_get_video_stream_format()
861  */
862 int camera_set_video_stream_format(void *camera_handle, camera_format_t *format);
863
864 /**
865  * @brief Gets the format of the video stream for recording.
866  * @since_tizen 3.0
867  * @param[in] camera_handle The handle to the camera HAL
868  * @param[out] format The format of the video stream
869  * @return @c 0 on success, otherwise a negative error value
870  * @retval #CAMERA_ERROR_NONE Successful
871  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
872  * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
873  * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
874  * @see camera_start_preview()
875  * @see camera_start_capture()
876  * @see camera_set_preview_stream_format()
877  * @see camera_foreach_supported_preview_format()
878  */
879 int camera_get_video_stream_format(void *camera_handle, camera_format_t *format);
880
881 /**
882  * @brief Starts the video frame for recording.
883  * @since_tizen 3.0
884  * @param[in] camera_handle The handle to the camera HAL
885  * @param[in] callback The callback for video frame
886  * @param[in] user_data The user data for callback
887  * @return @c 0 on success, otherwise a negative error value
888  * @retval #CAMERA_ERROR_NONE Successful
889  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
890  * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
891  * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
892  * @retval #CAMERA_ERROR_PERMISSION_DENIED The access to the resources can not be granted
893  * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
894  * @pre The camera state must be #CAMERA_STATE_PREVIEWING.
895  * @post The camera state will be #CAMERA_STATE_RECORDING.
896  * @see camera_set_video_stream_format()
897  * @see camera_get_video_stream_format()
898  * @see camera_stop_record()
899  */
900 int camera_start_record(void *camera_handle, camera_video_frame_cb callback, void *user_data);
901
902 /**
903  * @brief Release the video buffer.
904  * @remarks The video buffer should be released with this function after use it.
905  * @since_tizen 3.0
906  * @param[in] camera_handle The handle to the camera HAL
907  * @param[in] buffer_index The index of video buffer
908  * @return @c 0 on success, otherwise a negative error value
909  * @retval #CAMERA_ERROR_NONE Successful
910  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
911  * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
912  * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
913  * @pre    The camera state must be set to #CAMERA_STATE_PREVIEWING.
914  * @see camera_start_record()
915  */
916 int camera_release_video_buffer(void *camera_handle, int buffer_index);
917
918 /**
919  * @brief Stops the video frame.
920  * @since_tizen 3.0
921  * @param[in] camera_handle The handle to the camera HAL
922  * @return @c 0 on success, otherwise a negative error value
923  * @retval #CAMERA_ERROR_NONE Successful
924  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
925  * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
926  * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
927  * @pre The camera state must be #CAMERA_STATE_RECORDING.
928  * @post The camera state will be #CAMERA_STATE_PREVIEWING.
929  * @see camera_set_video_stream_format()
930  * @see camera_get_video_stream_format()
931  * @see camera_start_record()
932  */
933 int camera_stop_record(void *camera_handle);
934
935 /**
936  * @brief Sets the various command and value to control camera device.
937  * @since_tizen 3.0
938  * @param[in] camera_handle The handle to the camera HAL
939  * @param[in] command The command to control the camera device
940  * @param[in] value The value to set
941  * @return @c 0 on success, otherwise a negative error value
942  * @retval #CAMERA_ERROR_NONE Successful
943  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
944  * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
945  * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
946  * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
947  * @see camera_get_command()
948  */
949 int camera_set_command(void *camera_handle, int64_t command, void *value);
950
951 /**
952  * @brief Gets the current value of command.
953  * @since_tizen 3.0
954  * @param[in] camera_handle The handle to the camera HAL
955  * @param[in] command The command to control the camera device
956  * @param[out] value The value to get
957  * @return @c 0 on success, otherwise a negative error value
958  * @retval #CAMERA_ERROR_NONE Successful
959  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
960  * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
961  * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
962  * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
963  * @see camera_get_command()
964  */
965 int camera_get_command(void *camera_handle, int64_t command, void **value);
966
967 /**
968  * @brief Sets a set of commands.
969  * @since_tizen 3.0
970  * @remarks error_command will be set if error is returned from the function.
971  * @param[in] camera_handle The handle to the camera HAL
972  * @param[in] batch_command The batch command to set
973  * @param[out] error_command The error command
974  * @return @c 0 on success, otherwise a negative error value
975  * @retval #CAMERA_ERROR_NONE Successful
976  * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
977  * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
978  * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
979  * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
980  * @see camera_set_command()
981  * @see camera_get_command()
982  */
983 int camera_set_batch_command(void *camera_handle, camera_batch_command_control_t *batch_command, int64_t *error_command);
984
985 /**
986  * @}
987  */
988
989 #ifdef __cplusplus
990 }
991 #endif /* __cplusplus */
992
993 #endif /* __TIZEN_CAMERA_HAL_H__ */