From f4aa0253c0f401b86bf1769e200b216cd2d8b66d Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 25 Oct 2016 15:44:03 +0900 Subject: [PATCH 01/16] implementation for SCREEN_PREROTATION_HINT Change-Id: I8c5e90ac2a4f2119af380c405e31cf9645ea7a25 --- src/tdm_macro.h | 2 +- tools/tdm_test_server.c | 31 ++++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/tdm_macro.h b/src/tdm_macro.h index 0dfd031..2bbadcf 100644 --- a/src/tdm_macro.h +++ b/src/tdm_macro.h @@ -149,7 +149,7 @@ extern "C" { /* don't using !,$,# */ #define TDM_DELIM "@^&*+-|,:~" #define TDM_ALIGN(a, b) (((a) + ((b) - 1)) & ~((b) - 1)) - +#define TDM_SWAP(a, b) ({ int t; t = a; a = b; b = t; }) #define TDM_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) struct tdm_type_name { diff --git a/tools/tdm_test_server.c b/tools/tdm_test_server.c index d59c6ce..b948a96 100644 --- a/tools/tdm_test_server.c +++ b/tools/tdm_test_server.c @@ -748,6 +748,7 @@ interpret_args(tdm_test_server *data) } } +static unsigned int tts_screen_prerotation_hint; static tdm_test_server tts_data; static int tts_buffer_key; #define TTS_BUFFER_KEY ((unsigned long)&tts_buffer_key) @@ -757,6 +758,8 @@ buffer_allocate(int width, int height, int format, int flags) { tdm_test_server_buffer *tb = calloc(1, sizeof *tb); TDM_EXIT_IF_FAIL(tb != NULL); + if (tts_screen_prerotation_hint % 180) + TDM_SWAP(width, height); tb->b = tbm_surface_internal_create_with_flags(width, height, format, flags); TDM_EXIT_IF_FAIL(tb->b != NULL); tdm_helper_clear_buffer(tb->b); @@ -846,6 +849,14 @@ main(int argc, char *argv[]) char temp[TDM_SERVER_REPLY_MSG_LEN]; int len = sizeof temp; tdm_error ret; + const char *value; + + value = (const char*)getenv("SCREEN_PREROTATION_HINT"); + if (value) { + char *end; + tts_screen_prerotation_hint = strtol(value, &end, 10); + printf("SCREEN_PREROTATION_HINT = %d", tts_screen_prerotation_hint); + } signal(SIGINT, exit_test); /* 2 */ signal(SIGTERM, exit_test); /* 15 */ @@ -1036,12 +1047,22 @@ layer_setup(tdm_test_server_layer *l, tbm_surface_h b) /* The size and format information should be same with buffer's */ tbm_surface_get_info(b, &info); - if (IS_RGB(info.format)) { - l->info.src_config.size.h = info.planes[0].stride >> 2; - l->info.src_config.size.v = info.height; + if (tts_screen_prerotation_hint % 180) { + if (IS_RGB(info.format)) { + l->info.src_config.size.h = info.height; + l->info.src_config.size.v = info.planes[0].stride >> 2; + } else { + l->info.src_config.size.h = info.height; + l->info.src_config.size.v = info.planes[0].stride; + } } else { - l->info.src_config.size.h = info.planes[0].stride; - l->info.src_config.size.v = info.height; + if (IS_RGB(info.format)) { + l->info.src_config.size.h = info.planes[0].stride >> 2; + l->info.src_config.size.v = info.height; + } else { + l->info.src_config.size.h = info.planes[0].stride; + l->info.src_config.size.v = info.height; + } } l->info.src_config.format = info.format; -- 2.7.4 From 1547433b722384d2404001a9537bee29ae8d5341 Mon Sep 17 00:00:00 2001 From: YoungJun Cho Date: Wed, 2 Nov 2016 23:01:16 +0900 Subject: [PATCH 02/16] ut: stubs: synchronize tbm_surface_internal.h modification This patch synchronizes tbm_surface_internal.h modification with libtbm one. Change-Id: Ie134209554a88e872bb7871add0269c110ed1abe Signed-off-by: YoungJun Cho --- ut/stubs/tbm_surface_internal.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ut/stubs/tbm_surface_internal.h b/ut/stubs/tbm_surface_internal.h index 367adf6..6c85b77 100644 --- a/ut/stubs/tbm_surface_internal.h +++ b/ut/stubs/tbm_surface_internal.h @@ -143,7 +143,7 @@ void tbm_surface_internal_unref(tbm_surface_h surface); * @brief Gets the number of buffer objects associated with the tbm_surface. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] surface : the tbm_surface_h - * @return the number of buffer objects associated with the tbm_surface_h, otherwise -1. + * @return the number of buffer objects associated with the tbm_surface_h, otherwise 0. * @par Example @code #include @@ -196,7 +196,7 @@ tbm_bo tbm_surface_internal_get_bo(tbm_surface_h surface, int bo_idx); * @brief Gets the size of the surface. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] surface : the tbm_surface_h - * @return the size of tbm_surface, otherwise -1. + * @return the size of tbm_surface, otherwise 0. * @par Example @code #include @@ -211,7 +211,7 @@ tbm_bo tbm_surface_internal_get_bo(tbm_surface_h surface, int bo_idx); tbm_surface_destroy (surface); @endcode */ -int tbm_surface_internal_get_size(tbm_surface_h surface); +unsigned int tbm_surface_internal_get_size(tbm_surface_h surface); /** * @brief Gets size, offset and pitch data of plane by the plane_index. @@ -287,7 +287,7 @@ int tbm_surface_internal_get_bpp(tbm_format format); * @since_tizen 2.4 * @param[in] surface : the tbm_surface_h * @param[in] plane_idx : the bo index in the tbm_surface - * @return bo index of plane, otherwise -1. + * @return bo index of plane, otherwise 0. * @par Example @code #include -- 2.7.4 From 2495d630baed51c6a4da43b43f88fb6bdff2900b Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 9 Nov 2016 20:03:42 +0900 Subject: [PATCH 03/16] remove the profile condition at spec file make the symbolic link of tdm-socket-user.path to basic.target.want Change-Id: I47da65873b0cf94001300f06c78b72d28aecd335 --- packaging/libtdm.spec | 9 --------- 1 file changed, 9 deletions(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index babfb34..74240d0 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -97,23 +97,14 @@ install -m 644 service/tdm-socket-user.path %{buildroot}%{_unitdir_user} %__mkdir_p %{_unitdir}/graphical.target.wants ln -sf ../tdm-socket.path %{_unitdir}/graphical.target.wants/ -%if "%{?profile}" == "mobile" || "%{?profile}" == "wearable" %__mkdir_p %{_unitdir_user}/basic.target.wants ln -sf ../tdm-socket-user.path %{_unitdir_user}/basic.target.wants/ -%else -%__mkdir_p %{_unitdir_user}/default.target.wants -ln -sf ../tdm-socket-user.path %{_unitdir_user}/default.target.wants/ -%endif %post -p /sbin/ldconfig %postun -p /sbin/ldconfig rm -f %{_unitdir}/graphical.target.wants/tdm-socket.path -%if "%{?profile}" == "mobile" || "%{?profile}" == "wearable" rm -f %{_unitdir_user}/basic.target.wants/tdm-socket-user.path -%else -rm -f %{_unitdir_user}/default.target.wants/tdm-socket-user.path -%endif %files %manifest %{name}.manifest -- 2.7.4 From e2d83c7009ffb1a271da62e89ac794ec193fb228 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 11 Nov 2016 13:25:43 +0900 Subject: [PATCH 04/16] pakcage version up to 1.4.6 Change-Id: I6030b818f3755ffa860f3d21f87bf184deff64b9 --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index 74240d0..5a8431e 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -1,7 +1,7 @@ %bcond_with utest Name: libtdm -Version: 1.4.5 +Version: 1.4.6 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From 761c8d49c3c3b59d593dd343e1afdee9641a8b69 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Tue, 15 Nov 2016 14:33:53 +0900 Subject: [PATCH 05/16] Added cursor available size in caps output Change-Id: Ief1b42e61b51ba4710430f68b40e48bc3b189844 --- include/tdm.h | 15 +++++++++++++++ include/tdm_backend.h | 6 ++++++ src/tdm_display.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/include/tdm.h b/include/tdm.h index ee7b160..7834591 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -358,6 +358,21 @@ tdm_output_get_available_size(tdm_output *output, int *min_w, int *min_h, int *max_w, int *max_h, int *preferred_align); /** + * @brief Get the available cursor size of a output object. + * @details -1 means that a TDM backend module doesn't define the value. + * @param[in] output A output object + * @param[out] min_w The minimum width which TDM can handle + * @param[out] min_h The minimum height which TDM can handle + * @param[out] max_w The maximum width which TDM can handle + * @param[out] max_h The maximum height which TDM can handle + * @param[out] preferred_align The preferred align width which TDM can handle + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ +tdm_error +tdm_output_get_cursor_available_size(tdm_output *output, int *min_w, int *min_h, + int *max_w, int *max_h, int *preferred_align); + +/** * @brief Get the physical size of a output object. * @param[in] output A output object * @param[out] mmWidth The milimeter width diff --git a/include/tdm_backend.h b/include/tdm_backend.h index c1c2120..91ee955 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -119,6 +119,12 @@ typedef struct _tdm_caps_output { int preferred_align; /**< The prefered align. -1 means "not defined" */ tdm_output_capability capabilities; /**< The capabilities of output. @since 1.4.1 */ + + int cursor_min_w; /**< The minimun width. -1 means "not defined" @since 1.5.0 */ + int cursor_min_h; /**< The minimun height. -1 means "not defined" @since 1.5.0 */ + int cursor_max_w; /**< The maximum width. -1 means "not defined" @since 1.5.0 */ + int cursor_max_h; /**< The maximum height. -1 means "not defined" @since 1.5.0 */ + int cursor_preferred_align; /**< The prefered align. -1 means "not defined" @since 1.5.0 */ } tdm_caps_output; /** diff --git a/src/tdm_display.c b/src/tdm_display.c index 7d9b08f..975e72f 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -714,6 +714,48 @@ tdm_output_get_available_size(tdm_output *output, int *min_w, int *min_h, } EXTERN tdm_error +tdm_output_get_cursor_available_size(tdm_output *output, int *min_w, int *min_h, + int *max_w, int *max_h, int *preferred_align) +{ + OUTPUT_FUNC_ENTRY(); + + _pthread_mutex_lock(&private_display->lock); + + if (!tdm_display_check_module_abi(private_display, 1, 5)) { + + if (min_w) + *min_w = -1; + if (min_h) + *min_h = -1; + if (max_w) + *max_w = -1; + if (max_h) + *max_h = -1; + if (preferred_align) + *preferred_align = -1; + + _pthread_mutex_unlock(&private_display->lock); + + return TDM_ERROR_BAD_MODULE; + } + + if (min_w) + *min_w = private_output->caps.cursor_min_w; + if (min_h) + *min_h = private_output->caps.cursor_min_h; + if (max_w) + *max_w = private_output->caps.cursor_max_w; + if (max_h) + *max_h = private_output->caps.cursor_max_h; + if (preferred_align) + *preferred_align = private_output->caps.cursor_preferred_align; + + _pthread_mutex_unlock(&private_display->lock); + + return ret; +} + +EXTERN tdm_error tdm_output_get_physical_size(tdm_output *output, unsigned int *mmWidth, unsigned int *mmHeight) { -- 2.7.4 From 15482c9def34edcdc743e292d92207bdf81a4e33 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 22 Nov 2016 12:58:42 +0900 Subject: [PATCH 06/16] fix syntax error Change-Id: I990affce73424c66ea40962efd85398b34d74767 --- include/tdm_backend.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/tdm_backend.h b/include/tdm_backend.h index 91ee955..9255c4a 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -844,7 +844,7 @@ typedef tdm_error (*tdm_event_loop_timer_handler)(void *user_data); */ #define TDM_BACKEND_SET_ABI_VERSION(major, minor) \ (((major) << 16) & TDM_BACKEND_MAJOR_VERSION_MASK) | \ - ((major) & TDM_BACKEND_MINOR_VERSION_MASK) + ((minor) & TDM_BACKEND_MINOR_VERSION_MASK) /** * @brief -- 2.7.4 From 7166b42c4d1994cd7f1772b8588d5d80c0b650a6 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Mon, 21 Nov 2016 19:51:11 +0900 Subject: [PATCH 07/16] version up to 1.5.0 Change-Id: I3dd1ea8b28871046d474e814a75ad97f7e2fa74e --- configure.ac | 2 +- doc/tdm_doc.h | 2 +- packaging/libtdm.spec | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index f460e0a..1ed0aac 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ AC_PREREQ([2.60]) m4_define([tdm_major_version], [1]) -m4_define([tdm_minor_version], [4]) +m4_define([tdm_minor_version], [5]) m4_define([tdm_micro_version], [0]) m4_define([tdm_version], [tdm_major_version.tdm_minor_version.tdm_micro_version]) diff --git a/doc/tdm_doc.h b/doc/tdm_doc.h index ec0d3f3..2bcfce7 100644 --- a/doc/tdm_doc.h +++ b/doc/tdm_doc.h @@ -39,7 +39,7 @@ /** * @mainpage TDM * @author Boram Park, boram1288.park@samsung.com - * @version 1.4.0 + * @version 1.5.0 * @par Introduction * TDM stands for Tizen Display Manager. It's the display HAL layer for tizen * display server. It offers the frontend APIs(@ref tdm.h) for a frontend user diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index 5a8431e..28c3b85 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -1,7 +1,7 @@ %bcond_with utest Name: libtdm -Version: 1.4.6 +Version: 1.5.0 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From 90712dbef2f5dc4971c6857c3e8eadab1f8bdeb5 Mon Sep 17 00:00:00 2001 From: YoungJun Cho Date: Thu, 24 Nov 2016 14:20:18 +0900 Subject: [PATCH 08/16] tdm_backend: change _check_abi_version() return value This patch changes _check_abi_version() return value as 0 for success, -1 for failure. The caller only checks the result is less than 0 or not, so it is dead code. Change-Id: I194817bcd0fd928f0b66cdd0154c3669c95548f5 Signed-off-by: YoungJun Cho --- src/tdm_backend.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tdm_backend.c b/src/tdm_backend.c index c83b3da..acbde8e 100644 --- a/src/tdm_backend.c +++ b/src/tdm_backend.c @@ -53,14 +53,14 @@ _check_abi_version(tdm_backend_module *module, int abimaj, int abimin) int minor = TDM_BACKEND_GET_ABI_MINOR(module->abi_version); if (major < abimaj) goto failed; - if (major > abimaj) return 1; + if (major > abimaj) return 0; if (minor < abimin) goto failed; - return 1; + return 0; failed: TDM_ERR("The ABI version(%d.%d) of '%s' is less than %d.%d", major, minor, module->name ? module->name : "unknown", abimaj, abimin); - return 0; + return -1; } EXTERN tdm_error -- 2.7.4 From cd161b3b009da14bbdef9e3015320d053ebbf550 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Wed, 23 Nov 2016 10:20:58 +0900 Subject: [PATCH 09/16] add capture type enum Change-Id: I7d9b8f148f703128619b45a29128979708d15861 --- include/tdm_common.h | 8 ++++++++ include/tdm_types.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/tdm_common.h b/include/tdm_common.h index b5a9c2e..1894505 100644 --- a/include/tdm_common.h +++ b/include/tdm_common.h @@ -148,6 +148,14 @@ typedef enum { } tdm_capture_capability; /** + * @brief The capture type enumeration + */ +typedef enum { + TDM_CAPTURE_TYPE_ONESHOT = (1 << 0), /**< The oneshot capture */ + TDM_CAPTURE_TYPE_STREAM = (1 << 1), /**< The stream capture */ +} tdm_capture_type; + +/** * @brief The output change enumeration of #tdm_output_change_handler */ typedef enum { diff --git a/include/tdm_types.h b/include/tdm_types.h index fd446cd..3cd8560 100644 --- a/include/tdm_types.h +++ b/include/tdm_types.h @@ -122,7 +122,7 @@ typedef struct _tdm_info_pp { typedef struct _tdm_info_capture { tdm_info_config dst_config; tdm_transform transform; - int oneshot; + tdm_capture_type type; int frequency; int flags; } tdm_info_capture; -- 2.7.4 From a8bfecf9035a5b604b54a172b2185f87463f7f4f Mon Sep 17 00:00:00 2001 From: Boram Park Date: Wed, 23 Nov 2016 11:44:19 +0900 Subject: [PATCH 10/16] add tdm_display_get_capture_available_size & tdm_display_get_max_layer_count Change-Id: I3d3507ef1e3a590422032c35ee1f5c3adc7f2a44 --- include/tdm.h | 25 +++++++++++++++++++++++++ src/tdm_display.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/include/tdm.h b/include/tdm.h index 7834591..15b1f56 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -203,6 +203,31 @@ tdm_display_get_catpure_available_formats(tdm_display *dpy, const tbm_format **formats, int *count); /** + * @brief Get the capture available size of a display object. + * @details -1 means that a TDM backend module doesn't define the value. + * @param[in] dpy A display object + * @param[out] min_w The minimum width which TDM can handle + * @param[out] min_h The minimum height which TDM can handle + * @param[out] max_w The maximum width which TDM can handle + * @param[out] max_h The maximum height which TDM can handle + * @param[out] preferred_align The preferred align width which TDM can handle + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ +tdm_error +tdm_display_get_capture_available_size(tdm_display *dpy, int *min_w, int *min_h, + int *max_w, int *max_h, int *preferred_align); + +/** + * @brief Get the max layer counts which a display object can show on screen. + * @details -1 means that a TDM backend module doesn't define the value. + * @param[in] dpy A display object + * @param[out] count The max count of layers + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ +tdm_error +tdm_display_get_max_layer_count(tdm_display *dpy, int *max_count); + +/** * @brief Get the output counts which a display object has. * @param[in] dpy A display object * @param[out] count The count of outputs diff --git a/src/tdm_display.c b/src/tdm_display.c index 975e72f..d240d97 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -246,6 +246,52 @@ tdm_display_get_catpure_available_formats(tdm_display *dpy, } EXTERN tdm_error +tdm_display_get_capture_available_size(tdm_display *dpy, int *min_w, int *min_h, + int *max_w, int *max_h, int *preferred_align) +{ + DISPLAY_FUNC_ENTRY(); + + _pthread_mutex_lock(&private_display->lock); + + if (!(private_display->capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE)) { + TDM_ERR("no capture capability"); + _pthread_mutex_unlock(&private_display->lock); + return TDM_ERROR_NO_CAPABILITY; + } + + if (min_w) + *min_w = private_display->caps_capture.min_w; + if (min_h) + *min_h = private_display->caps_capture.min_h; + if (max_w) + *max_w = private_display->caps_capture.max_w; + if (max_h) + *max_h = private_display->caps_capture.max_h; + if (preferred_align) + *preferred_align = private_display->caps_capture.preferred_align; + + _pthread_mutex_unlock(&private_display->lock); + + return ret; +} + +EXTERN tdm_error +tdm_display_get_max_layer_count(tdm_display *dpy, int *max_count) +{ + DISPLAY_FUNC_ENTRY(); + + TDM_RETURN_VAL_IF_FAIL(max_count != NULL, TDM_ERROR_INVALID_PARAMETER); + + _pthread_mutex_lock(&private_display->lock); + + *max_count = private_display->caps_display.max_layer_count; + + _pthread_mutex_unlock(&private_display->lock); + + return ret; +} + +EXTERN tdm_error tdm_display_get_output_count(tdm_display *dpy, int *count) { tdm_private_output *private_output = NULL; -- 2.7.4 From ea1924cbdffc6ba69cf537c97a1e78334512db80 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Wed, 23 Nov 2016 11:45:38 +0900 Subject: [PATCH 11/16] treat 0 also as a "not-defined" value Change-Id: I208c7bb8a151433dd808ccb4ccafe84315577318 --- include/tdm_backend.h | 54 +++++++++++++++++++++++---------------------------- src/tdm.c | 2 +- src/tdm_display.c | 42 +++++++++++++++++++-------------------- src/tdm_helper.c | 24 ++++++++++++++--------- src/tdm_macro.h | 3 +++ 5 files changed, 64 insertions(+), 61 deletions(-) diff --git a/include/tdm_backend.h b/include/tdm_backend.h index 9255c4a..0949372 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -85,7 +85,7 @@ typedef void (*tdm_output_dpms_handler)(tdm_output *output, * @see The display_get_capability() function of #tdm_func_display */ typedef struct _tdm_caps_display { - int max_layer_count; /**< The maximum layer count. -1 means "not defined" */ + int max_layer_count; /**< The maximum layer count */ } tdm_caps_display; /** @@ -112,19 +112,19 @@ typedef struct _tdm_caps_output { unsigned int mmHeight; /**< The physical height (milimeter) */ unsigned int subpixel; /**< The subpixel */ - int min_w; /**< The minimun width. -1 means "not defined" */ - int min_h; /**< The minimun height. -1 means "not defined" */ - int max_w; /**< The maximum width. -1 means "not defined" */ - int max_h; /**< The maximum height. -1 means "not defined" */ - int preferred_align; /**< The prefered align. -1 means "not defined" */ + int min_w; /**< The minimun width */ + int min_h; /**< The minimun height */ + int max_w; /**< The maximum width */ + int max_h; /**< The maximum height */ + int preferred_align; /**< The prefered align */ tdm_output_capability capabilities; /**< The capabilities of output. @since 1.4.1 */ - int cursor_min_w; /**< The minimun width. -1 means "not defined" @since 1.5.0 */ - int cursor_min_h; /**< The minimun height. -1 means "not defined" @since 1.5.0 */ - int cursor_max_w; /**< The maximum width. -1 means "not defined" @since 1.5.0 */ - int cursor_max_h; /**< The maximum height. -1 means "not defined" @since 1.5.0 */ - int cursor_preferred_align; /**< The prefered align. -1 means "not defined" @since 1.5.0 */ + int cursor_min_w; /**< The minimun width. @since 1.5.0 */ + int cursor_min_h; /**< The minimun height. @since 1.5.0 */ + int cursor_max_w; /**< The maximum width. @since 1.5.0 */ + int cursor_max_h; /**< The maximum height. @since 1.5.0 */ + int cursor_preferred_align; /**< The prefered align. @since 1.5.0 */ } tdm_caps_output; /** @@ -168,16 +168,13 @@ typedef struct _tdm_caps_pp { tbm_format *formats; /**< The @b newly-allocated array. will be freed in frontend. */ - int min_w; /**< The minimun width. -1 means "not defined" */ - int min_h; /**< The minimun height. -1 means "not defined" */ - int max_w; /**< The maximum width. -1 means "not defined" */ - int max_h; /**< The maximum height. -1 means "not defined" */ - int preferred_align; /**< The prefered align. -1 means "not defined" */ + int min_w; /**< The minimun width */ + int min_h; /**< The minimun height */ + int max_w; /**< The maximum width */ + int max_h; /**< The maximum height */ + int preferred_align; /**< The prefered align */ - /**< The attach count which a PP object can handle. - * -1 means "not defined". - * @since 1.2.0 - */ + /**< The attach count which a PP object can handle. @since 1.2.0 */ int max_attach_count; } tdm_caps_pp; @@ -192,16 +189,13 @@ typedef struct _tdm_caps_capture { tbm_format *formats; /**< The @b newly-allocated array of formats. will be freed in frontend. */ - int min_w; /**< The minimun width. -1 means "not defined" */ - int min_h; /**< The minimun height. -1 means "not defined" */ - int max_w; /**< The maximum width. -1 means "not defined" */ - int max_h; /**< The maximum height. -1 means "not defined" */ - int preferred_align; /**< The prefered align. -1 means "not defined" */ + int min_w; /**< The minimun width */ + int min_h; /**< The minimun height */ + int max_w; /**< The maximum width */ + int max_h; /**< The maximum height */ + int preferred_align; /**< The prefered align */ - /**< The attach count which a capture object can handle. - * -1 means "not defined". - * @since 1.2.0 - */ + /**< The attach count which a capture object can handle. @since 1.2.0 */ int max_attach_count; } tdm_caps_capture; @@ -220,7 +214,7 @@ typedef struct _tdm_func_display { * is connected.\n * If a hardware has the restriction of the number of max usable layer count, * a backend module can set the max count to max_layer_count of #tdm_caps_display - * structure. Otherwise, set -1. + * structure. */ tdm_error (*display_get_capability)(tdm_backend_data *bdata, tdm_caps_display *caps); diff --git a/src/tdm.c b/src/tdm.c index 74ebcb2..4918a22 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -213,7 +213,7 @@ _tdm_display_destroy_private_display(tdm_private_display *private_display) _tdm_display_destroy_caps_capture(&private_display->caps_capture); private_display->capabilities = 0; - private_display->caps_display.max_layer_count = -1; + private_display->caps_display.max_layer_count = 0; } static tdm_error diff --git a/src/tdm_display.c b/src/tdm_display.c index d240d97..a34daab 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -182,15 +182,15 @@ tdm_display_get_pp_available_size(tdm_display *dpy, int *min_w, int *min_h, } if (min_w) - *min_w = private_display->caps_pp.min_w; + *min_w = TDM_FRONT_VALUE(private_display->caps_pp.min_w); if (min_h) - *min_h = private_display->caps_pp.min_h; + *min_h = TDM_FRONT_VALUE(private_display->caps_pp.min_h); if (max_w) - *max_w = private_display->caps_pp.max_w; + *max_w = TDM_FRONT_VALUE(private_display->caps_pp.max_w); if (max_h) - *max_h = private_display->caps_pp.max_h; + *max_h = TDM_FRONT_VALUE(private_display->caps_pp.max_h); if (preferred_align) - *preferred_align = private_display->caps_pp.preferred_align; + *preferred_align = TDM_FRONT_VALUE(private_display->caps_pp.preferred_align); _pthread_mutex_unlock(&private_display->lock); @@ -260,15 +260,15 @@ tdm_display_get_capture_available_size(tdm_display *dpy, int *min_w, int *min_h, } if (min_w) - *min_w = private_display->caps_capture.min_w; + *min_w = TDM_FRONT_VALUE(private_display->caps_capture.min_w); if (min_h) - *min_h = private_display->caps_capture.min_h; + *min_h = TDM_FRONT_VALUE(private_display->caps_capture.min_h); if (max_w) - *max_w = private_display->caps_capture.max_w; + *max_w = TDM_FRONT_VALUE(private_display->caps_capture.max_w); if (max_h) - *max_h = private_display->caps_capture.max_h; + *max_h = TDM_FRONT_VALUE(private_display->caps_capture.max_h); if (preferred_align) - *preferred_align = private_display->caps_capture.preferred_align; + *preferred_align = TDM_FRONT_VALUE(private_display->caps_capture.preferred_align); _pthread_mutex_unlock(&private_display->lock); @@ -284,7 +284,7 @@ tdm_display_get_max_layer_count(tdm_display *dpy, int *max_count) _pthread_mutex_lock(&private_display->lock); - *max_count = private_display->caps_display.max_layer_count; + *max_count = TDM_FRONT_VALUE(private_display->caps_display.max_layer_count); _pthread_mutex_unlock(&private_display->lock); @@ -744,15 +744,15 @@ tdm_output_get_available_size(tdm_output *output, int *min_w, int *min_h, _pthread_mutex_lock(&private_display->lock); if (min_w) - *min_w = private_output->caps.min_w; + *min_w = TDM_FRONT_VALUE(private_output->caps.min_w); if (min_h) - *min_h = private_output->caps.min_h; + *min_h = TDM_FRONT_VALUE(private_output->caps.min_h); if (max_w) - *max_w = private_output->caps.max_w; + *max_w = TDM_FRONT_VALUE(private_output->caps.max_w); if (max_h) - *max_h = private_output->caps.max_h; + *max_h = TDM_FRONT_VALUE(private_output->caps.max_h); if (preferred_align) - *preferred_align = private_output->caps.preferred_align; + *preferred_align = TDM_FRONT_VALUE(private_output->caps.preferred_align); _pthread_mutex_unlock(&private_display->lock); @@ -786,15 +786,15 @@ tdm_output_get_cursor_available_size(tdm_output *output, int *min_w, int *min_h, } if (min_w) - *min_w = private_output->caps.cursor_min_w; + *min_w = TDM_FRONT_VALUE(private_output->caps.cursor_min_w); if (min_h) - *min_h = private_output->caps.cursor_min_h; + *min_h = TDM_FRONT_VALUE(private_output->caps.cursor_min_h); if (max_w) - *max_w = private_output->caps.cursor_max_w; + *max_w = TDM_FRONT_VALUE(private_output->caps.cursor_max_w); if (max_h) - *max_h = private_output->caps.cursor_max_h; + *max_h = TDM_FRONT_VALUE(private_output->caps.cursor_max_h); if (preferred_align) - *preferred_align = private_output->caps.cursor_preferred_align; + *preferred_align = TDM_FRONT_VALUE(private_output->caps.cursor_preferred_align); _pthread_mutex_unlock(&private_display->lock); diff --git a/src/tdm_helper.c b/src/tdm_helper.c index 999bd1a..f5e39b3 100644 --- a/src/tdm_helper.c +++ b/src/tdm_helper.c @@ -613,9 +613,11 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) tdm_status_str(private_output->caps.status), tdm_dpms_str(private_output->current_dpms_value), private_output->caps.subpixel, - private_output->caps.preferred_align, - private_output->caps.min_w, private_output->caps.min_h, - private_output->caps.max_w, private_output->caps.max_h, + TDM_FRONT_VALUE(private_output->caps.preferred_align), + TDM_FRONT_VALUE(private_output->caps.min_w), + TDM_FRONT_VALUE(private_output->caps.min_h), + TDM_FRONT_VALUE(private_output->caps.max_w), + TDM_FRONT_VALUE(private_output->caps.max_h), private_output->caps.mmWidth, private_output->caps.mmHeight); TDM_SNPRINTF(reply, len, "\t%d modes:\n", private_output->caps.mode_count); @@ -766,9 +768,11 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) } TDM_SNPRINTF(reply, len, "\n"); TDM_SNPRINTF(reply, len, "size\t: min(%dx%d) max(%dx%d) align_w(%d)\n", - private_display->caps_pp.min_w, private_display->caps_pp.min_h, - private_display->caps_pp.max_w, private_display->caps_pp.max_h, - private_display->caps_pp.preferred_align); + TDM_FRONT_VALUE(private_display->caps_pp.min_w), + TDM_FRONT_VALUE(private_display->caps_pp.min_h), + TDM_FRONT_VALUE(private_display->caps_pp.max_w), + TDM_FRONT_VALUE(private_display->caps_pp.max_h), + TDM_FRONT_VALUE(private_display->caps_pp.preferred_align)); if (!LIST_IS_EMPTY(&private_display->pp_list)) { TDM_SNPRINTF(reply, len, "-------------------------------------------------------------\n"); TDM_SNPRINTF(reply, len, "src(format size crop) | dst(format size crop) | transform\n"); @@ -808,9 +812,11 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) } TDM_SNPRINTF(reply, len, "\n"); TDM_SNPRINTF(reply, len, "size\t: min(%dx%d) max(%dx%d) align_w(%d)\n", - private_display->caps_capture.min_w, private_display->caps_capture.min_h, - private_display->caps_capture.max_w, private_display->caps_capture.max_h, - private_display->caps_capture.preferred_align); + TDM_FRONT_VALUE(private_display->caps_capture.min_w), + TDM_FRONT_VALUE(private_display->caps_capture.min_h), + TDM_FRONT_VALUE(private_display->caps_capture.max_w), + TDM_FRONT_VALUE(private_display->caps_capture.max_h), + TDM_FRONT_VALUE(private_display->caps_capture.preferred_align)); if (!LIST_IS_EMPTY(&private_display->capture_list)) { TDM_SNPRINTF(reply, len, "-----------------------------------\n"); TDM_SNPRINTF(reply, len, "dst(format size crop) | transform\n"); diff --git a/src/tdm_macro.h b/src/tdm_macro.h index 2bbadcf..61d8658 100644 --- a/src/tdm_macro.h +++ b/src/tdm_macro.h @@ -135,6 +135,9 @@ extern "C" { } \ } +#define TDM_NOT_DEFINED_VALUE (-1) +#define TDM_FRONT_VALUE(n) (((n) > 0) ? (n) : TDM_NOT_DEFINED_VALUE) + #define TDM_TIME(sec, usec) ((double)(sec) + ((double)(usec)) / 1000000.0) #define TDM_TIME_SEC(time) ((unsigned int)(time)) #define TDM_TIME_USEC(time) (unsigned int)(((time) - (unsigned int)(time)) * 1000000.0) -- 2.7.4 From 954bff7eca6dc25684bd830c128cfe8fe24de96b Mon Sep 17 00:00:00 2001 From: Boram Park Date: Wed, 23 Nov 2016 13:16:44 +0900 Subject: [PATCH 12/16] check capture capability Change-Id: If3db8bd96f960ddf5ddd8d22f9e9a8ea20ecdc58 --- src/tdm.c | 6 ++++-- src/tdm_capture.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/tdm.c b/src/tdm.c index 4918a22..5d2714c 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -726,8 +726,10 @@ _tdm_display_check_backend_functions(tdm_private_display *private_display) if (private_display->capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE) { tdm_func_capture *func_capture = &private_display->func_capture; TDM_RETURN_VAL_IF_FAIL(func_display->display_get_capture_capability, TDM_ERROR_BAD_MODULE); - TDM_RETURN_VAL_IF_FAIL(func_output->output_create_capture, TDM_ERROR_BAD_MODULE); - TDM_RETURN_VAL_IF_FAIL(func_layer->layer_create_capture, TDM_ERROR_BAD_MODULE); + if (private_display->caps_capture.capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT) + TDM_RETURN_VAL_IF_FAIL(func_output->output_create_capture, TDM_ERROR_BAD_MODULE); + if (private_display->caps_capture.capabilities & TDM_CAPTURE_CAPABILITY_LAYER) + TDM_RETURN_VAL_IF_FAIL(func_layer->layer_create_capture, TDM_ERROR_BAD_MODULE); TDM_RETURN_VAL_IF_FAIL(func_capture->capture_destroy, TDM_ERROR_BAD_MODULE); TDM_RETURN_VAL_IF_FAIL(func_capture->capture_commit, TDM_ERROR_BAD_MODULE); TDM_RETURN_VAL_IF_FAIL(func_capture->capture_set_done_handler, TDM_ERROR_BAD_MODULE); diff --git a/src/tdm_capture.c b/src/tdm_capture.c index da1a0e5..798f738 100644 --- a/src/tdm_capture.c +++ b/src/tdm_capture.c @@ -164,6 +164,13 @@ tdm_capture_create_output_internal(tdm_private_output *private_output, return NULL; } + if (!(private_display->caps_capture.capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT)) { + TDM_ERR("no output capture capability"); + if (error) + *error = TDM_ERROR_NO_CAPABILITY; + return NULL; + } + capture_backend = func_output->output_create_capture( private_output->output_backend, &ret); if (ret != TDM_ERROR_NONE) { @@ -235,6 +242,13 @@ tdm_capture_create_layer_internal(tdm_private_layer *private_layer, return NULL; } + if (!(private_display->caps_capture.capabilities & TDM_CAPTURE_CAPABILITY_LAYER)) { + TDM_ERR("no layer capture capability"); + if (error) + *error = TDM_ERROR_NO_CAPABILITY; + return NULL; + } + capture_backend = func_layer->layer_create_capture(private_layer->layer_backend, &ret); if (ret != TDM_ERROR_NONE) -- 2.7.4 From 9ca1c88f3d4353a73f54b560cc4a7015ddcb1be4 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Wed, 23 Nov 2016 15:56:00 +0900 Subject: [PATCH 13/16] remove unused helper function Change-Id: I4e996c26aaab61adb0ae10969b39c8871f28296c --- include/tdm_helper.h | 50 --------------- src/tdm_display.c | 25 -------- src/tdm_helper.c | 173 --------------------------------------------------- 3 files changed, 248 deletions(-) diff --git a/include/tdm_helper.h b/include/tdm_helper.h index 459b1b1..3e4459c 100644 --- a/include/tdm_helper.h +++ b/include/tdm_helper.h @@ -120,56 +120,6 @@ int tdm_helper_get_fd(const char *env); void tdm_helper_set_fd(const char *env, int fd); /** - * @brief Start the dump debugging. - * @details - * Start tdm dump. - * Make dump file when tdm_layer_set_buffer() function is called. - * Set the dump count to 1. - * @param[in] dumppath The given dump path - * @param[in] count The dump count number - * @see #tdm_helper_dump_stop() - */ -void -tdm_helper_dump_start(char *dumppath, int *count); - -/** - * @brief Stop the dump debugging. - * @details - * Stop tdm dump. - * Set the dump count to 0. - * @see #tdm_helper_dump_start() - */ -void -tdm_helper_dump_stop(void); - -/** - * @brief The tdm helper capture handler - * @details - * This handler will be called when composit image produced. - * @see #tdm_helper_capture_output() function - */ -typedef void (*tdm_helper_capture_handler)(tbm_surface_h buffer, void *user_data); - -/** - * @brief Make an output's image surface. - * @details Composit specific output's all layer's buffer to dst_buffer surface. - * After composing, tdm_helper_capture_handler func will be called. - * @param[in] output A output object - * @param[in] dst_buffer A surface composite image saved - * @param[in] x A horizontal position of composite image on dst_buffer - * @param[in] y A vertical position of composite image on dst_buffer - * @param[in] w A composite image width - * @param[in] h A composite image height - * @param[in] func A composing done handler - * @param[in] user_data The user data - * @return #TDM_ERROR_NONE if success. Otherwise, error value. - */ -tdm_error -tdm_helper_capture_output(tdm_output *output, tbm_surface_h dst_buffer, - int x, int y, int w, int h, - tdm_helper_capture_handler func, void *data); - -/** * @brief Fill the display information to the reply buffer as string. * @param[in] dpy A display object * @param[out] reply the string buffer to be filled by this function. diff --git a/src/tdm_display.c b/src/tdm_display.c index a34daab..8d0cdd2 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -40,7 +40,6 @@ #include "tdm.h" #include "tdm_backend.h" #include "tdm_private.h" -#include "tdm_helper.h" #define COUNT_MAX 10 @@ -1597,26 +1596,6 @@ tdm_layer_get_info(tdm_layer *layer, tdm_info_layer *info) return ret; } -static void -_tdm_layer_dump_buffer(tdm_layer *layer, tbm_surface_h buffer) -{ - tdm_private_layer *private_layer = (tdm_private_layer*)layer; - tdm_private_output *private_output = private_layer->private_output; - unsigned int pipe; - int zpos; - char fname[PATH_MAX]; - - pipe = private_output->pipe; - zpos = private_layer->caps.zpos; - - snprintf(fname, sizeof(fname), "tdm_%d_lyr_%d", pipe, zpos); - - tbm_surface_internal_dump_buffer(buffer, fname); - TDM_DBG("%s dump excute", fname); - - return; -} - EXTERN tdm_error tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer) { @@ -1653,10 +1632,6 @@ tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer) ret = func_layer->layer_set_buffer(private_layer->layer_backend, buffer); TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE); - /* dump buffer */ - if (tdm_dump_enable && !(private_layer->caps.capabilities & TDM_LAYER_CAPABILITY_VIDEO)) - _tdm_layer_dump_buffer(layer, buffer); - if (ret == TDM_ERROR_NONE) { /* FIXME: should save to pending_buffer first. And after committing * successfully, need to move to waiting_buffer. diff --git a/src/tdm_helper.c b/src/tdm_helper.c index f5e39b3..f2fce58 100644 --- a/src/tdm_helper.c +++ b/src/tdm_helper.c @@ -398,179 +398,6 @@ tdm_helper_set_fd(const char *env, int fd) } EXTERN void -tdm_helper_dump_start(char *dumppath, int *count) -{ - if (dumppath == NULL || count == NULL) { - TDM_DBG("tdm_helper_dump dumppath or count is null."); - return; - } - - tdm_dump_enable = 1; - - TDM_DBG("tdm_helper_dump start.(path : %s)", dumppath); -} - -EXTERN void -tdm_helper_dump_stop(void) -{ - tdm_dump_enable = 0; - - TDM_DBG("tdm_helper_dump stop."); -} - -static pixman_format_code_t -_tdm_helper_pixman_format_get(tbm_format format) -{ - switch (format) { - case TBM_FORMAT_ARGB8888: - return PIXMAN_a8r8g8b8; - case TBM_FORMAT_XRGB8888: - return PIXMAN_x8r8g8b8; - default: - return 0; - } - - return 0; -} - -static tdm_error -_tdm_helper_buffer_convert(tbm_surface_h srcbuf, tbm_surface_h dstbuf, - int dx, int dy, int dw, int dh, int count) -{ - pixman_image_t *src_img = NULL, *dst_img = NULL; - pixman_format_code_t src_format, dst_format; - pixman_transform_t t; - struct pixman_f_transform ft; - pixman_op_t op; - tbm_surface_info_s src_info = {0, }; - tbm_surface_info_s dst_info = {0, }; - int stride, width; - double scale_x, scale_y; - - TDM_RETURN_VAL_IF_FAIL(srcbuf != NULL, TDM_ERROR_INVALID_PARAMETER); - TDM_RETURN_VAL_IF_FAIL(dstbuf != NULL, TDM_ERROR_INVALID_PARAMETER); - - if (tbm_surface_map(srcbuf, TBM_SURF_OPTION_READ, &src_info) - != TBM_SURFACE_ERROR_NONE) { - TDM_ERR("cannot mmap srcbuf\n"); - return TDM_ERROR_OPERATION_FAILED; - } - - if (tbm_surface_map(dstbuf, TBM_SURF_OPTION_WRITE, &dst_info) - != TBM_SURFACE_ERROR_NONE) { - TDM_ERR("cannot mmap dstbuf\n"); - tbm_surface_unmap(srcbuf); - return TDM_ERROR_OPERATION_FAILED; - } - TDM_GOTO_IF_FAIL(src_info.num_planes == 1, cant_convert); - TDM_GOTO_IF_FAIL(dst_info.num_planes == 1, cant_convert); - - /* src */ - src_format = _tdm_helper_pixman_format_get(src_info.format); - TDM_GOTO_IF_FAIL(src_format > 0, cant_convert); - - width = src_info.planes[0].stride / 4; - stride = src_info.planes[0].stride; - src_img = pixman_image_create_bits(src_format, width, src_info.height, - (uint32_t*)src_info.planes[0].ptr, stride); - TDM_GOTO_IF_FAIL(src_img != NULL, cant_convert); - - /* dst */ - dst_format = _tdm_helper_pixman_format_get(dst_info.format); - TDM_GOTO_IF_FAIL(dst_format > 0, cant_convert); - - width = dst_info.planes[0].stride / 4; - stride = dst_info.planes[0].stride; - dst_img = pixman_image_create_bits(dst_format, width, dst_info.height, - (uint32_t*)dst_info.planes[0].ptr, stride); - TDM_GOTO_IF_FAIL(dst_img != NULL, cant_convert); - - pixman_f_transform_init_identity(&ft); - - scale_x = (double)src_info.width / dw; - scale_y = (double)src_info.height / dh; - - pixman_f_transform_scale(&ft, NULL, scale_x, scale_y); - pixman_f_transform_translate(&ft, NULL, 0, 0); - pixman_transform_from_pixman_f_transform(&t, &ft); - pixman_image_set_transform(src_img, &t); - - if (count == 0) - op = PIXMAN_OP_SRC; - else - op = PIXMAN_OP_OVER; - - pixman_image_composite(op, src_img, NULL, dst_img, - 0, 0, 0, 0, dx, dy, dw, dh); - - if (src_img) - pixman_image_unref(src_img); - if (dst_img) - pixman_image_unref(dst_img); - - tbm_surface_unmap(srcbuf); - tbm_surface_unmap(dstbuf); - - return TDM_ERROR_NONE; - -cant_convert: - if (src_img) - pixman_image_unref(src_img); - - tbm_surface_unmap(srcbuf); - tbm_surface_unmap(dstbuf); - - return TDM_ERROR_OPERATION_FAILED; -} - -EXTERN tdm_error -tdm_helper_capture_output(tdm_output *output, tbm_surface_h dst_buffer, - int x, int y, int w, int h, - tdm_helper_capture_handler func, void *data) -{ - tbm_surface_h surface; - tdm_error err; - int i, count, first = 0; - - TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER); - TDM_RETURN_VAL_IF_FAIL(dst_buffer != NULL, TDM_ERROR_INVALID_PARAMETER); - TDM_RETURN_VAL_IF_FAIL(x >= 0, TDM_ERROR_INVALID_PARAMETER); - TDM_RETURN_VAL_IF_FAIL(y >= 0, TDM_ERROR_INVALID_PARAMETER); - TDM_RETURN_VAL_IF_FAIL(w >= 0, TDM_ERROR_INVALID_PARAMETER); - TDM_RETURN_VAL_IF_FAIL(h >= 0, TDM_ERROR_INVALID_PARAMETER); - TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER); - TDM_RETURN_VAL_IF_FAIL(data != NULL, TDM_ERROR_INVALID_PARAMETER); - - err = tdm_output_get_layer_count(output, &count); - if (err != TDM_ERROR_NONE) { - TDM_ERR("tdm_output_get_layer_count fail(%d)\n", err); - return TDM_ERROR_OPERATION_FAILED; - } - if (count <= 0) { - TDM_ERR("tdm_output_get_layer_count err(%d, %d)\n", err, count); - return TDM_ERROR_BAD_MODULE; - } - - for (i = count - 1; i >= 0; i--) { - tdm_layer *layer = tdm_output_get_layer(output, i, NULL); - - surface = tdm_layer_get_displaying_buffer(layer, &err); - if (err != TDM_ERROR_NONE) - continue; - - err = _tdm_helper_buffer_convert(surface, dst_buffer, x, y, w, h, first++); - if (err != TDM_ERROR_NONE) - TDM_DBG("convert fail %d-layer buffer\n", i); - else - TDM_DBG("convert success %d-layer buffer\n", i); - } - - func(dst_buffer, data); - - return TDM_ERROR_NONE; -} - -EXTERN void tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) { tdm_private_display *private_display; -- 2.7.4 From c1fc4ce4dcdae191b3f90f5237168af67910da1c Mon Sep 17 00:00:00 2001 From: Boram Park Date: Thu, 24 Nov 2016 12:15:05 +0900 Subject: [PATCH 14/16] test the only connected output Change-Id: I482ee9f9dd0e92094cf2e9998adf9ff381f1721f --- tools/tdm_test_server.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/tdm_test_server.c b/tools/tdm_test_server.c index b948a96..e7ee525 100644 --- a/tools/tdm_test_server.c +++ b/tools/tdm_test_server.c @@ -630,6 +630,11 @@ interpret_args(tdm_test_server *data) TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); for (i = 0; i < output_count; i++) { + tdm_output *output = tdm_display_get_output(data->display, i, NULL); + tdm_output_conn_status status; + tdm_output_get_conn_status(output, &status); + if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED) + continue; o = calloc(1, sizeof * o); TDM_EXIT_IF_FAIL(o != NULL); o->data = data; -- 2.7.4 From cde7f5a554815a93f1b2503e271d266f13e0305a Mon Sep 17 00:00:00 2001 From: Boram Park Date: Thu, 24 Nov 2016 12:16:37 +0900 Subject: [PATCH 15/16] add punch option to tdm-monitor Change-Id: Ib70965942ed775a421a9465ab3e9f2b38ff40a3e --- include/tdm_helper.h | 17 +++++++++++++ src/tdm_helper.c | 26 +++++++++++++++++--- src/tdm_monitor_server.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 3 deletions(-) diff --git a/include/tdm_helper.h b/include/tdm_helper.h index 3e4459c..3de7da3 100644 --- a/include/tdm_helper.h +++ b/include/tdm_helper.h @@ -76,6 +76,23 @@ void tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file); /** + * @brief fill a buffer with 0 for given pos. + * @details + * This function supports only if a buffer has below formats. + * - TBM_FORMAT_ARGB8888 + * - TBM_FORMAT_XRGB8888 + * - TBM_FORMAT_YVU420 + * - TBM_FORMAT_YUV420 + * - TBM_FORMAT_NV12 + * - TBM_FORMAT_NV21 + * - TBM_FORMAT_YUYV + * - TBM_FORMAT_UYVY + * @param[in] buffer A TDM buffer + */ +void +tdm_helper_clear_buffer_pos(tbm_surface_h buffer, tdm_pos *pos); + +/** * @brief fill a buffer with 0. * @details * This function supports only if a buffer has below formats. diff --git a/src/tdm_helper.c b/src/tdm_helper.c index f2fce58..3e4af9d 100644 --- a/src/tdm_helper.c +++ b/src/tdm_helper.c @@ -293,8 +293,8 @@ tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file) TDM_INFO("dump %s", file); } -EXTERN void -tdm_helper_clear_buffer(tbm_surface_h buffer) +void +tdm_helper_clear_buffer_pos(tbm_surface_h buffer, tdm_pos *pos) { tbm_surface_info_s info; int ret; @@ -307,7 +307,19 @@ tdm_helper_clear_buffer(tbm_surface_h buffer) switch (info.format) { case TBM_FORMAT_ARGB8888: case TBM_FORMAT_XRGB8888: - memset(info.planes[0].ptr, 0, info.planes[0].stride * info.height); + if (!pos) { + memset(info.planes[0].ptr, 0, info.planes[0].stride * info.height); + } else { + unsigned char *p; + int x, y; + for (y = pos->y; y <= (pos->y + pos->h); y++) { + p = info.planes[0].ptr + info.planes[0].stride * y; + for (x = pos->x; x <= (pos->x + pos->w); x++) { + int *ibuf = (int*)p; + ibuf[x] = 0x00000000; + } + } + } break; case TBM_FORMAT_YVU420: case TBM_FORMAT_YUV420: @@ -344,6 +356,14 @@ tdm_helper_clear_buffer(tbm_surface_h buffer) tbm_surface_unmap(buffer); } +EXTERN void +tdm_helper_clear_buffer(tbm_surface_h buffer) +{ + TDM_RETURN_IF_FAIL(buffer != NULL); + + tdm_helper_clear_buffer_pos(buffer, NULL); +} + EXTERN int tdm_helper_get_fd(const char *env) { diff --git a/src/tdm_monitor_server.c b/src/tdm_monitor_server.c index 4ea1184..2a1b318 100644 --- a/src/tdm_monitor_server.c +++ b/src/tdm_monitor_server.c @@ -304,6 +304,64 @@ _tdm_monitor_server_dump(unsigned int pid, char *cwd, int argc, char *argv[], ch tdm_display_enable_dump(dpy, (const char*)argv[2], reply, len); } +static void +_tdm_monitor_server_punch(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy) +{ + char *arg, *end; + unsigned int output_id, layer_id; + tdm_output *output; + tdm_layer *layer; + tbm_surface_h buffer; + + arg = argv[2]; + + output_id = strtol(arg, &end, 10); + output = tdm_display_get_output(dpy, output_id, NULL); + if (!output) { + TDM_SNPRINTF(reply, len, "not found output\n"); + return; + } + if (*end != ',') { + TDM_SNPRINTF(reply, len, "not found ','\n"); + return; + } + + arg = end + 1; + layer_id = strtol(arg, &end, 10); + layer = tdm_output_get_layer(output, layer_id, NULL); + if (!layer) { + TDM_SNPRINTF(reply, len, "not found layer\n"); + return; + } + + buffer = tdm_layer_get_displaying_buffer(layer, NULL); + if (!buffer) { + TDM_SNPRINTF(reply, len, "not found buffer\n"); + return; + } + + if (*end == ':') { + tdm_pos pos = {0,}; + + arg = end + 1; + pos.w = strtol(arg, &end, 10); + TDM_EXIT_IF_FAIL(*end == 'x'); + arg = end + 1; + pos.h = strtol(arg, &end, 10); + if (*end == '+') { + arg = end + 1; + pos.x = strtol(arg, &end, 10); + TDM_EXIT_IF_FAIL(*end == '+'); + arg = end + 1; + pos.y = strtol(arg, &end, 10); + } + + tdm_helper_clear_buffer_pos(buffer, &pos); + } + else + tdm_helper_clear_buffer(buffer); +} + static struct { const char *opt; void (*func)(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy); @@ -351,6 +409,12 @@ static struct { "[,[,...]][@]", NULL }, + { + "punch", _tdm_monitor_server_punch, + "punch a layer", + ",[:x[++]]", + NULL + }, }; static void -- 2.7.4 From 64c5c785d86c48dcd94ae43a1976f494ef979c13 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Thu, 24 Nov 2016 12:19:30 +0900 Subject: [PATCH 16/16] add tdm_helper_convert_buffer function Change-Id: I4c63d1e3546194229daf19f4a59444b96a33f46c --- include/tdm_helper.h | 14 ++++++ src/tdm_helper.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+) diff --git a/include/tdm_helper.h b/include/tdm_helper.h index 3de7da3..a6791aa 100644 --- a/include/tdm_helper.h +++ b/include/tdm_helper.h @@ -110,6 +110,20 @@ void tdm_helper_clear_buffer(tbm_surface_h buffer); /** + * @brief convert the source buffer to the destination buffer with given rectangles + * trannsform + * @details + * This function supports only if buffers have below formats. + * - TBM_FORMAT_ARGB8888 + * - TBM_FORMAT_XRGB8888 + * @param[in] buffer A TDM buffer + */ +tdm_error +tdm_helper_convert_buffer(tbm_surface_h srcbuf, tbm_surface_h dstbuf, + tdm_pos *srcpos, tdm_pos *dstpos, + tdm_transform transform, int over); + +/** * @brief Get a fd from the given enviroment variable. * @details * This function will dup the fd of the given enviroment variable. The Caller diff --git a/src/tdm_helper.c b/src/tdm_helper.c index 3e4af9d..e91033e 100644 --- a/src/tdm_helper.c +++ b/src/tdm_helper.c @@ -364,6 +364,134 @@ tdm_helper_clear_buffer(tbm_surface_h buffer) tdm_helper_clear_buffer_pos(buffer, NULL); } +static pixman_format_code_t +_tdm_helper_pixman_format_get(tbm_format format) +{ + switch (format) { + case TBM_FORMAT_ARGB8888: + return PIXMAN_a8r8g8b8; + case TBM_FORMAT_XRGB8888: + return PIXMAN_x8r8g8b8; + default: + return 0; + } + + return 0; +} + +EXTERN tdm_error +tdm_helper_convert_buffer(tbm_surface_h srcbuf, tbm_surface_h dstbuf, + tdm_pos *srcpos, tdm_pos *dstpos, + tdm_transform transform, int over) +{ + tbm_surface_info_s src_info, dst_info; + pixman_image_t *src_img = NULL, *dst_img = NULL; + pixman_format_code_t src_format, dst_format; + double scale_x, scale_y; + int rotate_step, bos; + pixman_transform_t t; + struct pixman_f_transform ft; + pixman_op_t op; + int src_stride, dst_stride; + int buf_width, err; + tdm_error ret = TDM_ERROR_OPERATION_FAILED; + + TDM_RETURN_VAL_IF_FAIL(srcbuf != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(dstbuf != NULL, TDM_ERROR_INVALID_PARAMETER); + + bos = tbm_surface_internal_get_num_bos(srcbuf); + TDM_RETURN_VAL_IF_FAIL(bos == 1, TDM_ERROR_OPERATION_FAILED); + + bos = tbm_surface_internal_get_num_bos(dstbuf); + TDM_RETURN_VAL_IF_FAIL(bos == 1, TDM_ERROR_OPERATION_FAILED); + + err = tbm_surface_map(srcbuf, TBM_OPTION_READ, &src_info); + TDM_RETURN_VAL_IF_FAIL(err == TBM_SURFACE_ERROR_NONE, TDM_ERROR_OPERATION_FAILED); + + err = tbm_surface_map(dstbuf, TBM_OPTION_WRITE, &dst_info); + TDM_GOTO_IF_FAIL(err == TBM_SURFACE_ERROR_NONE, unmap_srcbuf); + + /* not handle buffers which have 2 more gem handles */ + TDM_GOTO_IF_FAIL(src_info.planes[0].ptr != NULL, unmap_dstbuf); + TDM_GOTO_IF_FAIL(dst_info.planes[0].ptr != NULL, unmap_dstbuf); + + src_format = _tdm_helper_pixman_format_get(src_info.format); + TDM_GOTO_IF_FAIL(src_format > 0, unmap_dstbuf); + dst_format = _tdm_helper_pixman_format_get(dst_info.format); + TDM_GOTO_IF_FAIL(dst_format > 0, unmap_dstbuf); + + buf_width = src_info.planes[0].stride >> 2; + src_stride = src_info.planes[0].stride; + src_img = pixman_image_create_bits(src_format, buf_width, src_info.height, + (uint32_t*)src_info.planes[0].ptr, src_stride); + TDM_GOTO_IF_FAIL(src_img, unref_img); + + buf_width = dst_info.planes[0].stride >> 2; + dst_stride = dst_info.planes[0].stride; + dst_img = pixman_image_create_bits(dst_format, buf_width, dst_info.height, + (uint32_t*)dst_info.planes[0].ptr, dst_stride); + TDM_GOTO_IF_FAIL(dst_img, unref_img); + + pixman_f_transform_init_identity(&ft); + + if (transform & TDM_TRANSFORM_FLIPPED) { + pixman_f_transform_scale(&ft, NULL, -1, 1); + pixman_f_transform_translate(&ft, NULL, dstpos->w, 0); + } + + rotate_step = transform & 0x3; + if (rotate_step > 0) { + int c, s, tx = 0, ty = 0; + switch (rotate_step) { + case 1: + c = 0, s = -1, tx = -dstpos->w; + break; + case 2: + c = -1, s = 0, tx = -dstpos->w, ty = -dstpos->h; + break; + case 3: + c = 0, s = 1, ty = -dstpos->h; + break; + default: + break; + } + pixman_f_transform_translate(&ft, NULL, tx, ty); + pixman_f_transform_rotate(&ft, NULL, c, s); + } + + if (rotate_step % 2 == 0) { + scale_x = (double)srcpos->w / dstpos->w; + scale_y = (double)srcpos->h / dstpos->h; + } else { + scale_x = (double)srcpos->w / dstpos->h; + scale_y = (double)srcpos->h / dstpos->w; + } + + pixman_f_transform_scale(&ft, NULL, scale_x, scale_y); + pixman_f_transform_translate(&ft, NULL, srcpos->x, srcpos->y); + pixman_transform_from_pixman_f_transform(&t, &ft); + pixman_image_set_transform(src_img, &t); + + op = (!over) ? PIXMAN_OP_SRC : PIXMAN_OP_OVER; + + pixman_image_composite(op, src_img, NULL, dst_img, 0, 0, 0, 0, + dstpos->x, dstpos->y, dstpos->w, dstpos->h); + + ret = TDM_ERROR_NONE; + +unref_img: + if (src_img) + pixman_image_unref(src_img); + if (dst_img) + pixman_image_unref(dst_img); +unmap_dstbuf: + tbm_surface_unmap(dstbuf); +unmap_srcbuf: + tbm_surface_unmap(srcbuf); + + return ret; +} + EXTERN int tdm_helper_get_fd(const char *env) { -- 2.7.4