Support manual focus APIs 85/258185/5 accepted/tizen/unified/20210602.122548 submit/tizen/20210531.033817
authorJeongmo Yang <jm80.yang@samsung.com>
Wed, 12 May 2021 04:15:31 +0000 (13:15 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Fri, 14 May 2021 02:57:18 +0000 (11:57 +0900)
[Version] 0.3.43
[Issue Type] New feature

Change-Id: I33b39e7f1a5c47eeb699bfdd0e5687d94a5e5748
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
legacy/include/legacy_camera.h
legacy/src/legacy_camera.c
muse/include/muse_camera.h
muse/src/muse_camera_dispatcher.c
packaging/mmsvc-camera.spec

index ce9a34f..de41f24 100644 (file)
@@ -3853,6 +3853,58 @@ int legacy_camera_attr_set_display_roi_area(camera_h camera, int *display_roi_ar
  */
 int legacy_camera_attr_get_display_roi_area(camera_h camera, int *display_roi_area);
 
+/**
+ * @brief Sets the manual focus level.
+ * @since_tizen 6.5
+ * @remarks The auto focusing will be stopped when legacy_camera_attr_set_focus_level() is called.
+ * @param[in] camera The handle to the camera
+ * @param[in] level The manual focus level
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
+ * @see legacy_camera_attr_get_focus_level()
+ * @see legacy_camera_attr_get_focus_level_range()
+ */
+int legacy_camera_attr_set_focus_level(camera_h camera, int level);
+
+/**
+ * @brief Gets the manual focus level.
+ * @since_tizen 6.5
+ * @param[in] camera The handle to the camera
+ * @param[out] level The manual focus level
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
+ * @see legacy_camera_attr_set_focus_level()
+ * @see legacy_camera_attr_get_focus_level_range()
+ */
+int legacy_camera_attr_get_focus_level(camera_h camera, int *level);
+
+/**
+ * @brief Gets lower limit and upper limit for manual focus level.
+ * @since_tizen 6.5
+ * @remarks If the min value is greater than the max value, it means that this feature is not supported.
+ * @param[in] camera The handle to the camera
+ * @param[out] min The lower limit for manual focus level
+ * @param[out] max The upper limit for manual focus level
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
+ * @see legacy_camera_attr_set_focus_level()
+ * @see legacy_camera_attr_get_focus_level()
+ */
+int legacy_camera_attr_get_focus_level_range(camera_h camera, int *min, int *max);
+
+/**
+ * @}
+ */
+
 bool legacy_camera_is_used(camera_h camera);
 bool legacy_camera_wait(camera_h camera, unsigned int timeout);
 void legacy_camera_lock(camera_h camera, bool is_lock);
@@ -3898,9 +3950,6 @@ int legacy_camera_enable_extra_preview(camera_h camera, bool enable);
                        SLOGD("[V] "format, ##args); \
        } while (0)
 
-/**
- * @}
- */
 #ifdef __cplusplus
 }
 #endif
index 11197d5..eedb607 100644 (file)
@@ -141,6 +141,8 @@ int __convert_camera_error_code(const char *func, int code)
        if (code != MM_ERROR_NONE)
                CAM_LOG_ERROR("[%s] [%s][0x%x] : core frameworks error code[0x%x]",
                        func ? func : "NULL_FUNC", errorstr, ret, code);
+       else
+               CAM_LOG_INFO("[%s] done", func ? func : "NULL_FUNC");
 
        return ret;
 }
@@ -4244,6 +4246,70 @@ int legacy_camera_enable_extra_preview(camera_h camera, bool enable)
 }
 
 
