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 DEVICE_NAME_LENGTH_MAX 32
38 #define RESOLUTION_COUNT_MAX 10
41 * @addtogroup TIZEN_CAMERA_HAL_MODULE
46 * @brief Enumeration for the camera error.
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,
66 CAMERA_ERROR_NOT_IMPLEMENTED = 0x80002ffe,
67 CAMERA_ERROR_UNKNOWN = 0x80002fff
71 * @brief Enumeration for the camera state.
74 typedef enum camera_state {
75 CAMERA_STATE_INITIALIZED,
77 CAMERA_STATE_PREVIEWING,
78 CAMERA_STATE_CAPTURING,
79 CAMERA_STATE_RECORDING,
80 CAMERA_STATE_RECORDING_SNAPSHOT
84 * @brief The structure type of the resolution.
87 typedef struct camera_resolution {
90 } camera_resolution_t;
93 * @brief The structure type of the fraction.
96 typedef struct camera_fraction {
102 * @brief The structure type of the rectangle.
105 typedef struct camera_rectangle {
110 } camera_rectangle_t;
113 * @brief Enumeration for the camera pixel format.
116 typedef enum camera_pixel_format {
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,
126 CAMERA_PIXEL_FORMAT_BGRA8888,
127 CAMERA_PIXEL_FORMAT_ARGB8888,
130 CAMERA_PIXEL_FORMAT_ENCODED_JPEG,
131 CAMERA_PIXEL_FORMAT_ENCODED_H264,
134 CAMERA_PIXEL_FORMAT_MAX
135 } camera_pixel_format_t;
138 * @brief The structure type of the camera plane.
141 typedef struct camera_plane {
143 uint32_t align_width;
144 uint32_t align_height;
149 * @brief The structure type of the camera buffer.
152 typedef struct camera_buffer {
154 camera_pixel_format_t format;
155 camera_resolution_t resolution;
158 camera_plane_t planes[BUFFER_PLANE_MAX];
160 void *bos[BUFFER_PLANE_MAX];
164 * @brief The structure type of the camera metadata.
167 typedef struct camera_metadata {
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;
178 int component_configuration;
179 int aperture_in_apex;
183 * @brief Enumeration for the focus state.
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;
194 * @brief Enumeration for the facing direction of camera device.
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;
204 * @brief Enumeration for the camera rotation.
207 typedef enum camera_rotation {
215 * @brief Enumeration for the camera flip.
218 typedef enum camera_flip {
220 CAMERA_FLIP_HORIZONTAL,
221 CAMERA_FLIP_VERTICAL,
226 * @brief The structure type of the camera format.
229 typedef struct camera_format {
230 camera_pixel_format_t stream_format;
231 camera_resolution_t stream_resolution;
233 camera_rotation_t stream_rotation;
234 camera_pixel_format_t capture_format;
235 camera_resolution_t capture_resolution;
236 uint32_t capture_quality;
240 * @brief Enumeration for the focus mode.
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;
251 * @brief Enumeration for the focus range.
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;
262 * @brief Enumeration for the white balance.
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;
277 * @brief Enumeration for the effect.
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 */
299 * @brief Enumeration for the scene mode.
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;
322 * @brief Enumeration for the exposure mode.
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;
334 * @brief Enumeration for the shot mode.
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;
345 * @brief Enumeration for the flash mode.
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;
360 * @brief Enumeration for the face detection.
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;
369 * @brief Definitions for the camera command.
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))
399 typedef struct camera_batch_command_control {
400 /* flag for modified command */
401 int64_t command_set_flag;
404 camera_white_balance_t white_balance;
410 camera_effect_t effect;
411 camera_scene_mode_t scene_mode;
412 camera_exposure_mode_t exposure_mode;
414 camera_rotation_t rotation;
416 camera_focus_mode_t focus_mode;
417 camera_focus_range_t focus_range;
418 camera_exposure_mode_t shot_mode;
420 camera_rectangle_t focus_area;
425 camera_flash_mode_t flash_mode;
426 camera_face_detection_t face_detection;
427 } camera_batch_command_control_t;
430 * @brief The structure type of the format list.
433 typedef struct camera_pixel_format_list {
435 camera_pixel_format_t formats[CAMERA_PIXEL_FORMAT_MAX];
436 } camera_format_list_t;
439 * @brief The structure type of the resolution list.
442 typedef struct camera_resolution_list {
444 camera_resolution_t resolutions[RESOLUTION_COUNT_MAX];
445 } camera_resolution_list_t;
448 * @brief The structure type of the camera device information.
451 typedef struct camera_device_info {
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;
462 * @brief The structure type of the camera device list.
465 typedef struct camera_device_list {
467 camera_device_info_t device_info[DEVICE_COUNT_MAX];
468 } camera_device_list_t;
471 * @brief Enumeration for the camera message type.
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;
482 * @brief The structure type of the camera message.
485 typedef struct camera_message {
486 camera_message_type_t type;
488 camera_focus_state_t focus_state;
489 uint32_t hdr_progress;
490 camera_error_t error_code;
495 * @brief Callback function for notification from camera HAL.
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()
502 typedef int (*camera_message_cb)(camera_message_t *message, void *user_data);
505 * @brief Callback function for captured preview frame from camera device.
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()
514 typedef int (*camera_preview_frame_cb)(camera_buffer_t *buffer, camera_metadata_t *meta, void *user_data);
517 * @brief Callback function for captured video frame from camera device.
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()
526 typedef int (*camera_video_frame_cb)(camera_buffer_t *buffer, camera_metadata_t *meta, void *user_data);
529 * @brief Callback function for captured still image from camera device.
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()
539 typedef int (*camera_capture_cb)(camera_buffer_t *main, camera_buffer_t *postview, camera_buffer_t *thumbnail, void *user_data);
542 * @brief The structure type of the camera interface.
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;
574 * @brief Initializes new handle of camera HAL.
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.
585 * @see camera_deinit()
587 int camera_init(void **camera_handle);
590 * @brief Deinitializes handle of camera HAL.
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
598 int camera_deinit(void *camera_handle);
601 * @brief Gets the device list of camera.
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
610 int camera_get_device_list(void *camera_handle, camera_device_list_t *device_list);
613 * @brief Opens camera device.
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()
630 int camera_open_device(void *camera_handle, int device_index);
633 * @brief Closes camera device.
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()
644 int camera_close_device(void *camera_handle);
647 * @brief Registers a callback function to be called to send a message by camera HAL.
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()
659 int camera_add_message_callback(void *camera_handle, camera_message_cb callback, void *user_data, uint32_t *cb_id);
662 * @brief Unregisters a callback function.
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()
671 int camera_remove_message_callback(void *camera_handle, uint32_t cb_id);
674 * @brief Sets the format of the preview stream.
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()
689 int camera_set_preview_stream_format(void *camera_handle, camera_format_t *format);
692 * @brief Gets the format of the preview stream.
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()
706 int camera_get_preview_stream_format(void *camera_handle, camera_format_t *format);
709 * @brief Starts preview frames on the screen.
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()
725 int camera_start_preview(void *camera_handle, camera_preview_frame_cb callback, void *user_data);
728 * @brief Release the preview buffer.
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()
740 int camera_release_preview_buffer(void *camera_handle, int buffer_index);
743 * @brief Stops preview frames.
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()
755 int camera_stop_preview(void *camera_handle);
758 * @brief Starts camera auto focusing operation.
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()
774 int camera_start_auto_focus(void *camera_handle);
777 * @brief Stops camera auto focusing operation.
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()
792 int camera_stop_auto_focus(void *camera_handle);
795 * @brief Starts capturing of still images.
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()
813 int camera_start_capture(void *camera_handle, camera_capture_cb callback, void *user_data);
816 * @brief Stops capturing of still images.
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()
838 int camera_stop_capture(void *camera_handle);
841 * @brief Sets the format of the video stream for recording.
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()
857 int camera_set_video_stream_format(void *camera_handle, camera_format_t *format);
860 * @brief Gets the format of the video stream for recording.
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()
874 int camera_get_video_stream_format(void *camera_handle, camera_format_t *format);
877 * @brief Starts the video frame for recording.
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()
895 int camera_start_record(void *camera_handle, camera_video_frame_cb callback, void *user_data);
898 * @brief Release the video buffer.
899 * @remarks The video buffer should be released with this function after use it.
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()
911 int camera_release_video_buffer(void *camera_handle, int buffer_index);
914 * @brief Stops the video frame.
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()
928 int camera_stop_record(void *camera_handle);
931 * @brief Sets the various command and value to control camera device.
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()
944 int camera_set_command(void *camera_handle, int64_t command, void *value);
947 * @brief Gets the current value of command.
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()
960 int camera_get_command(void *camera_handle, int64_t command, void *value);
963 * @brief Sets a set of commands.
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()
978 int camera_set_batch_command(void *camera_handle, camera_batch_command_control_t *batch_command, int64_t *error_command);
986 #endif /* __cplusplus */
988 #endif /* __TIZEN_CAMERA_HAL_H__ */