From 3f62bcc8be0ec76c5a2394ea8fbc5c9f64b909e0 Mon Sep 17 00:00:00 2001 From: Jeongmo Yang Date: Thu, 13 May 2021 21:23:19 +0900 Subject: [PATCH] New internal APIs for focus level [Version] 0.4.56 [Issue Type] New feature Change-Id: I3021b27507a8ecc515d124c8bc6f9ce1c0aaeab4 Signed-off-by: Jeongmo Yang --- include/camera_internal.h | 51 +++++++++++++++++++++++++++ packaging/capi-media-camera.spec | 2 +- src/camera_internal.c | 74 ++++++++++++++++++++++++++++++++++++++++ test/camera_test.c | 22 ++++++++++++ 4 files changed, 148 insertions(+), 1 deletion(-) diff --git a/include/camera_internal.h b/include/camera_internal.h index 7f37ecf..27e2b37 100644 --- a/include/camera_internal.h +++ b/include/camera_internal.h @@ -378,6 +378,57 @@ int camera_set_extra_preview_cb(camera_h camera, camera_extra_preview_cb callbac int camera_unset_extra_preview_cb(camera_h camera); /** + * @internal + * @brief Sets the manual focus level. + * @since_tizen 6.5 + * @remarks The auto focusing will be stopped when 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 camera_attr_get_focus_level() + * @see camera_attr_get_focus_level_range() + */ +int camera_attr_set_focus_level(camera_h camera, int level); + +/** + * @internal + * @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 camera_attr_set_focus_level() + * @see camera_attr_get_focus_level_range() + */ +int camera_attr_get_focus_level(camera_h camera, int *level); + +/** + * @internal + * @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 camera_attr_set_focus_level() + * @see camera_attr_get_focus_level() + */ +int camera_attr_get_focus_level_range(camera_h camera, int *min, int *max); + +/** * @} */ #ifdef __cplusplus diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec index 9261581..144730f 100644 --- a/packaging/capi-media-camera.spec +++ b/packaging/capi-media-camera.spec @@ -1,6 +1,6 @@ Name: capi-media-camera Summary: A Camera API -Version: 0.4.55 +Version: 0.4.56 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/camera_internal.c b/src/camera_internal.c index ab2b4f1..1d91e36 100644 --- a/src/camera_internal.c +++ b/src/camera_internal.c @@ -435,6 +435,80 @@ int camera_attr_get_flash_brightness_range(camera_h camera, int *min, int *max) } +int camera_attr_set_focus_level(camera_h camera, int level) +{ + int ret = CAMERA_ERROR_NONE; + camera_cli_s *pc = (camera_cli_s *)camera; + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FOCUS_LEVEL; + camera_msg_param param; + + if (!pc || !pc->cb_info) { + CAM_LOG_ERROR("NULL handle"); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + CAM_LOG_INFO("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, level); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + + CAM_LOG_INFO("ret : 0x%x", ret); + + return ret; +} + + +int camera_attr_get_focus_level(camera_h camera, int *level) +{ + int ret = CAMERA_ERROR_NONE; + camera_cli_s *pc = (camera_cli_s *)camera; + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FOCUS_LEVEL; + + if (!pc || !pc->cb_info || !level) { + CAM_LOG_ERROR("NULL pointer %p %p", pc, level); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + CAM_LOG_INFO("Enter"); + + _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + + if (ret == CAMERA_ERROR_NONE) + *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FOCUS_LEVEL]; + + CAM_LOG_INFO("ret : 0x%x", ret); + + return ret; +} + + +int camera_attr_get_focus_level_range(camera_h camera, int *min, int *max) +{ + int ret = CAMERA_ERROR_NONE; + camera_cli_s *pc = (camera_cli_s *)camera; + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FOCUS_LEVEL_RANGE; + + if (!pc || !pc->cb_info || !min || !max) { + CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + CAM_LOG_INFO("Enter"); + + _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + + if (ret == CAMERA_ERROR_NONE) { + *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_FOCUS_LEVEL_RANGE][0]; + *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_FOCUS_LEVEL_RANGE][1]; + } + + CAM_LOG_INFO("ret : 0x%x", ret); + + return ret; +} + + int camera_set_extra_preview_cb(camera_h camera, camera_extra_preview_cb callback, void *user_data) { int ret = CAMERA_ERROR_NONE; diff --git a/test/camera_test.c b/test/camera_test.c index 4cd0b99..181d885 100644 --- a/test/camera_test.c +++ b/test/camera_test.c @@ -912,6 +912,7 @@ static void print_menu() g_print("\t '6' Exposure value \n"); g_print("\t '7' F number \n"); g_print("\t '8' Display reuse hint \n"); + g_print("\t '9' Manual Focus \n"); g_print("\t 'i' ISO \n"); g_print("\t 'r' Rotate camera input \n"); g_print("\t 'f' Flip camera input \n"); @@ -1218,6 +1219,27 @@ static void setting_menu(gchar buf) g_print("set display reuse hint result : 0x%x\n", err); } break; + case '9': /* Setting > Manual focus */ + g_print("*Manual focus !\n"); + camera_attr_get_focus_level_range(hcamcorder->camera, &min, &max); + if (min > max) { + g_print("\n\tManual focus is NOT SUPPORTED\n"); + break; + } + camera_attr_get_focus_level(hcamcorder->camera, &idx); + g_print("\tCurrent focus level (%d)\n", idx); + g_print("\tSelect focus level min(%d) - max(%d) > ", min, max); + err = scanf("%d", &idx); + flush_stdin(); + bret = camera_attr_set_focus_level(hcamcorder->camera, idx); + idx = -1; + if (bret == CAMERA_ERROR_NONE) { + bret = camera_attr_get_focus_level(hcamcorder->camera, &idx); + g_print("\tfocus level[%d] after set\n", idx); + } else { + g_print("\tset focus level failed[0x%x]\n", bret); + } + break; case 'i': /* Setting > ISO */ g_print("*ISO !\n"); camera_attr_foreach_supported_iso(hcamcorder->camera, iso_mode_cb, NULL); -- 2.7.4