+int legacy_camera_attr_set_focus_level(camera_h camera, int level)
+{
+       int ret = MM_ERROR_NONE;
+       int current_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
+       camera_s *handle = (camera_s *)camera;
+
+       camera_return_val_if_fail(handle, CAMERA_ERROR_INVALID_PARAMETER);
+
+       CAM_LOG_INFO("level[%d]", level);
+
+       ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
+               MMCAM_CAMERA_FOCUS_MODE, &current_mode,
+               NULL);
+       camera_return_val_if_fail(ret == MM_ERROR_NONE, __convert_camera_error_code(__func__, ret));
+
+       if (current_mode != MM_CAMCORDER_FOCUS_MODE_MANUAL) {
+               CAM_LOG_INFO("set focus mode from[%d] to MANUAL", current_mode);
+
+               ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
+                       MMCAM_CAMERA_FOCUS_MODE, MM_CAMCORDER_FOCUS_MODE_MANUAL,
+                       NULL);
+               camera_return_val_if_fail(ret == MM_ERROR_NONE, __convert_camera_error_code(__func__, ret));
+       }
+
+       ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
+               MMCAM_CAMERA_FOCUS_LEVEL, level,
+               NULL);
+
+       return __convert_camera_error_code(__func__, ret);
+}
+
+
+int legacy_camera_attr_get_focus_level(camera_h camera, int *level)
+{
+       int ret = MM_ERROR_NONE;
+       camera_s *handle = (camera_s *)camera;
+
+       camera_return_val_if_fail(handle, CAMERA_ERROR_INVALID_PARAMETER);
+       camera_return_val_if_fail(level, CAMERA_ERROR_INVALID_PARAMETER);
+
+       ret = mm_camcorder_get_focus_level(handle->mm_handle, level);
+
+       return __convert_camera_error_code(__func__, ret);
+}
+
+
+int legacy_camera_attr_get_focus_level_range(camera_h camera, int *min, int *max)
+{
+       int ret = MM_ERROR_NONE;
+       camera_s *handle = (camera_s *)camera;
+       MMCamAttrsInfo ainfo;
+
+       camera_return_val_if_fail(handle && min && max, CAMERA_ERROR_INVALID_PARAMETER);
+
+       ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FOCUS_LEVEL, &ainfo);
+       if (ret == MM_ERROR_NONE) {
+               *min = ainfo.int_range.min;
+               *max = ainfo.int_range.max;
+       }
+
+       return __convert_camera_error_code(__func__, ret);
+}
+
+
 int legacy_camera_get_log_level(void)
 {
        return mm_camcorder_get_log_level();
index a9922aa..988c796 100644 (file)
@@ -197,6 +197,9 @@ typedef enum {
        MUSE_CAMERA_API_UNSET_MEDIA_BRIDGE,
        MUSE_CAMERA_API_SET_EXTRA_PREVIEW_CB,      /* 160 */
        MUSE_CAMERA_API_UNSET_EXTRA_PREVIEW_CB,
+       MUSE_CAMERA_API_ATTR_SET_FOCUS_LEVEL,
+       MUSE_CAMERA_API_ATTR_GET_FOCUS_LEVEL,
+       MUSE_CAMERA_API_ATTR_GET_FOCUS_LEVEL_RANGE,
        MUSE_CAMERA_API_MAX
 } muse_camera_api_e;
 
@@ -314,6 +317,7 @@ typedef enum {
        MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL,
        MUSE_CAMERA_GET_INT_HUE,
        MUSE_CAMERA_GET_INT_FLASH_BRIGHTNESS,
+       MUSE_CAMERA_GET_INT_FOCUS_LEVEL,
        MUSE_CAMERA_GET_INT_NUM
 } muse_camera_get_int_e;
 
@@ -329,6 +333,7 @@ typedef enum {
        MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE,
        MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE,
        MUSE_CAMERA_GET_INT_PAIR_FLASH_BRIGHTNESS_RANGE,
+       MUSE_CAMERA_GET_INT_PAIR_FOCUS_LEVEL_RANGE,
        MUSE_CAMERA_GET_INT_PAIR_NUM
 } muse_camera_get_int_pair_e;
 
index 3e51d95..5704207 100644 (file)
@@ -5350,6 +5350,77 @@ int camera_dispatcher_unset_extra_preview_cb(muse_module_h module)
 }
 
 
