From 76ae3e74c5b6c60fa55acd690da6ea4a06efe499 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 1 Jul 2015 14:06:54 +0900 Subject: [PATCH 01/16] remove destry resource it occurs crash.. Change-Id: I63f3fa99f0942306c1a1614225d23687adb2b985 --- src/e_mod_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 30c4a98..c68a217 100755 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -149,7 +149,9 @@ static const struct wl_eom_interface _e_eom_wl_implementation = { static void _e_eom_wl_resource_destory_cb(struct wl_resource *resource) { - wl_resource_destroy(resource); + +/* TODO : destroy resources if exist */ + } /* wl_eom global object bind function */ -- 2.7.4 From db411842075d0878553760f4a0782abbde574ba7 Mon Sep 17 00:00:00 2001 From: Gwanglim Lee Date: Tue, 4 Aug 2015 14:40:14 +0900 Subject: [PATCH 02/16] remove noisy log message. Change-Id: I2e54acef8a39ba67acd7d526ea859638c6c8b6e1 --- src/e_mod_main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index c68a217..c5cc230 100755 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -43,8 +43,6 @@ _e_eom_e_client_remove_cb(void *data, int type, void *event) (void) event; (void) data; - EOM_DBG("e_client: %p is died\n", ec); - return ECORE_CALLBACK_PASS_ON; } -- 2.7.4 From bd5efcd5d86ca07c259c264e0da34d5743fd694c Mon Sep 17 00:00:00 2001 From: Gwanglim Lee Date: Tue, 4 Aug 2015 16:34:44 +0900 Subject: [PATCH 03/16] fix coding conventions and style. Change-Id: I15c5416451f681c9363b2a2a263647c8b9f6a346 --- src/e_mod_main.c | 120 ++++++++++++++++++++++--------------------------------- src/e_mod_main.h | 0 2 files changed, 47 insertions(+), 73 deletions(-) mode change 100755 => 100644 src/e_mod_main.c mode change 100755 => 100644 src/e_mod_main.h diff --git a/src/e_mod_main.c b/src/e_mod_main.c old mode 100755 new mode 100644 index c5cc230..215d9ae --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -26,28 +26,14 @@ _e_eom_e_comp_wl_output_get(Eina_List *outputs, const char *id) EINA_LIST_FOREACH(outputs, l, output) { - if (!strcmp(output->id, id)) - return output; + if (!strcmp(output->id, id)) + return output; } return NULL; } static Eina_Bool -_e_eom_e_client_remove_cb(void *data, int type, void *event) -{ - E_Event_Client *ev = event; - E_Client *ec = ev->ec; - - (void) type; - (void) event; - (void) data; - - return ECORE_CALLBACK_PASS_ON; -} - - -static Eina_Bool _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) { Ecore_Drm_Event_Output *e; @@ -64,7 +50,7 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e if (!e->plug) goto end; EOM_DBG("id:%d (x,y,w,h):(%d,%d,%d,%d) (w_mm,h_mm):(%d,%d) refresh:%d subpixel_order:%d transform:%d make:%s model:%s plug:%d\n", - e->id, e->x, e->y, e->w, e->h, e->phys_width, e->phys_height, e->refresh, e->subpixel_order, e->transform, e->make, e->model, e->plug); + e->id, e->x, e->y, e->w, e->h, e->phys_width, e->phys_height, e->refresh, e->subpixel_order, e->transform, e->make, e->model, e->plug); if (!(cdata = e_comp->wl_comp_data)) goto end; @@ -78,24 +64,26 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e goto end; } - /* TODO: we need ecore_drm_output_connector_get()/ecore_drm_output_conn_name_get() function to get the connector type */ - + /* TODO: + * we need ecore_drm_output_connector_get()/ecore_drm_output_conn_name_get() + * function to get the connector type + */ /* send notify in each outputs associated with e_comp_wl_output */ EINA_LIST_FOREACH(output->resources, l2, output_resource) { if (e->plug) - wl_eom_send_output_type(eom->resource, output_resource, eom_type, WL_EOM_STATUS_CONNECTION); + wl_eom_send_output_type(eom->resource, + output_resource, + eom_type, + WL_EOM_STATUS_CONNECTION); else - wl_eom_send_output_type(eom->resource, output_resource, eom_type, WL_EOM_STATUS_DISCONNECTION); + wl_eom_send_output_type(eom->resource, + output_resource, + eom_type, + WL_EOM_STATUS_DISCONNECTION); } -#if 0 - e_comp_wl_output_init(buff, e->make, e->model, e->x, e->y, e->w, e->h, - e->phys_width, e->phys_height, e->refresh, - e->subpixel_order, e->transform); -#endif - end: return ECORE_CALLBACK_PASS_ON; } @@ -112,34 +100,35 @@ _e_eom_ecore_drm_activate_cb(void *data, int type EINA_UNUSED, void *event) if (e->active) { - /* TODO: something do */ + /* TODO: do something */ } else { - /* TODO: something do */ + /* TODO: do something */ } end: return ECORE_CALLBACK_PASS_ON; } - /* wl_eom_set_keygrab request handler */ static void -_e_eom_wl_request_set_attribute_cb(struct wl_client *client, - struct wl_resource *resource, - struct wl_resource *output, - uint32_t attribute) +_e_eom_wl_request_set_attribute_cb(struct wl_client *client, struct wl_resource *resource, struct wl_resource *output, uint32_t attribute) { (void) client; (void) attribute; EOM_DBG("attribute:%d\n", attribute); - wl_eom_send_output_attribute(resource, output, attribute, WL_EOM_ATTRIBUTE_STATE_ACTIVE, WL_EOM_ERROR_NONE); + wl_eom_send_output_attribute(resource, + output, + attribute, + WL_EOM_ATTRIBUTE_STATE_ACTIVE, + WL_EOM_ERROR_NONE); } -static const struct wl_eom_interface _e_eom_wl_implementation = { +static const struct wl_eom_interface _e_eom_wl_implementation = +{ _e_eom_wl_request_set_attribute_cb }; @@ -147,9 +136,7 @@ static const struct wl_eom_interface _e_eom_wl_implementation = { static void _e_eom_wl_resource_destory_cb(struct wl_resource *resource) { - -/* TODO : destroy resources if exist */ - + /* TODO : destroy resources if exist */ } /* wl_eom global object bind function */ @@ -159,7 +146,10 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 E_EomPtr eom = data; struct wl_resource *resource; - resource = wl_resource_create(client, &wl_eom_interface, MIN(version, 1), id); + resource = wl_resource_create(client, + &wl_eom_interface, + MIN(version, 1), + id); if (!resource) { EOM_ERR("error. resource is null. (version :%d, id:%d)\n", version, id); @@ -167,7 +157,10 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 return; } - wl_resource_set_implementation(resource, &_e_eom_wl_implementation, eom, _e_eom_wl_resource_destory_cb); + wl_resource_set_implementation(resource, + &_e_eom_wl_implementation, + eom, + _e_eom_wl_resource_destory_cb); eom->resource = resource; @@ -177,11 +170,10 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 static void _e_eom_deinit() { - Ecore_Event_Handler *h = NULL; + Ecore_Event_Handler *h; if (!g_eom) return; - /* remove event handlers */ if (g_eom->handlers) { EINA_LIST_FREE(g_eom->handlers, h) @@ -191,7 +183,6 @@ _e_eom_deinit() if (g_eom->global) wl_global_destroy(g_eom->global); E_FREE(g_eom); - g_eom = NULL; } static Eina_Bool @@ -199,44 +190,29 @@ _e_eom_init() { E_Comp_Data *cdata = NULL; - g_eom = E_NEW(E_Eom, 1); - if (!g_eom) - { - EOM_ERR("error. fail to allocate the memory.\n"); - return EINA_FALSE; - } - - if (!e_comp) - { - EOM_ERR("error. e_comp is null.\n"); - goto err; - } + EINA_SAFETY_ON_NULL_GOTO(e_comp, err); cdata = e_comp->wl_comp_data; - if (!cdata) - { - EOM_ERR("error. e_comp->wl_comp_data is null.\n"); - goto err; - } + EINA_SAFETY_ON_NULL_GOTO(cdata, err); + + g_eom = E_NEW(E_Eom, 1); + EINA_SAFETY_ON_NULL_RETURN_VAL(g_eom, NULL); g_eom->cdata = cdata; - g_eom->global = wl_global_create(cdata->wl.disp, &wl_eom_interface, 1, g_eom, _e_eom_wl_bind_cb); - if (!g_eom->global) - { - EOM_ERR("error. g_eom->global is null.\n"); - goto err; - } + g_eom->global = wl_global_create(cdata->wl.disp, + &wl_eom_interface, + 1, + g_eom, + _e_eom_wl_bind_cb); + EINA_SAFETY_ON_NULL_GOTO(g_eom->global, err); - /* add event hanlders */ E_LIST_HANDLER_APPEND(g_eom->handlers, ECORE_DRM_EVENT_ACTIVATE, _e_eom_ecore_drm_activate_cb, g_eom); - E_LIST_HANDLER_APPEND(g_eom->handlers, ECORE_DRM_EVENT_OUTPUT, _e_eom_ecore_drm_output_cb, g_eom); - E_LIST_HANDLER_APPEND(g_eom->handlers, E_EVENT_CLIENT_REMOVE, _e_eom_e_client_remove_cb, g_eom); + E_LIST_HANDLER_APPEND(g_eom->handlers, ECORE_DRM_EVENT_OUTPUT, _e_eom_ecore_drm_output_cb, g_eom); return EINA_TRUE; err: _e_eom_deinit(); - return EINA_FALSE; } @@ -250,7 +226,6 @@ EAPI int e_modapi_shutdown(E_Module *m EINA_UNUSED) { _e_eom_deinit(); - return 1; } @@ -260,4 +235,3 @@ e_modapi_save(E_Module *m EINA_UNUSED) /* Save something to be kept */ return 1; } - diff --git a/src/e_mod_main.h b/src/e_mod_main.h old mode 100755 new mode 100644 -- 2.7.4 From e6052cc5ad3baded0fa331a52fa2eb9fd5a982a6 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 28 Oct 2015 19:40:49 +0900 Subject: [PATCH 04/16] add dummy x11 module for avoiding build break Change-Id: Ieb750c5164278967f1d37137e83ef6c7ca75a0fd --- configure.ac | 21 +++++++++++++++++++++ packaging/e-mod-tizen-eom.spec | 3 ++- src/Makefile.am | 8 ++++++++ src/e_mod_main_x11.c | 26 ++++++++++++++++++++++++++ src/e_mod_main_x11.h | 11 +++++++++++ 5 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 src/e_mod_main_x11.c create mode 100644 src/e_mod_main_x11.h diff --git a/configure.ac b/configure.ac index 39a2c1b..cec8ae1 100644 --- a/configure.ac +++ b/configure.ac @@ -37,6 +37,27 @@ PKG_CHECK_MODULES(WAYLAND_SCANNER, wayland-scanner) PKG_CHECK_MODULES(WAYLAND, [wayland-server]) PKG_CHECK_MODULES(ENLIGHTENMENT, [enlightenment]) +dnl ======================================================================== +# checks for wayland only argument +dnl ======================================================================== +have_wayland_only=no +AC_ARG_ENABLE([wayland-only], + AS_HELP_STRING([--enable-wayland-only],[enable wayland-only version of enlightenment @<:@default=disabled@:>@]), + [have_wayland_only=$enableval], + [have_wayland_only=no]) +AC_MSG_CHECKING([whether wayland-only version is enabled]) +AM_CONDITIONAL(WAYLAND_ONLY, test x$have_wayland_only = xyes) +if test "x${have_wayland_only}" != "xno"; then + AC_DEFINE_UNQUOTED([HAVE_WAYLAND_ONLY],[1],[enable wayland-only version of enlightenment]) +fi + +dnl ======================================================================== +# checks for wayland only argument +dnl ======================================================================== +if test "x${have_wayland_only}" = "xyes"; then + PKG_CHECK_MODULES(WAYLAND, [wayland-server]) +fi + AC_SUBST(ENLIGHTENMENT_CFLAGS) AC_SUBST(ENLIGHTENMENT_LIBS) diff --git a/packaging/e-mod-tizen-eom.spec b/packaging/e-mod-tizen-eom.spec index a290b5d..52e9762 100644 --- a/packaging/e-mod-tizen-eom.spec +++ b/packaging/e-mod-tizen-eom.spec @@ -12,6 +12,7 @@ License: BSD-2-Clause BuildRequires: pkgconfig(enlightenment) BuildRequires: gettext %if %{with x} +BuildRequires: pkgconfig(x11) %endif %if %{with wayland} BuildRequires: pkgconfig(wayland-server) @@ -35,7 +36,7 @@ export LDFLAGS+=" -Wl,--hash-style=both -Wl,--as-needed -Wl,--rpath=/usr/lib" %autogen %if %{with wayland} -%configure --prefix=/usr +%configure --prefix=/usr --enable-wayland-only %else %configure --prefix=/usr %endif diff --git a/src/Makefile.am b/src/Makefile.am index ee78075..7ae647e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -6,6 +6,8 @@ filesdir = $(libdir)/enlightenment/modules/$(MODULE) pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH) pkg_LTLIBRARIES = module.la + +if WAYLAND_ONLY module_la_SOURCES = e_mod_main.c eom-protocol.c module_la_LIBADD = module_la_CFLAGS = @WAYLAND_CFLAGS@ @ENLIGHTENMENT_CFLAGS@ -DHAVE_WAYLAND_ONLY @@ -26,3 +28,9 @@ CLEANFILES = $(BUILT_SOURCES) %-client-protocol.h : $(top_srcdir)/protocol/%.xml $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) client-header < $< > $@ +else +module_la_SOURCES = e_mod_main_x11.c +module_la_LIBADD = +module_la_CFLAGS = @ENLIGHTENMENT_CFLAGS@ +module_la_LDFLAGS = -module -avoid-version @ENLIGHTENMENT_LIBS@ +endif diff --git a/src/e_mod_main_x11.c b/src/e_mod_main_x11.c new file mode 100644 index 0000000..964e025 --- /dev/null +++ b/src/e_mod_main_x11.c @@ -0,0 +1,26 @@ +#include "e.h" +#include "e_mod_main.h" + +EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "EOM Module of Window Manager" }; + +EAPI void * +e_modapi_init(E_Module *m) +{ + + return m; +} + +EAPI int +e_modapi_shutdown(E_Module *m EINA_UNUSED) +{ + + return 1; +} + +EAPI int +e_modapi_save(E_Module *m EINA_UNUSED) +{ + /* Save something to be kept */ + return 1; +} + diff --git a/src/e_mod_main_x11.h b/src/e_mod_main_x11.h new file mode 100644 index 0000000..b848208 --- /dev/null +++ b/src/e_mod_main_x11.h @@ -0,0 +1,11 @@ +#ifndef E_MOD_MAIN_H +#define E_MOD_MAIN_H + +/*** E Module ***/ +EAPI extern E_Module_Api e_modapi; + +EAPI void *e_modapi_init(E_Module *m); +EAPI int e_modapi_shutdown(E_Module *m); +EAPI int e_modapi_save(E_Module *m); + +#endif -- 2.7.4 From 5a524be00d52f60e0b34601db51ebe3ef3e8a729 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Tue, 12 Jan 2016 22:36:50 +0900 Subject: [PATCH 05/16] Modification for enlightenment version upgrade 0.20.0 Change-Id: Ie6e4d551b3c8aa981232dc7c71a71aad0f86f3b8 --- src/Makefile.am | 2 +- src/e_mod_main.c | 24 +++++++----------------- src/e_mod_main.h | 8 ++++---- src/e_mod_main_x11.c | 8 ++++---- src/e_mod_main_x11.h | 8 ++++---- 5 files changed, 20 insertions(+), 30 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 7ae647e..dfde2d5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -10,7 +10,7 @@ pkg_LTLIBRARIES = module.la if WAYLAND_ONLY module_la_SOURCES = e_mod_main.c eom-protocol.c module_la_LIBADD = -module_la_CFLAGS = @WAYLAND_CFLAGS@ @ENLIGHTENMENT_CFLAGS@ -DHAVE_WAYLAND_ONLY +module_la_CFLAGS = @WAYLAND_CFLAGS@ @ENLIGHTENMENT_CFLAGS@ -DHAVE_WAYLAND_ONLY -DHAVE_WAYLAND module_la_LDFLAGS = -module -avoid-version @WAYLAND_LIBS@ @ENLIGHTENMENT_LIBS@ module_la_DEPENDENCIES = $(top_builddir)/config.h diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 215d9ae..6c2101c 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -8,7 +8,6 @@ typedef struct _E_Eom E_Eom, *E_EomPtr; struct _E_Eom { - E_Comp_Data *cdata; struct wl_global *global; struct wl_resource *resource; Eina_List *handlers; @@ -16,7 +15,7 @@ struct _E_Eom E_EomPtr g_eom = NULL; -EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "EOM Module" }; +E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "EOM Module" }; static E_Comp_Wl_Output * _e_eom_e_comp_wl_output_get(Eina_List *outputs, const char *id) @@ -38,7 +37,6 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e { Ecore_Drm_Event_Output *e; E_EomPtr eom = data; - E_Comp_Data *cdata; E_Comp_Wl_Output *output; Eina_List *l2; struct wl_resource *output_resource; @@ -52,12 +50,10 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e EOM_DBG("id:%d (x,y,w,h):(%d,%d,%d,%d) (w_mm,h_mm):(%d,%d) refresh:%d subpixel_order:%d transform:%d make:%s model:%s plug:%d\n", e->id, e->x, e->y, e->w, e->h, e->phys_width, e->phys_height, e->refresh, e->subpixel_order, e->transform, e->make, e->model, e->plug); - if (!(cdata = e_comp->wl_comp_data)) goto end; - snprintf(buff, sizeof(buff), "%d", e->id); /* get the e_comp_wl_output */ - output = _e_eom_e_comp_wl_output_get(cdata->outputs, buff); + output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, buff); if (!output) { EOM_ERR("no e_comp_wl_outputs.\n"); @@ -188,18 +184,12 @@ _e_eom_deinit() static Eina_Bool _e_eom_init() { - E_Comp_Data *cdata = NULL; - - EINA_SAFETY_ON_NULL_GOTO(e_comp, err); - - cdata = e_comp->wl_comp_data; - EINA_SAFETY_ON_NULL_GOTO(cdata, err); + EINA_SAFETY_ON_NULL_GOTO(e_comp_wl, err); g_eom = E_NEW(E_Eom, 1); EINA_SAFETY_ON_NULL_RETURN_VAL(g_eom, NULL); - g_eom->cdata = cdata; - g_eom->global = wl_global_create(cdata->wl.disp, + g_eom->global = wl_global_create(e_comp_wl->wl.disp, &wl_eom_interface, 1, g_eom, @@ -216,20 +206,20 @@ err: return EINA_FALSE; } -EAPI void * +E_API void * e_modapi_init(E_Module *m) { return (_e_eom_init() ? m : NULL); } -EAPI int +E_API int e_modapi_shutdown(E_Module *m EINA_UNUSED) { _e_eom_deinit(); return 1; } -EAPI int +E_API int e_modapi_save(E_Module *m EINA_UNUSED) { /* Save something to be kept */ diff --git a/src/e_mod_main.h b/src/e_mod_main.h index 14fb89f..94675fc 100644 --- a/src/e_mod_main.h +++ b/src/e_mod_main.h @@ -11,9 +11,9 @@ #define EOM_DBG(msg, ARG...) DBG("[eom module][%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG) /* E Module */ -EAPI extern E_Module_Api e_modapi; -EAPI void *e_modapi_init(E_Module *m); -EAPI int e_modapi_shutdown(E_Module *m); -EAPI int e_modapi_save(E_Module *m); +E_API extern E_Module_Api e_modapi; +E_API void *e_modapi_init(E_Module *m); +E_API int e_modapi_shutdown(E_Module *m); +E_API int e_modapi_save(E_Module *m); #endif diff --git a/src/e_mod_main_x11.c b/src/e_mod_main_x11.c index 964e025..93e4e04 100644 --- a/src/e_mod_main_x11.c +++ b/src/e_mod_main_x11.c @@ -1,23 +1,23 @@ #include "e.h" #include "e_mod_main.h" -EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "EOM Module of Window Manager" }; +E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "EOM Module of Window Manager" }; -EAPI void * +E_API void * e_modapi_init(E_Module *m) { return m; } -EAPI int +E_API int e_modapi_shutdown(E_Module *m EINA_UNUSED) { return 1; } -EAPI int +E_API int e_modapi_save(E_Module *m EINA_UNUSED) { /* Save something to be kept */ diff --git a/src/e_mod_main_x11.h b/src/e_mod_main_x11.h index b848208..cc3a882 100644 --- a/src/e_mod_main_x11.h +++ b/src/e_mod_main_x11.h @@ -2,10 +2,10 @@ #define E_MOD_MAIN_H /*** E Module ***/ -EAPI extern E_Module_Api e_modapi; +E_API extern E_Module_Api e_modapi; -EAPI void *e_modapi_init(E_Module *m); -EAPI int e_modapi_shutdown(E_Module *m); -EAPI int e_modapi_save(E_Module *m); +E_API void *e_modapi_init(E_Module *m); +E_API int e_modapi_shutdown(E_Module *m); +E_API int e_modapi_save(E_Module *m); #endif -- 2.7.4 From 629ff6846eb60a271b53e65ded7a4adf5d075e23 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Wed, 17 Feb 2016 16:42:55 +0900 Subject: [PATCH 06/16] fix _e_eom_e_comp_wl_output_get error Change-Id: Ica89b3e0ba2066a93b68079060c42ed06ebc868d Signed-off-by: Junkyeong Kim --- src/e_mod_main.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 6c2101c..fc73de3 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -25,8 +25,20 @@ _e_eom_e_comp_wl_output_get(Eina_List *outputs, const char *id) EINA_LIST_FOREACH(outputs, l, output) { - if (!strcmp(output->id, id)) - return output; + char *temp_id = NULL; + temp_id = strchr(output->id, '/'); + if (temp_id == NULL) + { + if (!strcmp(output->id, id)) + return output; + } + else + { + int loc = temp_id - output->id; + + if (!strncmp(output->id, id, loc)) + return output; + } } return NULL; @@ -47,16 +59,16 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e if (!e->plug) goto end; - EOM_DBG("id:%d (x,y,w,h):(%d,%d,%d,%d) (w_mm,h_mm):(%d,%d) refresh:%d subpixel_order:%d transform:%d make:%s model:%s plug:%d\n", - e->id, e->x, e->y, e->w, e->h, e->phys_width, e->phys_height, e->refresh, e->subpixel_order, e->transform, e->make, e->model, e->plug); + EOM_DBG("id:%d (x,y,w,h):(%d,%d,%d,%d) (w_mm,h_mm):(%d,%d) refresh:%d subpixel_order:%d transform:%d make:%s model:%s name:%s plug:%d\n", + e->id, e->x, e->y, e->w, e->h, e->phys_width, e->phys_height, e->refresh, e->subpixel_order, e->transform, e->make, e->model, e->name, e->plug); - snprintf(buff, sizeof(buff), "%d", e->id); + snprintf(buff, sizeof(buff), "%s", e->name); /* get the e_comp_wl_output */ output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, buff); if (!output) { - EOM_ERR("no e_comp_wl_outputs.\n"); + EOM_ERR("no e_comp_wl_outputs. (%s)\n", buff); goto end; } @@ -90,9 +102,13 @@ _e_eom_ecore_drm_activate_cb(void *data, int type EINA_UNUSED, void *event) Ecore_Drm_Event_Activate *e = NULL; E_EomPtr eom = NULL; + EOM_DBG("_e_eom_ecore_drm_activate_cb called\n"); + if ((!event) || (!data)) goto end; e = event; - data = eom; + eom = data; + + EOM_DBG("e->active:%d\n", e->active); if (e->active) { -- 2.7.4 From 1cdecb5de613def1f3ec039a9a7b587c0c5c48b3 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 11 Mar 2016 13:17:23 +0900 Subject: [PATCH 07/16] use the tizen directory macros at spec file Change-Id: Icda5624e866a87267def34d03042cdc5c771d3cf --- packaging/e-mod-tizen-eom.spec | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packaging/e-mod-tizen-eom.spec b/packaging/e-mod-tizen-eom.spec index 52e9762..bd55b69 100644 --- a/packaging/e-mod-tizen-eom.spec +++ b/packaging/e-mod-tizen-eom.spec @@ -25,6 +25,8 @@ BuildRequires: e-tizen-data %description This package is a the Enlightenment eom Module for Tizen. +%global TZ_SYS_RO_SHARE %{?TZ_SYS_RO_SHARE:%TZ_SYS_RO_SHARE}%{!?TZ_SYS_RO_SHARE:/usr/share} + %prep %setup -q @@ -47,8 +49,8 @@ make rm -rf %{buildroot} # for license notification -mkdir -p %{buildroot}/usr/share/license -cp -a %{_builddir}/%{buildsubdir}/COPYING %{buildroot}/usr/share/license/%{name} +mkdir -p %{buildroot}%{TZ_SYS_RO_SHARE}/license +cp -a %{_builddir}/%{buildsubdir}/COPYING %{buildroot}%{TZ_SYS_RO_SHARE}/license/%{name} # install make install DESTDIR=%{buildroot} @@ -59,4 +61,4 @@ find %{buildroot}%{_libdir}/enlightenment/modules/%{name} -name *.la | xargs rm %files %defattr(-,root,root,-) %{_libdir}/enlightenment/modules/e-mod-tizen-eom -/usr/share/license/%{name} +%{TZ_SYS_RO_SHARE}/license/%{name} -- 2.7.4 From fce456463621e8b770412189d90c390c16cfc97f Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Fri, 8 Apr 2016 14:37:05 +0900 Subject: [PATCH 08/16] erase build warning Change-Id: I2b7a464a1707cf66bd701a687f318ccb69807092 Signed-off-by: Junkyeong Kim --- src/e_mod_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index fc73de3..ff137f1 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -100,13 +100,13 @@ static Eina_Bool _e_eom_ecore_drm_activate_cb(void *data, int type EINA_UNUSED, void *event) { Ecore_Drm_Event_Activate *e = NULL; - E_EomPtr eom = NULL; + /* E_EomPtr eom = NULL; */ EOM_DBG("_e_eom_ecore_drm_activate_cb called\n"); if ((!event) || (!data)) goto end; e = event; - eom = data; + /* eom = data; */ EOM_DBG("e->active:%d\n", e->active); @@ -203,7 +203,7 @@ _e_eom_init() EINA_SAFETY_ON_NULL_GOTO(e_comp_wl, err); g_eom = E_NEW(E_Eom, 1); - EINA_SAFETY_ON_NULL_RETURN_VAL(g_eom, NULL); + EINA_SAFETY_ON_NULL_RETURN_VAL(g_eom, EINA_FALSE); g_eom->global = wl_global_create(e_comp_wl->wl.disp, &wl_eom_interface, -- 2.7.4 From 6a98082ebfbb2e9f840c11a47df71f310ee0c7b8 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 8 Apr 2016 17:48:23 +0900 Subject: [PATCH 09/16] add -Werror Change-Id: I357129560e8edc003a68f11bdd9608a47fa2b6f6 --- packaging/e-mod-tizen-eom.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/e-mod-tizen-eom.spec b/packaging/e-mod-tizen-eom.spec index bd55b69..7a5adcf 100644 --- a/packaging/e-mod-tizen-eom.spec +++ b/packaging/e-mod-tizen-eom.spec @@ -33,7 +33,7 @@ This package is a the Enlightenment eom Module for Tizen. %build export GC_SECTIONS_FLAGS="-fdata-sections -ffunction-sections -Wl,--gc-sections" -export CFLAGS+=" -Wall -g -fPIC -rdynamic ${GC_SECTIONS_FLAGS}" +export CFLAGS+=" -Wall -Werror -g -fPIC -rdynamic ${GC_SECTIONS_FLAGS}" export LDFLAGS+=" -Wl,--hash-style=both -Wl,--as-needed -Wl,--rpath=/usr/lib" %autogen -- 2.7.4 From cc394ef595cf52bd154c924c6df83ce43e48d8eb Mon Sep 17 00:00:00 2001 From: Roman Marchenko Date: Fri, 18 Mar 2016 17:52:42 +0200 Subject: [PATCH 10/16] add handling of eom window setting Change-Id: I9471ca7a3956346ec8ef27689e56d1eb030e121d Signed-off-by: Roman Marchenko --- packaging/e-mod-tizen-eom.spec | 1 + src/e_mod_main.c | 88 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/packaging/e-mod-tizen-eom.spec b/packaging/e-mod-tizen-eom.spec index 7a5adcf..68312d1 100644 --- a/packaging/e-mod-tizen-eom.spec +++ b/packaging/e-mod-tizen-eom.spec @@ -16,6 +16,7 @@ BuildRequires: pkgconfig(x11) %endif %if %{with wayland} BuildRequires: pkgconfig(wayland-server) +BuildRequires: pkgconfig(libtbm) %endif BuildRequires: pkgconfig(dlog) %if "%{?profile}" == "common" diff --git a/src/e_mod_main.c b/src/e_mod_main.c index ff137f1..08fce7d 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -4,6 +4,9 @@ #include "eom-server-protocol.h" #include "Ecore_Drm.h" +#include +#include + typedef struct _E_Eom E_Eom, *E_EomPtr; struct _E_Eom @@ -17,6 +20,8 @@ E_EomPtr g_eom = NULL; E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "EOM Module" }; +static E_Client_Hook *fullscreen_pre_hook = NULL; + static E_Comp_Wl_Output * _e_eom_e_comp_wl_output_get(Eina_List *outputs, const char *id) { @@ -96,6 +101,81 @@ end: return ECORE_CALLBACK_PASS_ON; } +void +_e_eom_set_output(Ecore_Drm_Output * drm_output, tbm_surface_h surface) +{ + /* TODO: chack save and commit*/ +} + +static Ecore_Drm_Output * +_e_eom_get_drm_output_for_client(E_Client *ec) +{ + Ecore_Drm_Output *drm_output; + Ecore_Drm_Device *dev; + Eina_List *l; + + /* TODO: get real output, now we just return HDMI */ + EINA_LIST_FOREACH(ecore_drm_devices_get(), l, dev) + { + drm_output = ecore_drm_device_output_name_find(dev, "HDMI-A-0"); + if (drm_output) + return drm_output; + } + return NULL; +} + +static tbm_surface_h +_e_eom_get_tbm_surface_for_client(E_Client *ec) +{ + E_Pixmap *pixmap = ec->pixmap; + E_Comp_Wl_Buffer *buffer = e_pixmap_resource_get(pixmap); + tbm_surface_h tsurface = NULL; + E_Comp_Wl_Data *wl_comp_data = (E_Comp_Wl_Data *) e_comp->wl_comp_data; + + EINA_SAFETY_ON_NULL_RETURN_VAL(buffer != NULL, NULL); + + tsurface = wayland_tbm_server_get_surface(wl_comp_data->tbm.server, buffer->resource); + + return tsurface; +} + +static void +_e_eom_canvas_render_post(void *data EINA_UNUSED, Evas *e EINA_UNUSED, void *event_info EINA_UNUSED) +{ + Ecore_Drm_Output * drm_output; + tbm_surface_h surface; + + E_Client *ec = data; + EINA_SAFETY_ON_NULL_RETURN(ec != NULL); + EINA_SAFETY_ON_NULL_RETURN(ec->frame != NULL); + + drm_output = _e_eom_get_drm_output_for_client(ec); + EINA_SAFETY_ON_NULL_RETURN(drm_output != NULL); + + surface = _e_eom_get_tbm_surface_for_client(ec); + + _e_eom_set_output(drm_output, surface); +} + +static void +_e_eom_fullscreen_pre_cb_hook(void *data, E_Client *ec) +{ + Ecore_Drm_Output * drm_output; + tbm_surface_h surface; + + EINA_SAFETY_ON_NULL_RETURN(ec != NULL); + EINA_SAFETY_ON_NULL_RETURN(ec->frame != NULL); + + drm_output = _e_eom_get_drm_output_for_client(ec); + EINA_SAFETY_ON_NULL_RETURN(drm_output != NULL); + + surface = _e_eom_get_tbm_surface_for_client(ec); + + _e_eom_set_output(drm_output, surface); + + evas_event_callback_add(ec->frame, EVAS_CALLBACK_RENDER_POST, _e_eom_canvas_render_post, ec); +} + static Eina_Bool _e_eom_ecore_drm_activate_cb(void *data, int type EINA_UNUSED, void *event) { @@ -192,6 +272,12 @@ _e_eom_deinit() ecore_event_handler_del(h); } + if (fullscreen_pre_hook) + { + e_client_hook_del(fullscreen_pre_hook); + fullscreen_pre_hook = NULL; + } + if (g_eom->global) wl_global_destroy(g_eom->global); E_FREE(g_eom); @@ -215,6 +301,8 @@ _e_eom_init() E_LIST_HANDLER_APPEND(g_eom->handlers, ECORE_DRM_EVENT_ACTIVATE, _e_eom_ecore_drm_activate_cb, g_eom); E_LIST_HANDLER_APPEND(g_eom->handlers, ECORE_DRM_EVENT_OUTPUT, _e_eom_ecore_drm_output_cb, g_eom); + fullscreen_pre_hook = e_client_hook_add(E_CLIENT_HOOK_FULLSCREEN_PRE, _e_eom_fullscreen_pre_cb_hook, NULL); + return EINA_TRUE; err: -- 2.7.4 From 0c78701644e77ba92f07449bc3fd09838d1ed983 Mon Sep 17 00:00:00 2001 From: Roman Peresipkyn Date: Fri, 18 Mar 2016 20:52:51 +0200 Subject: [PATCH 11/16] base implemenation of clone mode Change-Id: I155048786d2ef21b7b75f6a364eda80aab8008e5 Signed-off-by: Roman Peresipkyn --- src/e_mod_main.c | 187 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 171 insertions(+), 16 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 08fce7d..a64778d 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -7,6 +7,8 @@ #include #include +#include + typedef struct _E_Eom E_Eom, *E_EomPtr; struct _E_Eom @@ -16,6 +18,23 @@ struct _E_Eom Eina_List *handlers; }; +typedef struct _Ecore_Drm_Hal_Output +{ + tdm_output *output; + tdm_layer *primary_layer; +} Ecore_Drm_Hal_Output; + +typedef struct +{ + tdm_layer *layer; + tdm_output *output; +} Eom_Event; + +static Eom_Event g_eom_event; + +/* hack to get frambuffer of primary output*/ +static int dci_output_id = -1; + E_EomPtr g_eom = NULL; E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "EOM Module" }; @@ -49,16 +68,123 @@ _e_eom_e_comp_wl_output_get(Eina_List *outputs, const char *id) return NULL; } + +static Ecore_Drm_Hal_Output * +_e_eom_e_comp_hal_output_get(const char *id, int primary_output_id) +{ + Ecore_Drm_Hal_Output * hal_output; + Ecore_Drm_Output *drm_output; + Ecore_Drm_Device *dev; + Eina_List *l; + + + if (strcmp(id, "HDMI-A-0")) + { + dci_output_id = 1; + EOM_DBG("not find output\n"); + return NULL; + } + + if ( dci_output_id == -1 ) + { + /* + * We are trying to find id of build in output aka main one, by this id we + * will get frambuffer. HDMI is found first by E during initialization + * so we need this function to be called twice to get appropriate + * primary output id. That mean that E must emit ECORE_DRM_EVENT_OUTPUT + * event twice + */ + return NULL; + } + + EOM_DBG("dci_output_id:%d\n", dci_output_id); + + EINA_LIST_FOREACH(ecore_drm_devices_get(), l, dev) + { + drm_output = ecore_drm_device_output_name_find(dev, id); + } + + if (!drm_output) + { + EOM_DBG("not find drm output\n"); + return NULL; + } + + hal_output = ecore_drm_output_hal_private_get(drm_output); + if (!hal_output) + { + EOM_DBG("not find hal output output\n"); + return NULL; + } + + EOM_DBG("find\n"); + return hal_output; +} + +static tbm_surface_h +_e_eom_e_comp_tdm_surface_get() +{ + Ecore_Drm_Fb* fb; + + fb = _ecore_drm_display_fb_find_with_id(dci_output_id); + if (!fb) + { + EOM_DBG("no Ecore_Drm_Fb for dci_output_id:%d\n", dci_output_id); + return NULL; + } + + if (!fb->hal_buffer) + { + EOM_DBG("no hal_buffer\n"); + return NULL; + } + + return fb->hal_buffer; +} + +static void +_ecore_drm_display_output_cb_commit(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUSED, + unsigned int tv_sec EINA_UNUSED, unsigned int tv_usec EINA_UNUSED, + void *user_data) +{ + Eom_Event *eom_event = (Eom_Event *)user_data; + tdm_error err = TDM_ERROR_NONE; + + tbm_surface_h tdm_buffer = _e_eom_e_comp_tdm_surface_get(); + if (!tdm_buffer) + { + EOM_ERR("Event: tdm_buffer is NULL\n"); + return; + } + + /* Do clone */ + tdm_layer_set_buffer(eom_event->layer, tdm_buffer); + + err = tdm_output_commit(eom_event->output, 0, NULL, eom_event); + if (err != TDM_ERROR_NONE) + { + EOM_ERR("Event: Cannot commit crtc\n"); + return; + } +} + static Eina_Bool _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) { Ecore_Drm_Event_Output *e; E_EomPtr eom = data; - E_Comp_Wl_Output *output; - Eina_List *l2; + E_Comp_Wl_Output *wl_output; + Ecore_Drm_Hal_Output *hal_output; + tbm_surface_h tdm_buffer; + Ecore_Drm_Fb *fb; + Ecore_Drm_Device *dev; + Eina_List *l, *l2; + Eom_Event *eom_event = &g_eom_event; struct wl_resource *output_resource; enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; char buff[PATH_MAX]; + tdm_error err = TDM_ERROR_NONE; + if (!(e = event)) goto end; @@ -70,20 +196,48 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e snprintf(buff, sizeof(buff), "%s", e->name); /* get the e_comp_wl_output */ - output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, buff); - if (!output) - { - EOM_ERR("no e_comp_wl_outputs. (%s)\n", buff); - goto end; - } - - /* TODO: - * we need ecore_drm_output_connector_get()/ecore_drm_output_conn_name_get() - * function to get the connector type - */ - - /* send notify in each outputs associated with e_comp_wl_output */ - EINA_LIST_FOREACH(output->resources, l2, output_resource) + wl_output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, buff); + if (!wl_output) + { + EOM_ERR("no e_comp_wl_outputs. (%s)\n", buff); + goto end; + } + + /* Get hal output */ + hal_output = _e_eom_e_comp_hal_output_get(buff, e->id); + if (!hal_output) + { + EOM_ERR("no hal outputs, (%s)\n", buff); + goto end; + } + + /* Get main frame buffer */ + tdm_buffer = _e_eom_e_comp_tdm_surface_get(); + if (!tdm_buffer ) + { + EOM_ERR("no framebuffer\n"); + goto end; + } + + /* + * TODO: convert primary output size to external one + */ + + /* Do clone */ + tdm_layer_set_buffer(hal_output->primary_layer, tdm_buffer); + + eom_event->layer = hal_output->primary_layer; + eom_event->output = hal_output->output; + + err = tdm_output_commit(hal_output->output, 0, _ecore_drm_display_output_cb_commit, &eom_event); + if (err != TDM_ERROR_NONE) + { + EOM_ERR("Cannot commit crtc\n"); + return ECORE_CALLBACK_PASS_ON; + } + + + EINA_LIST_FOREACH(wl_output->resources, l2, output_resource) { if (e->plug) wl_eom_send_output_type(eom->resource, @@ -101,6 +255,7 @@ end: return ECORE_CALLBACK_PASS_ON; } + void _e_eom_set_output(Ecore_Drm_Output * drm_output, tbm_surface_h surface) { -- 2.7.4 From 21ebe03c6aba30e21527aeb96f103fa83bd33c35 Mon Sep 17 00:00:00 2001 From: Roman Peresipkyn Date: Mon, 21 Mar 2016 14:15:57 +0200 Subject: [PATCH 12/16] do enlightenmetn's code style Change-Id: I8f61ad345b3df4aec1b31922764089864e084d85 Signed-off-by: Roman Peresipkyn --- src/e_mod_main.c | 414 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 216 insertions(+), 198 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index a64778d..241dd4d 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -2,8 +2,12 @@ #include "e.h" #include "e_mod_main.h" #include "eom-server-protocol.h" +#include +#include +#include #include "Ecore_Drm.h" - +#include +#include #include #include @@ -32,42 +36,48 @@ typedef struct static Eom_Event g_eom_event; -/* hack to get frambuffer of primary output*/ -static int dci_output_id = -1; - E_EomPtr g_eom = NULL; E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "EOM Module" }; static E_Client_Hook *fullscreen_pre_hook = NULL; + static E_Comp_Wl_Output * _e_eom_e_comp_wl_output_get(Eina_List *outputs, const char *id) { Eina_List *l; - E_Comp_Wl_Output *output; + E_Comp_Wl_Output *output, *out; + int num_outputs = 0; - EINA_LIST_FOREACH(outputs, l, output) + EINA_LIST_FOREACH(outputs, l, out) { - char *temp_id = NULL; - temp_id = strchr(output->id, '/'); - if (temp_id == NULL) - { - if (!strcmp(output->id, id)) - return output; - } - else - { - int loc = temp_id - output->id; - - if (!strncmp(output->id, id, loc)) - return output; - } + char *temp_id = NULL; + temp_id = strchr(out->id, '/'); + if (temp_id == NULL) + { + if (!strcmp(out->id, id)) + output = out; + } + else + { + int loc = temp_id - out->id; + + if (!strncmp(out->id, id, loc)) + output = out; + } + + num_outputs += 1; } - return NULL; -} + /* + * There is no external output + */ + if (num_outputs == 1) + return NULL; + return output; +} static Ecore_Drm_Hal_Output * _e_eom_e_comp_hal_output_get(const char *id, int primary_output_id) @@ -78,44 +88,32 @@ _e_eom_e_comp_hal_output_get(const char *id, int primary_output_id) Eina_List *l; + /* + * Temporary take into account only HDMI + */ if (strcmp(id, "HDMI-A-0")) - { - dci_output_id = 1; - EOM_DBG("not find output\n"); - return NULL; - } - - if ( dci_output_id == -1 ) - { - /* - * We are trying to find id of build in output aka main one, by this id we - * will get frambuffer. HDMI is found first by E during initialization - * so we need this function to be called twice to get appropriate - * primary output id. That mean that E must emit ECORE_DRM_EVENT_OUTPUT - * event twice - */ - return NULL; - } - - EOM_DBG("dci_output_id:%d\n", dci_output_id); + { + EOM_DBG("not find output\n"); + return NULL; + } EINA_LIST_FOREACH(ecore_drm_devices_get(), l, dev) - { - drm_output = ecore_drm_device_output_name_find(dev, id); - } + { + drm_output = ecore_drm_device_output_name_find(dev, id); + } if (!drm_output) - { - EOM_DBG("not find drm output\n"); - return NULL; - } + { + EOM_DBG("not find drm output\n"); + return NULL; + } hal_output = ecore_drm_output_hal_private_get(drm_output); if (!hal_output) - { - EOM_DBG("not find hal output output\n"); - return NULL; - } + { + EOM_DBG("not find hal output output\n"); + return NULL; + } EOM_DBG("find\n"); return hal_output; @@ -124,48 +122,63 @@ _e_eom_e_comp_hal_output_get(const char *id, int primary_output_id) static tbm_surface_h _e_eom_e_comp_tdm_surface_get() { - Ecore_Drm_Fb* fb; - - fb = _ecore_drm_display_fb_find_with_id(dci_output_id); - if (!fb) - { - EOM_DBG("no Ecore_Drm_Fb for dci_output_id:%d\n", dci_output_id); - return NULL; - } - - if (!fb->hal_buffer) - { - EOM_DBG("no hal_buffer\n"); - return NULL; - } - - return fb->hal_buffer; + Evas_Engine_Info_Drm *einfo; + Ecore_Drm_Fb* fb; + Ecore_Evas *ee; + Evas *evas; + + EOM_DBG("1\n"); + + if (!e_comp || !e_comp->evas /*|| e_comp->ee->evas*/) + return NULL; + + EOM_DBG("2\n"); + + einfo = (Evas_Engine_Info_Drm *)evas_engine_info_get(e_comp->evas); + + EOM_DBG("3\n"); + + fb = _ecore_drm_display_fb_find_with_id(einfo->info.buffer_id); + if (!fb) + { + EOM_DBG("no Ecore_Drm_Fb for dci_output_id:%d\n", einfo->info.buffer_id); + return NULL; + } + + if (!fb->hal_buffer) + { + EOM_DBG("no hal_buffer\n"); + return NULL; + } + + EOM_DBG("find hal_buffer"); + return fb->hal_buffer; } static void _ecore_drm_display_output_cb_commit(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUSED, - unsigned int tv_sec EINA_UNUSED, unsigned int tv_usec EINA_UNUSED, - void *user_data) + unsigned int tv_sec EINA_UNUSED, unsigned int tv_usec EINA_UNUSED, + void *user_data) { - Eom_Event *eom_event = (Eom_Event *)user_data; - tdm_error err = TDM_ERROR_NONE; - - tbm_surface_h tdm_buffer = _e_eom_e_comp_tdm_surface_get(); - if (!tdm_buffer) - { - EOM_ERR("Event: tdm_buffer is NULL\n"); - return; - } - - /* Do clone */ - tdm_layer_set_buffer(eom_event->layer, tdm_buffer); - - err = tdm_output_commit(eom_event->output, 0, NULL, eom_event); - if (err != TDM_ERROR_NONE) - { - EOM_ERR("Event: Cannot commit crtc\n"); - return; - } + Eom_Event *eom_event = (Eom_Event *)user_data; + tdm_error err = TDM_ERROR_NONE; + + tbm_surface_h tdm_buffer = _e_eom_e_comp_tdm_surface_get(); + if (!tdm_buffer) + { + EOM_ERR("Event: tdm_buffer is NULL\n"); + return; + } + + /* Do clone */ + tdm_layer_set_buffer(eom_event->layer, tdm_buffer); + + err = tdm_output_commit(eom_event->output, 0, NULL, eom_event); + if (err != TDM_ERROR_NONE) + { + EOM_ERR("Event: Cannot commit crtc\n"); + return; + } } static Eina_Bool @@ -176,6 +189,7 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e E_Comp_Wl_Output *wl_output; Ecore_Drm_Hal_Output *hal_output; tbm_surface_h tdm_buffer; + tbm_surface_info_s tdm_buffer_info; Ecore_Drm_Fb *fb; Ecore_Drm_Device *dev; Eina_List *l, *l2; @@ -185,70 +199,74 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e char buff[PATH_MAX]; tdm_error err = TDM_ERROR_NONE; - if (!(e = event)) goto end; if (!e->plug) goto end; EOM_DBG("id:%d (x,y,w,h):(%d,%d,%d,%d) (w_mm,h_mm):(%d,%d) refresh:%d subpixel_order:%d transform:%d make:%s model:%s name:%s plug:%d\n", - e->id, e->x, e->y, e->w, e->h, e->phys_width, e->phys_height, e->refresh, e->subpixel_order, e->transform, e->make, e->model, e->name, e->plug); + e->id, e->x, e->y, e->w, e->h, e->phys_width, e->phys_height, e->refresh, e->subpixel_order, e->transform, e->make, e->model, e->name, e->plug); snprintf(buff, sizeof(buff), "%s", e->name); /* get the e_comp_wl_output */ wl_output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, buff); if (!wl_output) - { - EOM_ERR("no e_comp_wl_outputs. (%s)\n", buff); - goto end; - } + { + EOM_ERR("no e_comp_wl_outputs. (%s)\n", buff); + goto end; + } /* Get hal output */ hal_output = _e_eom_e_comp_hal_output_get(buff, e->id); - if (!hal_output) - { - EOM_ERR("no hal outputs, (%s)\n", buff); - goto end; - } - - /* Get main frame buffer */ - tdm_buffer = _e_eom_e_comp_tdm_surface_get(); - if (!tdm_buffer ) - { - EOM_ERR("no framebuffer\n"); - goto end; - } - - /* - * TODO: convert primary output size to external one - */ - - /* Do clone */ - tdm_layer_set_buffer(hal_output->primary_layer, tdm_buffer); - - eom_event->layer = hal_output->primary_layer; - eom_event->output = hal_output->output; - - err = tdm_output_commit(hal_output->output, 0, _ecore_drm_display_output_cb_commit, &eom_event); - if (err != TDM_ERROR_NONE) - { - EOM_ERR("Cannot commit crtc\n"); - return ECORE_CALLBACK_PASS_ON; - } + if (!hal_output) + { + EOM_ERR("no hal outputs, (%s)\n", buff); + goto end; + } + + /* Get main frame buffer */ + tdm_buffer = _e_eom_e_comp_tdm_surface_get(); + if (!tdm_buffer ) + { + EOM_ERR("no framebuffer\n"); + goto end; + } + + tbm_surface_get_info(tdm_buffer, tdm_buffer_info ); + + EOM_DBG("%dx%d bpp:%d size:%d", tdm_buffer_info->width, + tdm_buffer_info->height, tdm_buffer_info->bpp, tdm_buffer_info->size); + + /* + * TODO: convert primary output size to external one + */ + + /* Do clone */ + tdm_layer_set_buffer(hal_output->primary_layer, tdm_buffer); + + eom_event->layer = hal_output->primary_layer; + eom_event->output = hal_output->output; + + err = tdm_output_commit(hal_output->output, 0, _ecore_drm_display_output_cb_commit, &eom_event); + if (err != TDM_ERROR_NONE) + { + EOM_ERR("Cannot commit crtc\n"); + return ECORE_CALLBACK_PASS_ON; + } EINA_LIST_FOREACH(wl_output->resources, l2, output_resource) { - if (e->plug) - wl_eom_send_output_type(eom->resource, - output_resource, - eom_type, - WL_EOM_STATUS_CONNECTION); - else - wl_eom_send_output_type(eom->resource, - output_resource, - eom_type, - WL_EOM_STATUS_DISCONNECTION); + if (e->plug) + wl_eom_send_output_type(eom->resource, + output_resource, + eom_type, + WL_EOM_STATUS_CONNECTION); + else + wl_eom_send_output_type(eom->resource, + output_resource, + eom_type, + WL_EOM_STATUS_DISCONNECTION); } end: @@ -259,76 +277,76 @@ end: void _e_eom_set_output(Ecore_Drm_Output * drm_output, tbm_surface_h surface) { - /* TODO: chack save and commit*/ + /* TODO: chack save and commit*/ } static Ecore_Drm_Output * _e_eom_get_drm_output_for_client(E_Client *ec) { - Ecore_Drm_Output *drm_output; - Ecore_Drm_Device *dev; - Eina_List *l; - - /* TODO: get real output, now we just return HDMI */ - EINA_LIST_FOREACH(ecore_drm_devices_get(), l, dev) - { - drm_output = ecore_drm_device_output_name_find(dev, "HDMI-A-0"); - if (drm_output) - return drm_output; - } - return NULL; + Ecore_Drm_Output *drm_output; + Ecore_Drm_Device *dev; + Eina_List *l; + + /* TODO: get real output, now we just return HDMI */ + EINA_LIST_FOREACH(ecore_drm_devices_get(), l, dev) + { + drm_output = ecore_drm_device_output_name_find(dev, "HDMI-A-0"); + if (drm_output) + return drm_output; + } + return NULL; } static tbm_surface_h _e_eom_get_tbm_surface_for_client(E_Client *ec) { - E_Pixmap *pixmap = ec->pixmap; - E_Comp_Wl_Buffer *buffer = e_pixmap_resource_get(pixmap); - tbm_surface_h tsurface = NULL; - E_Comp_Wl_Data *wl_comp_data = (E_Comp_Wl_Data *) e_comp->wl_comp_data; + E_Pixmap *pixmap = ec->pixmap; + E_Comp_Wl_Buffer *buffer = e_pixmap_resource_get(pixmap); + tbm_surface_h tsurface = NULL; + E_Comp_Wl_Data *wl_comp_data = (E_Comp_Wl_Data *) e_comp->wl_comp_data; - EINA_SAFETY_ON_NULL_RETURN_VAL(buffer != NULL, NULL); + EINA_SAFETY_ON_NULL_RETURN_VAL(buffer != NULL, NULL); - tsurface = wayland_tbm_server_get_surface(wl_comp_data->tbm.server, buffer->resource); + tsurface = wayland_tbm_server_get_surface(wl_comp_data->tbm.server, buffer->resource); - return tsurface; + return tsurface; } static void _e_eom_canvas_render_post(void *data EINA_UNUSED, Evas *e EINA_UNUSED, void *event_info EINA_UNUSED) { - Ecore_Drm_Output * drm_output; - tbm_surface_h surface; + Ecore_Drm_Output * drm_output; + tbm_surface_h surface; - E_Client *ec = data; - EINA_SAFETY_ON_NULL_RETURN(ec != NULL); - EINA_SAFETY_ON_NULL_RETURN(ec->frame != NULL); + E_Client *ec = data; + EINA_SAFETY_ON_NULL_RETURN(ec != NULL); + EINA_SAFETY_ON_NULL_RETURN(ec->frame != NULL); - drm_output = _e_eom_get_drm_output_for_client(ec); - EINA_SAFETY_ON_NULL_RETURN(drm_output != NULL); + drm_output = _e_eom_get_drm_output_for_client(ec); + EINA_SAFETY_ON_NULL_RETURN(drm_output != NULL); - surface = _e_eom_get_tbm_surface_for_client(ec); + surface = _e_eom_get_tbm_surface_for_client(ec); - _e_eom_set_output(drm_output, surface); + _e_eom_set_output(drm_output, surface); } static void _e_eom_fullscreen_pre_cb_hook(void *data, E_Client *ec) { - Ecore_Drm_Output * drm_output; - tbm_surface_h surface; + Ecore_Drm_Output * drm_output; + tbm_surface_h surface; - EINA_SAFETY_ON_NULL_RETURN(ec != NULL); - EINA_SAFETY_ON_NULL_RETURN(ec->frame != NULL); + EINA_SAFETY_ON_NULL_RETURN(ec != NULL); + EINA_SAFETY_ON_NULL_RETURN(ec->frame != NULL); - drm_output = _e_eom_get_drm_output_for_client(ec); - EINA_SAFETY_ON_NULL_RETURN(drm_output != NULL); + drm_output = _e_eom_get_drm_output_for_client(ec); + EINA_SAFETY_ON_NULL_RETURN(drm_output != NULL); - surface = _e_eom_get_tbm_surface_for_client(ec); + surface = _e_eom_get_tbm_surface_for_client(ec); - _e_eom_set_output(drm_output, surface); + _e_eom_set_output(drm_output, surface); - evas_event_callback_add(ec->frame, EVAS_CALLBACK_RENDER_POST, _e_eom_canvas_render_post, ec); + evas_event_callback_add(ec->frame, EVAS_CALLBACK_RENDER_POST, _e_eom_canvas_render_post, ec); } static Eina_Bool @@ -347,11 +365,11 @@ _e_eom_ecore_drm_activate_cb(void *data, int type EINA_UNUSED, void *event) if (e->active) { - /* TODO: do something */ + /* TODO: do something */ } else { - /* TODO: do something */ + /* TODO: do something */ } end: @@ -368,10 +386,10 @@ _e_eom_wl_request_set_attribute_cb(struct wl_client *client, struct wl_resource EOM_DBG("attribute:%d\n", attribute); wl_eom_send_output_attribute(resource, - output, - attribute, - WL_EOM_ATTRIBUTE_STATE_ACTIVE, - WL_EOM_ERROR_NONE); + output, + attribute, + WL_EOM_ATTRIBUTE_STATE_ACTIVE, + WL_EOM_ERROR_NONE); } static const struct wl_eom_interface _e_eom_wl_implementation = @@ -394,20 +412,20 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 struct wl_resource *resource; resource = wl_resource_create(client, - &wl_eom_interface, - MIN(version, 1), - id); + &wl_eom_interface, + MIN(version, 1), + id); if (!resource) - { - EOM_ERR("error. resource is null. (version :%d, id:%d)\n", version, id); - wl_client_post_no_memory(client); - return; - } + { + EOM_ERR("error. resource is null. (version :%d, id:%d)\n", version, id); + wl_client_post_no_memory(client); + return; + } wl_resource_set_implementation(resource, - &_e_eom_wl_implementation, - eom, - _e_eom_wl_resource_destory_cb); + &_e_eom_wl_implementation, + eom, + _e_eom_wl_resource_destory_cb); eom->resource = resource; @@ -423,14 +441,14 @@ _e_eom_deinit() if (g_eom->handlers) { - EINA_LIST_FREE(g_eom->handlers, h) - ecore_event_handler_del(h); + EINA_LIST_FREE(g_eom->handlers, h) + ecore_event_handler_del(h); } if (fullscreen_pre_hook) { - e_client_hook_del(fullscreen_pre_hook); - fullscreen_pre_hook = NULL; + e_client_hook_del(fullscreen_pre_hook); + fullscreen_pre_hook = NULL; } if (g_eom->global) wl_global_destroy(g_eom->global); @@ -447,10 +465,10 @@ _e_eom_init() EINA_SAFETY_ON_NULL_RETURN_VAL(g_eom, EINA_FALSE); g_eom->global = wl_global_create(e_comp_wl->wl.disp, - &wl_eom_interface, - 1, - g_eom, - _e_eom_wl_bind_cb); + &wl_eom_interface, + 1, + g_eom, + _e_eom_wl_bind_cb); EINA_SAFETY_ON_NULL_GOTO(g_eom->global, err); E_LIST_HANDLER_APPEND(g_eom->handlers, ECORE_DRM_EVENT_ACTIVATE, _e_eom_ecore_drm_activate_cb, g_eom); -- 2.7.4 From 9ffc2bb6a993ee8e10c2bb608b571b5501ffab2f Mon Sep 17 00:00:00 2001 From: Roman Peresipkyn Date: Mon, 21 Mar 2016 21:24:18 +0200 Subject: [PATCH 13/16] add reinitialization of external output layer and buffer Change-Id: I642afed3fa954abed2dd0149127bab572c02dd19 Signed-off-by: Roman Peresipkyn --- src/e_mod_main.c | 326 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 270 insertions(+), 56 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 241dd4d..7784bce 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -20,6 +20,10 @@ struct _E_Eom struct wl_global *global; struct wl_resource *resource; Eina_List *handlers; + + tdm_display *dpy; + tbm_bufmgr bufmgr; + int fd; }; typedef struct _Ecore_Drm_Hal_Output @@ -32,6 +36,7 @@ typedef struct { tdm_layer *layer; tdm_output *output; + tbm_surface_h dst_buffers; } Eom_Event; static Eom_Event g_eom_event; @@ -42,12 +47,11 @@ E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "EOM Module" }; static E_Client_Hook *fullscreen_pre_hook = NULL; - static E_Comp_Wl_Output * _e_eom_e_comp_wl_output_get(Eina_List *outputs, const char *id) { Eina_List *l; - E_Comp_Wl_Output *output, *out; + E_Comp_Wl_Output *output = NULL, *out; int num_outputs = 0; EINA_LIST_FOREACH(outputs, l, out) @@ -79,18 +83,21 @@ _e_eom_e_comp_wl_output_get(Eina_List *outputs, const char *id) return output; } -static Ecore_Drm_Hal_Output * -_e_eom_e_comp_hal_output_get(const char *id, int primary_output_id) +static tdm_output * +_e_eom_hal_output_get(const char *id, int primary_output_id) { - Ecore_Drm_Hal_Output * hal_output; Ecore_Drm_Output *drm_output; Ecore_Drm_Device *dev; Eina_List *l; + int crtc_id = 0; + tdm_error err = TDM_ERROR_NONE; + + tdm_output *output = NULL; /* - * Temporary take into account only HDMI - */ + * Temporary take into account only HDMI + */ if (strcmp(id, "HDMI-A-0")) { EOM_DBG("not find output\n"); @@ -108,36 +115,100 @@ _e_eom_e_comp_hal_output_get(const char *id, int primary_output_id) return NULL; } - hal_output = ecore_drm_output_hal_private_get(drm_output); - if (!hal_output) + crtc_id = ecore_drm_output_crtc_id_get(drm_output); + if (crtc_id == 0) + { + EOM_DBG("crtc is 0\n"); + return NULL; + } + + output = tdm_display_get_output(g_eom->dpy, crtc_id, NULL); + if (!output) { - EOM_DBG("not find hal output output\n"); + EOM_DBG("there is no HAL output for:%d\n", crtc_id); return NULL; } EOM_DBG("find\n"); - return hal_output; + return output; +} + +static tdm_layer * +_e_eom_hal_layer_get(tdm_output *output, int width, int height) +{ + int i = 0; + int count = 0; + tdm_layer *layer; + tdm_error err = TDM_ERROR_NONE; + tdm_layer_capability capa; + + tdm_info_layer set_layer_info; + + err = tdm_output_get_layer_count(output, &count); + if (err != TDM_ERROR_NONE) + { + EOM_DBG ("tdm_output_get_layer_count fail(%d)\n", err); + return NULL; + } + + for (i = 0; i < count; i++) + { + layer = (tdm_layer *)tdm_output_get_layer(output, i, &err); + if (err != TDM_ERROR_NONE) + { + EOM_DBG ("tdm_output_get_layer fail(%d)\n", err); + return NULL; + } + + err = tdm_layer_get_capabilities(layer, &capa); + if (err != TDM_ERROR_NONE) + { + EOM_DBG ("tdm_layer_get_capabilities fail(%d)\n", err); + return NULL; + } + + if (capa & TDM_LAYER_CAPABILITY_PRIMARY) + { + EOM_DBG("TDM_LAYER_CAPABILITY_PRIMARY layer found : %d\n", i); + break; + } + } + + memset(&set_layer_info, 0x0, sizeof(tdm_info_layer)); + set_layer_info.src_config.size.h = width; + set_layer_info.src_config.size.v = height; + set_layer_info.src_config.pos.x = 0; + set_layer_info.src_config.pos.y = 0; + set_layer_info.src_config.pos.w = width; + set_layer_info.src_config.pos.h = height; + set_layer_info.src_config.format = TBM_FORMAT_ARGB8888; + set_layer_info.dst_pos.x = 0; + set_layer_info.dst_pos.y = 0; + set_layer_info.dst_pos.w = width; + set_layer_info.dst_pos.h = height; + set_layer_info.transform = TDM_TRANSFORM_NORMAL; + + err = tdm_layer_set_info(layer, &set_layer_info); + if (err != TDM_ERROR_NONE) + { + EOM_DBG ("tdm_layer_set_info fail(%d)\n", err); + return NULL; + } + + return layer; } static tbm_surface_h -_e_eom_e_comp_tdm_surface_get() +_e_eom_root_window_tdm_surface_get() { Evas_Engine_Info_Drm *einfo; Ecore_Drm_Fb* fb; - Ecore_Evas *ee; - Evas *evas; - EOM_DBG("1\n"); - - if (!e_comp || !e_comp->evas /*|| e_comp->ee->evas*/) - return NULL; - - EOM_DBG("2\n"); + if (!e_comp || !e_comp->evas) + return NULL; einfo = (Evas_Engine_Info_Drm *)evas_engine_info_get(e_comp->evas); - EOM_DBG("3\n"); - fb = _ecore_drm_display_fb_find_with_id(einfo->info.buffer_id); if (!fb) { @@ -156,22 +227,28 @@ _e_eom_e_comp_tdm_surface_get() } static void -_ecore_drm_display_output_cb_commit(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUSED, +_e_eom_output_cb_commit(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUSED, unsigned int tv_sec EINA_UNUSED, unsigned int tv_usec EINA_UNUSED, void *user_data) { Eom_Event *eom_event = (Eom_Event *)user_data; tdm_error err = TDM_ERROR_NONE; + tbm_surface_h src_buffer; + tbm_surface_h dst_buffer; + + EOM_ERR("Event\n"); - tbm_surface_h tdm_buffer = _e_eom_e_comp_tdm_surface_get(); - if (!tdm_buffer) + src_buffer = _e_eom_root_window_tdm_surface_get(); + if (!src_buffer ) { EOM_ERR("Event: tdm_buffer is NULL\n"); return; } + dst_buffer = eom_event->dst_buffers; + /* Do clone */ - tdm_layer_set_buffer(eom_event->layer, tdm_buffer); + tdm_layer_set_buffer(eom_event->layer, dst_buffer); err = tdm_output_commit(eom_event->output, 0, NULL, eom_event); if (err != TDM_ERROR_NONE) @@ -181,23 +258,68 @@ _ecore_drm_display_output_cb_commit(tdm_output *output EINA_UNUSED, unsigned int } } +static tbm_surface_h +_e_eom_create_extrenal_output_buffer(int width, int height) +{ + tbm_surface_h buffer; + tbm_surface_info_s buffer_info; + + /* + * TODO: Add support of other formats + */ + buffer = tbm_surface_internal_create_with_flags(width, height, + TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT); + if (!buffer) + { + EOM_DBG("can not create dst_buffer\n"); + return NULL; + } + + /* + * TODO: temp code for testing, actual convert will be in _e_eom_put_src_to_dst() + */ + memset(&buffer_info, 0x0, sizeof(tbm_surface_info_s)); + if (tbm_surface_map(buffer, + TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, + &buffer_info) != TBM_SURFACE_ERROR_NONE) + { + EOM_DBG("can not mmap buffer\n"); + return NULL; + } + + memset(buffer_info.planes[0].ptr, 0xff, buffer_info.planes[0].size); + tbm_surface_unmap(buffer); + + return buffer; +} + +static void +_e_eom_put_src_to_dst( tbm_surface_h src_buffer, tbm_surface_h dst_buffer) +{ + + + +} + static Eina_Bool _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) { Ecore_Drm_Event_Output *e; E_EomPtr eom = data; E_Comp_Wl_Output *wl_output; - Ecore_Drm_Hal_Output *hal_output; - tbm_surface_h tdm_buffer; - tbm_surface_info_s tdm_buffer_info; - Ecore_Drm_Fb *fb; - Ecore_Drm_Device *dev; - Eina_List *l, *l2; + tdm_output *hal_output; + tdm_layer *hal_layer; + tdm_info_layer layer_info; + tbm_surface_h src_buffer; + tbm_surface_h dst_buffer; + tbm_surface_info_s src_buffer_info ; + Eina_List *l2; Eom_Event *eom_event = &g_eom_event; struct wl_resource *output_resource; enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; char buff[PATH_MAX]; - tdm_error err = TDM_ERROR_NONE; + tdm_error tdm_err = TDM_ERROR_NONE; + int tbm_err = 0; if (!(e = event)) goto end; @@ -217,58 +339,101 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e } /* Get hal output */ - hal_output = _e_eom_e_comp_hal_output_get(buff, e->id); + hal_output = _e_eom_hal_output_get(buff, e->id); if (!hal_output) { EOM_ERR("no hal outputs, (%s)\n", buff); goto end; } + hal_layer = _e_eom_hal_layer_get(hal_output, e->w, e->h); + if (!hal_layer) + { + EOM_ERR("no hal layer\n"); + goto end; + } + /* Get main frame buffer */ - tdm_buffer = _e_eom_e_comp_tdm_surface_get(); - if (!tdm_buffer ) + src_buffer = _e_eom_root_window_tdm_surface_get(); + if (!src_buffer ) { EOM_ERR("no framebuffer\n"); goto end; } - tbm_surface_get_info(tdm_buffer, tdm_buffer_info ); + dst_buffer = _e_eom_create_extrenal_output_buffer(e->w, e->h); + if (!dst_buffer ) + { + EOM_ERR("no framebuffer\n"); + goto end; + } - EOM_DBG("%dx%d bpp:%d size:%d", tdm_buffer_info->width, - tdm_buffer_info->height, tdm_buffer_info->bpp, tdm_buffer_info->size); + tbm_surface_get_info(src_buffer, &src_buffer_info ); - /* - * TODO: convert primary output size to external one - */ + EOM_DBG("FRAMEBUFFER buffer: %dx%d bpp:%d size:%d", + src_buffer_info.width, + src_buffer_info.height, + src_buffer_info.bpp, + src_buffer_info.size); - /* Do clone */ - tdm_layer_set_buffer(hal_output->primary_layer, tdm_buffer); + _e_eom_put_src_to_dst(src_buffer, dst_buffer); - eom_event->layer = hal_output->primary_layer; - eom_event->output = hal_output->output; - err = tdm_output_commit(hal_output->output, 0, _ecore_drm_display_output_cb_commit, &eom_event); - if (err != TDM_ERROR_NONE) + tdm_err = tdm_layer_get_info(hal_layer, &layer_info); + if (tdm_err != TDM_ERROR_NONE) { - EOM_ERR("Cannot commit crtc\n"); - return ECORE_CALLBACK_PASS_ON; + EOM_ERR ("failed get layer info", tdm_err); + goto end; + } + + EOM_DBG("LAYER INFO: %dx%d, pos (x:%d, y:%d, w:%d, h:%d, dpos (x:%d, y:%d, w:%d, h:%d))", + layer_info.src_config.size.h, layer_info.src_config.size.v, + layer_info.src_config.pos.x, layer_info.src_config.pos.y, + layer_info.src_config.pos.w, layer_info.src_config.pos.h, + layer_info.dst_pos.x, layer_info.dst_pos.y, + layer_info.dst_pos.w, layer_info.dst_pos.h); + + tdm_err = tdm_layer_set_buffer(hal_layer, dst_buffer); + if (tdm_err != TDM_ERROR_NONE) + { + EOM_ERR("Failed set buffer on layer:%d\n", tdm_err); + goto end; } + eom_event->layer = hal_layer; + eom_event->output = hal_output; + eom_event->dst_buffers = dst_buffer; + + tdm_err = tdm_output_commit(hal_output, 0, _e_eom_output_cb_commit, &eom_event); + if (tdm_err != TDM_ERROR_NONE) + { + EOM_ERR("Cannot commit crtc:%d\n", tdm_err); + goto end; + } EINA_LIST_FOREACH(wl_output->resources, l2, output_resource) { if (e->plug) - wl_eom_send_output_type(eom->resource, + { + + wl_eom_send_output_type(eom->resource, output_resource, eom_type, WL_EOM_STATUS_CONNECTION); + } else + { + EOM_DBG("7\n"); + wl_eom_send_output_type(eom->resource, output_resource, eom_type, WL_EOM_STATUS_DISCONNECTION); + } } + EOM_DBG("8\n"); + end: return ECORE_CALLBACK_PASS_ON; } @@ -416,11 +581,11 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 MIN(version, 1), id); if (!resource) - { - EOM_ERR("error. resource is null. (version :%d, id:%d)\n", version, id); - wl_client_post_no_memory(client); - return; - } + { + EOM_ERR("error. resource is null. (version :%d, id:%d)\n", version, id); + wl_client_post_no_memory(client); + return; + } wl_resource_set_implementation(resource, &_e_eom_wl_implementation, @@ -456,11 +621,53 @@ _e_eom_deinit() E_FREE(g_eom); } +int +_e_eom_init_internal() +{ + tdm_error err = TDM_ERROR_NONE; + + EOM_DBG("1\n"); + + g_eom->dpy = tdm_display_init(&err); + if (err != TDM_ERROR_NONE) + { + EOM_DBG("failed initialize TDM\n"); + goto err; + } + + EOM_DBG("2\n"); + + err = tdm_display_get_fd(g_eom->dpy, &g_eom->fd); + if (err != TDM_ERROR_NONE) + { + EOM_DBG("failed get FD\n"); + goto err; + } + + EOM_DBG("3\n"); + + g_eom->bufmgr = tbm_bufmgr_init(g_eom->fd); + if (!g_eom->bufmgr) + { + EOM_DBG("failed initialize buffer manager\n"); + goto err; + } + + EOM_DBG("4\n"); + + return 1; +err: + return 0; +} + static Eina_Bool _e_eom_init() { + int ret = 0; + EINA_SAFETY_ON_NULL_GOTO(e_comp_wl, err); + g_eom = E_NEW(E_Eom, 1); EINA_SAFETY_ON_NULL_RETURN_VAL(g_eom, EINA_FALSE); @@ -471,6 +678,13 @@ _e_eom_init() _e_eom_wl_bind_cb); EINA_SAFETY_ON_NULL_GOTO(g_eom->global, err); + ret = _e_eom_init_internal(); + if (!ret) + { + EOM_ERR("failed init_internal()"); + goto err; + } + E_LIST_HANDLER_APPEND(g_eom->handlers, ECORE_DRM_EVENT_ACTIVATE, _e_eom_ecore_drm_activate_cb, g_eom); E_LIST_HANDLER_APPEND(g_eom->handlers, ECORE_DRM_EVENT_OUTPUT, _e_eom_ecore_drm_output_cb, g_eom); -- 2.7.4 From f743a6ebe4edee1d88ef5d6329e732b4324c410f Mon Sep 17 00:00:00 2001 From: Roman Peresipkyn Date: Tue, 22 Mar 2016 16:22:00 +0200 Subject: [PATCH 14/16] add modeset to force TDM do SetCrtc Change-Id: I9fbee79399d01d5599e0df892c97d7499c0e47e0 Signed-off-by: Roman Peresipkyn --- src/e_mod_main.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 79 insertions(+), 5 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 7784bce..27807a8 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -93,6 +93,9 @@ _e_eom_hal_output_get(const char *id, int primary_output_id) tdm_error err = TDM_ERROR_NONE; tdm_output *output = NULL; + tdm_output_mode *modes; + tdm_output_mode *big_mode; + int count = 0; /* @@ -129,6 +132,57 @@ _e_eom_hal_output_get(const char *id, int primary_output_id) return NULL; } + int min_w, min_h, max_w, max_h, preferred_align; + err = tdm_output_get_available_size(output, &min_w, &min_h, &max_w, &max_h, + &preferred_align); + if (err != TDM_ERROR_NONE) + { + EOM_DBG("Gent get geometry for hal output"); + return NULL; + } + + EOM_DBG("HAL size min:%dx%d max:%dx%d alighn:%d\n", + min_w, min_h, max_w, max_h, preferred_align); + + /* + * Force TDM to make setCrtc onto new buffer + */ + + + err = tdm_output_get_available_modes(output, &modes, &count); + if (err != TDM_ERROR_NONE) + { + EOM_DBG("Get availvable modes filed\n"); + return NULL; + } + + big_mode = &modes[0]; + + int i = 0; + for (i = 0; i < count; i++) + { + if ((modes[i].vdisplay + modes[i].hdisplay) >= + (big_mode->vdisplay + big_mode->hdisplay)) + { + big_mode = &modes[i]; + } + } + + if (!big_mode) + { + EOM_DBG("no Big mode\n"); + return NULL; + } + + EOM_DBG("BIG_MODE: %dx%d\n", big_mode->hdisplay, big_mode->vdisplay); + + err = tdm_output_set_mode(output, big_mode); + if (err != TDM_ERROR_NONE) + { + EOM_DBG("set Mode failed\n"); + return NULL; + } + EOM_DBG("find\n"); return output; } @@ -175,8 +229,8 @@ _e_eom_hal_layer_get(tdm_output *output, int width, int height) } memset(&set_layer_info, 0x0, sizeof(tdm_info_layer)); - set_layer_info.src_config.size.h = width; - set_layer_info.src_config.size.v = height; + set_layer_info.src_config.size.h = 3840; + set_layer_info.src_config.size.v = 2560; set_layer_info.src_config.pos.x = 0; set_layer_info.src_config.pos.y = 0; set_layer_info.src_config.pos.w = width; @@ -204,11 +258,21 @@ _e_eom_root_window_tdm_surface_get() Evas_Engine_Info_Drm *einfo; Ecore_Drm_Fb* fb; - if (!e_comp || !e_comp->evas) - return NULL; + if (!e_comp) + { + EOM_DBG("e_comp NULL\n"); + return NULL; + } + + if (!e_comp->evas) + { + EOM_DBG("e_comp->evas NULL"); + return NULL; + } einfo = (Evas_Engine_Info_Drm *)evas_engine_info_get(e_comp->evas); + /* fb = _ecore_drm_display_fb_find_with_id(einfo->info.buffer_id); if (!fb) { @@ -223,6 +287,7 @@ _e_eom_root_window_tdm_surface_get() } EOM_DBG("find hal_buffer"); + */ return fb->hal_buffer; } @@ -264,6 +329,9 @@ _e_eom_create_extrenal_output_buffer(int width, int height) tbm_surface_h buffer; tbm_surface_info_s buffer_info; + width = 3840; + height = 2560; + /* * TODO: Add support of other formats */ @@ -354,20 +422,25 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e } /* Get main frame buffer */ + + /* src_buffer = _e_eom_root_window_tdm_surface_get(); if (!src_buffer ) { EOM_ERR("no framebuffer\n"); goto end; } + */ + dst_buffer = _e_eom_create_extrenal_output_buffer(e->w, e->h); if (!dst_buffer ) { - EOM_ERR("no framebuffer\n"); + EOM_ERR("no dst buffer\n"); goto end; } + /* tbm_surface_get_info(src_buffer, &src_buffer_info ); EOM_DBG("FRAMEBUFFER buffer: %dx%d bpp:%d size:%d", @@ -377,6 +450,7 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e src_buffer_info.size); _e_eom_put_src_to_dst(src_buffer, dst_buffer); + */ tdm_err = tdm_layer_get_info(hal_layer, &layer_info); -- 2.7.4 From bc93aac9c9c4c075f685e5b45804926f3b42201e Mon Sep 17 00:00:00 2001 From: Roman Peresipkyn Date: Tue, 22 Mar 2016 16:31:20 +0200 Subject: [PATCH 15/16] add 3 spaces inside if statments Change-Id: I85fe7bdeee85b599b2a42af13922bb0ca6bc4663 Signed-off-by: Roman Peresipkyn --- src/e_mod_main.c | 208 +++++++++++++++++++++++++++---------------------------- 1 file changed, 104 insertions(+), 104 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 27807a8..77c502f 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -60,15 +60,15 @@ _e_eom_e_comp_wl_output_get(Eina_List *outputs, const char *id) temp_id = strchr(out->id, '/'); if (temp_id == NULL) { - if (!strcmp(out->id, id)) - output = out; + if (!strcmp(out->id, id)) + output = out; } else { - int loc = temp_id - out->id; + int loc = temp_id - out->id; - if (!strncmp(out->id, id, loc)) - output = out; + if (!strncmp(out->id, id, loc)) + output = out; } num_outputs += 1; @@ -103,8 +103,8 @@ _e_eom_hal_output_get(const char *id, int primary_output_id) */ if (strcmp(id, "HDMI-A-0")) { - EOM_DBG("not find output\n"); - return NULL; + EOM_DBG("not find output\n"); + return NULL; } EINA_LIST_FOREACH(ecore_drm_devices_get(), l, dev) @@ -114,35 +114,35 @@ _e_eom_hal_output_get(const char *id, int primary_output_id) if (!drm_output) { - EOM_DBG("not find drm output\n"); - return NULL; + EOM_DBG("not find drm output\n"); + return NULL; } crtc_id = ecore_drm_output_crtc_id_get(drm_output); if (crtc_id == 0) { - EOM_DBG("crtc is 0\n"); - return NULL; + EOM_DBG("crtc is 0\n"); + return NULL; } output = tdm_display_get_output(g_eom->dpy, crtc_id, NULL); if (!output) { - EOM_DBG("there is no HAL output for:%d\n", crtc_id); - return NULL; + EOM_DBG("there is no HAL output for:%d\n", crtc_id); + return NULL; } int min_w, min_h, max_w, max_h, preferred_align; err = tdm_output_get_available_size(output, &min_w, &min_h, &max_w, &max_h, - &preferred_align); + &preferred_align); if (err != TDM_ERROR_NONE) { - EOM_DBG("Gent get geometry for hal output"); - return NULL; + EOM_DBG("Gent get geometry for hal output"); + return NULL; } EOM_DBG("HAL size min:%dx%d max:%dx%d alighn:%d\n", - min_w, min_h, max_w, max_h, preferred_align); + min_w, min_h, max_w, max_h, preferred_align); /* * Force TDM to make setCrtc onto new buffer @@ -160,18 +160,18 @@ _e_eom_hal_output_get(const char *id, int primary_output_id) int i = 0; for (i = 0; i < count; i++) - { - if ((modes[i].vdisplay + modes[i].hdisplay) >= - (big_mode->vdisplay + big_mode->hdisplay)) - { - big_mode = &modes[i]; - } - } + { + if ((modes[i].vdisplay + modes[i].hdisplay) >= + (big_mode->vdisplay + big_mode->hdisplay)) + { + big_mode = &modes[i]; + } + } if (!big_mode) { - EOM_DBG("no Big mode\n"); - return NULL; + EOM_DBG("no Big mode\n"); + return NULL; } EOM_DBG("BIG_MODE: %dx%d\n", big_mode->hdisplay, big_mode->vdisplay); @@ -179,8 +179,8 @@ _e_eom_hal_output_get(const char *id, int primary_output_id) err = tdm_output_set_mode(output, big_mode); if (err != TDM_ERROR_NONE) { - EOM_DBG("set Mode failed\n"); - return NULL; + EOM_DBG("set Mode failed\n"); + return NULL; } EOM_DBG("find\n"); @@ -201,31 +201,31 @@ _e_eom_hal_layer_get(tdm_output *output, int width, int height) err = tdm_output_get_layer_count(output, &count); if (err != TDM_ERROR_NONE) { - EOM_DBG ("tdm_output_get_layer_count fail(%d)\n", err); - return NULL; + EOM_DBG ("tdm_output_get_layer_count fail(%d)\n", err); + return NULL; } for (i = 0; i < count; i++) { - layer = (tdm_layer *)tdm_output_get_layer(output, i, &err); - if (err != TDM_ERROR_NONE) - { - EOM_DBG ("tdm_output_get_layer fail(%d)\n", err); - return NULL; - } - - err = tdm_layer_get_capabilities(layer, &capa); + layer = (tdm_layer *)tdm_output_get_layer(output, i, &err); if (err != TDM_ERROR_NONE) { - EOM_DBG ("tdm_layer_get_capabilities fail(%d)\n", err); - return NULL; + EOM_DBG ("tdm_output_get_layer fail(%d)\n", err); + return NULL; } - if (capa & TDM_LAYER_CAPABILITY_PRIMARY) - { - EOM_DBG("TDM_LAYER_CAPABILITY_PRIMARY layer found : %d\n", i); - break; - } + err = tdm_layer_get_capabilities(layer, &capa); + if (err != TDM_ERROR_NONE) + { + EOM_DBG ("tdm_layer_get_capabilities fail(%d)\n", err); + return NULL; + } + + if (capa & TDM_LAYER_CAPABILITY_PRIMARY) + { + EOM_DBG("TDM_LAYER_CAPABILITY_PRIMARY layer found : %d\n", i); + break; + } } memset(&set_layer_info, 0x0, sizeof(tdm_info_layer)); @@ -245,8 +245,8 @@ _e_eom_hal_layer_get(tdm_output *output, int width, int height) err = tdm_layer_set_info(layer, &set_layer_info); if (err != TDM_ERROR_NONE) { - EOM_DBG ("tdm_layer_set_info fail(%d)\n", err); - return NULL; + EOM_DBG ("tdm_layer_set_info fail(%d)\n", err); + return NULL; } return layer; @@ -260,15 +260,15 @@ _e_eom_root_window_tdm_surface_get() if (!e_comp) { - EOM_DBG("e_comp NULL\n"); - return NULL; + EOM_DBG("e_comp NULL\n"); + return NULL; } if (!e_comp->evas) - { - EOM_DBG("e_comp->evas NULL"); - return NULL; - } + { + EOM_DBG("e_comp->evas NULL"); + return NULL; + } einfo = (Evas_Engine_Info_Drm *)evas_engine_info_get(e_comp->evas); @@ -276,14 +276,14 @@ _e_eom_root_window_tdm_surface_get() fb = _ecore_drm_display_fb_find_with_id(einfo->info.buffer_id); if (!fb) { - EOM_DBG("no Ecore_Drm_Fb for dci_output_id:%d\n", einfo->info.buffer_id); - return NULL; + EOM_DBG("no Ecore_Drm_Fb for dci_output_id:%d\n", einfo->info.buffer_id); + return NULL; } if (!fb->hal_buffer) { - EOM_DBG("no hal_buffer\n"); - return NULL; + EOM_DBG("no hal_buffer\n"); + return NULL; } EOM_DBG("find hal_buffer"); @@ -306,8 +306,8 @@ _e_eom_output_cb_commit(tdm_output *output EINA_UNUSED, unsigned int sequence EI src_buffer = _e_eom_root_window_tdm_surface_get(); if (!src_buffer ) { - EOM_ERR("Event: tdm_buffer is NULL\n"); - return; + EOM_ERR("Event: tdm_buffer is NULL\n"); + return; } dst_buffer = eom_event->dst_buffers; @@ -318,8 +318,8 @@ _e_eom_output_cb_commit(tdm_output *output EINA_UNUSED, unsigned int sequence EI err = tdm_output_commit(eom_event->output, 0, NULL, eom_event); if (err != TDM_ERROR_NONE) { - EOM_ERR("Event: Cannot commit crtc\n"); - return; + EOM_ERR("Event: Cannot commit crtc\n"); + return; } } @@ -339,8 +339,8 @@ _e_eom_create_extrenal_output_buffer(int width, int height) TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT); if (!buffer) { - EOM_DBG("can not create dst_buffer\n"); - return NULL; + EOM_DBG("can not create dst_buffer\n"); + return NULL; } /* @@ -350,10 +350,10 @@ _e_eom_create_extrenal_output_buffer(int width, int height) if (tbm_surface_map(buffer, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, &buffer_info) != TBM_SURFACE_ERROR_NONE) - { - EOM_DBG("can not mmap buffer\n"); - return NULL; - } + { + EOM_DBG("can not mmap buffer\n"); + return NULL; + } memset(buffer_info.planes[0].ptr, 0xff, buffer_info.planes[0].size); tbm_surface_unmap(buffer); @@ -402,23 +402,23 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e wl_output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, buff); if (!wl_output) { - EOM_ERR("no e_comp_wl_outputs. (%s)\n", buff); - goto end; + EOM_ERR("no e_comp_wl_outputs. (%s)\n", buff); + goto end; } /* Get hal output */ hal_output = _e_eom_hal_output_get(buff, e->id); if (!hal_output) { - EOM_ERR("no hal outputs, (%s)\n", buff); - goto end; + EOM_ERR("no hal outputs, (%s)\n", buff); + goto end; } hal_layer = _e_eom_hal_layer_get(hal_output, e->w, e->h); if (!hal_layer) { - EOM_ERR("no hal layer\n"); - goto end; + EOM_ERR("no hal layer\n"); + goto end; } /* Get main frame buffer */ @@ -436,8 +436,8 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e dst_buffer = _e_eom_create_extrenal_output_buffer(e->w, e->h); if (!dst_buffer ) { - EOM_ERR("no dst buffer\n"); - goto end; + EOM_ERR("no dst buffer\n"); + goto end; } /* @@ -456,8 +456,8 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e tdm_err = tdm_layer_get_info(hal_layer, &layer_info); if (tdm_err != TDM_ERROR_NONE) { - EOM_ERR ("failed get layer info", tdm_err); - goto end; + EOM_ERR ("failed get layer info", tdm_err); + goto end; } EOM_DBG("LAYER INFO: %dx%d, pos (x:%d, y:%d, w:%d, h:%d, dpos (x:%d, y:%d, w:%d, h:%d))", @@ -470,8 +470,8 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e tdm_err = tdm_layer_set_buffer(hal_layer, dst_buffer); if (tdm_err != TDM_ERROR_NONE) { - EOM_ERR("Failed set buffer on layer:%d\n", tdm_err); - goto end; + EOM_ERR("Failed set buffer on layer:%d\n", tdm_err); + goto end; } eom_event->layer = hal_layer; @@ -481,8 +481,8 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e tdm_err = tdm_output_commit(hal_output, 0, _e_eom_output_cb_commit, &eom_event); if (tdm_err != TDM_ERROR_NONE) { - EOM_ERR("Cannot commit crtc:%d\n", tdm_err); - goto end; + EOM_ERR("Cannot commit crtc:%d\n", tdm_err); + goto end; } EINA_LIST_FOREACH(wl_output->resources, l2, output_resource) @@ -490,16 +490,16 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e if (e->plug) { - wl_eom_send_output_type(eom->resource, + wl_eom_send_output_type(eom->resource, output_resource, eom_type, WL_EOM_STATUS_CONNECTION); } else { - EOM_DBG("7\n"); + EOM_DBG("7\n"); - wl_eom_send_output_type(eom->resource, + wl_eom_send_output_type(eom->resource, output_resource, eom_type, WL_EOM_STATUS_DISCONNECTION); @@ -529,9 +529,9 @@ _e_eom_get_drm_output_for_client(E_Client *ec) /* TODO: get real output, now we just return HDMI */ EINA_LIST_FOREACH(ecore_drm_devices_get(), l, dev) { - drm_output = ecore_drm_device_output_name_find(dev, "HDMI-A-0"); - if (drm_output) - return drm_output; + drm_output = ecore_drm_device_output_name_find(dev, "HDMI-A-0"); + if (drm_output) + return drm_output; } return NULL; } @@ -604,11 +604,11 @@ _e_eom_ecore_drm_activate_cb(void *data, int type EINA_UNUSED, void *event) if (e->active) { - /* TODO: do something */ + /* TODO: do something */ } else { - /* TODO: do something */ + /* TODO: do something */ } end: @@ -656,9 +656,9 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 id); if (!resource) { - EOM_ERR("error. resource is null. (version :%d, id:%d)\n", version, id); - wl_client_post_no_memory(client); - return; + EOM_ERR("error. resource is null. (version :%d, id:%d)\n", version, id); + wl_client_post_no_memory(client); + return; } wl_resource_set_implementation(resource, @@ -680,14 +680,14 @@ _e_eom_deinit() if (g_eom->handlers) { - EINA_LIST_FREE(g_eom->handlers, h) - ecore_event_handler_del(h); + EINA_LIST_FREE(g_eom->handlers, h) + ecore_event_handler_del(h); } if (fullscreen_pre_hook) { - e_client_hook_del(fullscreen_pre_hook); - fullscreen_pre_hook = NULL; + e_client_hook_del(fullscreen_pre_hook); + fullscreen_pre_hook = NULL; } if (g_eom->global) wl_global_destroy(g_eom->global); @@ -705,8 +705,8 @@ _e_eom_init_internal() g_eom->dpy = tdm_display_init(&err); if (err != TDM_ERROR_NONE) { - EOM_DBG("failed initialize TDM\n"); - goto err; + EOM_DBG("failed initialize TDM\n"); + goto err; } EOM_DBG("2\n"); @@ -714,8 +714,8 @@ _e_eom_init_internal() err = tdm_display_get_fd(g_eom->dpy, &g_eom->fd); if (err != TDM_ERROR_NONE) { - EOM_DBG("failed get FD\n"); - goto err; + EOM_DBG("failed get FD\n"); + goto err; } EOM_DBG("3\n"); @@ -723,8 +723,8 @@ _e_eom_init_internal() g_eom->bufmgr = tbm_bufmgr_init(g_eom->fd); if (!g_eom->bufmgr) { - EOM_DBG("failed initialize buffer manager\n"); - goto err; + EOM_DBG("failed initialize buffer manager\n"); + goto err; } EOM_DBG("4\n"); @@ -755,8 +755,8 @@ _e_eom_init() ret = _e_eom_init_internal(); if (!ret) { - EOM_ERR("failed init_internal()"); - goto err; + EOM_ERR("failed init_internal()"); + goto err; } E_LIST_HANDLER_APPEND(g_eom->handlers, ECORE_DRM_EVENT_ACTIVATE, _e_eom_ecore_drm_activate_cb, g_eom); -- 2.7.4 From 49936541ff03afe74382bf9a4e6da31077379278 Mon Sep 17 00:00:00 2001 From: Roman Peresipkyn Date: Thu, 24 Mar 2016 17:54:24 +0200 Subject: [PATCH 16/16] add page fliping between two buffers. refactor of _e_eom_ecore_drm_output_cb() Change-Id: I46d39be5eaf75c29ac33e5397e77b547bee4dcea Signed-off-by: Roman Peresipkyn --- src/e_mod_main.c | 360 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 231 insertions(+), 129 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 77c502f..e3ded89 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -36,10 +36,13 @@ typedef struct { tdm_layer *layer; tdm_output *output; - tbm_surface_h dst_buffers; -} Eom_Event; -static Eom_Event g_eom_event; + tbm_surface_h dst_buffers[2]; + int current_buffer; + +} Eom_Data; + +static Eom_Data g_eom_data; E_EomPtr g_eom = NULL; @@ -78,66 +81,65 @@ _e_eom_e_comp_wl_output_get(Eina_List *outputs, const char *id) * There is no external output */ if (num_outputs == 1) - return NULL; + { + EOM_DBG("ONE OUTPUT\n"); + return NULL; + } return output; } static tdm_output * -_e_eom_hal_output_get(const char *id, int primary_output_id) +_e_eom_hal_output_get(const char *id) { - Ecore_Drm_Output *drm_output; Ecore_Drm_Device *dev; - Eina_List *l; - int crtc_id = 0; - tdm_error err = TDM_ERROR_NONE; - - tdm_output *output = NULL; + Ecore_Drm_Output *drm_output, *o; + tdm_output *output; tdm_output_mode *modes; tdm_output_mode *big_mode; + tdm_error err = TDM_ERROR_NONE; + Eina_List *l, *ll; + int crtc_id = 0; int count = 0; - /* * Temporary take into account only HDMI */ - if (strcmp(id, "HDMI-A-0")) - { - EOM_DBG("not find output\n"); - return NULL; - } EINA_LIST_FOREACH(ecore_drm_devices_get(), l, dev) { - drm_output = ecore_drm_device_output_name_find(dev, id); + EINA_LIST_FOREACH(dev->external_outputs, ll, o) + { + if ((ecore_drm_output_name_get(o)) && (!strcmp(id, ecore_drm_output_name_get(o)))) + drm_output = o; + } } if (!drm_output) { - EOM_DBG("not find drm output\n"); + EOM_DBG("ERROR: drm output was not found\n"); return NULL; } crtc_id = ecore_drm_output_crtc_id_get(drm_output); if (crtc_id == 0) { - EOM_DBG("crtc is 0\n"); + EOM_DBG("ERROR: crtc is 0\n"); return NULL; } output = tdm_display_get_output(g_eom->dpy, crtc_id, NULL); if (!output) { - EOM_DBG("there is no HAL output for:%d\n", crtc_id); + EOM_DBG("ERROR: there is no HAL output for:%d\n", crtc_id); return NULL; } int min_w, min_h, max_w, max_h, preferred_align; - err = tdm_output_get_available_size(output, &min_w, &min_h, &max_w, &max_h, - &preferred_align); + err = tdm_output_get_available_size(output, &min_w, &min_h, &max_w, &max_h, &preferred_align); if (err != TDM_ERROR_NONE) { - EOM_DBG("Gent get geometry for hal output"); + EOM_DBG("ERROR: Gent get geometry for hal output"); return NULL; } @@ -147,8 +149,6 @@ _e_eom_hal_output_get(const char *id, int primary_output_id) /* * Force TDM to make setCrtc onto new buffer */ - - err = tdm_output_get_available_modes(output, &modes, &count); if (err != TDM_ERROR_NONE) { @@ -161,11 +161,8 @@ _e_eom_hal_output_get(const char *id, int primary_output_id) int i = 0; for (i = 0; i < count; i++) { - if ((modes[i].vdisplay + modes[i].hdisplay) >= - (big_mode->vdisplay + big_mode->hdisplay)) - { - big_mode = &modes[i]; - } + if ((modes[i].vdisplay + modes[i].hdisplay) >= (big_mode->vdisplay + big_mode->hdisplay)) + big_mode = &modes[i]; } if (!big_mode) @@ -183,7 +180,7 @@ _e_eom_hal_output_get(const char *id, int primary_output_id) return NULL; } - EOM_DBG("find\n"); + EOM_DBG("Created output: %p\n", output); return output; } @@ -195,9 +192,9 @@ _e_eom_hal_layer_get(tdm_output *output, int width, int height) tdm_layer *layer; tdm_error err = TDM_ERROR_NONE; tdm_layer_capability capa; - tdm_info_layer set_layer_info; + err = tdm_output_get_layer_count(output, &count); if (err != TDM_ERROR_NONE) { @@ -229,8 +226,8 @@ _e_eom_hal_layer_get(tdm_output *output, int width, int height) } memset(&set_layer_info, 0x0, sizeof(tdm_info_layer)); - set_layer_info.src_config.size.h = 3840; - set_layer_info.src_config.size.v = 2560; + set_layer_info.src_config.size.h = width; + set_layer_info.src_config.size.v = height; set_layer_info.src_config.pos.x = 0; set_layer_info.src_config.pos.y = 0; set_layer_info.src_config.pos.w = width; @@ -292,55 +289,88 @@ _e_eom_root_window_tdm_surface_get() } static void -_e_eom_output_cb_commit(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUSED, +_e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUSED, unsigned int tv_sec EINA_UNUSED, unsigned int tv_usec EINA_UNUSED, void *user_data) { - Eom_Event *eom_event = (Eom_Event *)user_data; - tdm_error err = TDM_ERROR_NONE; + Eom_Data *eom_data; tbm_surface_h src_buffer; - tbm_surface_h dst_buffer; + tdm_error err = TDM_ERROR_NONE; + + EOM_DBG("Event 1\n"); + + if (!user_data) + { + EOM_ERR("ERROR: EVENT: user_data is NULL\n"); + return; + } + + eom_data = (Eom_Data *)user_data; - EOM_ERR("Event\n"); + EOM_DBG("Event 2\n"); +/* src_buffer = _e_eom_root_window_tdm_surface_get(); if (!src_buffer ) { EOM_ERR("Event: tdm_buffer is NULL\n"); return; } +*/ - dst_buffer = eom_event->dst_buffers; + if (eom_data->current_buffer == 1) + { + eom_data->current_buffer = 0; - /* Do clone */ - tdm_layer_set_buffer(eom_event->layer, dst_buffer); + err = tdm_layer_set_buffer(eom_data->layer, + eom_data->dst_buffers[eom_data->current_buffer]); + if (err != TDM_ERROR_NONE) + { + EOM_ERR("ERROR: EVENT: set buffer 0\n"); + return; + } - err = tdm_output_commit(eom_event->output, 0, NULL, eom_event); + EOM_DBG("Event 3\n"); + } + else + { + eom_data->current_buffer = 1; + + err = tdm_layer_set_buffer(eom_data->layer, + eom_data->dst_buffers[eom_data->current_buffer]); + if (err != TDM_ERROR_NONE) + { + EOM_ERR("ERROR: EVENT: set buffer 1\n"); + return; + } + + EOM_DBG("Event 4\n"); + } + + err = tdm_output_commit(eom_data->output, 0, _e_eom_output_commit_cb, eom_data); if (err != TDM_ERROR_NONE) { - EOM_ERR("Event: Cannot commit crtc\n"); + EOM_ERR("ERROR: EVENT: commit\n"); return; } + + EOM_DBG("Event 5\n"); } -static tbm_surface_h -_e_eom_create_extrenal_output_buffer(int width, int height) +static int +_e_eom_create_output_buffers(Eom_Data *eom_data, int width, int height) { tbm_surface_h buffer; tbm_surface_info_s buffer_info; - width = 3840; - height = 2560; - /* * TODO: Add support of other formats */ - buffer = tbm_surface_internal_create_with_flags(width, height, - TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT); + buffer = tbm_surface_internal_create_with_flags(width, height, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT); if (!buffer) { EOM_DBG("can not create dst_buffer\n"); - return NULL; + goto err; } /* @@ -348,17 +378,53 @@ _e_eom_create_extrenal_output_buffer(int width, int height) */ memset(&buffer_info, 0x0, sizeof(tbm_surface_info_s)); if (tbm_surface_map(buffer, - TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, - &buffer_info) != TBM_SURFACE_ERROR_NONE) + TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, + &buffer_info) != TBM_SURFACE_ERROR_NONE) { EOM_DBG("can not mmap buffer\n"); - return NULL; + goto err; } memset(buffer_info.planes[0].ptr, 0xff, buffer_info.planes[0].size); tbm_surface_unmap(buffer); - return buffer; + eom_data->dst_buffers[0] = buffer; + + /* + * TODO: Add support of other formats + */ + buffer = tbm_surface_internal_create_with_flags(width, height, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT); + if (!buffer) + { + EOM_DBG("can not create dst_buffer\n"); + goto err; + } + + /* + * TODO: temp code for testing, actual convert will be in _e_eom_put_src_to_dst() + */ + memset(&buffer_info, 0x00, sizeof(tbm_surface_info_s)); + if (tbm_surface_map(buffer, + TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, + &buffer_info) != TBM_SURFACE_ERROR_NONE) + { + EOM_DBG("can not mmap buffer\n"); + goto err; + } + + memset(buffer_info.planes[0].ptr, 0x55, buffer_info.planes[0].size); + tbm_surface_unmap(buffer); + + eom_data->dst_buffers[1] = buffer; + + return 1; + +err: + +/* + * Add deinitialization + */ + return 0; } static void @@ -369,122 +435,157 @@ _e_eom_put_src_to_dst( tbm_surface_h src_buffer, tbm_surface_h dst_buffer) } -static Eina_Bool -_e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) +static int +_e_eom_set_up_external_output(const char *output_name, int width, int height) { - Ecore_Drm_Event_Output *e; - E_EomPtr eom = data; - E_Comp_Wl_Output *wl_output; tdm_output *hal_output; tdm_layer *hal_layer; tdm_info_layer layer_info; - tbm_surface_h src_buffer; - tbm_surface_h dst_buffer; - tbm_surface_info_s src_buffer_info ; - Eina_List *l2; - Eom_Event *eom_event = &g_eom_event; - struct wl_resource *output_resource; - enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; - char buff[PATH_MAX]; tdm_error tdm_err = TDM_ERROR_NONE; - int tbm_err = 0; - - if (!(e = event)) goto end; - - if (!e->plug) goto end; - - EOM_DBG("id:%d (x,y,w,h):(%d,%d,%d,%d) (w_mm,h_mm):(%d,%d) refresh:%d subpixel_order:%d transform:%d make:%s model:%s name:%s plug:%d\n", - e->id, e->x, e->y, e->w, e->h, e->phys_width, e->phys_height, e->refresh, e->subpixel_order, e->transform, e->make, e->model, e->name, e->plug); + Eom_Data *eom_data = &g_eom_data; + int ret = 0; - snprintf(buff, sizeof(buff), "%s", e->name); - /* get the e_comp_wl_output */ - wl_output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, buff); - if (!wl_output) + hal_output = _e_eom_hal_output_get(output_name); + if (!hal_output) { - EOM_ERR("no e_comp_wl_outputs. (%s)\n", buff); - goto end; + EOM_ERR("ERROR: get hal output for, (%s)\n", output_name); + goto err; } - /* Get hal output */ - hal_output = _e_eom_hal_output_get(buff, e->id); - if (!hal_output) + hal_layer = _e_eom_hal_layer_get(hal_output, width, height); + if (!hal_layer) { - EOM_ERR("no hal outputs, (%s)\n", buff); - goto end; + EOM_ERR("ERROR: get hal layer\n"); + goto err; } - hal_layer = _e_eom_hal_layer_get(hal_output, e->w, e->h); - if (!hal_layer) + ret = _e_eom_create_output_buffers(eom_data, width, height); + if (!ret ) { - EOM_ERR("no hal layer\n"); - goto end; + EOM_ERR("ERROR: create buffers \n"); + goto err; } - /* Get main frame buffer */ - /* +/* src_buffer = _e_eom_root_window_tdm_surface_get(); if (!src_buffer ) - { + { EOM_ERR("no framebuffer\n"); - goto end; - } - */ - - - dst_buffer = _e_eom_create_extrenal_output_buffer(e->w, e->h); - if (!dst_buffer ) - { - EOM_ERR("no dst buffer\n"); - goto end; - } + goto end; + } +*/ - /* +/* tbm_surface_get_info(src_buffer, &src_buffer_info ); EOM_DBG("FRAMEBUFFER buffer: %dx%d bpp:%d size:%d", - src_buffer_info.width, - src_buffer_info.height, - src_buffer_info.bpp, - src_buffer_info.size); + src_buffer_info.width, + src_buffer_info.height, + src_buffer_info.bpp, + src_buffer_info.size); _e_eom_put_src_to_dst(src_buffer, dst_buffer); - */ +*/ tdm_err = tdm_layer_get_info(hal_layer, &layer_info); if (tdm_err != TDM_ERROR_NONE) { - EOM_ERR ("failed get layer info", tdm_err); - goto end; + EOM_ERR ("ERROR: get layer info: %d", tdm_err); + goto err; } EOM_DBG("LAYER INFO: %dx%d, pos (x:%d, y:%d, w:%d, h:%d, dpos (x:%d, y:%d, w:%d, h:%d))", - layer_info.src_config.size.h, layer_info.src_config.size.v, - layer_info.src_config.pos.x, layer_info.src_config.pos.y, - layer_info.src_config.pos.w, layer_info.src_config.pos.h, - layer_info.dst_pos.x, layer_info.dst_pos.y, - layer_info.dst_pos.w, layer_info.dst_pos.h); + layer_info.src_config.size.h, layer_info.src_config.size.v, + layer_info.src_config.pos.x, layer_info.src_config.pos.y, + layer_info.src_config.pos.w, layer_info.src_config.pos.h, + layer_info.dst_pos.x, layer_info.dst_pos.y, + layer_info.dst_pos.w, layer_info.dst_pos.h); + + eom_data->layer = hal_layer; + eom_data->output = hal_output; + eom_data->current_buffer = 0; - tdm_err = tdm_layer_set_buffer(hal_layer, dst_buffer); + tdm_err = tdm_layer_set_buffer(hal_layer, eom_data->dst_buffers[eom_data->current_buffer]); if (tdm_err != TDM_ERROR_NONE) { - EOM_ERR("Failed set buffer on layer:%d\n", tdm_err); + EOM_ERR("ERROR: set buffer on layer:%d\n", tdm_err); + goto err; + } + + tdm_err = tdm_output_commit(hal_output, 0, _e_eom_output_commit_cb, eom_data); + if (tdm_err != TDM_ERROR_NONE) + { + EOM_ERR("ERROR: commit crtc:%d\n", tdm_err); + goto err; + } + + return 1; + +err: +/* + * TODO: add deinitialization + */ + return 0; +} + +static Eina_Bool +_e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) +{ + Ecore_Drm_Event_Output *e; + E_EomPtr eom = data; + E_Comp_Wl_Output *wl_output; + struct wl_resource *output_resource; + enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; + char buff[PATH_MAX]; + int ret = 0; + + if (!(e = event)) goto end; + + if (!e->plug) goto end; + + EOM_DBG("id:%d (x,y,w,h):(%d,%d,%d,%d) (w_mm,h_mm):(%d,%d) refresh:%d subpixel_order:%d transform:%d make:%s model:%s name:%s plug:%d\n", + e->id, e->x, e->y, e->w, e->h, e->phys_width, e->phys_height, e->refresh, e->subpixel_order, e->transform, e->make, e->model, e->name, e->plug); + + snprintf(buff, sizeof(buff), "%s", e->name); + + if (strcmp(e->name, "HDMI-A-0")) + { + EOM_DBG("Skip internal output\n"); goto end; } - eom_event->layer = hal_layer; - eom_event->output = hal_output; - eom_event->dst_buffers = dst_buffer; + /* + * Get e_comp_wl_output + */ +/* + wl_output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, buff); + if (!wl_output) + { + EOM_ERR("no e_comp_wl_outputs. (%s)\n", buff); + goto end; + } +*/ - tdm_err = tdm_output_commit(hal_output, 0, _e_eom_output_cb_commit, &eom_event); - if (tdm_err != TDM_ERROR_NONE) + /* + * Initialize external output + */ + ret = _e_eom_set_up_external_output(buff, e->w, e->h); + if (!ret) { - EOM_ERR("Cannot commit crtc:%d\n", tdm_err); + EOM_ERR("Failed initialize external output\n"); goto end; } + + /* Get main frame buffer */ + + + + + /* EINA_LIST_FOREACH(wl_output->resources, l2, output_resource) { if (e->plug) @@ -505,8 +606,9 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e WL_EOM_STATUS_DISCONNECTION); } } + */ + - EOM_DBG("8\n"); end: return ECORE_CALLBACK_PASS_ON; -- 2.7.4