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_MAX
136 } camera_pixel_format_t;
139 * @brief The structure type of the camera plane.
142 typedef struct camera_plane {
144 uint32_t align_width;
145 uint32_t align_height;
150 * @brief The structure type of the camera buffer.
153 typedef struct camera_buffer {
155 camera_pixel_format_t format;
156 camera_resolution_t resolution;
159 camera_plane_t planes[BUFFER_PLANE_MAX];
161 void *bos[BUFFER_PLANE_MAX];
165 * @brief The structure type of the camera metadata.
168 typedef struct camera_metadata {
170 camera_fraction_t focal_length;
171 camera_fraction_t aperture_f_number;
172 camera_fraction_t shutter_speed;
173 camera_fraction_t exposure_time;
174 camera_fraction_t brightness;
175 camera_resolution_t exif_image;
179 int component_configuration;
180 int aperture_in_apex;
184 * @brief Enumeration for the focus state.
187 typedef enum camera_focus_state {
188 CAMERA_FOCUS_STATE_RELEASED,
189 CAMERA_FOCUS_STATE_ONGOING,
190 CAMERA_FOCUS_STATE_FOCUSED,
191 CAMERA_FOCUS_STATE_FAILED
192 } camera_focus_state_t;
195 * @brief Enumeration for the facing direction of camera device.
198 typedef enum camera_facing_direction {
199 CAMERA_FACING_DIRECTION_REAR,
200 CAMERA_FACING_DIRECTION_FRONT,
201 CAMERA_FACING_DIRECTION_EXTERNAL
202 } camera_facing_direction_t;
205 * @brief Enumeration for the camera rotation.
208 typedef enum camera_rotation {
216 * @brief Enumeration for the camera flip.
219 typedef enum camera_flip {
221 CAMERA_FLIP_HORIZONTAL,
222 CAMERA_FLIP_VERTICAL,
227 * @brief The structure type of the camera format.
230 typedef struct camera_format {
231 camera_pixel_format_t stream_format;
232 camera_resolution_t stream_resolution;
234 camera_rotation_t stream_rotation;
235 camera_pixel_format_t capture_format;
236 camera_resolution_t capture_resolution;
237 uint32_t capture_quality;
241 * @brief Enumeration for the focus mode.
244 typedef enum camera_focus_mode {
245 CAMERA_FOCUS_MODE_NONE,
246 CAMERA_FOCUS_MODE_PAN,
247 CAMERA_FOCUS_MODE_AUTO,
248 CAMERA_FOCUS_MODE_CONTINUOUS_AUTO
249 } camera_focus_mode_t;
252 * @brief Enumeration for the focus range.
255 typedef enum camera_focus_range {
256 CAMERA_FOCUS_RANGE_NONE,
257 CAMERA_FOCUS_RANGE_NORMAL,
258 CAMERA_FOCUS_RANGE_MACRO,
259 CAMERA_FOCUS_RANGE_FULL
260 } camera_focus_range_t;
263 * @brief Enumeration for the white balance.
266 typedef enum camera_white_balance {
267 CAMERA_WHITE_BALANCE_AUTO, /**< Automatic */
268 CAMERA_WHITE_BALANCE_DAYLIGHT, /**< Daylight */
269 CAMERA_WHITE_BALANCE_CLOUDY, /**< Cloudy */
270 CAMERA_WHITE_BALANCE_FLUORESCENT, /**< Fluorescent */
271 CAMERA_WHITE_BALANCE_INCANDESCENT, /**< Incandescent */
272 CAMERA_WHITE_BALANCE_SHADE, /**< Shade */
273 CAMERA_WHITE_BALANCE_HORIZON, /**< Horizon */
274 CAMERA_WHITE_BALANCE_FLASH /**< Flash */
275 } camera_white_balance_t;
278 * @brief Enumeration for the effect.
281 typedef enum camera_effect {
282 CAMERA_EFFECT_NONE, /**< None */
283 CAMERA_EFFECT_MONO, /**< Mono */
284 CAMERA_EFFECT_SEPIA, /**< Sepia */
285 CAMERA_EFFECT_NEGATIVE, /**< Negative */
286 CAMERA_EFFECT_RED, /**< Red */
287 CAMERA_EFFECT_GREEN, /**< Green */
288 CAMERA_EFFECT_BLUE, /**< Blue */
289 CAMERA_EFFECT_AQUA, /**< Aqua */
290 CAMERA_EFFECT_ANTIQUE, /**< Antique */
291 CAMERA_EFFECT_WARM, /**< Warm */
292 CAMERA_EFFECT_EMBOSS, /**< Emboss */
293 CAMERA_EFFECT_SKETCH, /**< Sketch */
294 CAMERA_EFFECT_SOLARIZATION, /**< Solarization */
295 CAMERA_EFFECT_POSTERIZATION, /**< Posterization */
296 CAMERA_EFFECT_CARTOON /**< Cartoon */
300 * @brief Enumeration for the scene mode.
303 typedef enum camera_scene_mode {
304 CAMERA_SCENE_MODE_NORMAL, /**< Normal */
305 CAMERA_SCENE_MODE_PORTRAIT, /**< Portrait */
306 CAMERA_SCENE_MODE_LANDSCAPE, /**< Landscape */
307 CAMERA_SCENE_MODE_SPORTS, /**< Sports */
308 CAMERA_SCENE_MODE_PARTY_N_INDOOR, /**< Party & indoor */
309 CAMERA_SCENE_MODE_BEACH_N_INDOOR, /**< Beach & indoor */
310 CAMERA_SCENE_MODE_SUNSET, /**< Sunset */
311 CAMERA_SCENE_MODE_DUSK_N_DAWN, /**< Dusk & dawn */
312 CAMERA_SCENE_MODE_FALL_COLOR, /**< Fall */
313 CAMERA_SCENE_MODE_NIGHT_SCENE, /**< Night scene */
314 CAMERA_SCENE_MODE_FIREWORK, /**< Firework */
315 CAMERA_SCENE_MODE_TEXT, /**< Text */
316 CAMERA_SCENE_MODE_SHOW_WINDOW, /**< Show window */
317 CAMERA_SCENE_MODE_CANDLE_LIGHT, /**< Candle light */
318 CAMERA_SCENE_MODE_BACKLIGHT, /**< Backlight */
319 CAMERA_SCENE_MODE_AQUA /**< Aqua */
320 } camera_scene_mode_t;
323 * @brief Enumeration for the exposure mode.
326 typedef enum camera_exposure_mode {
327 CAMERA_EXPOSURE_MODE_OFF = 0, /**< Off */
328 CAMERA_EXPOSURE_MODE_ALL, /**< All mode */
329 CAMERA_EXPOSURE_MODE_CENTER, /**< Center mode */
330 CAMERA_EXPOSURE_MODE_SPOT, /**< Spot mode */
331 CAMERA_EXPOSURE_MODE_CUSTOM /**< Custom mode */
332 } camera_exposure_mode_t;
335 * @brief Enumeration for the shot mode.
338 typedef enum camera_shot_mode {
339 CAMERA_SHOT_MODE_NORMAL = 0, /**< Normal */
340 CAMERA_SHOT_MODE_CONTINUOUS, /**< Continuous */
341 CAMERA_SHOT_MODE_HDR, /**< HDR */
342 CAMERA_SHOT_MODE_NIGHT /**< Night */
343 } camera_shot_mode_t;
346 * @brief Enumeration for the flash mode.
349 typedef enum camera_flash_mode {
350 CAMERA_FLASH_MODE_OFF = 0, /**< Always off */
351 CAMERA_FLASH_MODE_ON, /**< Always splashes */
352 CAMERA_FLASH_MODE_AUTO, /**< Depending on intensity of light, strobe starts to flash */
353 CAMERA_FLASH_MODE_REDEYE_REDUCTION, /**< Red eye reduction. Multiple flash before capturing */
354 CAMERA_FLASH_MODE_SLOW_SYNC, /**< Slow sync curtain synchronization */
355 CAMERA_FLASH_MODE_FRONT_CURTAIN, /**< Front curtain synchronization */
356 CAMERA_FLASH_MODE_REAR_CURTAIN, /**< Rear curtain synchronization */
357 CAMERA_FLASH_MODE_PERMANENT, /**< Keep turned on until turning off */
358 } camera_flash_mode_t;
361 * @brief Enumeration for the face detection.
364 typedef enum camera_face_detection {
365 CAMERA_FACE_DETECTION_OFF = 0, /**< Face detection off */
366 CAMERA_FACE_DETECTION_ON /**< Face detection on */
367 } camera_face_detection_t;
370 * @brief Definitions for the camera command.
373 #define CAMERA_COMMAND_BASE ((int64_t)1)
374 #define CAMERA_COMMAND_WHITE_BALANCE ((int64_t)(CAMERA_COMMAND_BASE << 1))
375 #define CAMERA_COMMAND_ISO ((int64_t)(CAMERA_COMMAND_BASE << 2))
376 #define CAMERA_COMMAND_CONTRAST ((int64_t)(CAMERA_COMMAND_BASE << 3))
377 #define CAMERA_COMMAND_SATURATION ((int64_t)(CAMERA_COMMAND_BASE << 4))
378 #define CAMERA_COMMAND_HUE ((int64_t)(CAMERA_COMMAND_BASE << 5))
379 #define CAMERA_COMMAND_SHARPNESS ((int64_t)(CAMERA_COMMAND_BASE << 6))
380 #define CAMERA_COMMAND_EFFECT ((int64_t)(CAMERA_COMMAND_BASE << 7))
381 #define CAMERA_COMMAND_SCENE_MODE ((int64_t)(CAMERA_COMMAND_BASE << 8))
382 #define CAMERA_COMMAND_EXPOSURE_MODE ((int64_t)(CAMERA_COMMAND_BASE << 9))
383 #define CAMERA_COMMAND_EXPOSURE ((int64_t)(CAMERA_COMMAND_BASE << 10))
384 #define CAMERA_COMMAND_ROTATION ((int64_t)(CAMERA_COMMAND_BASE << 11))
385 #define CAMERA_COMMAND_FLIP ((int64_t)(CAMERA_COMMAND_BASE << 12))
386 #define CAMERA_COMMAND_FOCUS_MODE ((int64_t)(CAMERA_COMMAND_BASE << 13))
387 #define CAMERA_COMMAND_FOCUS_RANGE ((int64_t)(CAMERA_COMMAND_BASE << 14))
388 #define CAMERA_COMMAND_SHOT_MODE ((int64_t)(CAMERA_COMMAND_BASE << 15))
389 #define CAMERA_COMMAND_ANTI_SHAKE ((int64_t)(CAMERA_COMMAND_BASE << 16))
390 #define CAMERA_COMMAND_FOCUS_AREA ((int64_t)(CAMERA_COMMAND_BASE << 17))
391 #define CAMERA_COMMAND_DIGITAL_ZOOM ((int64_t)(CAMERA_COMMAND_BASE << 18))
392 #define CAMERA_COMMAND_OPTICAL_ZOOM ((int64_t)(CAMERA_COMMAND_BASE << 19))
393 #define CAMERA_COMMAND_RECORDING_HINT ((int64_t)(CAMERA_COMMAND_BASE << 20))
394 #define CAMERA_COMMAND_WDR ((int64_t)(CAMERA_COMMAND_BASE << 21))
395 #define CAMERA_COMMAND_SHUTTER_SPEED ((int64_t)(CAMERA_COMMAND_BASE << 22))
396 #define CAMERA_COMMAND_FLASH_MODE ((int64_t)(CAMERA_COMMAND_BASE << 23))
397 #define CAMERA_COMMAND_FACE_DETECTION ((int64_t)(CAMERA_COMMAND_BASE << 24))
400 typedef struct camera_batch_command_control {
401 /* flag for modified command */
402 int64_t command_set_flag;
405 camera_white_balance_t white_balance;
411 camera_effect_t effect;
412 camera_scene_mode_t scene_mode;
413 camera_exposure_mode_t exposure_mode;
415 camera_rotation_t rotation;
417 camera_focus_mode_t focus_mode;
418 camera_focus_range_t focus_range;
419 camera_exposure_mode_t shot_mode;
421 camera_rectangle_t focus_area;
426 camera_flash_mode_t flash_mode;
427 camera_face_detection_t face_detection;
428 } camera_batch_command_control_t;
431 * @brief The structure type of the format list.
434 typedef struct camera_pixel_format_list {
436 camera_pixel_format_t formats[CAMERA_PIXEL_FORMAT_MAX];
437 } camera_format_list_t;
440 * @brief The structure type of the resolution list.
443 typedef struct camera_resolution_list {
445 camera_resolution_t resolutions[RESOLUTION_COUNT_MAX];
446 } camera_resolution_list_t;
449 * @brief The structure type of the camera device information.
452 typedef struct camera_device_info {
454 char name[DEVICE_NAME_LENGTH_MAX];
455 char node_path[DEVICE_NODE_PATH_LENGTH_MAX];
456 camera_facing_direction_t facing_direction;
457 camera_format_list_t format_list;
458 camera_resolution_list_t preview_list;
459 camera_resolution_list_t capture_list;
460 camera_resolution_list_t video_list;
461 } camera_device_info_t;
464 * @brief The structure type of the camera device information list.
467 typedef struct camera_device_info_list {
469 camera_device_info_t device_info[DEVICE_COUNT_MAX];
470 } camera_device_info_list_t;
473 * @brief Enumeration for the camera message type.
476 typedef enum camera_message_type {
477 CAMERA_MESSAGE_TYPE_FOCUS_CHANGED,
478 CAMERA_MESSAGE_TYPE_CAPTURED,
479 CAMERA_MESSAGE_TYPE_HDR_PROGRESS,
480 CAMERA_MESSAGE_TYPE_ERROR
481 } camera_message_type_t;
484 * @brief The structure type of the camera message.
487 typedef struct camera_message {
488 camera_message_type_t type;
490 camera_focus_state_t focus_state;
491 uint32_t hdr_progress;
492 camera_error_t error_code;
497 * @brief Callback function for notification from camera HAL.
499 * @param[in] message The message from camera HAL
500 * @param[in] user_data The user data for callback
501 * @see camera_add_message_callback()
502 * @see camera_remove_message_callback()
504 typedef int (*camera_message_cb)(camera_message_t *message, void *user_data);
507 * @brief Callback function for captured preview frame from camera device.
509 * @param[in] buffer The preview buffer
510 * @param[in] meta The meta data for the preview frame
511 * @param[in] user_data The user data for callback
512 * @pre camera_start_preview() will invoke this callback.
513 * @see camera_start_preview()
514 * @see camera_stop_preview()
516 typedef int (*camera_preview_frame_cb)(camera_buffer_t *buffer, camera_metadata_t *meta, void *user_data);
519 * @brief Callback function for captured video frame from camera device.
521 * @param[in] buffer The video buffer
522 * @param[in] meta The meta data for the video frame
523 * @param[in] user_data The user data for callback
524 * @pre camera_start_record() will invoke this callback.
525 * @see camera_start_record()
526 * @see camera_stop_record()
528 typedef int (*camera_video_frame_cb)(camera_buffer_t *buffer, camera_metadata_t *meta, void *user_data);
531 * @brief Callback function for captured still image from camera device.
533 * @param[in] main The main image data
534 * @param[in] postview The image data of the postview (it could be @c NULL if the available data does not exist)
535 * @param[in] thumbnail The image data of the thumbnail (it could be @c NULL if the available data does not exist)
536 * @param[in] user_data The user data passed from the callback registration function
537 * @pre camera_start_capture() will invoke this callback function.
538 * @see camera_start_capture()
539 * @see camera_stop_capture()
541 typedef int (*camera_capture_cb)(camera_buffer_t *main, camera_buffer_t *postview, camera_buffer_t *thumbnail, void *user_data);
544 * @brief The structure type of the camera interface.
547 typedef struct camera_interface {
548 int (*init)(void **camera_handle);
549 int (*deinit)(void *camera_handle);
550 int (*get_device_info_list)(camera_device_info_list_t *device_info_list);
551 int (*open_device)(void *camera_handle, int device_index);
552 int (*close_device)(void *camera_handle);
553 int (*add_message_callback)(void *camera_handle, camera_message_cb callback, void *user_data, uint32_t *cb_id);
554 int (*remove_message_callback)(void *camera_handle, uint32_t cb_id);
555 int (*set_preview_stream_format)(void *camera_handle, camera_format_t *format);
556 int (*get_preview_stream_format)(void *camera_handle, camera_format_t *format);
557 int (*start_preview)(void *camera_handle, camera_preview_frame_cb callback, void *user_data);
558 int (*release_preview_buffer)(void *camera_handle, int buffer_index);
559 int (*stop_preview)(void *camera_handle);
560 int (*start_auto_focus)(void *camera_handle);
561 int (*stop_auto_focus)(void *camera_handle);
562 int (*start_capture)(void *camera_handle, camera_capture_cb callback, void *user_data);
563 int (*stop_capture)(void *camera_handle);
564 int (*set_video_stream_format)(void *camera_handle, camera_format_t *format);
565 int (*get_video_stream_format)(void *camera_handle, camera_format_t *format);
566 int (*start_record)(void *camera_handle, camera_video_frame_cb callback, void *user_data);
567 int (*release_video_buffer)(void *camera_handle, int buffer_index);
568 int (*stop_record)(void *camera_handle);
569 int (*set_command)(void *camera_handle, int command, void *value);
570 int (*get_command)(void *camera_handle, int command, void **value);
571 int (*set_batch_command)(void *camera_handle, camera_batch_command_control_t *batch_command, int64_t *error_command);
572 } camera_interface_t;
576 * @brief Initializes new handle of camera HAL.
578 * @param[out] camera_handle A newly returned handle to the camera HAL
579 * @return @c 0 on success, otherwise a negative error value
580 * @retval #CAMERA_ERROR_NONE Successful
581 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
582 * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
583 * @retval #CAMERA_ERROR_PERMISSION_DENIED The access to the resources can not be granted
584 * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
585 * @post If it succeeds, the camera state will be #CAMERA_STATE_INITIALIZED.
587 * @see camera_deinit()
589 int camera_init(void **camera_handle);
592 * @brief Deinitializes handle of camera HAL.
594 * @param[in] camera_handle The handle to the camera HAL
595 * @return @c 0 on success, otherwise a negative error value
596 * @retval #CAMERA_ERROR_NONE Successful
597 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
600 int camera_deinit(void *camera_handle);
603 * @brief Gets the device list of camera.
605 * @param[out] device_info_list The list of the camera device information
606 * @return @c 0 on success, otherwise a negative error value
607 * @retval #CAMERA_ERROR_NONE Successful
608 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
609 * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
610 * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
612 int camera_get_device_info_list(camera_device_info_list_t *device_info_list);
615 * @brief Opens camera device.
617 * @param[in] camera_handle The handle to the camera HAL
618 * @param[in] device_index The device index of the camera
619 * @return @c 0 on success, otherwise a negative error value
620 * @retval #CAMERA_ERROR_NONE Successful
621 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
622 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
623 * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
624 * @retval #CAMERA_ERROR_PERMISSION_DENIED The access to the resources can not be granted
625 * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
626 * @retval #CAMERA_ERROR_DEVICE_NOT_FOUND Failed to find camera device
627 * @retval #CAMERA_ERROR_DEVICE_UNAVAILABLE The camera device is unavailable
628 * @pre The camera state must be set to #CAMERA_STATE_INITIALIZED.
629 * @post If it succeeds, the camera state will be #CAMERA_STATE_OPENED.
630 * @see camera_close_device()
632 int camera_open_device(void *camera_handle, int device_index);
635 * @brief Closes camera device.
637 * @param[in] camera_handle The handle to the camera HAL
638 * @return @c 0 on success, otherwise a negative error value
639 * @retval #CAMERA_ERROR_NONE Successful
640 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
641 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
642 * @pre The camera state must be set to #CAMERA_STATE_OPENED.
643 * @post If it succeeds, the camera state will be #CAMERA_STATE_INITIALIZED.
644 * @see camera_open_device()
646 int camera_close_device(void *camera_handle);
649 * @brief Registers a callback function to be called to send a message by camera HAL.
651 * @param[in] camera_handle The handle to the camera HAL
652 * @param[in] callback The callback function to be registered
653 * @param[in] user_data The user data to be passed to the callback function
654 * @param[out] cb_id The callback id
655 * @return @c 0 on success, otherwise a negative error value
656 * @retval #CAMERA_ERROR_NONE Successful
657 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
658 * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
659 * @see camera_remove_message_callback()
661 int camera_add_message_callback(void *camera_handle, camera_message_cb callback, void *user_data, uint32_t *cb_id);
664 * @brief Unregisters a callback function.
666 * @param[in] camera_handle The handle to the camera HAL
667 * @param[in] cb_id The callback id
668 * @return @c 0 on success, otherwise a negative error value
669 * @retval #CAMERA_ERROR_NONE Successful
670 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
671 * @see camera_remove_message_callback()
673 int camera_remove_message_callback(void *camera_handle, uint32_t cb_id);
676 * @brief Sets the format of the preview stream.
678 * @remarks This function should be called before previewing (see camera_start_preview()).
679 * @param[in] camera_handle The handle to the camera HAL
680 * @param[in] format The format of the preview stream
681 * @return @c 0 on success, otherwise a negative error value
682 * @retval #CAMERA_ERROR_NONE Successful
683 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
684 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
685 * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
686 * @pre The camera state must be set to #CAMERA_STATE_OPENED.
687 * @see camera_start_preview()
688 * @see camera_start_capture()
689 * @see camera_get_preview_stream_format()
691 int camera_set_preview_stream_format(void *camera_handle, camera_format_t *format);
694 * @brief Gets the format of the preview stream.
696 * @param[in] camera_handle The handle to the camera HAL
697 * @param[out] format The format of the preview stream
698 * @return @c 0 on success, otherwise a negative error value
699 * @retval #CAMERA_ERROR_NONE Successful
700 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
701 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
702 * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
703 * @see camera_start_preview()
704 * @see camera_start_capture()
705 * @see camera_set_preview_stream_format()
706 * @see camera_foreach_supported_preview_format()
708 int camera_get_preview_stream_format(void *camera_handle, camera_format_t *format);
711 * @brief Starts preview frames on the screen.
713 * @param[in] camera_handle The handle to the camera HAL
714 * @param[in] callback The callback for preview frame
715 * @param[in] user_data The user data for callback
716 * @return @c 0 on success, otherwise a negative error value
717 * @retval #CAMERA_ERROR_NONE Successful
718 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
719 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
720 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
721 * @retval #CAMERA_ERROR_DEVICE_BUSY The device is being used in another application or is performing other operations
722 * @retval #CAMERA_ERROR_PERMISSION_DENIED The access to the resources can not be granted
723 * @pre The camera state must be set to #CAMERA_STATE_OPENED.
724 * @post If it succeeds, the camera state will be #CAMERA_STATE_PREVIEWING.
725 * @see camera_stop_preview()
727 int camera_start_preview(void *camera_handle, camera_preview_frame_cb callback, void *user_data);
730 * @brief Release the preview buffer.
732 * @remarks The preview buffer should be released with this function after use it.
733 * @param[in] camera_handle The handle to the camera HAL
734 * @param[in] buffer_index The index of preview buffer
735 * @return @c 0 on success, otherwise a negative error value
736 * @retval #CAMERA_ERROR_NONE Successful
737 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
738 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
739 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
740 * @see camera_start_preview()
742 int camera_release_preview_buffer(void *camera_handle, int buffer_index);
745 * @brief Stops preview frames.
747 * @param[in] camera_handle The handle to the camera HAL
748 * @return @c 0 on success, otherwise a negative error value
749 * @retval #CAMERA_ERROR_NONE Successful
750 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
751 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
752 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
753 * @pre The camera state must be set to #CAMERA_STATE_PREVIEWING.
754 * @post The camera state will be #CAMERA_STATE_OPENED.
755 * @see camera_start_preview()
757 int camera_stop_preview(void *camera_handle);
760 * @brief Starts camera auto focusing operation.
762 * @param[in] camera_handle The handle to the camera HAL
763 * @return @c 0 on success, otherwise a negative error value
764 * @retval #CAMERA_ERROR_NONE Successful
765 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
766 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
767 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
768 * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
769 * @pre The camera state must be set to #CAMERA_STATE_PREVIEWING or #CAMERA_STATE_RECORDING.
770 * @post The camera focus state will be #CAMERA_FOCUS_STATE_ONGOING.
771 * @see camera_stop_auto_focus()
772 * @see camera_add_message_callback()
773 * @see camera_message_cb()
774 * @see camera_set_command()
776 int camera_start_auto_focus(void *camera_handle);
779 * @brief Stops camera auto focusing operation.
781 * @param[in] camera_handle The handle to the camera HAL
782 * @return @c 0 on success, otherwise a negative error value
783 * @retval #CAMERA_ERROR_NONE Successful
784 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
785 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
786 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
787 * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
788 * @pre The camera state must be set to #CAMERA_STATE_PREVIEWING or #CAMERA_STATE_RECORDING.
789 * @post The camera focus state will be #CAMERA_FOCUS_STATE_ONGOING.
790 * @see camera_start_auto_focus()
791 * @see camera_add_message_callback()
792 * @see camera_message_cb()
794 int camera_stop_auto_focus(void *camera_handle);
797 * @brief Starts capturing of still images.
799 * @remarks In case of zero shutter lag capture, preview frame won't be stopped while capturing.
800 * @param[in] camera_handle The handle to the camera HAL
801 * @param[in] callback The callback for captured data
802 * @param[in] user_data The user data for callback
803 * @return @c 0 on success, otherwise a negative error value
804 * @retval #CAMERA_ERROR_NONE Successful
805 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
806 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
807 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
808 * @pre The camera state must be set to #CAMERA_STATE_PREVIEWING or #CAMERA_STATE_RECORDING.
809 * @post If it succeeds the camera state will be #CAMERA_STATE_CAPTURING or #CAMERA_STATE_RECORDING_SNAPSHOT.
810 * @see camera_start_preview()
811 * @see camera_start_record()
812 * @see camera_set_preview_stream_format()
813 * @see camera_get_preview_stream_format()
815 int camera_start_capture(void *camera_handle, camera_capture_cb callback, void *user_data);
818 * @brief Stops capturing of still images.
820 * @remarks In case of zero shutter lag, this function will changes only the state of camera HAL \n
821 * from #CAMERA_STATE_PREVIEWING or #CAMERA_STATE_RECORDING to #CAMERA_STATE_PREVIEWING or #CAMERA_STATE_RECORDING.\n
822 * Otherwise, preview frame will be restarted.
823 * @param[in] camera_handle The handle to the camera HAL
824 * @param[in] callback The callback for captured data
825 * @param[in] user_data The user data
826 * @return @c 0 on success, otherwise a negative error value
827 * @retval #CAMERA_ERROR_NONE Successful
828 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
829 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
830 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
831 * @pre The camera state must be set to #CAMERA_STATE_CAPTURING or #CAMERA_STATE_RECORDING_SNAPSHOT.
832 * @post If it succeeds the camera state will be #CAMERA_STATE_PREVIEWING or #CAMERA_STATE_RECORDING.
833 * @see camera_start_capture()
834 * @see camera_start_record()
835 * @see camera_set_preview_stream_format()
836 * @see camera_get_preview_stream_format()
837 * @see camera_set_video_stream_format()
838 * @see camera_get_video_stream_format()
840 int camera_stop_capture(void *camera_handle);
843 * @brief Sets the format of the video stream for recording.
845 * @remarks This function should be called before recording (see camera_start_record()).
846 * @param[in] camera_handle The handle to the camera HAL
847 * @param[in] format The format of the video stream
848 * @return @c 0 on success, otherwise a negative error value
849 * @retval #CAMERA_ERROR_NONE Successful
850 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
851 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
852 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
853 * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
854 * @pre The camera state must be set to #CAMERA_STATE_OPENED.
855 * @see camera_start_record()
856 * @see camera_start_capture()
857 * @see camera_get_video_stream_format()
859 int camera_set_video_stream_format(void *camera_handle, camera_format_t *format);
862 * @brief Gets the format of the video stream for recording.
864 * @param[in] camera_handle The handle to the camera HAL
865 * @param[out] format The format of the video stream
866 * @return @c 0 on success, otherwise a negative error value
867 * @retval #CAMERA_ERROR_NONE Successful
868 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
869 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
870 * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
871 * @see camera_start_preview()
872 * @see camera_start_capture()
873 * @see camera_set_preview_stream_format()
874 * @see camera_foreach_supported_preview_format()
876 int camera_get_video_stream_format(void *camera_handle, camera_format_t *format);
879 * @brief Starts the video frame for recording.
881 * @param[in] camera_handle The handle to the camera HAL
882 * @param[in] callback The callback for video frame
883 * @param[in] user_data The user data for callback
884 * @return @c 0 on success, otherwise a negative error value
885 * @retval #CAMERA_ERROR_NONE Successful
886 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
887 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
888 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
889 * @retval #CAMERA_ERROR_PERMISSION_DENIED The access to the resources can not be granted
890 * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
891 * @pre The camera state must be #CAMERA_STATE_PREVIEWING.
892 * @post The camera state will be #CAMERA_STATE_RECORDING.
893 * @see camera_set_video_stream_format()
894 * @see camera_get_video_stream_format()
895 * @see camera_stop_record()
897 int camera_start_record(void *camera_handle, camera_video_frame_cb callback, void *user_data);
900 * @brief Release the video buffer.
901 * @remarks The video buffer should be released with this function after use it.
903 * @param[in] camera_handle The handle to the camera HAL
904 * @param[in] buffer_index The index of video buffer
905 * @return @c 0 on success, otherwise a negative error value
906 * @retval #CAMERA_ERROR_NONE Successful
907 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
908 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
909 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
910 * @pre The camera state must be set to #CAMERA_STATE_PREVIEWING.
911 * @see camera_start_record()
913 int camera_release_video_buffer(void *camera_handle, int buffer_index);
916 * @brief Stops the video frame.
918 * @param[in] camera_handle The handle to the camera HAL
919 * @return @c 0 on success, otherwise a negative error value
920 * @retval #CAMERA_ERROR_NONE Successful
921 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
922 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
923 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
924 * @pre The camera state must be #CAMERA_STATE_RECORDING.
925 * @post The camera state will be #CAMERA_STATE_PREVIEWING.
926 * @see camera_set_video_stream_format()
927 * @see camera_get_video_stream_format()
928 * @see camera_start_record()
930 int camera_stop_record(void *camera_handle);
933 * @brief Sets the various command and value to control camera device.
935 * @param[in] camera_handle The handle to the camera HAL
936 * @param[in] command The command to control the camera device
937 * @param[in] value The value to set
938 * @return @c 0 on success, otherwise a negative error value
939 * @retval #CAMERA_ERROR_NONE Successful
940 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
941 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
942 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
943 * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
944 * @see camera_get_command()
946 int camera_set_command(void *camera_handle, int64_t command, void *value);
949 * @brief Gets the current value of command.
951 * @param[in] camera_handle The handle to the camera HAL
952 * @param[in] command The command to control the camera device
953 * @param[out] value The value to get
954 * @return @c 0 on success, otherwise a negative error value
955 * @retval #CAMERA_ERROR_NONE Successful
956 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
957 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
958 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
959 * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
960 * @see camera_get_command()
962 int camera_get_command(void *camera_handle, int64_t command, void **value);
965 * @brief Sets a set of commands.
967 * @remarks error_command will be set if error is returned from the function.
968 * @param[in] camera_handle The handle to the camera HAL
969 * @param[in] batch_command The batch command to set
970 * @param[out] error_command The error command
971 * @return @c 0 on success, otherwise a negative error value
972 * @retval #CAMERA_ERROR_NONE Successful
973 * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
974 * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
975 * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
976 * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
977 * @see camera_set_command()
978 * @see camera_get_command()
980 int camera_set_batch_command(void *camera_handle, camera_batch_command_control_t *batch_command, int64_t *error_command);
988 #endif /* __cplusplus */
990 #endif /* __TIZEN_CAMERA_HAL_H__ */