+int camera_dispatcher_attr_set_focus_level(muse_module_h module)
+{
+       int ret = CAMERA_ERROR_NONE;
+       muse_camera_handle_s *muse_camera = NULL;
+       int level;
+       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FOCUS_LEVEL;
+       muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
+
+       muse_camera = (muse_camera_handle_s *)muse_server_ipc_get_handle(module);
+
+       muse_camera_msg_get(level, muse_server_module_get_msg(module));
+
+       CAM_LOG_INFO("handle[%p], level[%d]", muse_camera, level);
+
+       ret = legacy_camera_attr_set_focus_level(muse_camera->camera_handle, level);
+
+       CAM_LOG_INFO("ret[0x%x]", ret);
+
+       muse_camera_msg_return(api, class, ret, module);
+
+       return MUSE_CAMERA_ERROR_NONE;
+}
+
+int camera_dispatcher_attr_get_focus_level(muse_module_h module)
+{
+       int ret = CAMERA_ERROR_NONE;
+       muse_camera_handle_s *muse_camera = NULL;
+       int get_value = 0;
+       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FOCUS_LEVEL;
+       muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
+
+       muse_camera = (muse_camera_handle_s *)muse_server_ipc_get_handle(module);
+
+       CAM_LOG_INFO("handle[%p]", muse_camera);
+
+       ret = legacy_camera_attr_get_focus_level(muse_camera->camera_handle, &get_value);
+       if (ret == CAMERA_ERROR_NONE)
+               muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
+                       MUSE_CAMERA_GET_INT_FOCUS_LEVEL, "get_value", get_value, NULL);
+       else
+               muse_camera_msg_return(api, class, ret, module);
+
+       return MUSE_CAMERA_ERROR_NONE;
+}
+
+
+int camera_dispatcher_attr_get_focus_level_range(muse_module_h module)
+{
+       int ret = CAMERA_ERROR_NONE;
+       muse_camera_handle_s *muse_camera = NULL;
+       int get_value0 = 0;
+       int get_value1 = 0;
+       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FOCUS_LEVEL_RANGE;
+       muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
+       muse_camera_get_type_e get_type = MUSE_CAMERA_GET_TYPE_INT_PAIR;
+       muse_camera_get_int_pair_e index = MUSE_CAMERA_GET_INT_PAIR_FOCUS_LEVEL_RANGE;
+
+       muse_camera = (muse_camera_handle_s *)muse_server_ipc_get_handle(module);
+
+       CAM_LOG_INFO("handle[%p]", muse_camera);
+
+       ret = legacy_camera_attr_get_focus_level_range(muse_camera->camera_handle, &get_value0, &get_value1);
+       if (ret == CAMERA_ERROR_NONE)
+               muse_camera_msg_return2(api, class, ret, module, get_type, index, get_value0, get_value1);
+       else
+               muse_camera_msg_return(api, class, ret, module);
+
+       return MUSE_CAMERA_ERROR_NONE;
+}
+
+
 static tbm_bo __camera_normal_buffer_bo_new(MMCamcorderVideoStreamDataType *stream, tbm_bufmgr bufmgr)
 {
        int data_size[3] = {0, 0, 0};
@@ -5696,7 +5767,10 @@ int (*dispatcher[MUSE_CAMERA_API_MAX]) (muse_module_h module) = {
        camera_dispatcher_set_media_bridge, /* MUSE_CAMERA_API_SET_MEDIA_BRIDGE */
        camera_dispatcher_unset_media_bridge, /* MUSE_CAMERA_API_UNSET_MEDIA_BRIDGE */
        camera_dispatcher_set_extra_preview_cb, /* MUSE_CAMERA_API_SET_EXTRA_PREVIEW_CB, */
-       camera_dispatcher_unset_extra_preview_cb /* MUSE_CAMERA_API_UNSET_EXTRA_PREVIEW_CB, */
+       camera_dispatcher_unset_extra_preview_cb, /* MUSE_CAMERA_API_UNSET_EXTRA_PREVIEW_CB, */
+       camera_dispatcher_attr_set_focus_level, /* MUSE_CAMERA_API_ATTR_SET_FOCUS_LEVEL */
+       camera_dispatcher_attr_get_focus_level, /* MUSE_CAMERA_API_ATTR_GET_FOCUS_LEVEL */
+       camera_dispatcher_attr_get_focus_level_range /* MUSE_CAMERA_API_ATTR_GET_FOCUS_LEVEL_RANGE */
 };
 
 
index bd51599..7888f34 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mmsvc-camera
 Summary:    A Camera module for muse server
-Version:    0.3.42
+Version:    0.3.43
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0