From 1ba361ac02c289a9cc180e8a0febb7bfef3de7a5 Mon Sep 17 00:00:00 2001 From: jae915 Date: Fri, 9 Dec 2022 14:28:35 +0900 Subject: [PATCH] add API for thread boosting Change-Id: I156b686643170ecca1c938a218bf169551f2f52d --- configure.ac | 15 ++++++++ packaging/libmm-camcorder.spec | 4 ++- src/Makefile.am | 9 +++++ src/include/mm_camcorder_boost.h | 36 +++++++++++++++++++ src/mm_camcorder_boost.c | 77 ++++++++++++++++++++++++++++++++++++++++ src/mm_camcorder_stillshot.c | 14 ++++++++ 6 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 src/include/mm_camcorder_boost.h create mode 100644 src/mm_camcorder_boost.c diff --git a/configure.ac b/configure.ac index d7afe31..9da14bc 100644 --- a/configure.ac +++ b/configure.ac @@ -109,6 +109,21 @@ PKG_CHECK_MODULES(RM, tv-resource-manager) AC_SUBST(RM_CFLAGS) AC_SUBST(RM_LIBS) +AC_ARG_ENABLE(boost, AC_HELP_STRING([--enable-boost], [enable boost]), +[ + case "${enableval}" in + yes) BOOST_TV=yes ;; + no) BOOST_TV=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-boost) ;; + esac +],[BOOST_TV=no]) +if test "x$BOOST_TV" = "xyes"; then +PKG_CHECK_MODULES(BOOST, capi-boost-tv) +AC_SUBST(BOOST_TV_CFLAGS) +AC_SUBST(BOOST_TV_LIBS) +fi +AM_CONDITIONAL([BOOST_TV], [test "x$BOOST_TV" = "xyes"]) + PKG_CHECK_MODULES(AUL, aul) AC_SUBST(AUL_CFLAGS) AC_SUBST(AUL_LIBS) diff --git a/packaging/libmm-camcorder.spec b/packaging/libmm-camcorder.spec index b42dd5a..094742a 100755 --- a/packaging/libmm-camcorder.spec +++ b/packaging/libmm-camcorder.spec @@ -1,6 +1,6 @@ Name: libmm-camcorder Summary: Camera and recorder library -Version: 0.10.281 +Version: 0.10.282 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 @@ -27,6 +27,7 @@ BuildRequires: pkgconfig(tv-resource-manager) BuildRequires: pkgconfig(tv-resource-information) BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(resource-center-api) +BuildRequires: pkgconfig(capi-boost-tv) %if (("%{_vd_cfg_product_type}" != "AUDIO") && ("%{_vd_cfg_target_repository}" != "emulator")) BuildRequires: pkgconfig(camera-conf-mgr-tv) %endif @@ -70,6 +71,7 @@ export CFLAGS+=" -D_LARGEFILE64_SOURCE -DGST_USE_UNSTABLE_API -DSYSCONFDIR=\\\"% %if "%{tizen_profile_name}" == "tv" --enable-rm \ --enable-product-tv \ + --enable-boost \ %if (("%{_vd_cfg_product_type}" != "AUDIO") && ("%{_vd_cfg_target_repository}" != "emulator")) --enable-camera-conf-mgr-tv \ %endif diff --git a/src/Makefile.am b/src/Makefile.am index e04f1bf..04dde15 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -38,6 +38,10 @@ if RM_SUPPORT libmmfcamcorder_la_SOURCES += mm_camcorder_rm.c endif +if BOOST_TV +libmmfcamcorder_la_SOURCES += mm_camcorder_boost.c +endif + libmmfcamcorder_la_CFLAGS = -I$(srcdir)/include \ $(GST_CFLAGS) \ $(GST_PLUGIN_BASE_CFLAGS) \ @@ -95,6 +99,11 @@ libmmfcamcorder_la_CFLAGS += $(CAMERA_CONF_MGR_CFLAGS) -D_MMCAMCORDER_CAMERA_CON libmmfcamcorder_la_LIBADD += $(CAMERA_CONF_MGR_LIBS) endif +if BOOST_TV +libmmfcamcorder_la_CFLAGS += $(BOOST_TV_CFLAGS) -D_MMCAMCORDER_CAMERA_BOOST_SUPPORT +libmmfcamcorder_la_LIBADD += $(BOOST_TV_LIBS) +endif + if PRODUCT_TV libmmfcamcorder_la_CFLAGS += -D_MMCAMCORDER_PRODUCT_TV endif diff --git a/src/include/mm_camcorder_boost.h b/src/include/mm_camcorder_boost.h new file mode 100644 index 0000000..2f013a0 --- /dev/null +++ b/src/include/mm_camcorder_boost.h @@ -0,0 +1,36 @@ +/* + * libmm-camcorder + * + * Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: jaekyu shim + * + * 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 __MM_CAMCORDER_BOOST_H__ +#define __MM_CAMCORDER_BOOST_H__ + +#include + +/*======================================================================================= +| GLOBAL FUNCTION PROTOTYPES | +========================================================================================*/ + +void _mmcamcorder_start_boosting(void); +void _mmcamcorder_stop_boosting(void); + + + +#endif /*__MM_CAMCORDER_BOOST_H__*/ + diff --git a/src/mm_camcorder_boost.c b/src/mm_camcorder_boost.c new file mode 100644 index 0000000..9ccc0ea --- /dev/null +++ b/src/mm_camcorder_boost.c @@ -0,0 +1,77 @@ +/* + * libmm-camcorder + * + * Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: jaekyu shim + * + * 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 FILES | +========================================================================================*/ +#ifdef _MMCAMCORDER_CAMERA_BOOST_SUPPORT +#include +#include "mm_camcorder_internal.h" +#include "mm_camcorder_boost.h" + + +static void __apply_thread_boosting(const boost_generic_info_t *generic_info) +{ + int ret = 0; + const char *thread_list[] = { + "vsrc_q-src", + "vsink_q-src", + "vsrc_s-src" + }; + const int thread_list_size = sizeof(thread_list) / sizeof(char *); + + pid_t pid = getpid(); + + for (int i = 0 ; i < thread_list_size ; i++) { + ret = boost_request_by_thread_name(pid, thread_list[i], (const boost_info_t *)generic_info); + MMCAM_LOG_INFO("apply boosting thread[%11s], event[%d], sched[%d] : ret[%d]", + thread_list[i], generic_info->event, generic_info->sched, ret); + } +} + +void _mmcamcorder_start_boosting(void) +{ + boost_generic_info_t generic_info = { + .parent.framework_type = BOOST_GENERIC, + .event = BOOST_GENERIC_EVENT_START, + .group = BOOST_CGROUP_END, + .sched = BOOST_API_SCHED_RR, + .boostingTimeMs = 0 + }; + + __apply_thread_boosting(&generic_info); +} + +void _mmcamcorder_stop_boosting(void) +{ + boost_generic_info_t generic_info = { + .parent.framework_type = BOOST_GENERIC, + .event = BOOST_GENERIC_EVENT_STOP, + .group = BOOST_CGROUP_END, + .sched = BOOST_API_SCHED_OTHER, + .boostingTimeMs = 0 + }; + + __apply_thread_boosting(&generic_info); +} + +#endif /* _MMCAMCORDER_CAMERA_BOOST_SUPPORT*/ + diff --git a/src/mm_camcorder_stillshot.c b/src/mm_camcorder_stillshot.c index df2dcd7..8bd9bf2 100644 --- a/src/mm_camcorder_stillshot.c +++ b/src/mm_camcorder_stillshot.c @@ -33,6 +33,11 @@ #include #include +#ifdef _MMCAMCORDER_CAMERA_BOOST_SUPPORT +#include "mm_camcorder_boost.h" +#endif /* _MMCAMCORDER_CAMERA_BOOST_SUPPORT */ + + /*--------------------------------------------------------------------------------------- | GLOBAL VARIABLE DEFINITIONS for internal | ---------------------------------------------------------------------------------------*/ @@ -1203,6 +1208,10 @@ static int __mmcamcorder_image_cmd_preview_start(MMHandleType handle) MMCAM_LOG_INFO("sound status %d", info->sound_status); } + +#ifdef _MMCAMCORDER_CAMERA_BOOST_SUPPORT + _mmcamcorder_start_boosting(); +#endif /* _MMCAMCORDER_CAMERA_BOOST_SUPPORT */ } cmd_error: @@ -1323,6 +1332,11 @@ int _mmcamcorder_video_capture_command(MMHandleType handle, int command) break; case _MMCamcorder_CMD_PREVIEW_STOP: ret = __mmcamcorder_image_cmd_preview_stop(handle); + +#ifdef _MMCAMCORDER_CAMERA_BOOST_SUPPORT + _mmcamcorder_stop_boosting(); +#endif /*_MMCAMCORDER_CAMERA_BOOST_SUPPORT */ + break; case _MMCamcorder_CMD_RECORD: case _MMCamcorder_CMD_PAUSE: -- 2.7.4