add API for thread boosting 26/285326/10
authorjae915 <jae915@samsung.com>
Fri, 9 Dec 2022 05:28:35 +0000 (14:28 +0900)
committerjae915 <jae915@samsung.com>
Wed, 14 Dec 2022 04:08:19 +0000 (13:08 +0900)
Change-Id: I156b686643170ecca1c938a218bf169551f2f52d

configure.ac
packaging/libmm-camcorder.spec
src/Makefile.am
src/include/mm_camcorder_boost.h [new file with mode: 0644]
src/mm_camcorder_boost.c [new file with mode: 0644]
src/mm_camcorder_stillshot.c

index d7afe31..9da14bc 100644 (file)
@@ -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)
index b42dd5a..094742a 100755 (executable)
@@ -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
index e04f1bf..04dde15 100644 (file)
@@ -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 (file)
index 0000000..2f013a0
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * libmm-camcorder
+ *
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: jaekyu shim <jae915@samsung.com>
+ *
+ * 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 <mm_types.h>
+
+/*=======================================================================================
+| 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 (file)
index 0000000..9ccc0ea
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * libmm-camcorder
+ *
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: jaekyu shim <jae915@samsung.com>
+ *
+ * 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 <boost-api.h>
+#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*/
+
index df2dcd7..8bd9bf2 100644 (file)
 #include <libexif/exif-utils.h>
 #include <libexif/exif-data.h>
 
+#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: