Initial release 71/251171/13 accepted/tizen/unified/20210130.030724 submit/tizen/20210129.102628
authorJeongmo Yang <jm80.yang@samsung.com>
Mon, 11 Jan 2021 02:54:55 +0000 (11:54 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Thu, 28 Jan 2021 08:50:07 +0000 (17:50 +0900)
[Version] 0.0.1
[Issue Type] Initial release

Change-Id: I379897381020ba7743582b3a91e052ba21d456dc
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
CMakeLists.txt [new file with mode: 0644]
LICENSE [new file with mode: 0644]
hal-api-camera.manifest [new file with mode: 0644]
hal-api-camera.pc.in [new file with mode: 0644]
include/hal-camera-interface.h [new file with mode: 0644]
include/hal-camera.h [new file with mode: 0644]
packaging/hal-api-camera.spec [new file with mode: 0644]
src/hal-api-camera.c [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..fb6cb8d
--- /dev/null
@@ -0,0 +1,50 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(hal-api-camera C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "${CMAKE_INSTALL_PREFIX}/bin")
+SET(INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include")
+SET(LIBDIR ${CMAKE_LIBDIR_PREFIX})
+SET(VERSION_MAJOR 0)
+SET(VERSION "${VERSION_MAJOR}.1.0")
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+SET(PKG_MODULES
+       dlog
+       glib-2.0
+       hal-api-common
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED ${PKG_MODULES})
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall -Wextra -Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wno-unused-parameter -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -lrt")
+
+SET(SRCS src/hal-api-camera.c)
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -Wl,--as-needed -Wl,--rpath=${LIBDIR}/hal)
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
+
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
+
+INSTALL(TARGETS        ${PROJECT_NAME} DESTINATION ${LIBDIR}/hal)
+
+INSTALL(DIRECTORY include/ DESTINATION include/hal
+               FILES_MATCHING
+               PATTERN "*_private.h" EXCLUDE
+               PATTERN "include/*.h")
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIBDIR}/pkgconfig)
+
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..c5455bc
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,203 @@
+Copyright (c) 2000 - 2021 Samsung Electronics Co., Ltd. All rights reserved.
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/hal-api-camera.manifest b/hal-api-camera.manifest
new file mode 100644 (file)
index 0000000..81ace0c
--- /dev/null
@@ -0,0 +1,6 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>
+
diff --git a/hal-api-camera.pc.in b/hal-api-camera.pc.in
new file mode 100644 (file)
index 0000000..484072c
--- /dev/null
@@ -0,0 +1,13 @@
+# Package Information for pkg-config
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@/hal
+libdir=@LIBDIR@/hal
+includedir=@INCLUDEDIR@/hal
+
+Name: @PROJECT_NAME@
+Description: @PROJECT_NAME@ interface
+Version: @VERSION@
+Requires:
+Libs: -L${libdir} -l@PROJECT_NAME@
+Cflags: -I${includedir}
+CXXflags: -I${includedir}
diff --git a/include/hal-camera-interface.h b/include/hal-camera-interface.h
new file mode 100644 (file)
index 0000000..4015cf6
--- /dev/null
@@ -0,0 +1,611 @@
+/*
+ * HAL (Hardware Abstract Layer) interface API for Camera
+ *
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __HAL_CAMERA_INTERFACE__
+#define __HAL_CAMERA_INTERFACE__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file hal-camera-interface.h
+ * @brief This file contains the Tizen camera HAL interface API, related structures and enumerations.
+ * @since_tizen 6.5
+ */
+
+#define BUFFER_PLANE_MAX                    4
+#define DEVICE_COUNT_MAX                    16
+#define RESOLUTION_COUNT_MAX                10
+#define DEVICE_NAME_LENGTH_MAX              16
+#define DEVICE_NODE_PATH_LENGTH_MAX         16
+
+/**
+ * @addtogroup HAL_CAMERA_INTERFACE_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumeration for the camera error.
+ * @since_tizen 6.5
+ */
+typedef enum camera_error {
+       CAMERA_ERROR_NONE                   = 0,
+       CAMERA_ERROR_INVALID_PARAMETER      = (int32_t)0x80002001,
+       CAMERA_ERROR_INVALID_STATE          = (int32_t)0x80002002,
+       CAMERA_ERROR_PERMISSION_DENIED      = (int32_t)0x80002003,
+       CAMERA_ERROR_OUT_OF_MEMORY          = (int32_t)0x80002004,
+       CAMERA_ERROR_DEVICE_OPEN            = (int32_t)0x80002005,
+       CAMERA_ERROR_DEVICE_NOT_FOUND       = (int32_t)0x80002006,
+       CAMERA_ERROR_DEVICE_UNAVAILABLE     = (int32_t)0x80002007,
+       CAMERA_ERROR_DEVICE_NOT_SUPPORTED   = (int32_t)0x80002008,
+       CAMERA_ERROR_DEVICE_READ            = (int32_t)0x80002009,
+       CAMERA_ERROR_DEVICE_WRITE           = (int32_t)0x8000200a,
+       CAMERA_ERROR_DEVICE_BUSY            = (int32_t)0x8000200b,
+       CAMERA_ERROR_DEVICE_TIME_OUT        = (int32_t)0x8000200c,
+       CAMERA_ERROR_DEVICE_ESD             = (int32_t)0x8000200d,
+       CAMERA_ERROR_INTERNAL               = (int32_t)0x8000200e,
+
+       CAMERA_ERROR_NOT_IMPLEMENTED        = (int32_t)0x80002ffe,
+       CAMERA_ERROR_UNKNOWN                = (int32_t)0x80002fff
+} camera_error_e;
+
+/**
+ * @brief Enumeration for the camera state.
+ * @since_tizen 6.5
+ */
+typedef enum camera_state {
+       CAMERA_STATE_INITIALIZED,
+       CAMERA_STATE_OPENED,
+       CAMERA_STATE_PREVIEWING,
+       CAMERA_STATE_CAPTURING,
+       CAMERA_STATE_RECORDING,
+       CAMERA_STATE_RECORDING_SNAPSHOT
+} camera_state_e;
+
+/**
+ * @brief The structure type of the resolution.
+ * @since_tizen 6.5
+ */
+typedef struct camera_resolution {
+       uint32_t width;
+       uint32_t height;
+} camera_resolution_s;
+
+/**
+ * @brief The structure type of the fraction.
+ * @since_tizen 6.5
+ */
+typedef struct camera_fraction {
+       int numerator;
+       int denominator;
+} camera_fraction_s;
+
+/**
+ * @brief The structure type of the rectangle.
+ * @since_tizen 6.5
+ */
+typedef struct camera_rectangle {
+       int x;
+       int y;
+       uint32_t width;
+       uint32_t height;
+} camera_rectangle_s;
+
+/**
+ * @brief Enumeration for the camera pixel format.
+ * @since_tizen 6.5
+ */
+typedef enum camera_pixel_format {
+       /* YUV */
+       CAMERA_PIXEL_FORMAT_NV12 = 0x0000,
+       CAMERA_PIXEL_FORMAT_NV21,
+       CAMERA_PIXEL_FORMAT_I420,
+       CAMERA_PIXEL_FORMAT_YV12,
+       CAMERA_PIXEL_FORMAT_YUYV,
+       CAMERA_PIXEL_FORMAT_UYVY,
+
+       /* RGB */
+       CAMERA_PIXEL_FORMAT_BGRA8888,
+       CAMERA_PIXEL_FORMAT_ARGB8888,
+
+       /* ENCODED */
+       CAMERA_PIXEL_FORMAT_JPEG,
+       CAMERA_PIXEL_FORMAT_H264,
+       CAMERA_PIXEL_FORMAT_MJPEG,
+
+       /* DEPTH */
+       CAMERA_PIXEL_FORMAT_DEPTH,
+
+       /* MAX */
+       CAMERA_PIXEL_FORMAT_MAX
+} camera_pixel_format_e;
+
+/**
+ * @brief The structure type of the camera plane.
+ * @since_tizen 6.5
+ */
+typedef struct camera_plane {
+       unsigned char *data;
+       uint32_t align_width;
+       uint32_t align_height;
+       uint32_t size;
+} camera_plane_s;
+
+/**
+ * @brief The structure type of the camera buffer.
+ * @since_tizen 6.5
+ */
+typedef struct camera_buffer {
+       int index;
+       camera_pixel_format_e format;
+       camera_resolution_s resolution;
+       uint32_t total_size;
+       uint32_t num_planes;
+       camera_plane_s planes[BUFFER_PLANE_MAX];
+       uint32_t num_bos;
+       void *bos[BUFFER_PLANE_MAX];
+} camera_buffer_s;
+
+/**
+ * @brief The structure type of the camera metadata.
+ * @since_tizen 6.5
+ */
+typedef struct camera_metadata {
+       int is_flashed;
+       camera_fraction_s focal_length;
+       camera_fraction_s aperture_f_number;
+       camera_fraction_s shutter_speed;
+       camera_fraction_s exposure_time;
+       camera_fraction_s brightness;
+       camera_resolution_s exif_image;
+       int iso;
+       int metering_mode;
+       int color_space;
+       int component_configuration;
+       int aperture_in_apex;
+} camera_metadata_s;
+
+/**
+ * @brief Enumeration for the focus state.
+ * @since_tizen 6.5
+ */
+typedef enum camera_focus_state {
+       CAMERA_FOCUS_STATE_RELEASED,
+       CAMERA_FOCUS_STATE_ONGOING,
+       CAMERA_FOCUS_STATE_FOCUSED,
+       CAMERA_FOCUS_STATE_FAILED
+} camera_focus_state_e;
+
+/**
+ * @brief Enumeration for the facing direction of camera device.
+ * @since_tizen 6.5
+ */
+typedef enum camera_facing_direction {
+       CAMERA_FACING_DIRECTION_REAR,
+       CAMERA_FACING_DIRECTION_FRONT,
+       CAMERA_FACING_DIRECTION_EXTERNAL
+} camera_facing_direction_e;
+
+/**
+ * @brief Enumeration for the camera rotation.
+ * @since_tizen 6.5
+ */
+typedef enum camera_rotation {
+       CAMERA_ROTATION_0,
+       CAMERA_ROTATION_90,
+       CAMERA_ROTATION_180,
+       CAMERA_ROTATION_270
+} camera_rotation_e;
+
+/**
+ * @brief Enumeration for the camera flip.
+ * @since_tizen 6.5
+ */
+typedef enum camera_flip {
+       CAMERA_FLIP_NONE,
+       CAMERA_FLIP_HORIZONTAL,
+       CAMERA_FLIP_VERTICAL,
+       CAMERA_FLIP_BOTH
+} camera_flip_e;
+
+/**
+ * @brief The structure type of the camera format.
+ * @since_tizen 6.5
+ */
+typedef struct camera_format {
+       camera_pixel_format_e stream_format;
+       camera_resolution_s stream_resolution;
+       uint32_t stream_fps;
+       camera_rotation_e stream_rotation;
+       camera_pixel_format_e capture_format;
+       camera_resolution_s capture_resolution;
+       uint32_t capture_quality;
+} camera_format_s;
+
+/**
+ * @brief Enumeration for the focus mode.
+ * @since_tizen 6.5
+ */
+typedef enum camera_focus_mode {
+       CAMERA_FOCUS_MODE_NONE,
+       CAMERA_FOCUS_MODE_PAN,
+       CAMERA_FOCUS_MODE_AUTO,
+       CAMERA_FOCUS_MODE_CONTINUOUS_AUTO
+} camera_focus_mode_e;
+
+/**
+ * @brief Enumeration for the focus range.
+ * @since_tizen 6.5
+ */
+typedef enum camera_focus_range {
+       CAMERA_FOCUS_RANGE_NONE,
+       CAMERA_FOCUS_RANGE_NORMAL,
+       CAMERA_FOCUS_RANGE_MACRO,
+       CAMERA_FOCUS_RANGE_FULL
+} camera_focus_range_e;
+
+/**
+ * @brief Enumeration for the white balance.
+ * @since_tizen 6.5
+ */
+typedef enum camera_white_balance {
+       CAMERA_WHITE_BALANCE_AUTO,          /**< Automatic */
+       CAMERA_WHITE_BALANCE_DAYLIGHT,      /**< Daylight */
+       CAMERA_WHITE_BALANCE_CLOUDY,        /**< Cloudy */
+       CAMERA_WHITE_BALANCE_FLUORESCENT,   /**< Fluorescent */
+       CAMERA_WHITE_BALANCE_INCANDESCENT,  /**< Incandescent */
+       CAMERA_WHITE_BALANCE_SHADE,         /**< Shade */
+       CAMERA_WHITE_BALANCE_HORIZON,       /**< Horizon */
+       CAMERA_WHITE_BALANCE_FLASH          /**< Flash */
+} camera_white_balance_e;
+
+/**
+ * @brief Enumeration for the effect.
+ * @since_tizen 6.5
+ */
+typedef enum camera_effect {
+       CAMERA_EFFECT_NONE,                 /**< None */
+       CAMERA_EFFECT_MONO,                 /**< Mono */
+       CAMERA_EFFECT_SEPIA,                /**< Sepia */
+       CAMERA_EFFECT_NEGATIVE,             /**< Negative */
+       CAMERA_EFFECT_RED,                  /**< Red */
+       CAMERA_EFFECT_GREEN,                /**< Green */
+       CAMERA_EFFECT_BLUE,                 /**< Blue */
+       CAMERA_EFFECT_AQUA,                 /**< Aqua */
+       CAMERA_EFFECT_ANTIQUE,              /**< Antique */
+       CAMERA_EFFECT_WARM,                 /**< Warm */
+       CAMERA_EFFECT_EMBOSS,               /**< Emboss */
+       CAMERA_EFFECT_SKETCH,               /**< Sketch */
+       CAMERA_EFFECT_SOLARIZATION,         /**< Solarization */
+       CAMERA_EFFECT_POSTERIZATION,        /**< Posterization */
+       CAMERA_EFFECT_CARTOON               /**< Cartoon */
+} camera_effect_e;
+
+/**
+ * @brief Enumeration for the scene mode.
+ * @since_tizen 6.5
+ */
+typedef enum camera_scene_mode {
+       CAMERA_SCENE_MODE_NORMAL,           /**< Normal */
+       CAMERA_SCENE_MODE_PORTRAIT,         /**< Portrait */
+       CAMERA_SCENE_MODE_LANDSCAPE,        /**< Landscape */
+       CAMERA_SCENE_MODE_SPORTS,           /**< Sports */
+       CAMERA_SCENE_MODE_PARTY_N_INDOOR,   /**< Party & indoor */
+       CAMERA_SCENE_MODE_BEACH_N_INDOOR,   /**< Beach & indoor */
+       CAMERA_SCENE_MODE_SUNSET,           /**< Sunset */
+       CAMERA_SCENE_MODE_DUSK_N_DAWN,      /**< Dusk & dawn */
+       CAMERA_SCENE_MODE_FALL_COLOR,       /**< Fall */
+       CAMERA_SCENE_MODE_NIGHT_SCENE,      /**< Night scene */
+       CAMERA_SCENE_MODE_FIREWORK,         /**< Firework */
+       CAMERA_SCENE_MODE_TEXT,             /**< Text */
+       CAMERA_SCENE_MODE_SHOW_WINDOW,      /**< Show window */
+       CAMERA_SCENE_MODE_CANDLE_LIGHT,     /**< Candle light */
+       CAMERA_SCENE_MODE_BACKLIGHT,        /**< Backlight */
+       CAMERA_SCENE_MODE_AQUA              /**< Aqua */
+} camera_scene_mode_e;
+
+/**
+ * @brief Enumeration for the exposure mode.
+ * @since_tizen 6.5
+ */
+typedef enum camera_exposure_mode {
+       CAMERA_EXPOSURE_MODE_OFF = 0,       /**< Off */
+       CAMERA_EXPOSURE_MODE_ALL,           /**< All mode */
+       CAMERA_EXPOSURE_MODE_CENTER,        /**< Center mode */
+       CAMERA_EXPOSURE_MODE_SPOT,          /**< Spot mode */
+       CAMERA_EXPOSURE_MODE_CUSTOM         /**< Custom mode */
+} camera_exposure_mode_e;
+
+/**
+ * @brief Enumeration for the shot mode.
+ * @since_tizen 6.5
+ */
+typedef enum camera_shot_mode {
+       CAMERA_SHOT_MODE_NORMAL = 0,        /**< Normal */
+       CAMERA_SHOT_MODE_CONTINUOUS,        /**< Continuous */
+       CAMERA_SHOT_MODE_HDR,               /**< HDR */
+       CAMERA_SHOT_MODE_NIGHT              /**< Night */
+} camera_shot_mode_e;
+
+/**
+ * @brief Enumeration for the flash mode.
+ * @since_tizen 6.5
+ */
+typedef enum camera_flash_mode {
+       CAMERA_FLASH_MODE_OFF = 0,          /**< Always off */
+       CAMERA_FLASH_MODE_ON,               /**< Always splashes */
+       CAMERA_FLASH_MODE_AUTO,             /**< Depending on intensity of light, strobe starts to flash */
+       CAMERA_FLASH_MODE_REDEYE_REDUCTION, /**< Red eye reduction. Multiple flash before capturing */
+       CAMERA_FLASH_MODE_SLOW_SYNC,        /**< Slow sync curtain synchronization */
+       CAMERA_FLASH_MODE_FRONT_CURTAIN,    /**< Front curtain synchronization */
+       CAMERA_FLASH_MODE_REAR_CURTAIN,     /**< Rear curtain synchronization */
+       CAMERA_FLASH_MODE_PERMANENT,        /**< Keep turned on until turning off */
+} camera_flash_mode_e;
+
+/**
+ * @brief Enumeration for the face detection.
+ * @since_tizen 6.5
+ */
+typedef enum camera_face_detection {
+       CAMERA_FACE_DETECTION_OFF = 0,      /**< Face detection off */
+       CAMERA_FACE_DETECTION_ON            /**< Face detection on */
+} camera_face_detection_e;
+
+/**
+ * @brief Enumeration for the PTZ(Pan Tilt Zoom) type.
+ * @since_tizen 6.5
+ */
+typedef enum camera_ptz_type {
+       CAMERA_PTZ_TYPE_MECHANICAL = 0,     /**< Move the camera device physically */
+       CAMERA_PTZ_TYPE_ELECTRONIC          /**< Zoom digitally and move into portion of the image */
+} camera_ptz_type_e;
+
+/**
+ * @brief Definitions for the camera command.
+ * @since_tizen 6.5
+ */
+#define CAMERA_COMMAND_BASE                     ((int64_t)1)
+#define CAMERA_COMMAND_WHITE_BALANCE            ((int64_t)(CAMERA_COMMAND_BASE << 1))
+#define CAMERA_COMMAND_ISO                      ((int64_t)(CAMERA_COMMAND_BASE << 2))
+#define CAMERA_COMMAND_CONTRAST                 ((int64_t)(CAMERA_COMMAND_BASE << 3))
+#define CAMERA_COMMAND_SATURATION               ((int64_t)(CAMERA_COMMAND_BASE << 4))
+#define CAMERA_COMMAND_HUE                      ((int64_t)(CAMERA_COMMAND_BASE << 5))
+#define CAMERA_COMMAND_SHARPNESS                ((int64_t)(CAMERA_COMMAND_BASE << 6))
+#define CAMERA_COMMAND_EFFECT                   ((int64_t)(CAMERA_COMMAND_BASE << 7))
+#define CAMERA_COMMAND_SCENE_MODE               ((int64_t)(CAMERA_COMMAND_BASE << 8))
+#define CAMERA_COMMAND_EXPOSURE_MODE            ((int64_t)(CAMERA_COMMAND_BASE << 9))
+#define CAMERA_COMMAND_EXPOSURE                 ((int64_t)(CAMERA_COMMAND_BASE << 10))
+#define CAMERA_COMMAND_ROTATION                 ((int64_t)(CAMERA_COMMAND_BASE << 11))
+#define CAMERA_COMMAND_FLIP                     ((int64_t)(CAMERA_COMMAND_BASE << 12))
+#define CAMERA_COMMAND_FOCUS_MODE               ((int64_t)(CAMERA_COMMAND_BASE << 13))
+#define CAMERA_COMMAND_FOCUS_RANGE              ((int64_t)(CAMERA_COMMAND_BASE << 14))
+#define CAMERA_COMMAND_SHOT_MODE                ((int64_t)(CAMERA_COMMAND_BASE << 15))
+#define CAMERA_COMMAND_ANTI_SHAKE               ((int64_t)(CAMERA_COMMAND_BASE << 16))
+#define CAMERA_COMMAND_FOCUS_AREA               ((int64_t)(CAMERA_COMMAND_BASE << 17))
+#define CAMERA_COMMAND_DIGITAL_ZOOM             ((int64_t)(CAMERA_COMMAND_BASE << 18))
+#define CAMERA_COMMAND_OPTICAL_ZOOM             ((int64_t)(CAMERA_COMMAND_BASE << 19))
+#define CAMERA_COMMAND_RECORDING_HINT           ((int64_t)(CAMERA_COMMAND_BASE << 20))
+#define CAMERA_COMMAND_WDR                      ((int64_t)(CAMERA_COMMAND_BASE << 21))
+#define CAMERA_COMMAND_SHUTTER_SPEED            ((int64_t)(CAMERA_COMMAND_BASE << 22))
+#define CAMERA_COMMAND_FLASH_MODE               ((int64_t)(CAMERA_COMMAND_BASE << 23))
+#define CAMERA_COMMAND_FACE_DETECTION           ((int64_t)(CAMERA_COMMAND_BASE << 24))
+#define CAMERA_COMMAND_BITRATE                  ((int64_t)(CAMERA_COMMAND_BASE << 25))
+#define CAMERA_COMMAND_PTZ_TYPE                 ((int64_t)(CAMERA_COMMAND_BASE << 26))
+#define CAMERA_COMMAND_PAN                      ((int64_t)(CAMERA_COMMAND_BASE << 27))
+#define CAMERA_COMMAND_TILT                     ((int64_t)(CAMERA_COMMAND_BASE << 28))
+#define CAMERA_COMMAND_BRIGHTNESS               ((int64_t)(CAMERA_COMMAND_BASE << 29))
+#define CAMERA_COMMAND_GOP_INTERVAL             ((int64_t)(CAMERA_COMMAND_BASE << 30))
+#define CAMERA_COMMAND_CAPTURE_COUNT            ((int64_t)(CAMERA_COMMAND_BASE << 31))
+#define CAMERA_COMMAND_CAPTURE_INTERVAL         ((int64_t)(CAMERA_COMMAND_BASE << 32))
+#define CAMERA_COMMAND_FLASH_BRIGHTNESS         ((int64_t)(CAMERA_COMMAND_BASE << 33))
+
+
+typedef struct camera_batch_command_control {
+       /* flag for modified command */
+       int64_t command_set_flag;
+
+       /* value list */
+       camera_white_balance_e white_balance;
+       int iso;
+       int contrast;
+       int saturation;
+       int hue;
+       int sharpness;
+       camera_effect_e effect;
+       camera_scene_mode_e scene_mode;
+       camera_exposure_mode_e exposure_mode;
+       int exposure;
+       camera_rotation_e rotation;
+       camera_flip_e flip;
+       camera_focus_mode_e focus_mode;
+       camera_focus_range_e focus_range;
+       camera_exposure_mode_e shot_mode;
+       int anti_shake;
+       camera_rectangle_s focus_area;
+       int digital_zoom;
+       int optical_zoom;
+       int recording_hint;
+       int wdr;
+       camera_flash_mode_e flash_mode;
+       camera_face_detection_e face_detection;
+       int bitrate;
+       int ptz_type;
+       int pan;
+       int tilt;
+       int gop_interval;
+       int capture_count;
+       int capture_interval;
+       int flash_brightness;
+} camera_batch_command_control_s;
+
+/**
+ * @brief The structure type of the format list.
+ * @since_tizen 6.5
+ */
+typedef struct camera_pixel_format_list {
+       uint32_t count;
+       camera_pixel_format_e formats[CAMERA_PIXEL_FORMAT_MAX];
+} camera_format_list_s;
+
+/**
+ * @brief The structure type of the resolution list.
+ * @since_tizen 6.5
+ */
+typedef struct camera_resolution_list {
+       uint32_t count;
+       camera_resolution_s resolutions[RESOLUTION_COUNT_MAX];
+} camera_resolution_list_s;
+
+/**
+ * @brief The structure type of the camera device information.
+ * @since_tizen 6.5
+ */
+typedef struct camera_device_info {
+       uint32_t index;
+       char name[DEVICE_NAME_LENGTH_MAX];
+       char node_path[DEVICE_NODE_PATH_LENGTH_MAX];
+       camera_facing_direction_e facing_direction;
+       camera_format_list_s format_list;
+       camera_resolution_list_s preview_list;
+       camera_resolution_list_s capture_list;
+       camera_resolution_list_s video_list;
+} camera_device_info_s;
+
+/**
+ * @brief The structure type of the camera device information list.
+ * @since_tizen 6.5
+ */
+typedef struct camera_device_info_list {
+       uint32_t count;
+       camera_device_info_s device_info[DEVICE_COUNT_MAX];
+} camera_device_info_list_s;
+
+/**
+ * @brief Enumeration for the camera message type.
+ * @since_tizen 6.5
+ */
+typedef enum camera_message_type {
+       CAMERA_MESSAGE_TYPE_FOCUS_CHANGED,
+       CAMERA_MESSAGE_TYPE_CAPTURED,
+       CAMERA_MESSAGE_TYPE_HDR_PROGRESS,
+       CAMERA_MESSAGE_TYPE_ERROR
+} camera_message_type_e;
+
+/**
+ * @brief The structure type of the camera message.
+ * @since_tizen 6.5
+ */
+typedef struct camera_message {
+       camera_message_type_e type;
+       union {
+               camera_focus_state_e focus_state;
+               uint32_t hdr_progress;
+               camera_error_e error_code;
+       };
+} camera_message_s;
+
+/**
+ * @brief Callback function for notification from camera HAL.
+ * @since_tizen 6.5
+ * @param[in] message The message from camera HAL
+ * @param[in] user_data The user data for callback
+ * @see hal_camera_add_message_callback()
+ * @see hal_camera_remove_message_callback()
+ */
+typedef int (*hal_camera_message_cb)(camera_message_s *message, void *user_data);
+
+/**
+ * @brief Callback function for captured preview frame from camera device.
+ * @since_tizen 6.5
+ * @param[in] buffer The preview buffer
+ * @param[in] meta The meta data for the preview frame
+ * @param[in] user_data The user data for callback
+ * @pre hal_camera_start_preview() will invoke this callback.
+ * @see hal_camera_start_preview()
+ * @see hal_camera_stop_preview()
+ */
+typedef int (*hal_camera_preview_frame_cb)(camera_buffer_s *buffer, camera_metadata_s *meta, void *user_data);
+
+/**
+ * @brief Callback function for captured video frame from camera device.
+ * @since_tizen 6.5
+ * @param[in] buffer The video buffer
+ * @param[in] meta The meta data for the video frame
+ * @param[in] user_data The user data for callback
+ * @pre hal_camera_start_record() will invoke this callback.
+ * @see hal_camera_start_record()
+ * @see hal_camera_stop_record()
+ */
+typedef int (*hal_camera_video_frame_cb)(camera_buffer_s *buffer, camera_metadata_s *meta, void *user_data);
+
+/**
+ * @brief Callback function for captured still image from camera device.
+ * @since_tizen 6.5
+ * @param[in] main The main image data
+ * @param[in] postview The image data of the postview (it could be @c NULL if the available data does not exist)
+ * @param[in] thumbnail The image data of the thumbnail (it could be @c NULL if the available data does not exist)
+ * @param[in] user_data The user data passed from the callback registration function
+ * @pre hal_camera_start_capture() will invoke this callback function.
+ * @see hal_camera_start_capture()
+ * @see hal_camera_stop_capture()
+ */
+typedef int (*hal_camera_capture_cb)(camera_buffer_s *main, camera_buffer_s *postview, camera_buffer_s *thumbnail, void *user_data);
+
+
+/**
+ * @brief The structure type of the camera HAL functions.
+ * @since_tizen 6.5
+ */
+typedef struct _hal_backend_media_camera_funcs {
+       int (*init)(void **camera_handle);
+       int (*deinit)(void *camera_handle);
+       int (*get_device_info_list)(camera_device_info_list_s *device_info_list);
+       int (*open_device)(void *camera_handle, int device_index);
+       int (*open_device_ext)(void *camera_handle, const char *device_name);
+       int (*close_device)(void *camera_handle);
+       int (*add_message_callback)(void *camera_handle, hal_camera_message_cb callback, void *user_data, uint32_t *cb_id);
+       int (*remove_message_callback)(void *camera_handle, uint32_t cb_id);
+       int (*set_preview_stream_format)(void *camera_handle, camera_format_s *format);
+       int (*get_preview_stream_format)(void *camera_handle, camera_format_s *format);
+       int (*set_user_buffer_fd)(void *camera_handle, int *fds, int number);
+       int (*start_preview)(void *camera_handle, hal_camera_preview_frame_cb callback, void *user_data);
+       int (*release_preview_buffer)(void *camera_handle, int buffer_index);
+       int (*stop_preview)(void *camera_handle);
+       int (*start_auto_focus)(void *camera_handle);
+       int (*stop_auto_focus)(void *camera_handle);
+       int (*start_capture)(void *camera_handle, hal_camera_capture_cb callback, void *user_data);
+       int (*stop_capture)(void *camera_handle);
+       int (*set_video_stream_format)(void *camera_handle, camera_format_s *format);
+       int (*get_video_stream_format)(void *camera_handle, camera_format_s *format);
+       int (*start_record)(void *camera_handle, hal_camera_video_frame_cb callback, void *user_data);
+       int (*release_video_buffer)(void *camera_handle, int buffer_index);
+       int (*stop_record)(void *camera_handle);
+       int (*set_command)(void *camera_handle, int64_t command, void *value);
+       int (*get_command)(void *camera_handle, int64_t command, void **value);
+       int (*set_batch_command)(void *camera_handle, camera_batch_command_control_s *batch_command, int64_t *error_command);
+} hal_backend_camera_funcs;
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __HAL_CAMERA_INTERFACE__ */
diff --git a/include/hal-camera.h b/include/hal-camera.h
new file mode 100644 (file)
index 0000000..b7c26ae
--- /dev/null
@@ -0,0 +1,488 @@
+/*
+ * HAL (Hardware Abstract Layer) API for Camera
+ *
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __HAL_CAMERA__
+#define __HAL_CAMERA__
+
+#include <hal-camera-interface.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file hal-camera.h
+ * @brief This file contains the Tizen camera HAL API, related structures and enumerations.
+ * @since_tizen 6.5
+ */
+
+/**
+ * @addtogroup HAL_CAMERA_MODULE
+ * @{
+ */
+
+/**
+ * @brief Initializes new handle of camera HAL.
+ * @since_tizen 6.5
+ * @param[in]  hal_name A name of library for HAL implementation
+ * @param[out] camera_handle A newly returned handle to the camera HAL
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CAMERA_ERROR_PERMISSION_DENIED The access to the resources can not be granted
+ * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
+ * @post If it succeeds, the camera state will be #CAMERA_STATE_INITIALIZED.
+ * @see hal_camera_deinit()
+ */
+int hal_camera_init(const char *hal_name, void **camera_handle);
+
+/**
+ * @brief Deinitializes handle of camera HAL.
+ * @since_tizen 6.5
+ * @param[in] camera_handle The handle to the camera HAL
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see hal_camera_init()
+ */
+int hal_camera_deinit(void *camera_handle);
+
+/**
+ * @brief Gets the device list of camera.
+ * @since_tizen 6.5
+ * @param[in]  camera_handle The handle to the camera HAL
+ * @param[out] device_info_list The list of the camera device information
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
+ */
+int hal_camera_get_device_info_list(void *camera_handle, camera_device_info_list_s *device_info_list);
+
+/**
+ * @brief Opens camera device.
+ * @since_tizen 6.5
+ * @param[in] camera_handle The handle to the camera HAL
+ * @param[in] device_index The device index of the camera
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CAMERA_ERROR_PERMISSION_DENIED The access to the resources can not be granted
+ * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
+ * @retval #CAMERA_ERROR_DEVICE_NOT_FOUND Failed to find camera device
+ * @retval #CAMERA_ERROR_DEVICE_UNAVAILABLE The camera device is unavailable
+ * @pre    The camera state must be set to #CAMERA_STATE_INITIALIZED.
+ * @post   If it succeeds, the camera state will be #CAMERA_STATE_OPENED.
+ * @see hal_camera_close_device()
+ */
+int hal_camera_open_device(void *camera_handle, int device_index);
+
+/**
+ * @brief Opens camera device with device name.
+ * @since_tizen 6.5
+ * @param[in] camera_handle The handle to the camera HAL
+ * @param[in] device_name The device name of the camera
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CAMERA_ERROR_PERMISSION_DENIED The access to the resources can not be granted
+ * @retval #CAMERA_ERROR_DEVICE_NOT_FOUND Failed to find camera device
+ * @retval #CAMERA_ERROR_DEVICE_UNAVAILABLE The camera device is unavailable
+ * @pre    The camera state must be set to #CAMERA_STATE_INITIALIZED.
+ * @post   If it succeeds, the camera state will be #CAMERA_STATE_OPENED.
+ * @see hal_camera_close_device()
+ */
+int hal_camera_open_device_ext(void *camera_handle, const char *device_name);
+
+/**
+ * @brief Closes camera device.
+ * @since_tizen 6.5
+ * @param[in] camera_handle The handle to the camera HAL
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @pre    The camera state must be set to #CAMERA_STATE_OPENED.
+ * @post   If it succeeds, the camera state will be #CAMERA_STATE_INITIALIZED.
+ * @see hal_camera_open_device()
+ */
+int hal_camera_close_device(void *camera_handle);
+
+/**
+ * @brief Registers a callback function to be called to send a message by camera HAL.
+ * @since_tizen 6.5
+ * @param[in] camera_handle The handle to the camera HAL
+ * @param[in] callback The callback function to be registered
+ * @param[in] user_data The user data to be passed to the callback function
+ * @param[out] cb_id The callback id
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
+ * @see hal_camera_remove_message_callback()
+ */
+int hal_camera_add_message_callback(void *camera_handle, hal_camera_message_cb callback, void *user_data, uint32_t *cb_id);
+
+/**
+ * @brief Unregisters a callback function.
+ * @since_tizen 6.5
+ * @param[in] camera_handle The handle to the camera HAL
+ * @param[in] cb_id The callback id
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see hal_camera_remove_message_callback()
+ */
+int hal_camera_remove_message_callback(void *camera_handle, uint32_t cb_id);
+
+/**
+ * @brief Sets the format of the preview stream.
+ * @since_tizen 6.5
+ * @remarks This function should be called before previewing (see camera_start_preview()).
+ * @param[in] camera_handle The handle to the camera HAL
+ * @param[in] format The format of the preview stream
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
+ * @pre The camera state must be set to #CAMERA_STATE_OPENED.
+ * @see hal_camera_start_preview()
+ * @see hal_camera_start_capture()
+ * @see hal_camera_get_preview_stream_format()
+ */
+int hal_camera_set_preview_stream_format(void *camera_handle, camera_format_s *format);
+
+/**
+ * @brief Gets the format of the preview stream.
+ * @since_tizen 6.5
+ * @param[in] camera_handle The handle to the camera HAL
+ * @param[out] format The format of the preview stream
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
+ * @see hal_camera_start_preview()
+ * @see hal_camera_start_capture()
+ * @see hal_camera_set_preview_stream_format()
+ * @see hal_camera_foreach_supported_preview_format()
+ */
+int hal_camera_get_preview_stream_format(void *camera_handle, camera_format_s *format);
+
+/**
+ * @brief Sets the buffer fd from user for preview buffer.
+ * @since_tizen 6.5
+ * @param[in] camera_handle The handle to the camera HAL
+ * @param[in] fds The array of buffer fd
+ * @param[in] number The number of buffer
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
+ * @pre    The camera state must be set to #CAMERA_STATE_OPENED.
+ * @see hal_camera_start_preview()
+ */
+int hal_camera_set_user_buffer_fd(void *camera_handle, int *fds, int number);
+
+/**
+ * @brief Starts preview frames on the screen.
+ * @since_tizen 6.5
+ * @param[in] camera_handle The handle to the camera HAL
+ * @param[in] callback The callback for preview frame
+ * @param[in] user_data The user data for callback
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #CAMERA_ERROR_DEVICE_BUSY The device is being used in another application or is performing other operations
+ * @retval #CAMERA_ERROR_PERMISSION_DENIED The access to the resources can not be granted
+ * @pre    The camera state must be set to #CAMERA_STATE_OPENED.
+ * @post   If it succeeds, the camera state will be #CAMERA_STATE_PREVIEWING.
+ * @see hal_camera_stop_preview()
+ */
+int hal_camera_start_preview(void *camera_handle, hal_camera_preview_frame_cb callback, void *user_data);
+
+/**
+ * @brief Release the preview buffer.
+ * @since_tizen 6.5
+ * @remarks The preview buffer should be released with this function after use it.
+ * @param[in] camera_handle The handle to the camera HAL
+ * @param[in] buffer_index The index of preview buffer
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
+ * @see hal_camera_start_preview()
+ */
+int hal_camera_release_preview_buffer(void *camera_handle, int buffer_index);
+
+/**
+ * @brief Stops preview frames.
+ * @since_tizen 6.5
+ * @param[in] camera_handle The handle to the camera HAL
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
+ * @pre    The camera state must be set to #CAMERA_STATE_PREVIEWING.
+ * @post   The camera state will be #CAMERA_STATE_OPENED.
+ * @see hal_camera_start_preview()
+ */
+int hal_camera_stop_preview(void *camera_handle);
+
+/**
+ * @brief Starts camera auto focusing operation.
+ * @since_tizen 6.5
+ * @param[in] camera_handle The handle to the camera HAL
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
+ * @pre    The camera state must be set to #CAMERA_STATE_PREVIEWING or #CAMERA_STATE_RECORDING.
+ * @post   The camera focus state will be #CAMERA_FOCUS_STATE_ONGOING.
+ * @see hal_camera_stop_auto_focus()
+ * @see hal_camera_add_message_callback()
+ * @see hal_camera_message_cb()
+ * @see hal_camera_set_command()
+ */
+int hal_camera_start_auto_focus(void *camera_handle);
+
+/**
+ * @brief Stops camera auto focusing operation.
+ * @since_tizen 6.5
+ * @param[in] camera_handle The handle to the camera HAL
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
+ * @pre    The camera state must be set to #CAMERA_STATE_PREVIEWING or #CAMERA_STATE_RECORDING.
+ * @post   The camera focus state will be #CAMERA_FOCUS_STATE_ONGOING.
+ * @see hal_camera_start_auto_focus()
+ * @see hal_camera_add_message_callback()
+ * @see hal_camera_message_cb()
+ */
+int hal_camera_stop_auto_focus(void *camera_handle);
+
+/**
+ * @brief Starts capturing of still images.
+ * @since_tizen 6.5
+ * @remarks In case of zero shutter lag capture, preview frame won't be stopped while capturing.
+ * @param[in] camera_handle The handle to the camera HAL
+ * @param[in] callback The callback for captured data
+ * @param[in] user_data The user data for callback
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
+ * @pre    The camera state must be set to #CAMERA_STATE_PREVIEWING or #CAMERA_STATE_RECORDING.
+ * @post   If it succeeds the camera state will be #CAMERA_STATE_CAPTURING or #CAMERA_STATE_RECORDING_SNAPSHOT.
+ * @see hal_camera_start_preview()
+ * @see hal_camera_start_record()
+ * @see hal_camera_set_preview_stream_format()
+ * @see hal_camera_get_preview_stream_format()
+ */
+int hal_camera_start_capture(void *camera_handle, hal_camera_capture_cb callback, void *user_data);
+
+/**
+ * @brief Stops capturing of still images.
+ * @since_tizen 6.5
+ * @remarks In case of zero shutter lag, this function will changes only the state of camera HAL \n
+ *          from #CAMERA_STATE_PREVIEWING or #CAMERA_STATE_RECORDING to #CAMERA_STATE_PREVIEWING or #CAMERA_STATE_RECORDING.\n
+ *          Otherwise, preview frame will be restarted.
+ * @param[in] camera_handle The handle to the camera HAL
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
+ * @pre    The camera state must be set to #CAMERA_STATE_CAPTURING or #CAMERA_STATE_RECORDING_SNAPSHOT.
+ * @post   If it succeeds the camera state will be #CAMERA_STATE_PREVIEWING or #CAMERA_STATE_RECORDING.
+ * @see hal_camera_start_capture()
+ * @see hal_camera_start_record()
+ * @see hal_camera_set_preview_stream_format()
+ * @see hal_camera_get_preview_stream_format()
+ * @see hal_camera_set_video_stream_format()
+ * @see hal_camera_get_video_stream_format()
+ */
+int hal_camera_stop_capture(void *camera_handle);
+
+/**
+ * @brief Sets the format of the video stream for recording.
+ * @since_tizen 6.5
+ * @remarks This function should be called before recording (see camera_start_record()).
+ * @param[in] camera_handle The handle to the camera HAL
+ * @param[in] format The format of the video stream
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
+ * @pre The camera state must be set to #CAMERA_STATE_OPENED.
+ * @see hal_camera_start_record()
+ * @see hal_camera_start_capture()
+ * @see hal_camera_get_video_stream_format()
+ */
+int hal_camera_set_video_stream_format(void *camera_handle, camera_format_s *format);
+
+/**
+ * @brief Gets the format of the video stream for recording.
+ * @since_tizen 6.5
+ * @param[in] camera_handle The handle to the camera HAL
+ * @param[out] format The format of the video stream
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
+ * @see hal_camera_start_preview()
+ * @see hal_camera_start_capture()
+ * @see hal_camera_set_preview_stream_format()
+ * @see hal_camera_foreach_supported_preview_format()
+ */
+int hal_camera_get_video_stream_format(void *camera_handle, camera_format_s *format);
+
+/**
+ * @brief Starts the video frame for recording.
+ * @since_tizen 6.5
+ * @param[in] camera_handle The handle to the camera HAL
+ * @param[in] callback The callback for video frame
+ * @param[in] user_data The user data for callback
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @retval #CAMERA_ERROR_PERMISSION_DENIED The access to the resources can not be granted
+ * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
+ * @pre The camera state must be #CAMERA_STATE_PREVIEWING.
+ * @post The camera state will be #CAMERA_STATE_RECORDING.
+ * @see hal_camera_set_video_stream_format()
+ * @see hal_camera_get_video_stream_format()
+ * @see hal_camera_stop_record()
+ */
+int hal_camera_start_record(void *camera_handle, hal_camera_video_frame_cb callback, void *user_data);
+
+/**
+ * @brief Release the video buffer.
+ * @remarks The video buffer should be released with this function after use it.
+ * @since_tizen 6.5
+ * @param[in] camera_handle The handle to the camera HAL
+ * @param[in] buffer_index The index of video buffer
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
+ * @pre The camera state must be set to #CAMERA_STATE_PREVIEWING.
+ * @see hal_camera_start_record()
+ */
+int hal_camera_release_video_buffer(void *camera_handle, int buffer_index);
+
+/**
+ * @brief Stops the video frame.
+ * @since_tizen 6.5
+ * @param[in] camera_handle The handle to the camera HAL
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @pre The camera state must be #CAMERA_STATE_RECORDING.
+ * @post The camera state will be #CAMERA_STATE_PREVIEWING.
+ * @see hal_camera_set_video_stream_format()
+ * @see hal_camera_get_video_stream_format()
+ * @see hal_camera_start_record()
+ */
+int hal_camera_stop_record(void *camera_handle);
+
+/**
+ * @brief Sets the various command and value to control camera device.
+ * @since_tizen 6.5
+ * @param[in] camera_handle The handle to the camera HAL
+ * @param[in] command The command to control the camera device
+ * @param[in] value The value to set
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
+ * @see hal_camera_get_command()
+ */
+int hal_camera_set_command(void *camera_handle, int64_t command, void *value);
+
+/**
+ * @brief Gets the current value of command.
+ * @since_tizen 6.5
+ * @param[in] camera_handle The handle to the camera HAL
+ * @param[in] command The command to control the camera device
+ * @param[out] value The value to get
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
+ * @see hal_camera_get_command()
+ */
+int hal_camera_get_command(void *camera_handle, int64_t command, void **value);
+
+/**
+ * @brief Sets a set of commands.
+ * @since_tizen 6.5
+ * @remarks error_command will be set if error is returned from the function.
+ * @param[in] camera_handle The handle to the camera HAL
+ * @param[in] batch_command The batch command to set
+ * @param[out] error_command The error command
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
+ * @retval #CAMERA_ERROR_DEVICE_NOT_SUPPORTED The feature is not supported
+ * @see hal_camera_set_command()
+ * @see hal_camera_get_command()
+ */
+int hal_camera_set_batch_command(void *camera_handle, camera_batch_command_control_s *batch_command, int64_t *error_command);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __HAL_CAMERA__ */
diff --git a/packaging/hal-api-camera.spec b/packaging/hal-api-camera.spec
new file mode 100644 (file)
index 0000000..7d5b353
--- /dev/null
@@ -0,0 +1,68 @@
+%define module_name    camera
+%define name           hal-api-%{module_name}
+
+### main package #########
+Name:       %{name}
+Summary:    %{name} interface
+Version:    0.0.1
+Release:    0
+Group:      Development/Libraries
+License:    Apache-2.0
+Source0:    %{name}-%{version}.tar.gz
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+BuildRequires: cmake
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(hal-api-common)
+
+%description
+%{name} interface package for product vendor developer
+
+
+### devel package #########
+%package    devel
+Summary:    %{name} interface
+Group:      Development/Libraries
+Requires:   %{name} = %{version}-%{release}
+
+%description devel
+%{name} interface development package for product vendor developer
+
+
+### build and install #########
+%prep
+%setup -q
+
+%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_LIBDIR_PREFIX=%{_libdir}
+
+%build
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%clean
+rm -rf %{buildroot}
+
+%post
+/sbin/ldconfig
+
+%postun
+/sbin/ldconfig
+
+
+%files
+%manifest %{name}.manifest
+%license LICENSE
+%defattr(-,root,root,-)
+%{_libdir}/hal/*.so.*
+
+
+%files devel
+%defattr(-,root,root,-)
+%{_includedir}/hal/*.h
+%{_libdir}/hal/*.so
+%{_libdir}/pkgconfig/*.pc
+
diff --git a/src/hal-api-camera.c b/src/hal-api-camera.c
new file mode 100644 (file)
index 0000000..598bd24
--- /dev/null
@@ -0,0 +1,400 @@
+/*
+ * HAL (Hardware Abstract Layer) API Camera
+ *
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <dlfcn.h>
+#include <dlog.h>
+#include <glib.h>
+
+#include <hal/hal-common.h>
+
+#include "hal-camera-interface.h"
+#include "hal-camera.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "HALAPI_CAMERA"
+
+#define HAL_CAMERA_RETURN_IF_FAILED(arg, ret) \
+       do {\
+               if (!(arg)) {\
+                       SLOGE("[%s]failed, return[%s]", #arg, #ret);\
+                       return (ret);\
+               }\
+       } while (0)
+
+#define HAL_CAMERA_DO_RETURN_IF_FAILED(arg, do_something, ret) \
+       do {\
+               if (!(arg)) {\
+                       SLOGE("[%s]failed, return[%s]", #arg, #ret);\
+                       do_something;\
+                       return (ret);\
+               }\
+       } while (0);
+
+
+typedef struct _hal_camera_s {
+       void *backend;
+       hal_backend_camera_funcs *funcs;
+} hal_camera_s;
+
+
+int hal_camera_init(const char *hal_name, void **camera_handle)
+{
+       int ret = 0;
+       hal_camera_s *new_handle = NULL;
+
+       HAL_CAMERA_RETURN_IF_FAILED(camera_handle, CAMERA_ERROR_INVALID_PARAMETER);
+
+       new_handle = g_new0(hal_camera_s, 1);
+
+       ret = hal_common_get_backend(HAL_MODULE_CAMERA, (void **)&new_handle->funcs);
+       if (ret != TIZEN_ERROR_NONE) {
+               SLOGE("Failed to get backend");
+               g_free(new_handle);
+               return CAMERA_ERROR_INTERNAL;
+       }
+
+       HAL_CAMERA_DO_RETURN_IF_FAILED(new_handle->funcs, g_free(new_handle), CAMERA_ERROR_NOT_IMPLEMENTED);
+       HAL_CAMERA_DO_RETURN_IF_FAILED(new_handle->funcs->init, g_free(new_handle), CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       ret = new_handle->funcs->init(&new_handle->backend);
+       if (ret != CAMERA_ERROR_NONE) {
+               SLOGE("backend init failed[0x%x]", ret);
+               g_free(new_handle);
+               return CAMERA_ERROR_INTERNAL;
+       }
+
+       *camera_handle = (void *)new_handle;
+
+       return CAMERA_ERROR_NONE;
+}
+
+
+int hal_camera_deinit(void *camera_handle)
+{
+       int ret = 0;
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->deinit, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       ret = handle->funcs->deinit(handle->backend);
+       if (ret != CAMERA_ERROR_NONE) {
+               SLOGE("deinit failed[0x%x]", ret);
+               return ret;
+       }
+
+       hal_common_put_backend(HAL_MODULE_CAMERA, (void *)handle->funcs);
+
+       memset(handle, 0x0, sizeof(hal_camera_s));
+       g_free(handle);
+
+       return CAMERA_ERROR_NONE;
+}
+
+
+int hal_camera_get_device_info_list(void *camera_handle, camera_device_info_list_s *device_info_list)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->get_device_info_list, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->get_device_info_list(device_info_list);
+}
+
+
+int hal_camera_open_device(void *camera_handle, int device_index)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->open_device, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->open_device(camera_handle, device_index);
+}
+
+
+int hal_camera_open_device_ext(void *camera_handle, const char *device_name)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->open_device_ext, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->open_device_ext(camera_handle, device_name);
+}
+
+
+int hal_camera_close_device(void *camera_handle)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->close_device, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->close_device(camera_handle);
+}
+
+
+int hal_camera_add_message_callback(void *camera_handle, hal_camera_message_cb callback, void *user_data, uint32_t *cb_id)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->add_message_callback, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->add_message_callback(camera_handle, callback, user_data, cb_id);
+}
+
+
+int hal_camera_remove_message_callback(void *camera_handle, uint32_t cb_id)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->remove_message_callback, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->remove_message_callback(camera_handle, cb_id);
+}
+
+
+int hal_camera_set_preview_stream_format(void *camera_handle, camera_format_s *format)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->set_preview_stream_format, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->set_preview_stream_format(camera_handle, format);
+}
+
+
+int hal_camera_get_preview_stream_format(void *camera_handle, camera_format_s *format)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->get_preview_stream_format, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->get_preview_stream_format(camera_handle, format);
+}
+
+
+int hal_camera_set_user_buffer_fd(void *camera_handle, int *fds, int number)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->set_user_buffer_fd, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->set_user_buffer_fd(camera_handle, fds, number);
+}
+
+
+int hal_camera_start_preview(void *camera_handle, hal_camera_preview_frame_cb callback, void *user_data)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->start_preview, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->start_preview(camera_handle, callback, user_data);
+}
+
+
+int hal_camera_release_preview_buffer(void *camera_handle, int buffer_index)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->release_preview_buffer, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->release_preview_buffer(camera_handle, buffer_index);
+}
+
+
+int hal_camera_stop_preview(void *camera_handle)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->stop_preview, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->stop_preview(camera_handle);
+}
+
+
+int hal_camera_start_auto_focus(void *camera_handle)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->start_auto_focus, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->start_auto_focus(camera_handle);
+}
+
+
+int hal_camera_stop_auto_focus(void *camera_handle)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->stop_auto_focus, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->stop_auto_focus(camera_handle);
+}
+
+
+int hal_camera_start_capture(void *camera_handle, hal_camera_capture_cb callback, void *user_data)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->start_capture, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->start_capture(camera_handle, callback, user_data);
+}
+
+
+int hal_camera_stop_capture(void *camera_handle)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->stop_capture, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->stop_capture(camera_handle);
+}
+
+
+int hal_camera_set_video_stream_format(void *camera_handle, camera_format_s *format)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->set_video_stream_format, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->set_video_stream_format(camera_handle, format);
+}
+
+
+int hal_camera_get_video_stream_format(void *camera_handle, camera_format_s *format)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->get_video_stream_format, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->get_video_stream_format(camera_handle, format);
+}
+
+
+int hal_camera_start_record(void *camera_handle, hal_camera_video_frame_cb callback, void *user_data)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->start_record, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->start_record(camera_handle, callback, user_data);
+}
+
+
+int hal_camera_release_video_buffer(void *camera_handle, int buffer_index)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->release_video_buffer, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->release_video_buffer(camera_handle, buffer_index);
+}
+
+
+int hal_camera_stop_record(void *camera_handle)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->stop_record, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->stop_record(camera_handle);
+}
+
+
+int hal_camera_set_command(void *camera_handle, int64_t command, void *value)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->set_command, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->set_command(camera_handle, command, value);
+}
+
+
+int hal_camera_get_command(void *camera_handle, int64_t command, void **value)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->get_command, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->get_command(camera_handle, command, value);
+}
+
+
+int hal_camera_set_batch_command(void *camera_handle, camera_batch_command_control_s *batch_command, int64_t *error_command)
+{
+       hal_camera_s *handle = (hal_camera_s *)camera_handle;
+
+       HAL_CAMERA_RETURN_IF_FAILED(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs, CAMERA_ERROR_INVALID_PARAMETER);
+       HAL_CAMERA_RETURN_IF_FAILED(handle->funcs->set_batch_command, CAMERA_ERROR_NOT_IMPLEMENTED);
+
+       return handle->funcs->set_batch_command(camera_handle, batch_command, error_command);
+}