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