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