From aa6fdd8acc10433578afa2d123db52a5ee18407c Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 20 Apr 2021 15:26:55 +0900 Subject: [PATCH 01/16] Package version up to 3.0.3 Change-Id: I5e57f6ea8ea574ebd3a20d257ef255d332750a34 --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index ab9f47c..b37f171 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define HALTESTS_GCOV 0 Name: libtdm -Version: 3.0.2 +Version: 3.0.3 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From c10ada594e15b791fb711b59b13b1749c452ad15 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 28 May 2021 09:36:54 +0900 Subject: [PATCH 02/16] tdm: make a module_data at use_tdm_hal case. Even though there is no module_data at use_tdm_hal case, make a module_data for supporting the tdm api. Change-Id: I8c488ed3b7a12335255d10d311bf69703ad6bd99 --- include/tdm_backend.h | 4 ++-- src/tdm.c | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/include/tdm_backend.h b/include/tdm_backend.h index 5fe3f34..078815c 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -1375,8 +1375,8 @@ typedef tdm_error (*tdm_event_loop_timer_handler)(void *user_data); * at the initial time and call init() function of #tdm_backend_module. */ typedef struct _tdm_backend_module { - const char *name; /**< The module name of a backend module */ - const char *vendor; /**< The vendor name of a backend module */ + char *name; /**< The module name of a backend module */ + char *vendor; /**< The vendor name of a backend module */ unsigned long abi_version; /**< The ABI version of a backend module */ /** diff --git a/src/tdm.c b/src/tdm.c index 3f0363d..889b3b8 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -910,6 +910,7 @@ _tdm_display_load_hal_backend(tdm_private_display *private_display) hal_tdm_backend *tdm_backend = NULL; hal_tdm_display *hal_tdm_dpy = NULL; tdm_private_module *private_module = NULL; + tdm_backend_module *module_data = NULL; hal_tdm_event_source **event_sources = NULL; hal_tdm_caps_display caps; hal_tdm_caps_pp pp_caps; @@ -932,6 +933,15 @@ _tdm_display_load_hal_backend(tdm_private_display *private_display) return TDM_ERROR_OUT_OF_MEMORY; } + module_data = calloc(1, sizeof *module_data); + if (module_data == NULL) { + TDM_ERR("failed: alloc"); + goto fail; + } + module_data->name = hal_tdm_backend_get_name(tdm_backend); + module_data->vendor = hal_tdm_backend_get_vendor(tdm_backend); + module_data->abi_version = hal_tdm_backend_get_abi_version(tdm_backend); + hal_tdm_dpy = hal_tdm_backend_get_display(tdm_backend, &hret); if (hal_tdm_dpy == NULL || hret != HAL_TDM_ERROR_NONE) { TDM_ERR("failed hal_tdm_backend_get_display"); @@ -970,6 +980,7 @@ _tdm_display_load_hal_backend(tdm_private_display *private_display) private_module->use_hal_tdm = 1; private_module->htdm_backend = tdm_backend; + private_module->module_data = module_data; private_module->htdm_dpy = hal_tdm_dpy; private_module->private_display = private_display; private_display->current_module = private_module; @@ -1029,7 +1040,9 @@ fail: if (master_drm_fd >= 0) close(master_drm_fd); hal_tdm_put_backend(tdm_backend); + free(module_data); free(private_module); + return TDM_ERROR_NO_MODULE; } @@ -1295,6 +1308,7 @@ static void _tdm_display_unload_modules(tdm_private_display *private_display) { tdm_private_module *private_module = NULL, *bb = NULL; + tdm_backend_module *module_data = NULL; LIST_FOR_EACH_ENTRY_SAFE(private_module, bb, &private_display->module_list, link) { LIST_DEL(&private_module->link); @@ -1305,17 +1319,23 @@ _tdm_display_unload_modules(tdm_private_display *private_display) tdm_event_loop_source_remove(htdm_event_source); } } + + module_data = private_module->module_data; + if (module_data){ + free(module_data->name); + free(module_data->vendor); + free(module_data); + } hal_tdm_put_backend(private_module->htdm_backend); free(private_module); - continue; - } - - if (private_module->module_data) - private_module->module_data->deinit(private_module->bdata); - if (private_module->module) - dlclose(private_module->module); + } else { + if (private_module->module_data) + private_module->module_data->deinit(private_module->bdata); + if (private_module->module) + dlclose(private_module->module); - free(private_module); + free(private_module); + } } } /* LCOV_EXCL_STOP */ -- 2.7.4 From 2e13df96e75c71a34a9672ac71c2c1c88d685ba8 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 7 Jun 2021 16:59:32 +0900 Subject: [PATCH 03/16] tdm_display: return the module information at use_hal_tdm case. The two api can return the values at use_hal_tdm case. - tdm_display_get_backend_info - tdm_module_get_info Change-Id: Ie71280a15cbcf7019054bc3ae60ba3eb41dba52b --- src/tdm_display.c | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/src/tdm_display.c b/src/tdm_display.c index a7a44f7..46cd486 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -969,18 +969,17 @@ tdm_display_get_backend_info(tdm_display *dpy, const char **name, break; } - if (!private_module->use_hal_tdm) { - assert(module_data != NULL); - - if (name) - *name = module_data->name; - if (vendor) - *vendor = module_data->vendor; - if (major) - *major = TDM_BACKEND_GET_ABI_MAJOR(module_data->abi_version); - if (minor) - *minor = TDM_BACKEND_GET_ABI_MINOR(module_data->abi_version); - } + assert(module_data != NULL); + + if (name) + *name = module_data->name; + if (vendor) + *vendor = module_data->vendor; + if (major) + *major = TDM_BACKEND_GET_ABI_MAJOR(module_data->abi_version); + if (minor) + *minor = TDM_BACKEND_GET_ABI_MINOR(module_data->abi_version); + _pthread_mutex_unlock(&private_display->lock); return ret; @@ -1014,16 +1013,14 @@ tdm_module_get_info(tdm_module *module, const char **name, module_data = private_module->module_data; - if (!private_module->use_hal_tdm) { - if (name) - *name = module_data->name; - if (vendor) - *vendor = module_data->vendor; - if (major) - *major = TDM_BACKEND_GET_ABI_MAJOR(module_data->abi_version); - if (minor) - *minor = TDM_BACKEND_GET_ABI_MINOR(module_data->abi_version); - } + if (name) + *name = module_data->name; + if (vendor) + *vendor = module_data->vendor; + if (major) + *major = TDM_BACKEND_GET_ABI_MAJOR(module_data->abi_version); + if (minor) + *minor = TDM_BACKEND_GET_ABI_MINOR(module_data->abi_version); _pthread_mutex_unlock(&private_display->lock); -- 2.7.4 From d3ada646dfa3589f08bf6ce3288e206e7b952242 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 7 Jun 2021 17:15:42 +0900 Subject: [PATCH 04/16] Package version up to 3.0.4 Change-Id: Ic8322ef333d33fe3faf5824a8194831a27f5166b --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index b37f171..23c8c07 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define HALTESTS_GCOV 0 Name: libtdm -Version: 3.0.3 +Version: 3.0.4 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From a7cf2c071170b397d1af0a556c6c6f90a40d94d2 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 17 Jun 2021 11:06:07 +0900 Subject: [PATCH 05/16] tdm: fix the memory leak Change-Id: I2919b6f5296852a5ce2d93e4d866e5885fad6990 --- src/tdm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tdm.c b/src/tdm.c index 889b3b8..295f162 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -1040,6 +1040,8 @@ fail: if (master_drm_fd >= 0) close(master_drm_fd); hal_tdm_put_backend(tdm_backend); + free(module_data->name); + free(module_data->vendor); free(module_data); free(private_module); -- 2.7.4 From e18609b4b8523adb40b49d8ef46788fdde59f3ff Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 17 Jun 2021 11:21:27 +0900 Subject: [PATCH 06/16] Package version up to 3.0.5 Change-Id: I901c589369ef369f5b7829612d3616c975027d44 --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index 23c8c07..da6212e 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define HALTESTS_GCOV 0 Name: libtdm -Version: 3.0.4 +Version: 3.0.5 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From 8184afa7e6b07b06ae251f54f909070cde6ea68d Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 17 Jun 2021 14:29:51 +0900 Subject: [PATCH 07/16] tdm: fix the dereference value check if the variable is null. Change-Id: Iccf2775c5a77a72b8e96c66ba6b2e08840028b7f --- src/tdm.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/tdm.c b/src/tdm.c index 295f162..bdc7118 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -1040,9 +1040,13 @@ fail: if (master_drm_fd >= 0) close(master_drm_fd); hal_tdm_put_backend(tdm_backend); - free(module_data->name); - free(module_data->vendor); - free(module_data); + if (module_data) { + if (module_data->name) + free(module_data->name); + if (module_data->vendor) + free(module_data->vendor); + free(module_data); + } free(private_module); return TDM_ERROR_NO_MODULE; -- 2.7.4 From 50666c3b418f70bbcf90f20111184244ee221d0d Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 27 Jul 2021 18:23:00 +0900 Subject: [PATCH 08/16] add --with-default-dlog build option The default value of this option is yes. If this option sets no, the default log is stdout. Change-Id: Id710203804368e9397149e3dcf4b8a8be33db423 --- common/tdm_log.c | 4 ++++ configure.ac | 10 ++++++++++ packaging/libtdm.spec | 1 + 3 files changed, 15 insertions(+) diff --git a/common/tdm_log.c b/common/tdm_log.c index 975eb19..68621bf 100644 --- a/common/tdm_log.c +++ b/common/tdm_log.c @@ -59,7 +59,11 @@ #undef LOG_TAG #define LOG_TAG "TDM" +#if ENABLE_DLOG static unsigned int dlog_enable = 1; +#else +static unsigned int dlog_enable = 0; +#endif static unsigned int color_enable = 1; static unsigned int assert_level = TDM_LOG_LEVEL_NONE; diff --git a/configure.ac b/configure.ac index c0bf70a..d1f3dcc 100644 --- a/configure.ac +++ b/configure.ac @@ -37,6 +37,16 @@ AC_ARG_WITH(haltests, AS_HELP_STRING([--with-haltests=yes/no], [whether build/ru AM_CONDITIONAL(HAVE_HALTESTS, test "x$haltests" = "xyes") +AC_ARG_WITH(default-dlog, AS_HELP_STRING([--with-default-dlog=yes/no], [whether use dlog as a default log or not]), + [ use_dlog="$withval" ], + [ use_dlog="yes" ]) + +AM_CONDITIONAL(ENABLE_DLOG, test "x$use_dlog" = "xyes") + +if test "x$use_dlog" = "xyes"; then + AC_DEFINE([ENABLE_DLOG], 1, "Use dlog as a default log") +fi + AC_PATH_PROG([wayland_scanner], [wayland-scanner]) if test x$wayland_scanner = x; then AC_MSG_ERROR([wayland-scanner is needed to compile]) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index da6212e..98a2a55 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -85,6 +85,7 @@ LDFLAGS+=" -lgcov" %endif %reconfigure --disable-static --with-haltests=${HALTESTS} --bindir=%{_bindir}/hal \ + --with-default-dlog=yes \ --with-tdm-data-path=%{TZ_SYS_RO_SHARE}/tdm \ CFLAGS="${CFLAGS} -Wall -Werror" \ CXXFLAGS="${CXXFLAGS} -Wall -Werror" \ -- 2.7.4 From 29349f50749eb1ac7d42b9af4d1f2d5a0410842b Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 24 Aug 2021 14:56:27 +0900 Subject: [PATCH 09/16] Exclude dlog dependency when dlog disabled. Change-Id: Ieacca63024ed65a0719e1e7a84786db3af655741 Signed-off-by: Joonbum Ko --- common/tdm_log.c | 12 +++++++++--- configure.ac | 18 ++++++++++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/common/tdm_log.c b/common/tdm_log.c index 68621bf..b16f86b 100644 --- a/common/tdm_log.c +++ b/common/tdm_log.c @@ -42,7 +42,6 @@ #include #include #include -#include #include #include "tdm.h" @@ -60,8 +59,10 @@ #define LOG_TAG "TDM" #if ENABLE_DLOG +#include static unsigned int dlog_enable = 1; #else +#include static unsigned int dlog_enable = 0; #endif static unsigned int color_enable = 1; @@ -193,6 +194,7 @@ tdm_log_print(int level, const char *fmt, ...) if (level > tdm_log_debug_level) return; +#if ENABLE_DLOG if (dlog_enable) { log_priority dlog_prio; switch (level) { @@ -214,11 +216,15 @@ tdm_log_print(int level, const char *fmt, ...) va_start(arg, fmt); __dlog_vprint(LOG_ID_SYSTEM, dlog_prio, LOG_TAG, fmt, arg); va_end(arg); - } else { + } + else +#endif + { va_start(arg, fmt); _tdm_log_vprint_stdout(level, fmt, arg); va_end(arg); - } + } + assert(level > assert_level); } diff --git a/configure.ac b/configure.ac index d1f3dcc..c161573 100644 --- a/configure.ac +++ b/configure.ac @@ -54,8 +54,22 @@ fi PKG_CHECK_MODULES(WAYLAND_SCANNER, wayland-scanner >= 1.7.0) -PKG_CHECK_MODULES(TDM, dlog libtbm libpng pixman-1 wayland-server iniparser hal-api-tdm) -PKG_CHECK_MODULES(TDM_CLIENT, dlog libtbm wayland-client) +PKG_CHECK_MODULES(TDM, libtbm libpng pixman-1 wayland-server iniparser hal-api-tdm) +PKG_CHECK_MODULES(TDM_CLIENT, libtbm wayland-client) + +PKG_CHECK_EXISTS([dlog], [have_dlog="yes"], [have_dlog="no"]) +AC_MSG_CHECKING([Have dlog logger]) +AC_MSG_RESULT([${have_dlog}]) +if test "x${have_dlog}" = "xyes"; then + AC_DEFINE([HAVE_DLOG], [1], [Define to 1 if you have dlog]) + + PKG_CHECK_MODULES(DLOG, dlog) + + TDM_CFLAGS="$TDM_CFLAGS $DLOG_CFLAGS " + TDM_CLIENT_CFLAGS+="$TDM_CLIENT_CFLAGS $DLOG_CFLAGS " + TDM_LIBS+="$TDM_LIBS $DLOG_LIBS " + TDM_CLIENT_LIBS="$TDM_CLIENT_LIBS $DLOG_LIBS " +fi PKG_CHECK_MODULES(TTRACE, [ttrace], -- 2.7.4 From 4959859d6e18a34ff8bd78193163b872c2299e16 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 24 Aug 2021 19:22:56 +0900 Subject: [PATCH 10/16] Fix the misused preset output variables of autoconf Change-Id: Ic46d95687b0b8115278cd9ad388547e86b5ccc40 Signed-off-by: Joonbum Ko --- client/Makefile.am | 4 ++-- common/Makefile.am | 2 +- haltests/Makefile.am | 8 ++++---- src/Makefile.am | 4 ++-- tools/Makefile.am | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/client/Makefile.am b/client/Makefile.am index d50c6b2..fe3632a 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -18,11 +18,11 @@ libtdm_client_la_CFLAGS = \ $(WARN_CFLAGS) \ $(TDM_CLIENT_CFLAGS) \ -I$(top_srcdir)/include \ - -I$(top_srcdir)/protocol \ + -I$(top_builddir)/protocol \ -I$(top_srcdir)/src \ -I$(top_srcdir)/client libtdm_client_la_SOURCES = \ - $(top_srcdir)/protocol/tdm-protocol.c \ + $(top_builddir)/protocol/tdm-protocol.c \ tdm_client.c diff --git a/common/Makefile.am b/common/Makefile.am index e3f2dbe..d3c1fe5 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -8,5 +8,5 @@ libtdm_common_la_CFLAGS = \ $(WARN_CFLAGS) \ $(TDM_CFLAGS) \ -I$(top_srcdir)/include \ - -I$(top_srcdir)/protocol \ + -I$(top_builddir)/protocol \ -I$(top_srcdir)/src diff --git a/haltests/Makefile.am b/haltests/Makefile.am index c0da6de..45f7aa7 100644 --- a/haltests/Makefile.am +++ b/haltests/Makefile.am @@ -28,10 +28,10 @@ tdm_haltests_CXXFLAGS = \ $(CXXFLAGS) \ $(TDM_CFLAGS) \ $(EXTRA_CFLAGS) \ - -I../src \ - -I../include \ - -I../client \ - -I../tools \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/client \ + -I$(top_srcdir)/tools \ -I$(includedir)/gtest \ -fpermissive # The flag -w is used, because there are many warnings in libtdm's sources. diff --git a/src/Makefile.am b/src/Makefile.am index f9616e4..77a34cb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,11 +7,11 @@ libtdm_la_CFLAGS = \ $(WARN_CFLAGS) \ $(TDM_CFLAGS) \ -I$(top_srcdir)/include \ - -I$(top_srcdir)/protocol \ + -I$(top_builddir)/protocol \ -I$(top_srcdir)/src libtdm_la_SOURCES = \ - $(top_srcdir)/protocol/tdm-protocol.c \ + $(top_builddir)/protocol/tdm-protocol.c \ tdm_backend.c \ tdm_config.c \ tdm_server.c \ diff --git a/tools/Makefile.am b/tools/Makefile.am index 2f07236..163cfce 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -37,7 +37,7 @@ tdm_test_client_LDADD = \ #tdm-monitor tdm_monitor_SOURCES = \ - $(top_srcdir)/protocol/tdm-protocol.c \ + $(top_builddir)/protocol/tdm-protocol.c \ tdm_monitor.c tdm_monitor_LDFLAGS = \ -pie \ @@ -48,5 +48,5 @@ tdm_monitor_CFLAGS = \ $(CFLAGS) \ $(TDM_CFLAGS) \ -I$(top_srcdir)/include \ - -I$(top_srcdir)/protocol \ + -I$(top_builddir)/protocol \ -I$(top_srcdir)/src -- 2.7.4 From 3f66eefbafbdce878a10276e0a5d8299b7267b56 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Fri, 11 Feb 2022 18:10:25 +0900 Subject: [PATCH 11/16] add tdm_hwc_set_client_target_buffer_info Change-Id: I2d1e5b302cd15355e4869faf59802a77c5cf0ca5 --- include/tdm.h | 11 +++++++++++ include/tdm_backend.h | 8 ++++++++ src/tdm_hwc.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/include/tdm.h b/include/tdm.h index 92718f7..0772b7f 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -978,6 +978,17 @@ tbm_surface_queue_h tdm_hwc_get_client_target_buffer_queue(tdm_hwc *hwc, tdm_error *error); /** + * @brief Set the information of the client target buffer + * @details This function lets the backend know information of the target. + * @param[in] hwc A output hwc + * @param[in] info The information + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + * @since 3.1.0 + */ +tdm_error +tdm_hwc_set_client_target_buffer_info(tdm_hwc *hwc, tdm_hwc_window_info *info); + +/** * @brief Set the client(relative to the TDM) target buffer * @details This function lets the backend know the target buffer. * The target buffer contains the result of the gl composition with the diff --git a/include/tdm_backend.h b/include/tdm_backend.h index 078815c..e53eb10 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -1024,6 +1024,14 @@ typedef struct _tdm_func_hwc { * @return #TDM_ERROR_NONE if success. Otherwise, error value. */ tdm_error (*hwc_get_commit_interval)(tdm_hwc *hwc, tdm_hwc_commit_interval *interval); + + /** + * @brief Set the information of the client target buffer + * @param[in] hwc A output hwc + * @param[in] info The information + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ + tdm_error (*hwc_set_client_target_buffer_info)(tdm_hwc *hwc, tdm_hwc_window_info *info); } tdm_func_hwc; /** diff --git a/src/tdm_hwc.c b/src/tdm_hwc.c index 11a7d5d..18fca9c 100644 --- a/src/tdm_hwc.c +++ b/src/tdm_hwc.c @@ -521,6 +521,37 @@ tdm_hwc_get_client_target_buffer_queue(tdm_hwc *hwc, tdm_error *error) } EXTERN tdm_error +tdm_hwc_set_client_target_buffer_info(tdm_hwc *hwc, tdm_hwc_window_info *info) +{ + tdm_private_module *private_module; + tdm_func_hwc *func_hwc = NULL; + + HWC_FUNC_ENTRY(); + + _pthread_mutex_lock(&private_display->lock); + + private_module = private_hwc->private_module; + func_hwc = &private_module->func_hwc; + + if (private_module->use_hal_tdm) { + ret = (tdm_error)hal_tdm_hwc_set_client_target_buffer_info((hal_tdm_hwc *)private_hwc->hwc_backend, (hal_tdm_hwc_window_info *)info); + } else { + if (!func_hwc->hwc_set_client_target_buffer_info) { + /* LCOV_EXCL_START */ + _pthread_mutex_unlock(&private_display->lock); + return TDM_ERROR_NOT_IMPLEMENTED; + /* LCOV_EXCL_STOP */ + } + + ret = func_hwc->hwc_set_client_target_buffer_info(private_hwc->hwc_backend, info); + } + + _pthread_mutex_unlock(&private_display->lock); + + return ret; +} + +EXTERN tdm_error tdm_hwc_set_client_target_buffer(tdm_hwc *hwc, tbm_surface_h target_buffer, tdm_region damage) { tdm_private_module *private_module; -- 2.7.4 From b7ce75fbac3126f2717e4b6fd8567cdb708485a8 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Thu, 17 Feb 2022 13:51:33 +0900 Subject: [PATCH 12/16] Package version up to 3.1.0 Change-Id: Ie9bbfdf73df7c397895917eec2c18cff54bc027a --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index 98a2a55..8df8174 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define HALTESTS_GCOV 0 Name: libtdm -Version: 3.0.5 +Version: 3.1.0 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From b2a4adbe23461671b5c3d648001618aa90b1b64d Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 2 Mar 2022 10:32:55 +0900 Subject: [PATCH 13/16] do not use "+" at configure.ac fix the build break due to upgrade pkg-config 0.29.2. Change-Id: I1a32c1c8c572785fbe402097704ff60ef2bdb6eb --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index c161573..fc7ce92 100644 --- a/configure.ac +++ b/configure.ac @@ -66,8 +66,8 @@ if test "x${have_dlog}" = "xyes"; then PKG_CHECK_MODULES(DLOG, dlog) TDM_CFLAGS="$TDM_CFLAGS $DLOG_CFLAGS " - TDM_CLIENT_CFLAGS+="$TDM_CLIENT_CFLAGS $DLOG_CFLAGS " - TDM_LIBS+="$TDM_LIBS $DLOG_LIBS " + TDM_CLIENT_CFLAGS="$TDM_CLIENT_CFLAGS $DLOG_CFLAGS " + TDM_LIBS="$TDM_LIBS $DLOG_LIBS " TDM_CLIENT_LIBS="$TDM_CLIENT_LIBS $DLOG_LIBS " fi -- 2.7.4 From 8b8aa20ee03a738f23fb99c02d5feb5e1b52791a Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 2 Mar 2022 10:34:49 +0900 Subject: [PATCH 14/16] Package version up to 3.1.1 Change-Id: Ibf1ed41f1eec0aa118a3710afecdfbf4745a0b22 --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index 8df8174..ce44a4f 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define HALTESTS_GCOV 0 Name: libtdm -Version: 3.1.0 +Version: 3.1.1 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From 8f618c363d696421de3f881376fba7a29129f1a4 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Fri, 24 Jun 2022 20:15:44 +0900 Subject: [PATCH 15/16] tdm_test_client: Use tbm api for dump buffer for removing duplicate code Change-Id: I83e666c2e450c7bb884e1befee9620fd5f9c6cc1 --- tools/tdm_test_client.c | 168 ++---------------------------------------------- 1 file changed, 7 insertions(+), 161 deletions(-) diff --git a/tools/tdm_test_client.c b/tools/tdm_test_client.c index 14feed9..a3f9cb2 100644 --- a/tools/tdm_test_client.c +++ b/tools/tdm_test_client.c @@ -40,7 +40,6 @@ #include #include #include -#include #include "tdm_client.h" #include "tdm_macro.h" @@ -384,179 +383,26 @@ done: tdm_client_vblank_destroy(vblank); } -#define PNG_DEPTH 8 - -void -_tdm_client_get_buffer_full_size(tbm_surface_h buffer, int *buffer_w, int *buffer_h) -{ - tbm_surface_info_s info; - int ret; - - TDM_RETURN_IF_FAIL(buffer != NULL); - - ret = tbm_surface_get_info(buffer, &info); - TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE); - - if (buffer_w) { - if (IS_RGB(info.format)) - *buffer_w = info.planes[0].stride >> 2; - else - *buffer_w = info.planes[0].stride; - } - - if (buffer_h) - *buffer_h = info.planes[0].size / info.planes[0].stride; -} - static void -_tdm_client_dump_png(const char *file, const void *data, int width, - int height) -{ - FILE *fp; - - fp = fopen(file, "wb"); - TDM_RETURN_IF_FAIL(fp != NULL); - - png_structp pPngStruct = - png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!pPngStruct) { - fclose(fp); - return; - } - - png_infop pPngInfo = png_create_info_struct(pPngStruct); - if (!pPngInfo) { - png_destroy_write_struct(&pPngStruct, NULL); - fclose(fp); - return; - } - - png_init_io(pPngStruct, fp); - png_set_IHDR(pPngStruct, - pPngInfo, - width, - height, - PNG_DEPTH, - PNG_COLOR_TYPE_RGBA, - PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - - png_set_bgr(pPngStruct); - png_write_info(pPngStruct, pPngInfo); - - const int pixel_size = 4; // RGBA - png_bytep *row_pointers = - png_malloc(pPngStruct, height * sizeof(png_byte *)); - if (!row_pointers) { - png_destroy_write_struct(&pPngStruct, &pPngInfo); - fclose(fp); - return; - } - - unsigned int *blocks = (unsigned int *)data; - int y = 0; - int x = 0; - - for (; y < height; ++y) { - png_bytep row = - png_malloc(pPngStruct, sizeof(png_byte) * width * pixel_size); - if (!row) { - for (x = 0; x < y; x++) - png_free(pPngStruct, row_pointers[x]); - png_free(pPngStruct, row_pointers); - png_destroy_write_struct(&pPngStruct, &pPngInfo); - fclose(fp); - return; - } - - row_pointers[y] = (png_bytep)row; - for (x = 0; x < width; ++x) { - unsigned int curBlock = blocks[y * width + x]; - row[x * pixel_size] = (curBlock & 0xFF); - row[1 + x * pixel_size] = (curBlock >> 8) & 0xFF; - row[2 + x * pixel_size] = (curBlock >> 16) & 0xFF; - row[3 + x * pixel_size] = (curBlock >> 24) & 0xFF; - } - } - - png_write_image(pPngStruct, row_pointers); - png_write_end(pPngStruct, pPngInfo); - - for (y = 0; y < height; y++) - png_free(pPngStruct, row_pointers[y]); - png_free(pPngStruct, row_pointers); - - png_destroy_write_struct(&pPngStruct, &pPngInfo); - - fclose(fp); -} - -void -_tdm_client_dump_buffer(tbm_surface_h buffer, const char *file) +_dump_buffer(tbm_surface_h buffer, int count) { char temp[TDM_PATH_LEN] = {0,}; - tbm_surface_info_s info; - int len, ret; - const char *ext; - int bo_cnt; - int bw, bh; - char *dot, *p = temp; - const char *file_exts[2] = {"png", "raw"}; - - TDM_RETURN_IF_FAIL(buffer != NULL); - TDM_RETURN_IF_FAIL(file != NULL); + tbm_format tformat; + const char *ext, *file_exts[2] = {"png", "yuv"}; - ret = tbm_surface_map(buffer, TBM_OPTION_READ, &info); - TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE); + tformat = tbm_surface_get_format(buffer); - if (IS_RGB(info.format)) + if (IS_RGB(tformat)) ext = file_exts[0]; else ext = file_exts[1]; - dot = strrchr(file, '.'); - if (!dot || strlen(dot + 1) != 3 || strncmp(dot + 1, ext, 3)) { - len = strnlen(file, TDM_PATH_LEN - 5); - strncat(p, file, len); - p += len; - *(p++) = '.'; - strncat(p, ext, 4); - p += 3; - *p = '\0'; - } else { - len = strnlen(file, TDM_PATH_LEN - 1); - strncat(p, file, len); - p += len; - *p = '\0'; - } - - _tdm_client_get_buffer_full_size(buffer, &bw, &bh); - - bo_cnt = tbm_surface_internal_get_num_bos(buffer); - TDM_DBG("buffer: bo_cnt(%d) %dx%d(%dx%d) %c%c%c%c, plane: (%p+%d, %d,%d) (%p+%d, %d,%d) (%p+%d, %d,%d)", - bo_cnt, bw, bh, info.width, info.height, FOURCC_STR(info.format), - info.planes[0].ptr, info.planes[0].offset, info.planes[0].stride, info.planes[0].size, - info.planes[1].ptr, info.planes[1].offset, info.planes[1].stride, info.planes[1].size, - info.planes[2].ptr, info.planes[2].offset, info.planes[2].stride, info.planes[2].size); - - _tdm_client_dump_png(temp, info.planes[0].ptr, bw, bh); - - tbm_surface_unmap(buffer); - - printf("dump %s\n", temp); -} - -static void -_dump_buffer(tbm_surface_h buffer, int count) -{ - char temp[TDM_PATH_LEN] = {0,}; - - snprintf(temp, TDM_PATH_LEN, "/tmp/%c%c%c%c_%dx%d_%d", + snprintf(temp, TDM_PATH_LEN, "%c%c%c%c_%dx%d_%d", FOURCC_STR(tbm_surface_get_format(buffer)), tbm_surface_get_width(buffer), tbm_surface_get_height(buffer), count); - _tdm_client_dump_buffer(buffer, temp); + tbm_surface_internal_capture_buffer(buffer, "/tmp", temp, ext); } static void -- 2.7.4 From fe8bcd39bc87391503371d027f1138f42c70f876 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Mon, 27 Jun 2022 12:55:30 +0900 Subject: [PATCH 16/16] tdm_client: Remove duplicate code Change-Id: I1b61378b6a458c7196e3869aeabba1a15e119467 --- client/tdm_client.c | 190 +++++++++++++++------------------------------------- 1 file changed, 54 insertions(+), 136 deletions(-) diff --git a/client/tdm_client.c b/client/tdm_client.c index f322a49..0cf3df4 100644 --- a/client/tdm_client.c +++ b/client/tdm_client.c @@ -184,6 +184,11 @@ typedef struct _tdm_client_voutput_commit_handler_info { struct list_head call_link; } tdm_client_voutput_commit_handler_info; +typedef enum { + VBLANK_WAIT_TYPE_INTERVAL, + VBLANK_WAIT_TYPE_SEQUENCE, +} tdm_client_vblank_wait_type; + static unsigned int _tdm_client_check_wl_error(tdm_private_client *private_client, const char *func, int line) { @@ -1492,8 +1497,9 @@ tdm_client_vblank_set_enable_fake(tdm_client_vblank *vblank, unsigned int enable return TDM_ERROR_NONE; } -tdm_error -tdm_client_vblank_wait(tdm_client_vblank *vblank, unsigned int interval, tdm_client_vblank_handler func, void *user_data) +static tdm_error +_tdm_client_vblank_wait(tdm_client_vblank *vblank, tdm_client_vblank_wait_type wait_type, unsigned int wait_value, + tdm_client_vblank_handler func, void *user_data) { tdm_private_client *private_client; tdm_private_client_output *private_output; @@ -1503,14 +1509,6 @@ tdm_client_vblank_wait(tdm_client_vblank *vblank, unsigned int interval, tdm_cli unsigned int req_sec, req_usec; int ret = 0; - TDM_RETURN_VAL_IF_FAIL(vblank != NULL, TDM_ERROR_INVALID_PARAMETER); - TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER); - /* can't support "interval 0" and "getting current_msc" things because - * there is a socket communication between TDM client and server. It's impossible - * to return the current msc or sequence immediately. - */ - TDM_RETURN_VAL_IF_FAIL(interval > 0, TDM_ERROR_INVALID_PARAMETER); - private_vblank = vblank; private_output = private_vblank->private_output; private_client = private_output->private_client; @@ -1564,13 +1562,16 @@ tdm_client_vblank_wait(tdm_client_vblank *vblank, unsigned int interval, tdm_cli w->req_time = TDM_TIME(req_sec, req_usec); w->need_free = (private_vblank->sync) ? 0 : 1; - wl_tdm_vblank_wait_vblank(private_vblank->vblank, interval, w->req_id, req_sec, req_usec); + if (wait_type == VBLANK_WAIT_TYPE_INTERVAL) + wl_tdm_vblank_wait_vblank(private_vblank->vblank, wait_value, w->req_id, req_sec, req_usec); + else + wl_tdm_vblank_wait_vblank_seq(private_vblank->vblank, wait_value, w->req_id, req_sec, req_usec); if (private_vblank->enable_ttrace) TDM_TRACE_ASYNC_BEGIN((int)w->req_time, "TDM_Client_Vblank:%u", private_vblank->stamp); - TDM_DBG("vblank(%p) interval(%u) req_id(%d) req(%.6f)", - vblank, interval, w->req_id, w->req_time); + TDM_DBG("vblank(%p) wait_type(%d) wait_value(%u) req_id(%d) req(%.6f)", + vblank, wait_type, wait_value, w->req_id, w->req_time); private_vblank->req_time = w->req_time; @@ -1609,115 +1610,28 @@ tdm_client_vblank_wait(tdm_client_vblank *vblank, unsigned int interval, tdm_cli } tdm_error -tdm_client_vblank_wait_seq(tdm_client_vblank *vblank, unsigned int sequence, - tdm_client_vblank_handler func, void *user_data) +tdm_client_vblank_wait(tdm_client_vblank *vblank, unsigned int interval, tdm_client_vblank_handler func, void *user_data) { - tdm_private_client *private_client; - tdm_private_client_output *private_output; - tdm_private_client_vblank *private_vblank; - tdm_client_wait_info *w; - struct timespec tp; - unsigned int req_sec, req_usec; - int ret = 0; - TDM_RETURN_VAL_IF_FAIL(vblank != NULL, TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER); - private_vblank = vblank; - private_output = private_vblank->private_output; - private_client = private_output->private_client; - - pthread_mutex_lock(&private_client->lock); - - if (CHECK_WL_PROTOCOL_ERROR(private_client)) { - pthread_mutex_unlock(&private_client->lock); - return TDM_ERROR_PROTOCOL_ERROR; - } - - if (!private_vblank->started) - private_vblank->started = 1; - - if (!private_vblank->enable_fake) { - if (private_output->connection == TDM_OUTPUT_CONN_STATUS_DISCONNECTED) { - TDM_ERR("output disconnected"); - pthread_mutex_unlock(&private_client->lock); - return TDM_ERROR_OUTPUT_DISCONNECTED; - } - if (TDM_OUTPUT_DPMS_VSYNC_IS_OFF(private_output->dpms)) { - TDM_ERR("dpms %s", tdm_dpms_str(private_output->dpms)); - pthread_mutex_unlock(&private_client->lock); - return TDM_ERROR_DPMS_OFF; - } - } - - w = calloc(1, sizeof *w); - if (!w) { - /* LCOV_EXCL_START */ - - TDM_ERR("alloc failed"); - pthread_mutex_unlock(&private_client->lock); - return TDM_ERROR_OUT_OF_MEMORY; - - /* LCOV_EXCL_STOP */ - } - - w->private_vblank = private_vblank; - w->func = func; - w->user_data = user_data; - - LIST_ADDTAIL(&w->link, &private_vblank->wait_list); - LIST_INITHEAD(&w->call_link); - - clock_gettime(CLOCK_MONOTONIC, &tp); - req_sec = (unsigned int)tp.tv_sec; - req_usec = (unsigned int)(tp.tv_nsec / 1000); - - w->req_id = ++private_output->req_id; - w->req_time = TDM_TIME(req_sec, req_usec); - w->need_free = (private_vblank->sync) ? 0 : 1; - - wl_tdm_vblank_wait_vblank_seq(private_vblank->vblank, sequence, w->req_id, req_sec, req_usec); - - if (private_vblank->enable_ttrace) - TDM_TRACE_ASYNC_BEGIN((int)w->req_time, "TDM_Client_Vblank:%u", private_vblank->stamp); - - TDM_DBG("vblank(%p) sequence(%u) req_id(%d) req(%.6f)", - vblank, sequence, w->req_id, w->req_time); - - private_vblank->req_time = w->req_time; - - if (private_vblank->last_time >= w->req_time) - TDM_ERR("'last(%.6f) < req(%.6f)' failed", private_vblank->last_time, w->req_time); - - if (!private_vblank->sync) { - wl_display_flush(private_client->display); - pthread_mutex_unlock(&private_client->lock); - return TDM_ERROR_NONE; - } - - /* LCOV_EXCL_START */ - - while (ret != -1 && !w->need_free) - ret = wl_display_dispatch(private_client->display); - - clock_gettime(CLOCK_MONOTONIC, &tp); - TDM_DBG("block during %d us", - ((unsigned int)(tp.tv_sec * 1000000) + (unsigned int)(tp.tv_nsec / 1000)) - - (req_sec * 1000000 + req_usec)); - - LIST_DEL(&w->link); - free(w); - - if (CHECK_WL_PROTOCOL_ERROR(private_client)) { - pthread_mutex_unlock(&private_client->lock); - return TDM_ERROR_PROTOCOL_ERROR; - } + /* can't support "interval 0" and "getting current_msc" things because + * there is a socket communication between TDM client and server. It's impossible + * to return the current msc or sequence immediately. + */ + TDM_RETURN_VAL_IF_FAIL(interval > 0, TDM_ERROR_INVALID_PARAMETER); - pthread_mutex_unlock(&private_client->lock); + return _tdm_client_vblank_wait(vblank, VBLANK_WAIT_TYPE_INTERVAL, interval, func, user_data); +} - return TDM_ERROR_NONE; +tdm_error +tdm_client_vblank_wait_seq(tdm_client_vblank *vblank, unsigned int sequence, + tdm_client_vblank_handler func, void *user_data) +{ + TDM_RETURN_VAL_IF_FAIL(vblank != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER); - /* LCOV_EXCL_STOP */ + return _tdm_client_vblank_wait(vblank, VBLANK_WAIT_TYPE_SEQUENCE, sequence, func, user_data); } unsigned int @@ -1808,6 +1722,27 @@ _tdm_client_voutput_create_surface_from_param(tbm_bufmgr bufmgr, return tbm_surface; } + +static tdm_private_client_buffer * +_tdm_client_voutput_create_buffer(tdm_private_client_voutput *private_voutput, + tbm_surface_h tbm_surface, + struct wl_buffer *wl_buffer) +{ + tdm_private_client_buffer *buffer = NULL; + + buffer = calloc(1, sizeof *buffer); + TDM_RETURN_VAL_IF_FAIL(buffer != NULL, NULL); + + tbm_surface_internal_ref(tbm_surface); + wl_buffer_set_user_data(wl_buffer, tbm_surface); + + buffer->wl_buffer = wl_buffer; + + LIST_ADDTAIL(&buffer->link, &private_voutput->buffer_list); + + return buffer; +} + static void tdm_client_voutput_cb_buffer_import_with_id(void *data, struct wl_tdm_voutput *wl_voutput, @@ -1834,9 +1769,6 @@ tdm_client_voutput_cb_buffer_import_with_id(void *data, TDM_RETURN_IF_FAIL(private_voutput != NULL); - buffer = calloc(1, sizeof *buffer); - TDM_RETURN_IF_FAIL(buffer != NULL); - tbm_surface = _tdm_client_voutput_create_surface_from_param(private_voutput->bufmgr, 0, width, height, format, bpp, size, num_plane, @@ -1846,19 +1778,12 @@ tdm_client_voutput_cb_buffer_import_with_id(void *data, buf0, buf1, buf2); TDM_GOTO_IF_FAIL(tbm_surface != NULL, fail); - tbm_surface_internal_ref(tbm_surface); - wl_buffer_set_user_data(wl_buffer, tbm_surface); - - buffer->wl_buffer = wl_buffer; - - LIST_ADDTAIL(&buffer->link, &private_voutput->buffer_list); + buffer = _tdm_client_voutput_create_buffer(private_voutput, tbm_surface, wl_buffer); + TDM_GOTO_IF_FAIL(buffer != NULL, fail); return; fail: - if (buffer) - free(buffer); - if (wl_buffer) wl_buffer_destroy(wl_buffer); } @@ -1901,19 +1826,12 @@ tdm_client_voutput_cb_buffer_import_with_fd(void *data, buf0, buf1, buf2); TDM_GOTO_IF_FAIL(tbm_surface != NULL, fail); - tbm_surface_internal_ref(tbm_surface); - wl_buffer_set_user_data(wl_buffer, tbm_surface); - - buffer->wl_buffer = wl_buffer; - - LIST_ADDTAIL(&buffer->link, &private_voutput->buffer_list); + buffer = _tdm_client_voutput_create_buffer(private_voutput, tbm_surface, wl_buffer); + TDM_GOTO_IF_FAIL(buffer != NULL, fail); return; fail: - if (buffer) - free(buffer); - if (wl_buffer) wl_buffer_destroy(wl_buffer); } -- 2.7.4