From 2e34878fe12e363ed637f9d35d712407e9807fea Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Fri, 30 Mar 2018 11:47:22 +0900 Subject: [PATCH 01/16] set to null current mode after output update if output disconnected Change-Id: I27b78b4ea4cd63c1ba2ef480e2c3afab71d0140e Signed-off-by: Junkyeong Kim --- src/tdm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tdm.c b/src/tdm.c index 9f41287..15840f4 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -453,6 +453,9 @@ tdm_display_update_output(tdm_private_module *private_module, ret = _tdm_display_update_caps_output(private_module, pipe, output_backend, &private_output->caps); TDM_RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, ret); + + if (private_output->caps.status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED) + private_output->current_mode = NULL; } layers = func_output->output_get_layers(output_backend, &layer_count, &ret); -- 2.7.4 From 6f850479b3b81b84899e09fd99a51b580e00164b Mon Sep 17 00:00:00 2001 From: Boram Park Date: Fri, 30 Mar 2018 10:51:55 +0900 Subject: [PATCH 02/16] helper: try to dump all formats to a raw file Change-Id: Id2aa867fe19930aa01d5c3d73e1156b28aa45dd5 --- src/tdm_helper.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/tdm_helper.c b/src/tdm_helper.c index 61971e5..0c8b336 100644 --- a/src/tdm_helper.c +++ b/src/tdm_helper.c @@ -44,7 +44,7 @@ #define PNG_DEPTH 8 -static const char *file_exts[2] = {"png", "yuv"}; +static const char *file_exts[2] = {"png", "raw"}; int tdm_dump_enable; char *tdm_debug_dump_dir; @@ -332,9 +332,14 @@ tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file) 0); break; default: - TDM_ERR("can't dump %c%c%c%c buffer", FOURCC_STR(info.format)); - tbm_surface_unmap(buffer); - return; + _tdm_helper_dump_raw((const char*)temp, + info.planes[0].ptr, + info.planes[0].size, + info.planes[1].ptr, + info.planes[1].size, + info.planes[2].ptr, + info.planes[2].size); + break; } tbm_surface_unmap(buffer); -- 2.7.4 From e6035c2be184ee7fc40a7425a70b8f4d583246d0 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Fri, 30 Mar 2018 10:54:22 +0900 Subject: [PATCH 03/16] utests: use TDM_CONFIG_KEY_DEBUG_DUMP to dump all tc's buffer All tcs do tdm_display_init/deinit repeatly. "tdm-monitor -dump" can't be used. So we'd better use env. Change-Id: If518b97cc45e4d8620e89c2e513ad8056be1b8f9 --- utests/src/ut_tdm_env.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utests/src/ut_tdm_env.cpp b/utests/src/ut_tdm_env.cpp index 47144ab..25915aa 100644 --- a/utests/src/ut_tdm_env.cpp +++ b/utests/src/ut_tdm_env.cpp @@ -62,6 +62,10 @@ void TDMEnv::SetUp(void) const char *debug = getenv("TDM_UT_DEBUG_MODULE"); if (debug && strstr(debug, "1")) tdm_config_set_string(TDM_CONFIG_KEY_DEBUG_MODULE, "buffer,vblank,commit,pp,capture"); + + debug = getenv("TDM_UT_DEBUG_DUMP"); + if (debug && (debug[0] == '1')) + tdm_config_set_string(TDM_CONFIG_KEY_DEBUG_DUMP, "all"); } void TDMEnv::TearDown(void) -- 2.7.4 From 8dcd982832e67f110c4622fee789c755ecb28cf3 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Fri, 30 Mar 2018 10:55:24 +0900 Subject: [PATCH 04/16] utests: scale up to screen size We have to make more TCs to test various different sizes later. Change-Id: Ie36ef263d486d17905d0b73fcc58c23cef7a1d70 --- utests/src/ut_tdm_backend_pp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utests/src/ut_tdm_backend_pp.cpp b/utests/src/ut_tdm_backend_pp.cpp index f1d4991..794046c 100644 --- a/utests/src/ut_tdm_backend_pp.cpp +++ b/utests/src/ut_tdm_backend_pp.cpp @@ -627,7 +627,7 @@ TEST_P(TDMBackendPP, PPConvertScale) ASSERT_EQ(PreparePP(), true); ASSERT_EQ(PrepareBuffers(640, 480, dst_formats[f], - mode->hdisplay, mode->vdisplay / 2, dst_formats[f], + mode->hdisplay, mode->vdisplay, dst_formats[f], TDM_TRANSFORM_NORMAL), true); ASSERT_EQ(tdm_pp_set_done_handler(pp, _ut_tdm_pp_done_cb, &done), TDM_ERROR_NONE); -- 2.7.4 From 83d1e54bd591e16a6a4529501cbcb2b32a232383 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Fri, 30 Mar 2018 13:04:00 +0900 Subject: [PATCH 05/16] add LIST_FIRST_ENTRY, LIST_LAST_ENTRY macro Change-Id: I98adf7df5ecb3dd94627e06bda3eb253033b289d --- include/tdm_list.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/tdm_list.h b/include/tdm_list.h index 7475894..3873817 100644 --- a/include/tdm_list.h +++ b/include/tdm_list.h @@ -112,6 +112,12 @@ static inline int list_length(struct list_head *item) #define LIST_ENTRY(__type, __item, __field) \ ((__type *)(((char *)(__item)) - offsetof(__type, __field))) +#define LIST_FIRST_ENTRY(__ptr, __type, __field) \ + LIST_ENTRY(__type, (__ptr)->next, __field) + +#define LIST_LAST_ENTRY(__ptr, __type, __field) \ + LIST_ENTRY(__type, (__ptr)->prev, __field) + #define LIST_IS_EMPTY(__list) \ ((__list)->next == (__list)) -- 2.7.4 From 5ab3aca4983744171a2a6e61a4e6a4156c65a068 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Fri, 30 Mar 2018 13:32:35 +0900 Subject: [PATCH 06/16] package version up to 1.16.12 Change-Id: I79b8bfc47a794f715802d1cecf63bfbfa9b3ab18 --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index bb8f425..a4c14d7 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define UTEST_GCOV 0 Name: libtdm -Version: 1.16.11 +Version: 1.16.12 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From 6bb3ddcffcd48ac1cd29ba28631d3e0d7e6edfef Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 27 Mar 2018 13:29:44 +0900 Subject: [PATCH 07/16] utests: use ut_tdm_display_handle_events for timeout Change-Id: I4b672f599e77d5b8ed5ec8679cb7a5a9efa05d36 --- utests/src/ut_tdm_output.cpp | 2 +- utests/src/ut_tdm_vblank.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/utests/src/ut_tdm_output.cpp b/utests/src/ut_tdm_output.cpp index f44109e..227b3e2 100644 --- a/utests/src/ut_tdm_output.cpp +++ b/utests/src/ut_tdm_output.cpp @@ -1343,7 +1343,7 @@ TEST_P(TDMOutput, OutputWaitVblankBeforeDpmsOff) if (t == 9) ASSERT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE); while (!done) - ASSERT_EQ(tdm_display_handle_events(dpy), TDM_ERROR_NONE); + ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE); } } } diff --git a/utests/src/ut_tdm_vblank.cpp b/utests/src/ut_tdm_vblank.cpp index c72da58..b9ae767 100644 --- a/utests/src/ut_tdm_vblank.cpp +++ b/utests/src/ut_tdm_vblank.cpp @@ -1147,7 +1147,7 @@ TEST_P(TDMVblank, VblankWaitBeforeDpmsOff) ASSERT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF), TDM_ERROR_NONE); while (temp == 0) - ASSERT_EQ(tdm_display_handle_events(dpy), TDM_ERROR_NONE); + ASSERT_EQ(ut_tdm_display_handle_events(dpy), TDM_ERROR_NONE); } } -- 2.7.4 From cffc8b39ddda18ef339799dfb64d53c0401b7aa3 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Mon, 2 Apr 2018 07:49:01 +0900 Subject: [PATCH 08/16] output: call output_change callbacks asynchronously Change-Id: I72a8460101efd8e12a109c465ecd8249890b7801 --- src/tdm_output.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tdm_output.c b/src/tdm_output.c index 691d7bb..6543b7d 100644 --- a/src/tdm_output.c +++ b/src/tdm_output.c @@ -259,6 +259,7 @@ static tdm_error _tdm_output_call_thread_cb_status(tdm_private_output *private_output, tdm_output_conn_status status) { tdm_thread_cb_output_status output_status; + pid_t caller_tid = syscall(SYS_gettid); tdm_error ret; memset(&output_status, 0, sizeof output_status); @@ -266,7 +267,10 @@ _tdm_output_call_thread_cb_status(tdm_private_output *private_output, tdm_output output_status.base.length = sizeof output_status; output_status.base.object_stamp = private_output->stamp; output_status.base.data = NULL; - output_status.base.sync = 1; + if (tdm_thread_in_display_thread(caller_tid)) + output_status.base.sync = 0; + else + output_status.base.sync = 1; output_status.status = status; ret = tdm_thread_cb_call(private_output, &output_status.base, 1); -- 2.7.4 From eb4fcfa56a50de6b8bb7a0ca3906533d1a4593c1 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Mon, 2 Apr 2018 12:59:08 +0900 Subject: [PATCH 09/16] monitor: move to tools Change-Id: I251df596f253a71293ad16b76b280e1a0372c129 --- client/Makefile.am | 21 --------------------- tools/Makefile.am | 19 ++++++++++++++++++- {client => tools}/tdm_monitor.c | 0 3 files changed, 18 insertions(+), 22 deletions(-) rename {client => tools}/tdm_monitor.c (100%) diff --git a/client/Makefile.am b/client/Makefile.am index 859e2d3..d50c6b2 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -26,24 +26,3 @@ libtdm_client_la_SOURCES = \ $(top_srcdir)/protocol/tdm-protocol.c \ tdm_client.c -########################################################################## -### tdm-monitor -########################################################################## -bin_PROGRAMS = \ - tdm-monitor - -#tdm-monitor -tdm_monitor_SOURCES = \ - $(top_srcdir)/protocol/tdm-protocol.c \ - tdm_monitor.c -tdm_monitor_LDFLAGS = \ - -pie \ - ${LDFLAGS} -tdm_monitor_LDADD = $(TDM_CLIENT_LIBS) ../common/libtdm-common.la -tdm_monitor_CFLAGS = \ - -fPIE \ - $(CFLAGS) \ - $(TDM_CFLAGS) \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/protocol \ - -I$(top_srcdir)/src diff --git a/tools/Makefile.am b/tools/Makefile.am index d19e5e6..2f07236 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,6 +1,7 @@ bin_PROGRAMS = \ tdm-test-server \ - tdm-test-client + tdm-test-client \ + tdm-monitor #tdm-test-server tdm_test_server_SOURCES = \ @@ -33,3 +34,19 @@ tdm_test_client_CFLAGS = \ tdm_test_client_LDADD = \ $(TDM_LIBS) \ $(top_builddir)/client/libtdm-client.la + +#tdm-monitor +tdm_monitor_SOURCES = \ + $(top_srcdir)/protocol/tdm-protocol.c \ + tdm_monitor.c +tdm_monitor_LDFLAGS = \ + -pie \ + ${LDFLAGS} +tdm_monitor_LDADD = $(TDM_CLIENT_LIBS) ../common/libtdm-common.la +tdm_monitor_CFLAGS = \ + -fPIE \ + $(CFLAGS) \ + $(TDM_CFLAGS) \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/protocol \ + -I$(top_srcdir)/src diff --git a/client/tdm_monitor.c b/tools/tdm_monitor.c similarity index 100% rename from client/tdm_monitor.c rename to tools/tdm_monitor.c -- 2.7.4 From f2a5863445a2e5a34448bb02542a90d329ff4352 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Mon, 2 Apr 2018 13:55:28 +0900 Subject: [PATCH 10/16] config: move to src Change-Id: If7c889f1704be1c0aa0d8bbd2f4b5785368feb60 --- include/Makefile.am | 1 - packaging/libtdm.spec | 1 - {include => src}/tdm_config.h | 2 -- 3 files changed, 4 deletions(-) rename {include => src}/tdm_config.h (99%) diff --git a/include/Makefile.am b/include/Makefile.am index a16c981..0e0884a 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -4,7 +4,6 @@ libtdminclude_HEADERS = \ tdm_common.h \ tdm_types.h \ tdm_list.h \ - tdm_config.h \ tdm_log.h \ tdm_backend.h \ tdm_helper.h \ diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index a4c14d7..493b7b7 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -128,7 +128,6 @@ rm -f %{_unitdir_user}/basic.target.wants/tdm-socket-user.path %{_includedir}/tdm_list.h %{_includedir}/tdm_log.h %{_includedir}/tdm_types.h -%{_includedir}/tdm_config.h %{_includedir}/tdm_deprecated.h %{_libdir}/pkgconfig/libtdm.pc %{_libdir}/libtdm.so diff --git a/include/tdm_config.h b/src/tdm_config.h similarity index 99% rename from include/tdm_config.h rename to src/tdm_config.h index 1b1e36a..b6a34ba 100644 --- a/include/tdm_config.h +++ b/src/tdm_config.h @@ -49,8 +49,6 @@ extern "C" { * @brief The config header file for a frontend library */ -tdm_error -tdm_config_init(void); void tdm_config_deinit(void); -- 2.7.4 From e304b438166ecfce08fec402ffe1b9b855e54644 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Mon, 2 Apr 2018 15:37:57 +0900 Subject: [PATCH 11/16] thread: not reset find_funcs table when deinit tdm_thread_cb_call can be called after tdm_thread deinited. Change-Id: Ic58fd0a1c194e1f977f7b9c3b26017bbfed0a57a --- src/tdm_thread.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/tdm_thread.c b/src/tdm_thread.c index 2ca90a0..6ca28f2 100644 --- a/src/tdm_thread.c +++ b/src/tdm_thread.c @@ -291,15 +291,11 @@ tdm_thread_deinit(tdm_private_loop *private_loop) tdm_private_display *private_display; tdm_private_thread_cb *cb = NULL, *hh = NULL; tdm_error ret; - int i; TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED()); - if (!private_loop->private_thread) { - for (i = 0; i < TDM_THREAD_CB_MAX; i++) - find_funcs[i] = NULL; + if (!private_loop->private_thread) return; - } ret = _tdm_thread_exit(private_loop); if (ret != TDM_ERROR_NONE) @@ -344,9 +340,6 @@ tdm_thread_deinit(tdm_private_loop *private_loop) private_loop->private_thread = NULL; keep_private_thread = NULL; - for (i = 0; i < TDM_THREAD_CB_MAX; i++) - find_funcs[i] = NULL; - TDM_INFO("Finish a TDM event thread"); } -- 2.7.4 From 4abfab3661147e28398df7be7b35f3cf7973be8f Mon Sep 17 00:00:00 2001 From: Boram Park Date: Mon, 2 Apr 2018 15:51:42 +0900 Subject: [PATCH 12/16] thread: only allow a sync event from tdm-thread to display-thread A sync-type event from display-thread to tdm-thread can't be handled. If sync-type events happen in both threads at the same time, it would make a deadlock issue. Change-Id: Ic45207a173dfe9413f419506da1a6d36e86d06e3 --- src/tdm_thread.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/tdm_thread.c b/src/tdm_thread.c index 6ca28f2..ea891a2 100644 --- a/src/tdm_thread.c +++ b/src/tdm_thread.c @@ -640,16 +640,18 @@ tdm_thread_cb_call(void *object, tdm_thread_cb_base *cb_base, unsigned int propa assert(find_funcs[cb_base->type] != NULL); + if (keep_private_thread && keep_private_thread->thread_tid != caller_tid) { + /* A sync-type event from display-thread to tdm-thread can't be handled. + * If sync-type events happen in both threads at the same time, + * it would make a deadlock issue. + */ + assert(cb_base->sync != 1); + } + if (tdm_debug_module & TDM_DEBUG_THREAD) TDM_INFO("'%s' thread_cb (sync:%d, propagation:%d) ------", tdm_cb_type_str(cb_base->type), cb_base->sync, propagation); - /* handling only output-status as sync. below logic can't handle two sync-type events */ - if (cb_base->type == TDM_THREAD_CB_OUTPUT_STATUS) - assert(cb_base->sync == 1); - else - assert(cb_base->sync == 0); - if (!object) { object = find_funcs[cb_base->type](private_display, cb_base->object_stamp); if (!object) { -- 2.7.4 From 782d100ad830459baaee9f46b179fd4998e80607 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 3 Apr 2018 16:26:13 +0900 Subject: [PATCH 13/16] add plantuml, dot files Change-Id: I99569149d5b46722426a97e8f59e39fa3db526bc --- doc/tdm_header.txt | 109 ++++++++++++++++++++++++++++++++++++++++++++ doc/tdm_thread.txt | 40 ++++++++++++++++ doc/tdm_thread_deadlock.txt | 40 ++++++++++++++++ 3 files changed, 189 insertions(+) create mode 100644 doc/tdm_header.txt create mode 100644 doc/tdm_thread.txt create mode 100644 doc/tdm_thread_deadlock.txt diff --git a/doc/tdm_header.txt b/doc/tdm_header.txt new file mode 100644 index 0000000..59c3cef --- /dev/null +++ b/doc/tdm_header.txt @@ -0,0 +1,109 @@ +#dot -Tpng a.dot -o a.png + +digraph G +{ + compound=true; + nodesep=0.2; + ranksep=0.5; + node [fontname=Courier,fontsize=10,width=0,height=0,shape=box]; + + { + node [fontname=Courier,fontsize=10,shape=plaintext,color=white]; + edge [style=invis]; + Lv0 -> Lv1 -> Lv2 -> Lv3 -> Lv4 -> Lv5 -> Lv6; + } + + { + rank=same; + Lv0; + "tdm_common.h"; + } + + { + rank=same; + Lv1; + + "tdm_types.h"; + "tdm_client_types.h"; + } + + { + rank=same; + Lv2; + + "tdm_list.h"; + "tdm_log.h"; + "tdm_helper.h"; + "tdm.h"; + "tdm_backend.h"; + "tdm_client.h"; + } + + { + rank=same; + Lv3; + + "tdm_private_types.h"; + } + + { + rank=same; + Lv4; + + "tdm_config.h"; + "tdm_thread.h"; + } + + + { + rank=same; + Lv5; + + "tdm_macro.h"; + } + + + { + rank=same; + Lv6; + + "tdm_private.h"; + } + + "tdm_list.h" [style="filled",fillcolor=gold]; + "tdm_log.h" [style="filled",fillcolor=gold]; + "tdm_helper.h" [style="filled",fillcolor=gold]; + + "tdm_private.h" [style="filled",fillcolor=grey]; + "tdm_private_types.h" [style="filled",fillcolor=grey]; + "tdm_config.h" [style="filled",fillcolor=grey]; + "tdm_macro.h" [style="filled",fillcolor=grey]; + "tdm_thread.h" [style="filled",fillcolor=grey]; + + "tdm_backend.h" [style="filled",fillcolor=darkorchid1]; + "tdm.h" [style="filled",fillcolor=cornflowerblue]; + + "tdm_client.h" [style="filled",fillcolor= skyblue]; + + "tdm_client_types.h" -> "tdm_common.h"; + "tdm_client.h" -> "tdm_client_types.h"; + "tdm_types.h" -> "tdm_common.h"; + "tdm.h" -> "tdm_types.h"; + "tdm_helper.h" -> "tdm_types.h"; + "tdm_backend.h" -> "tdm_types.h"; + "tdm_macro.h" -> "tdm_private_types.h"; + "tdm_macro.h" -> "tdm_thread.h"; + "tdm_thread.h" -> "tdm_private_types.h"; + "tdm_private_types.h" -> "tdm_types.h"; + "tdm_private_types.h" -> "tdm_list.h"; + "tdm_private_types.h" -> "tdm_log.h"; + "tdm_private_types.h" -> "tdm_backend.h"; + "tdm_config.h" -> "tdm_private_types.h"; + "tdm_private.h" -> "tdm_private_types.h"; + "tdm_private.h" -> "tdm_macro.h"; + "tdm_private.h" -> "tdm_helper.h"; + "tdm_private.h" -> "tdm_config.h"; + "tdm_private.h" -> "tdm_thread.h"; + + "tdm_private_types.h" -> "tdm.h"; +} diff --git a/doc/tdm_thread.txt b/doc/tdm_thread.txt new file mode 100644 index 0000000..5e6f28f --- /dev/null +++ b/doc/tdm_thread.txt @@ -0,0 +1,40 @@ +@startuml + +hide footbox + +participant "E20 main thread" as main +participant "tdm thread" as sub + +== an asynchronous event == +sub <-- : an asynchronous event +activate sub + sub -> sub: calling thread callbacks in tdm-thread + activate sub + deactivate sub + main <-- sub: sending an asynchronous event +deactivate sub +activate main +main -> main: calling thread callbacks in main-thread +activate main +deactivate main +deactivate main + +== a synchronous event == +sub <-- : a synchronous event +activate sub + sub -> sub: calling thread callbacks in tdm-thread + activate sub + deactivate sub + sub --> main: sending a synchronous event + activate main + sub -> sub: pthread_cond_wait + activate sub + main -> main: calling thread callbacks in main-thread + activate main + deactivate main + main --> sub: pthread_cond_signal + deactivate sub + deactivate main +deactivate sub + +@enduml diff --git a/doc/tdm_thread_deadlock.txt b/doc/tdm_thread_deadlock.txt new file mode 100644 index 0000000..3a01697 --- /dev/null +++ b/doc/tdm_thread_deadlock.txt @@ -0,0 +1,40 @@ +@startuml + +hide footbox + +participant "E20 main thread" as main +participant "tdm thread" as sub + +sub <-- : a synchronous event +activate sub +--> main: a synchronous event +activate main +sub -> sub: calling thread callbacks in tdm-thread +activate sub +deactivate sub +sub --> main: sending a synchronous event +sub -> sub: pthread_cond_wait +activate sub +main -> main: calling thread callbacks in main-thread +activate main +deactivate main +main --> sub: sending a synchronous event +main -> main: pthread_cond_wait +activate main +deactivate sub +deactivate main +deactivate main +deactivate sub + +... (DEADLOCK) ... +note over main, sub + * 만약 main-thread, tdm-thread에서 동시에 synchronous event가 발생되게 되면 deadlock발생됨 + - 양쪽에서 모두 pthread_cond_wait에서 대기 + * sync event는 한쪽 thread에서만 발생되도록 보장되어야 함. + - tdm-thread -> main-thread방향으로만 sync event전달만 허용 + * sync event의 종류 + - backend에서 스스로 발생되는 event들만 가능 + - output status변경중에 connection/disconnection, virtual output creation/destruction +end note + +@enduml -- 2.7.4 From 04ab8db6936dfb9a5d1f91a7ab3ccf78f13d0af0 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 3 Apr 2018 16:46:34 +0900 Subject: [PATCH 14/16] config: not export tdm_config function to backend Change-Id: I2c8d162912c0971e6be5443c18535df81055eca7 --- include/tdm_backend.h | 22 ---------------------- src/tdm_config.h | 38 ++++++++++++++++++++++++++++++++++++-- src/tdm_private.h | 3 +++ 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/include/tdm_backend.h b/include/tdm_backend.h index 970cbc4..0416a90 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -1443,28 +1443,6 @@ tdm_event_loop_source_timer_update(tdm_event_loop_source *source, unsigned int m void tdm_event_loop_source_remove(tdm_event_loop_source *source); -/** - * @brief Get the ini value with given key - * @details - * @param[in] key The given key - * @param[in] default_value The default value - * @return the value of given key if success. Otherwise, default_value. - * @see #tdm_config_get_string - */ -int -tdm_config_get_int(const char *key, int default_value); - -/** - * @brief Get the ini value with given key - * @details - * @param[in] key The given key - * @param[in] default_value The default value - * @return the value of given key if success. Otherwise, default_value. - * @see #tdm_config_get_int - */ -const char * -tdm_config_get_string(const char *key, const char *default_value); - /** * @brief Trigger a 'need to validate' event. diff --git a/src/tdm_config.h b/src/tdm_config.h index b6a34ba..73eeb9f 100644 --- a/src/tdm_config.h +++ b/src/tdm_config.h @@ -49,11 +49,45 @@ extern "C" { * @brief The config header file for a frontend library */ -void -tdm_config_deinit(void); +/** + * @brief Get the ini value with given key + * @details + * @param[in] key The given key + * @param[in] default_value The default value + * @return the value of given key if success. Otherwise, default_value. + * @see #tdm_config_get_string + */ +int +tdm_config_get_int(const char *key, int default_value); + +/** + * @brief Get the ini value with given key + * @details + * @param[in] key The given key + * @param[in] default_value The default value + * @return the value of given key if success. Otherwise, default_value. + * @see #tdm_config_get_int + */ +const char * +tdm_config_get_string(const char *key, const char *default_value); +/** + * @brief Set the ini value with given key + * @details + * @param[in] key The given key + * @param[in] value The value + * @return TDM_ERROR_NONE if success. Otherwise, error value. + */ tdm_error tdm_config_set_int(const char *key, int value); + +/** + * @brief Set the ini value with given key + * @details + * @param[in] key The given key + * @param[in] value The value + * @return TDM_ERROR_NONE if success. Otherwise, error value. + */ tdm_error tdm_config_set_string(const char *key, const char *value); diff --git a/src/tdm_private.h b/src/tdm_private.h index 9b1951d..40f9e79 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -238,6 +238,9 @@ tdm_error tdm_display_enable_fps(tdm_private_display *private_display, int enable); void +tdm_config_deinit(void); + +void tdm_monitor_server_command(tdm_display *dpy, const char *options, char *reply, int *len); #ifdef __cplusplus -- 2.7.4 From 46142c8a75ff9d1008abab34f090d79600658ba7 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 3 Apr 2018 17:04:00 +0900 Subject: [PATCH 15/16] doc: fix carriage return Change-Id: I850997b73174ff25e60b59c33e52b0b8cb89d1bc --- doc/tdm_thread.txt | 80 ++++++++++++++++++++++----------------------- doc/tdm_thread_deadlock.txt | 71 ++++++++++++++++++---------------------- 2 files changed, 71 insertions(+), 80 deletions(-) diff --git a/doc/tdm_thread.txt b/doc/tdm_thread.txt index 5e6f28f..71bf7a3 100644 --- a/doc/tdm_thread.txt +++ b/doc/tdm_thread.txt @@ -1,40 +1,40 @@ -@startuml - -hide footbox - -participant "E20 main thread" as main -participant "tdm thread" as sub - -== an asynchronous event == -sub <-- : an asynchronous event -activate sub - sub -> sub: calling thread callbacks in tdm-thread - activate sub - deactivate sub - main <-- sub: sending an asynchronous event -deactivate sub -activate main -main -> main: calling thread callbacks in main-thread -activate main -deactivate main -deactivate main - -== a synchronous event == -sub <-- : a synchronous event -activate sub - sub -> sub: calling thread callbacks in tdm-thread - activate sub - deactivate sub - sub --> main: sending a synchronous event - activate main - sub -> sub: pthread_cond_wait - activate sub - main -> main: calling thread callbacks in main-thread - activate main - deactivate main - main --> sub: pthread_cond_signal - deactivate sub - deactivate main -deactivate sub - -@enduml +@startuml + +hide footbox + +participant "E20 main thread" as main +participant "tdm thread" as sub + +== an asynchronous event == +sub <-- : an asynchronous event +activate sub +sub -> sub: calling thread callbacks in tdm-thread +activate sub +deactivate sub +main <-- sub: sending an asynchronous event +deactivate sub +activate main +main -> main: calling thread callbacks in main-thread +activate main +deactivate main +deactivate main + +== a synchronous event == +sub <-- : a synchronous event +activate sub +sub -> sub: calling thread callbacks in tdm-thread +activate sub +deactivate sub +sub --> main: sending a synchronous event +activate main +sub -> sub: pthread_cond_wait +activate sub +main -> main: calling thread callbacks in main-thread +activate main +deactivate main +main --> sub: pthread_cond_signal +deactivate sub +deactivate main +deactivate sub + +@enduml diff --git a/doc/tdm_thread_deadlock.txt b/doc/tdm_thread_deadlock.txt index 3a01697..85cca6f 100644 --- a/doc/tdm_thread_deadlock.txt +++ b/doc/tdm_thread_deadlock.txt @@ -1,40 +1,31 @@ -@startuml - -hide footbox - -participant "E20 main thread" as main -participant "tdm thread" as sub - -sub <-- : a synchronous event -activate sub ---> main: a synchronous event -activate main -sub -> sub: calling thread callbacks in tdm-thread -activate sub -deactivate sub -sub --> main: sending a synchronous event -sub -> sub: pthread_cond_wait -activate sub -main -> main: calling thread callbacks in main-thread -activate main -deactivate main -main --> sub: sending a synchronous event -main -> main: pthread_cond_wait -activate main -deactivate sub -deactivate main -deactivate main -deactivate sub - -... (DEADLOCK) ... -note over main, sub - * 만약 main-thread, tdm-thread에서 동시에 synchronous event가 발생되게 되면 deadlock발생됨 - - 양쪽에서 모두 pthread_cond_wait에서 대기 - * sync event는 한쪽 thread에서만 발생되도록 보장되어야 함. - - tdm-thread -> main-thread방향으로만 sync event전달만 허용 - * sync event의 종류 - - backend에서 스스로 발생되는 event들만 가능 - - output status변경중에 connection/disconnection, virtual output creation/destruction -end note - -@enduml +@startuml + +hide footbox + +participant "E20 main thread" as main +participant "tdm thread" as sub + +sub <-- : a synchronous event +activate sub +--> main: a synchronous event +activate main +sub -> sub: calling thread callbacks in tdm-thread +activate sub +deactivate sub +sub --> main: sending a synchronous event +sub -> sub: pthread_cond_wait +activate sub +main -> main: calling thread callbacks in main-thread +activate main +deactivate main +main --> sub: sending a synchronous event +main -> main: pthread_cond_wait +activate main +deactivate sub +deactivate main +deactivate main +deactivate sub + +... (DEADLOCK) ... + +@enduml -- 2.7.4 From aa70cc4a91cfcc516231964af272bbe6299d9490 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 3 Apr 2018 17:04:40 +0900 Subject: [PATCH 16/16] doc: update dot file Change-Id: I6cfe80a55147c2bf9ef22b4e095c2c2607dc43b0 --- doc/tdm_header.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/tdm_header.txt b/doc/tdm_header.txt index 59c3cef..37be79c 100644 --- a/doc/tdm_header.txt +++ b/doc/tdm_header.txt @@ -98,7 +98,7 @@ digraph G "tdm_private_types.h" -> "tdm_list.h"; "tdm_private_types.h" -> "tdm_log.h"; "tdm_private_types.h" -> "tdm_backend.h"; - "tdm_config.h" -> "tdm_private_types.h"; + "tdm_config.h" -> "tdm_common.h"; "tdm_private.h" -> "tdm_private_types.h"; "tdm_private.h" -> "tdm_macro.h"; "tdm_private.h" -> "tdm_helper.h"; -- 2.7.4