4 * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #ifndef __TIZEN_CAMERA_HAL_H__
21 #define __TIZEN_CAMERA_HAL_H__
27 #endif /* __cplusplus */
30 * @file tizen-camera.h
31 * @brief This file contains the Tizen camera HAL API, related structures and enumerations.
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
42 * @addtogroup TIZEN_CAMERA_HAL_MODULE
47 * @brief Enumeration for the camera error.
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,
67 CAMERA_ERROR_NOT_IMPLEMENTED = (int32_t)0x80002ffe,
68 CAMERA_ERROR_UNKNOWN = (int32_t)0x80002fff
72 * @brief Enumeration for the camera state.
75 typedef enum camera_state {
76 CAMERA_STATE_INITIALIZED,
78 CAMERA_STATE_PREVIEWING,
79 CAMERA_STATE_CAPTURING,
80 CAMERA_STATE_RECORDING,
81 CAMERA_STATE_RECORDING_SNAPSHOT
85 * @brief The structure type of the resolution.
88 typedef struct camera_resolution {
91 } camera_resolution_t;
94 * @brief The structure type of the fraction.
97 typedef struct camera_fraction {
103 * @brief The structure type of the rectangle.
106 typedef struct camera_rectangle {
111 } camera_rectangle_t;
114 * @brief Enumeration for the camera pixel format.
117 typedef enum camera_pixel_format {
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,
127 CAMERA_PIXEL_FORMAT_BGRA8888,
128 CAMERA_PIXEL_FORMAT_ARGB8888,
131 CAMERA_PIXEL_FORMAT_JPEG,
132 CAMERA_PIXEL_FORMAT_H264,
135 CAMERA_PIXEL_FORMAT_DEPTH,
138 CAMERA_PIXEL_FORMAT_MAX
139 } camera_pixel_format_t;
142 * @brief The structure type of the camera plane.
145 typedef struct camera_plane {
147 uint32_t align_width;
148 uint32_t align_height;
153 * @brief The structure type of the camera buffer.
156 typedef struct camera_buffer {
158 camera_pixel_format_t format;
159 camera_resolution_t resolution;
162 camera_plane_t planes[BUFFER_PLANE_MAX];
164 void *bos[BUFFER_PLANE_MAX];
168 * @brief The structure type of the camera metadata.
171 typedef struct camera_metadata {
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;
182 int component_configuration;
183 int aperture_in_apex;
187 * @brief Enumeration for the focus state.
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;
198 * @brief Enumeration for the facing direction of camera device.
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;
208 * @brief Enumeration for the camera rotation.
211 typedef enum camera_rotation {
219 * @brief Enumeration for the camera flip.
222 typedef enum camera_flip {
224 CAMERA_FLIP_HORIZONTAL,
225 CAMERA_FLIP_VERTICAL,
230 * @brief The structure type of the camera format.
233 typedef struct camera_format {
234 camera_pixel_format_t stream_format;
235 camera_resolution_t stream_resolution;
237 camera_rotation_t stream_rotation;
238 camera_pixel_format_t capture_format;
239 camera_resolution_t capture_resolution;
240 uint32_t capture_quality;
244 * @brief Enumeration for the focus mode.
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;
255 * @brief Enumeration for the focus range.
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;
266 * @brief Enumeration for the white balance.
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;
281 * @brief Enumeration for the effect.
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 */
303 * @brief Enumeration for the scene mode.
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;
326 * @brief Enumeration for the exposure mode.
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;
338 * @brief Enumeration for the shot mode.
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;
349 * @brief Enumeration for the flash mode.
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;
364 * @brief Enumeration for the face detection.
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;
373 * @brief Definitions for the camera command.
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))
403 typedef struct camera_batch_command_control {
404 /* flag for modified command */
405 int64_t command_set_flag;
408 camera_white_balance_t white_balance;
414 camera_effect_t effect;
415 camera_scene_mode_t scene_mode;
416 camera_exposure_mode_t exposure_mode;
418 camera_rotation_t rotation;
420 camera_focus_mode_t focus_mode;
421 camera_focus_range_t focus_range;
422 camera_exposure_mode_t shot_mode;
424 camera_rectangle_t focus_area;
429 camera_flash_mode_t flash_mode;
430 camera_face_detection_t face_detection;
431 } camera_batch_command_control_t;
434 * @brief The structure type of the format list.
437 typedef struct camera_pixel_format_list {
439 camera_pixel_format_t formats[CAMERA_PIXEL_FORMAT_MAX];
440 } camera_format_list_t;
443 * @brief The structure type of the resolution list.
446 typedef struct camera_resolution_list {
448 camera_resolution_t resolutions[RESOLUTION_COUNT_MAX];
449 } camera_resolution_list_t;
452 * @brief The structure type of the camera device information.
455 typedef struct camera_device_info {
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;
467 * @brief The structure type of the camera device information list.
470 typedef struct camera_device_info_list {
472 camera_device_info_t device_info[DEVICE_COUNT_MAX];
473 } camera_device_info_list_t;
476 * @brief Enumeration for the camera message type.
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;
487 * @brief The structure type of the camera message.
490 typedef struct camera_message {
491 camera_message_type_t type;
493 camera_focus_state_t focus_state;
494 uint32_t hdr_progress;
495 camera_error_t error_code;
500 * @brief Callback function for notification from camera HAL.
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()
507 typedef int (*camera_message_cb)(camera_message_t *message, void *user_data);
510 * @brief Callback function for captured preview frame from camera device.
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()
519 typedef int (*camera_preview_frame_cb)(camera_buffer_t *buffer, camera_metadata_t *meta, void *user_data);
522 * @brief Callback function for captured video frame from camera device.
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()
531 typedef int (*camera_video_frame_cb)(camera_buffer_t *buffer, camera_metadata_t *meta, void *user_data);
534 * @brief Callback function for captured still image from camera device.
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()
544 typedef int (*camera_capture_cb)(camera_buffer_t *main, camera_buffer_t *postview, camera_buffer_t *thumbnail, void *user_data);
547 * @brief The structure type of the camera interface.
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;
579 * @brief Initializes new handle of camera HAL.
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.
590 * @see camera_deinit()
592 int camera_init(void **camera_handle);
595 * @brief Deinitializes handle of camera HAL.
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
603 int camera_deinit(void *camera_handle);
606 * @brief Gets the device list of camera.
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
615 int camera_get_device_info_list(camera_device_info_list_t *device_info_list);
618 * @brief Opens camera device.
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()
635 int camera_open_device(void *camera_handle, int device_index);
638 * @brief Closes camera device.
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()
649 int camera_close_device(void *camera_handle);
652 * @brief Registers a callback function to be called to send a message by camera HAL.
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()
664 int camera_add_message_callback(void *camera_handle, camera_message_cb callback, void *user_data, uint32_t *cb_id);
667 * @brief Unregisters a callback function.
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()
676 int camera_remove_message_callback(void *camera_handle, uint32_t cb_id);
679 * @brief Sets the format of the preview stream.
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()
694 int camera_set_preview_stream_format(void *camera_handle, camera_format_t *format);
697 * @brief Gets the format of the preview stream.
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()
711 int camera_get_preview_stream_format(void *camera_handle, camera_format_t *format);
714 * @brief Starts preview frames on the screen.
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()
730 int camera_start_preview(void *camera_handle, camera_preview_frame_cb callback, void *user_data);
733 * @brief Release the preview buffer.
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()
745 int camera_release_preview_buffer(void *camera_handle, int buffer_index);
748 * @brief Stops preview frames.
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()
760 int camera_stop_preview(void *camera_handle);
763 * @brief Starts camera auto focusing operation.
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()
779 int camera_start_auto_focus(void *camera_handle);
782 * @brief Stops camera auto focusing operation.
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()
797 int camera_stop_auto_focus(void *camera_handle);
800 * @brief Starts capturing of still images.
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()
818 int camera_start_capture(void *camera_handle, camera_capture_cb callback, void *user_data);
821 * @brief Stops capturing of still images.
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()
843 int camera_stop_capture(void *camera_handle);
846 * @brief Sets the format of the video stream for recording.
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()
862 int camera_set_video_stream_format(void *camera_handle, camera_format_t *format);
865 * @brief Gets the format of the video stream for recording.
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()
879 int camera_get_video_stream_format(void *camera_handle, camera_format_t *format);
882 * @brief Starts the video frame for recording.
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()
900 int camera_start_record(void *camera_handle, camera_video_frame_cb callback, void *user_data);
903 * @brief Release the video buffer.
904 * @remarks The video buffer should be released with this function after use it.
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()
916 int camera_release_video_buffer(void *camera_handle, int buffer_index);
919 * @brief Stops the video frame.
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()
933 int camera_stop_record(void *camera_handle);
936 * @brief Sets the various command and value to control camera device.
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()
949 int camera_set_command(void *camera_handle, int64_t command, void *value);
952 * @brief Gets the current value of command.
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()
965 int camera_get_command(void *camera_handle, int64_t command, void **value);
968 * @brief Sets a set of commands.
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()
983 int camera_set_batch_command(void *camera_handle, camera_batch_command_control_t *batch_command, int64_t *error_command);
991 #endif /* __cplusplus */
993 #endif /* __TIZEN_CAMERA_HAL_H__ */