e_server: move the init/deinit of e_explicit_sync
[platform/upstream/enlightenment.git] / src / bin / e_comp_screen.c
index bae813c..71b22d1 100644 (file)
-#include "e.h"
-#include "Eeze.h"
+#include "e_client_intern.h"
+#include "e_utils_intern.h"
+#include "e_scale_intern.h"
+#include "e_comp_canvas_intern.h"
+#include "e_comp_screen_intern.h"
+#include "e_comp_wl_input_intern.h"
+#include "e_comp_wl_intern.h"
+#include "e_explicit_sync_intern.h"
+#include "e_comp_wl_tizen_hwc_intern.h"
+#include "e_comp_intern.h"
+#include "e_input_intern.h"
+#include "e_input_device_intern.h"
+#include "e_error_intern.h"
+#include "e_pointer_intern.h"
+#include "e_output_intern.h"
+#include "e_hwc_intern.h"
+#include "e_hwc_window_intern.h"
+#include "e_hwc_windows_intern.h"
+#include "e_egl_sync_intern.h"
+#include "e_config_intern.h"
+#include "e_dbus_conn_intern.h"
+#include "e_main_intern.h"
+#include "e_hwc_planes_intern.h"
+#include "e_linux_dmabuf_intern.h"
+#include "e_comp_input_intern.h"
+#include "e_screen_rotation_intern.h"
+#include "e_server_intern.h"
+
 #include <tizen-extension-server-protocol.h>
+#include <device/board-internal.h>
+#include <tbm_drm_helper.h>
+#include <gbm.h>
 
 #define PATH "/org/enlightenment/wm"
 #define IFACE "org.enlightenment.wm.screen_rotation"
 
-static Eldbus_Connection *e_comp_screen_conn;
+static Ecore_Event_Handler *dbus_init_done_handler;
+static Eldbus_Connection *edbus_conn = NULL;
+static Eldbus_Connection_Type edbus_conn_type = ELDBUS_CONNECTION_TYPE_SYSTEM;
 static Eldbus_Service_Interface *e_comp_screen_iface;
 
 static Eina_List *event_handlers = NULL;
+static Eina_List *output_hooks = NULL;
 
-static Eina_Bool dont_set_e_input_keymap = EINA_FALSE;
-static Eina_Bool dont_use_xkb_cache = EINA_FALSE;
-
-E_API int              E_EVENT_SCREEN_CHANGE = 0;
+EINTERN int E_EVENT_SCREEN_CHANGE = 0;
 
 enum
 {
    E_COMP_SCREEN_SIGNAL_ROTATION_CHANGED = 0
 };
 
-typedef struct _E_Comp_Screen_Tzsr
-{
-   struct wl_resource *resource; /* tizen_screen_rotation */
-   E_Client           *ec;
-} E_Comp_Screen_Tzsr;
-
-static Eina_List *tzsr_list;
-static E_Client_Hook *tzsr_client_hook_del;
-
-static E_Comp_Screen_Tzsr*
-_tz_surface_rotation_find(E_Client *ec)
-{
-   E_Comp_Screen_Tzsr *tzsr;
-   Eina_List *l;
-
-   EINA_LIST_FOREACH(tzsr_list, l, tzsr)
-     {
-        if (tzsr->ec == ec)
-          return tzsr;
-     }
-
-   return NULL;
-}
-
-static E_Comp_Screen_Tzsr*
-_tz_surface_rotation_find_with_resource(struct wl_resource *resource)
-{
-   E_Comp_Screen_Tzsr *tzsr;
-   Eina_List *l;
-
-   EINA_LIST_FOREACH(tzsr_list, l, tzsr)
-     {
-        if (tzsr->resource == resource)
-          return tzsr;
-     }
-
-   return NULL;
-}
-
-static void
-_tz_surface_rotation_free(E_Comp_Screen_Tzsr *tzsr)
-{
-   ELOGF("TRANSFORM", "|tzsr(%p) freed", NULL, tzsr->ec, tzsr);
-   tzsr_list = eina_list_remove(tzsr_list, tzsr);
-   free(tzsr);
-}
-
-static void
-_tz_screen_rotation_cb_client_del(void *data, E_Client *ec)
-{
-   E_Comp_Screen_Tzsr *tzsr = _tz_surface_rotation_find(ec);
-   if (!tzsr) return;
-   _tz_surface_rotation_free(tzsr);
-}
-
-static void
-_tz_screen_rotation_get_ignore_output_transform(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface)
-{
-   E_Comp_Screen_Tzsr *tzsr;
-   E_Client *ec;
-
-   ec = wl_resource_get_user_data(surface);
-   EINA_SAFETY_ON_NULL_RETURN(ec);
-
-   tzsr = _tz_surface_rotation_find(ec);
-   if (tzsr) return;
-
-   tzsr = E_NEW(E_Comp_Screen_Tzsr, 1);
-   if (!tzsr)
-     {
-        wl_client_post_no_memory(client);
-        return;
-     }
-
-   tzsr->resource = resource;
-   tzsr->ec = ec;
-
-   ELOGF("TRANSFORM", "|tzsr(%p) client_ignore(%d)", NULL, ec, tzsr, e_config->screen_rotation_client_ignore);
-
-   tzsr_list = eina_list_append(tzsr_list, tzsr);
-
-   /* make all clients ignore the output tramsform
-    * we will decide later when hwc prepared.
-    */
-   e_comp_screen_rotation_ignore_output_transform_send(ec, EINA_TRUE);
-}
-
-static void
-_tz_screen_rotation_iface_cb_destroy(struct wl_client *client, struct wl_resource *resource)
-{
-   wl_resource_destroy(resource);
-}
-
-static const struct tizen_screen_rotation_interface _tz_screen_rotation_interface =
-{
-   _tz_screen_rotation_get_ignore_output_transform,
-   _tz_screen_rotation_iface_cb_destroy,
-};
-
-static void _tz_screen_rotation_cb_destroy(struct wl_resource *resource)
-{
-   E_Comp_Screen_Tzsr *tzsr = _tz_surface_rotation_find_with_resource(resource);
-   if (!tzsr) return;
-   _tz_surface_rotation_free(tzsr);
-}
-
-static void
-_tz_screen_rotation_cb_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
-{
-   struct wl_resource *res;
-
-   if (!(res = wl_resource_create(client, &tizen_screen_rotation_interface, version, id)))
-     {
-        ERR("Could not create tizen_screen_rotation resource: %m");
-        wl_client_post_no_memory(client);
-        return;
-     }
-
-   wl_resource_set_implementation(res, &_tz_screen_rotation_interface, NULL, _tz_screen_rotation_cb_destroy);
-}
-
 static Eldbus_Message *
 _e_comp_screen_dbus_get_cb(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
 {
@@ -150,7 +58,7 @@ _e_comp_screen_dbus_get_cb(const Eldbus_Service_Interface *iface, const Eldbus_M
    if (e_comp && e_comp->e_comp_screen)
      rotation = e_comp->e_comp_screen->rotation;
 
-   DBG("got screen-rotation 'get' request: %d", rotation);
+   ELOGF("COMP_SCREEN","got screen-rotation 'get' request: %d", NULL, rotation);
 
    eldbus_message_arguments_append(reply, "i", rotation);
 
@@ -172,23 +80,12 @@ static const Eldbus_Service_Interface_Desc iface_desc = {
      IFACE, methods, signals, NULL, NULL, NULL
 };
 
-static Eina_Bool
-_e_comp_screen_dbus_init(void *data EINA_UNUSED)
+static void
+_e_comp_screen_dbus_init()
 {
    E_Comp_Screen *e_comp_screen = e_comp->e_comp_screen;
 
-   if (e_comp_screen_conn) return ECORE_CALLBACK_CANCEL;
-
-   if (!e_comp_screen_conn)
-     e_comp_screen_conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM);
-
-   if(!e_comp_screen_conn)
-     {
-        ecore_timer_add(1, _e_comp_screen_dbus_init, NULL);
-        return ECORE_CALLBACK_CANCEL;
-     }
-
-   e_comp_screen_iface = eldbus_service_interface_register(e_comp_screen_conn,
+   e_comp_screen_iface = eldbus_service_interface_register(edbus_conn,
                                                            PATH,
                                                            &iface_desc);
    EINA_SAFETY_ON_NULL_GOTO(e_comp_screen_iface, err);
@@ -196,19 +93,19 @@ _e_comp_screen_dbus_init(void *data EINA_UNUSED)
    if (e_comp_screen->rotation)
      {
         eldbus_service_signal_emit(e_comp_screen_iface, E_COMP_SCREEN_SIGNAL_ROTATION_CHANGED, e_comp_screen->rotation);
-        ELOGF("TRANSFORM", "screen-rotation sends signal: %d", NULL, NULL, e_comp_screen->rotation);
+        ELOGF("TRANSFORM", "screen-rotation sends signal: %d", NULL, e_comp_screen->rotation);
      }
 
-   return ECORE_CALLBACK_CANCEL;
+   return;
 
 err:
-   if (e_comp_screen_conn)
+   if (edbus_conn)
      {
-        eldbus_connection_unref(e_comp_screen_conn);
-        e_comp_screen_conn = NULL;
+        e_dbus_conn_connection_unref(edbus_conn);
+        edbus_conn = NULL;
      }
 
-   return ECORE_CALLBACK_CANCEL;
+   return;
 }
 
 static char *
@@ -241,6 +138,8 @@ _e_comp_screen_commit_idle_cb(void *data EINA_UNUSED)
    if (e_config->comp_canvas_norender.use)
      evas_norender(e_comp->evas);
 
+   if (e_comp->canvas_render_delayed) goto end;
+
    e_comp_screen = e_comp->e_comp_screen;
 
    EINA_LIST_FOREACH_SAFE(e_comp_screen->outputs, l, ll, output)
@@ -248,8 +147,6 @@ _e_comp_screen_commit_idle_cb(void *data EINA_UNUSED)
         if (!output) continue;
         if (!output->config.enabled) continue;
 
-        e_output_hwc_apply(output->output_hwc);
-
         if (!e_output_commit(output))
              ERR("fail to commit e_comp_screen->outputs.");
 
@@ -260,15 +157,33 @@ end:
    return ECORE_CALLBACK_RENEW;
 }
 
+static void
+_e_comp_screen_input_rotation_set(int rotation)
+{
+   if (rotation > 0)
+     {
+        const Eina_List *l;
+        E_Input_Device *dev;
+
+        EINA_LIST_FOREACH(e_input_devices_get(), l, dev)
+          {
+             e_input_device_touch_rotation_set(dev, rotation);
+             e_input_device_rotation_set(dev, rotation);
+
+             ELOGF("COMP_SCREEN","EE Input Device Rotate: %d", NULL, rotation);
+          }
+     }
+}
+
 static Eina_Bool
 _e_comp_screen_cb_input_device_add(void *data, int type, void *event)
 {
-   E_Input_Event_Input_Device_Add *e;
+   Ecore_Event_Device_Info *e;
    E_Comp *comp = data;
 
    if (!(e = event)) goto end;
 
-   if (e->caps & E_INPUT_SEAT_POINTER)
+   if (e->clas == ECORE_DEVICE_CLASS_MOUSE)
      {
         if (comp->wl_comp_data->ptr.num_devices == 0)
           {
@@ -277,14 +192,10 @@ _e_comp_screen_cb_input_device_add(void *data, int type, void *event)
           }
         comp->wl_comp_data->ptr.num_devices++;
      }
-   if (e->caps & E_INPUT_SEAT_KEYBOARD)
-     {
-        comp->wl_comp_data->kbd.num_devices++;
-        e_comp_wl_input_keyboard_enabled_set(EINA_TRUE);
-     }
-   if (e->caps & E_INPUT_SEAT_TOUCH)
+   else if (e->clas == ECORE_DEVICE_CLASS_TOUCH)
      {
         e_comp_wl_input_touch_enabled_set(EINA_TRUE);
+        _e_comp_screen_input_rotation_set(e_comp->e_comp_screen->rotation);
         comp->wl_comp_data->touch.num_devices++;
      }
 
@@ -293,11 +204,11 @@ end:
 }
 
 static void
-_e_comp_screen_pointer_renew(E_Input_Event_Input_Device_Del *ev)
+_e_comp_screen_pointer_renew(void)
 {
      if ((e_comp_wl->ptr.num_devices == 0) && e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->pointer_enter_sent)
      {
-        if (e_comp_wl->input_device_manager.last_device_ptr)
+        if (e_devicemgr->last_device_ptr)
           {
              Evas_Device *last_ptr = NULL, *dev;
              Eina_List *list, *l;
@@ -311,9 +222,9 @@ _e_comp_screen_pointer_renew(E_Input_Event_Input_Device_Del *ev)
                   description = evas_device_description_get(dev);
 
                   if (!name || !description) continue;
-                  if ((!strncmp(name, e_comp_wl->input_device_manager.last_device_ptr->name, strlen(e_comp_wl->input_device_manager.last_device_ptr->name))) &&
-                      (!strncmp(description, e_comp_wl->input_device_manager.last_device_ptr->identifier, strlen(e_comp_wl->input_device_manager.last_device_ptr->identifier))) &&
-                      (evas_device_class_get(dev) == (Evas_Device_Class)e_comp_wl->input_device_manager.last_device_ptr->clas))
+                  if ((!strncmp(name, e_devicemgr->last_device_ptr->name, strlen(e_devicemgr->last_device_ptr->name))) &&
+                      (!strncmp(description, e_devicemgr->last_device_ptr->identifier, strlen(e_devicemgr->last_device_ptr->identifier))) &&
+                      (evas_device_class_get(dev) == (Evas_Device_Class)e_devicemgr->last_device_ptr->clas))
                     {
                        last_ptr = dev;
                        break;
@@ -328,12 +239,12 @@ _e_comp_screen_pointer_renew(E_Input_Event_Input_Device_Del *ev)
 static Eina_Bool
 _e_comp_screen_cb_input_device_del(void *data, int type, void *event)
 {
-   E_Input_Event_Input_Device_Del *e;
+   Ecore_Event_Device_Info *e;
    E_Comp *comp = data;
 
    if (!(e = event)) goto end;
 
-   if (e->caps & E_INPUT_SEAT_POINTER)
+   if (e->clas == ECORE_DEVICE_CLASS_MOUSE)
      {
         comp->wl_comp_data->ptr.num_devices--;
         if (comp->wl_comp_data->ptr.num_devices == 0)
@@ -342,18 +253,10 @@ _e_comp_screen_cb_input_device_del(void *data, int type, void *event)
              e_pointer_object_set(comp->pointer, NULL, 0, 0);
              e_pointer_hide(e_comp->pointer);
 
-             _e_comp_screen_pointer_renew(e);
-          }
-     }
-   if (e->caps & E_INPUT_SEAT_KEYBOARD)
-     {
-        comp->wl_comp_data->kbd.num_devices--;
-        if (comp->wl_comp_data->kbd.num_devices == 0)
-          {
-             e_comp_wl_input_keyboard_enabled_set(EINA_FALSE);
+             _e_comp_screen_pointer_renew();
           }
      }
-   if (e->caps & E_INPUT_SEAT_TOUCH)
+   else if (e->clas == ECORE_DEVICE_CLASS_TOUCH)
      {
         comp->wl_comp_data->touch.num_devices--;
         if (comp->wl_comp_data->touch.num_devices == 0)
@@ -368,6 +271,48 @@ end:
 }
 
 static Eina_Bool
+_e_comp_screen_size_update(E_Comp_Screen *e_comp_screen)
+{
+   E_Output *output;
+   int sum_w = 0, max_h = 0, output_w, output_h;
+   Eina_List *l;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
+
+   /* we place external output to the right of primary output */
+   EINA_LIST_FOREACH(e_comp_screen->outputs, l, output)
+     {
+        if (!e_output_connected(output)) continue;
+
+        e_output_size_get(output, &output_w, &output_h);
+        sum_w += output_w;
+
+        if (max_h < output_h)
+          max_h = output_h;
+     }
+
+   e_comp_screen->w = sum_w;
+   e_comp_screen->h = max_h;
+
+   if (e_comp->ee)
+     {
+        /* rotation should be reset because tbm_surface_queue or gbm_surface of
+         * ecore_evas is created without rotation
+         * and rotation of ecore_evas is reset after it is resized
+         */
+        if (e_comp_screen->rotation)
+          ecore_evas_rotation_with_resize_set(e_comp->ee, 0);
+
+        ecore_evas_resize(e_comp->ee, e_comp_screen->w, e_comp_screen->h);
+
+        if (e_comp_screen->rotation)
+          ecore_evas_rotation_with_resize_set(e_comp->ee, e_comp_screen->rotation);
+     }
+
+   return EINA_TRUE;
+}
+
+static Eina_Bool
 _e_comp_screen_cb_event(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED)
 {
    E_Comp_Screen *e_comp_screen;
@@ -396,14 +341,18 @@ _e_comp_screen_new(E_Comp *comp)
    if (!e_comp_screen) return NULL;
 
    /* tdm display init */
+   e_main_ts_begin("\tTDM Display Init");
    e_comp_screen->tdisplay = tdm_display_init(&error);
    if (!e_comp_screen->tdisplay)
      {
+        e_main_ts_end("\tTDM Display Init Failed");
         ERR("fail to get tdm_display\n");
         free(e_comp_screen);
         return NULL;
      }
+   e_main_ts_end("\tTDM Display Init Done");
 
+   e_comp_screen->gdevice_fd = -1;
    e_comp_screen->fd = -1;
    tdm_display_get_fd(e_comp_screen->tdisplay, &fd);
    if (fd < 0)
@@ -417,14 +366,16 @@ _e_comp_screen_new(E_Comp *comp)
    e_comp_screen->hdlr =
      ecore_main_fd_handler_add(e_comp_screen->fd, ECORE_FD_READ,
                                _e_comp_screen_cb_event, e_comp_screen, NULL, NULL);
-
    /* tdm display init */
+   e_main_ts_begin("\tTBM Bufmgr Server Init");
    e_comp_screen->bufmgr = tbm_bufmgr_server_init();
    if (!e_comp_screen->bufmgr)
      {
+        e_main_ts_end("\tTBM Bufmgr Server Init Failed");
         ERR("tbm_bufmgr_init failed\n");
         goto fail;
      }
+   e_main_ts_end("\tTBM Bufmgr Server Init Done");
 
    error = tdm_display_get_capabilities(e_comp_screen->tdisplay, &capabilities);
    if (error != TDM_ERROR_NONE)
@@ -447,8 +398,10 @@ _e_comp_screen_new(E_Comp *comp)
           }
      }
 
+   e_main_ts_begin("\ttdm-socket Init");
    if (e_comp_socket_init("tdm-socket"))
      PRCTL("[Winsys] change permission and create sym link for %s", "tdm-socket");
+   e_main_ts_end("\ttdm-socket Init Done");
 
    return e_comp_screen;
 
@@ -459,6 +412,7 @@ fail:
    if (e_comp_screen->tdisplay) tdm_display_deinit(e_comp_screen->tdisplay);
 
    free(e_comp_screen);
+   TRACE_DS_END();
 
    return NULL;
 }
@@ -479,6 +433,9 @@ _e_comp_screen_del(E_Comp_Screen *e_comp_screen)
              e_comp_screen->available_pp_formats = eina_list_remove(e_comp_screen->available_pp_formats, l);
           }
      }
+
+   if (e_comp_screen->gdevice) gbm_device_destroy(e_comp_screen->gdevice);
+   if (e_comp_screen->gdevice_fd >= 0) close(e_comp_screen->gdevice_fd);
    if (e_comp_screen->bufmgr) tbm_bufmgr_deinit(e_comp_screen->bufmgr);
    if (e_comp_screen->fd >= 0) close(e_comp_screen->fd);
    if (e_comp_screen->hdlr) ecore_main_fd_handler_del(e_comp_screen->hdlr);
@@ -488,11 +445,143 @@ _e_comp_screen_del(E_Comp_Screen *e_comp_screen)
 }
 
 static void
+_e_comp_screen_output_mode_change_cb(tdm_output *toutput, unsigned int index, void *user_data)
+{
+   E_Comp_Screen *e_comp_screen = user_data;
+   E_Output *output = NULL;
+   Eina_Bool find = EINA_FALSE;
+   int count, num;
+   E_Output_Mode *set_emode = NULL, *current_emode = NULL;
+   E_Output_Mode *emode = NULL;
+   Eina_List *modelist = NULL, *l, *ll;
+
+   EINA_SAFETY_ON_NULL_RETURN(e_comp_screen);
+
+   EINA_LIST_FOREACH_SAFE(e_comp_screen->outputs, l, ll, output)
+     {
+        if (output->toutput == toutput)
+          {
+             find = EINA_TRUE;
+             break;
+          }
+     }
+   EINA_SAFETY_ON_FALSE_RETURN(find == EINA_TRUE);
+
+   current_emode = e_output_current_mode_get(output);
+   EINA_SAFETY_ON_NULL_RETURN(current_emode);
+
+   modelist = e_output_mode_list_get(output);
+   if (modelist)
+     {
+        num = eina_list_count(modelist);
+        EINA_SAFETY_ON_FALSE_RETURN(index < num);
+
+        count = 0;
+        EINA_LIST_FOREACH(modelist, l, emode)
+          {
+             if (count == index)
+               {
+                  set_emode = emode;
+                  break;
+               }
+             count++;
+          }
+
+        if (set_emode)
+          {
+             EINA_SAFETY_ON_TRUE_RETURN(current_emode == set_emode);
+
+             ELOGF("COMP_SCREEN","request mode change(%d) (%dx%d, %lf) -> (%dx%d, %lf)\n",
+                   NULL, index, current_emode->w, current_emode->h, current_emode->refresh,
+                   set_emode->w, set_emode->h, set_emode->refresh);
+
+             e_output_external_mode_change(output, set_emode);
+          }
+     }
+}
+
+static void
+_e_comp_screen_output_destroy_cb(tdm_output *toutput, void *user_data)
+{
+   E_Comp_Screen *e_comp_screen = user_data;
+   E_Output *output = NULL;
+   Eina_List *l, *ll;
+
+   EINA_SAFETY_ON_NULL_RETURN(e_comp_screen);
+
+   tdm_output_remove_destroy_handler(toutput, _e_comp_screen_output_destroy_cb, e_comp_screen);
+
+   EINA_LIST_FOREACH_SAFE(e_comp_screen->outputs, l, ll, output)
+     {
+        if (output->toutput == toutput)
+          {
+             e_comp_screen->num_outputs--;
+             e_comp_screen->outputs = eina_list_remove_list(e_comp_screen->outputs, l);
+             e_output_del(output);
+          }
+     }
+}
+
+static void
+_e_comp_screen_output_create_cb(tdm_display *dpy, tdm_output *toutput, void *user_data)
+{
+   E_Comp_Screen *e_comp_screen = user_data;
+   E_Output *output = NULL;
+   tdm_error ret = TDM_ERROR_NONE;
+
+   EINA_SAFETY_ON_NULL_RETURN(e_comp_screen);
+
+   TRACE_DS_BEGIN(OUTPUT:NEW);
+   output = e_output_new(e_comp_screen, e_comp_screen->num_outputs);
+   EINA_SAFETY_ON_NULL_GOTO(output, fail);
+   if (output->toutput != toutput) goto fail;
+   TRACE_DS_END();
+
+   TRACE_DS_BEGIN(OUTPUT:UPDATE);
+   if (!e_output_update(output))
+     {
+        ERR("fail to e_output_update.");
+        e_output_del(output);
+        goto fail;
+     }
+   TRACE_DS_END();
+
+   /* todo : add tdm_output_add_mode_change_request_handler()*/
+   ret = tdm_output_add_mode_change_request_handler(toutput, _e_comp_screen_output_mode_change_cb, e_comp_screen);
+   if (ret != TDM_ERROR_NONE)
+     {
+        ERR("fail to add output mode change handler.");
+        e_output_del(output);
+        return;
+     }
+
+   ret = tdm_output_add_destroy_handler(toutput, _e_comp_screen_output_destroy_cb, e_comp_screen);
+   if (ret != TDM_ERROR_NONE)
+     {
+        ERR("fail to add output destroy handler.");
+        e_output_del(output);
+        return;
+     }
+
+   e_comp_screen->outputs = eina_list_append(e_comp_screen->outputs, output);
+   e_comp_screen->num_outputs++;
+
+   return;
+
+fail:
+   TRACE_DS_END();
+}
+
+static void
 _e_comp_screen_deinit_outputs(E_Comp_Screen *e_comp_screen)
 {
    E_Output *output;
    Eina_List *l, *ll;
 
+   tdm_display_remove_output_create_handler(e_comp_screen->tdisplay, _e_comp_screen_output_create_cb, e_comp_screen);
+
+   e_hwc_ecore_evas_deinit();
+
    // free up e_outputs
    EINA_LIST_FOREACH_SAFE(e_comp_screen->outputs, l, ll, output)
      {
@@ -500,21 +589,33 @@ _e_comp_screen_deinit_outputs(E_Comp_Screen *e_comp_screen)
         e_output_del(output);
      }
 
+   e_egl_sync_deinit();
+   e_hwc_deinit();
+   e_hwc_windows_deinit();
+   e_hwc_planes_deinit();
    e_output_shutdown();
 }
 
 static Eina_Bool
 _e_comp_screen_fake_output_set(E_Comp_Screen *e_comp_screen)
 {
-   E_Output *output = NULL;
+   E_Output *primary_output = NULL;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
 
-   output = e_output_find_by_index(0);
+   primary_output = e_comp_screen_primary_output_get(e_comp_screen);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(primary_output, EINA_FALSE);
+
+   if (!e_output_hwc_setup(primary_output))
+     {
+        ERR("fail to e_output_hwc_setup.");
+        return EINA_FALSE;
+     }
 
-   if (!e_output_setup(output))
+   if (!e_output_fake_config_set(primary_output, 2, 1))
      {
-        ERR("fail to e_output_setup.");
+        e_error_message_show(_("Fail to set the fake output config!\n"));
+        e_hwc_ecore_evas_deinit();
         return EINA_FALSE;
      }
 
@@ -531,6 +632,9 @@ _e_comp_screen_init_outputs(E_Comp_Screen *e_comp_screen)
    int i;
    Eina_Bool scale_updated = EINA_FALSE;
    Eina_Bool connection_check = EINA_FALSE;
+   tdm_error err = TDM_ERROR_NONE;
+   char bootmode[32];
+   int ret;
 
    /* init e_output */
    if (!e_output_init())
@@ -540,26 +644,53 @@ _e_comp_screen_init_outputs(E_Comp_Screen *e_comp_screen)
      }
 
    /* get the num of outputs */
-   tdm_display_get_output_count(tdisplay, &num_outputs);
-   if (num_outputs < 1)
+   err = tdm_display_get_output_count(tdisplay, &num_outputs);
+   if ((err != TDM_ERROR_NONE) ||
+       (num_outputs < 1))
      {
         ERR("fail to get tdm_display_get_output_count\n");
         return EINA_FALSE;
      }
    e_comp_screen->num_outputs = num_outputs;
 
-   INF("E_COMP_SCREEN: num_outputs = %i", e_comp_screen->num_outputs);
+   ELOGF("COMP_SCREEN","num_outputs = %i", NULL, e_comp_screen->num_outputs);
+
+   if (!e_hwc_init())
+     {
+        ERR("e_hwc_init failed");
+        goto fail;
+     }
+
+   if (!e_hwc_planes_init())
+     {
+        ERR("e_hwc_planes_init failed");
+        goto fail;
+     }
+
+   if (!e_hwc_windows_init())
+     {
+        ERR("e_hwc_windows_init failed");
+        goto fail;
+     }
 
    for (i = 0; i < num_outputs; i++)
      {
+        e_main_ts_begin("\tE_Output New");
         output = e_output_new(e_comp_screen, i);
-        if (!output) goto fail;
+        if (!output)
+          {
+             e_main_ts_end("\tE_Output New Failed");
+             goto fail;
+          }
 
+        e_main_ts_begin("\tE_Output Update");
         if (!e_output_update(output))
           {
+            e_main_ts_end("\tE_Output Update Failed");
             ERR("fail to e_output_update.");
             goto fail;
           }
+        e_main_ts_end("\tE_Output Update Done");
 
         e_comp_screen->outputs = eina_list_append(e_comp_screen->outputs, output);
 
@@ -568,29 +699,51 @@ _e_comp_screen_init_outputs(E_Comp_Screen *e_comp_screen)
         connection_check = EINA_TRUE;
 
         /* setting with the best mode and enable the output */
+        e_main_ts_begin("\tE_Output Find Best Mode");
         mode = e_output_best_mode_find(output);
         if (!mode)
           {
+             e_main_ts_end("\tE_Output Find Best Mode Failed");
              ERR("fail to get best mode.");
              goto fail;
           }
+        e_main_ts_end("\tE_Output Find Best Mode Done");
 
+        e_main_ts_begin("\tE_Output Mode Apply");
         if (!e_output_mode_apply(output, mode))
           {
+             e_main_ts_end("\tE_Output Mode Apply Failed");
              ERR("fail to e_output_mode_apply.");
              goto fail;
           }
-        if (!e_output_dpms_set(output, E_OUTPUT_DPMS_ON))
+        e_main_ts_end("\tE_Output Mode Apply Done");
+
+        e_main_ts_begin("\tE_Output Set DPMS ON");
+        ret = device_board_get_boot_mode(bootmode, sizeof(bootmode));
+        if (!ret && !e_util_strcmp(bootmode, "silent"))
           {
-             ERR("fail to e_output_dpms.");
-             goto fail;
+             INF("silent reboot. do not set dpms");
+          }
+        else
+          {
+             if (!e_output_dpms_set(output, E_OUTPUT_DPMS_ON))
+               {
+                  e_main_ts_end("\tE_Output Set DPMS ON Failed");
+                  ERR("fail to e_output_dpms.");
+                  goto fail;
+               }
           }
 
-        if (!e_output_setup(output))
+        e_main_ts_end("\tE_Output Set DPMS ON Done");
+
+        e_main_ts_begin("\tE_Output Hwc Setup");
+        if (!e_output_hwc_setup(output))
           {
-             ERR("fail to e_output_setup.");
+             e_main_ts_end("\tE_Output Hwc Setup Failed");
+             ERR("fail to e_output_hwc_setup.");
              goto fail;
           }
+        e_main_ts_end("\tE_Output Hwc Setup Done");
 
         /* update e_scale with first available output size */
         if ((e_config->scale.for_tdm) && (!scale_updated))
@@ -607,86 +760,30 @@ _e_comp_screen_init_outputs(E_Comp_Screen *e_comp_screen)
      }
 
    //TODO: if there is no output connected, make the fake output which is connected.
-
    if (!connection_check)
      {
         if (!_e_comp_screen_fake_output_set(e_comp_screen))
           goto fail;
      }
 
-   return EINA_TRUE;
-fail:
-   _e_comp_screen_deinit_outputs(e_comp_screen);
-
-   return EINA_FALSE;
-}
-
-E_API void
-_e_comp_screen_keymap_set(struct xkb_context **ctx, struct xkb_keymap **map)
-{
-   char *keymap_path = NULL;
-   struct xkb_context *context;
-   struct xkb_keymap *keymap;
-   struct xkb_rule_names names = {0,};
-   const char* default_rules, *default_model, *default_layout, *default_variant, *default_options;
-
-   TRACE_INPUT_BEGIN(_e_comp_screen_keymap_set);
-
-   context = xkb_context_new(0);
-   EINA_SAFETY_ON_NULL_RETURN(context);
-
-   /* assemble xkb_rule_names so we can fetch keymap */
-   memset(&names, 0, sizeof(names));
-
-   default_rules = e_comp_wl_input_keymap_default_rules_get();
-   default_model = e_comp_wl_input_keymap_default_model_get();
-   default_layout = e_comp_wl_input_keymap_default_layout_get();
-   default_variant = e_comp_wl_input_keymap_default_variant_get();
-   default_options = e_comp_wl_input_keymap_default_options_get();
+   _e_comp_screen_size_update(e_comp_screen);
 
-   names.rules = strdup(default_rules);
-   names.model = strdup(default_model);
-   names.layout = strdup(default_layout);
-   if (default_variant) names.variant = strdup(default_variant);
-   if (default_options) names.options = strdup(default_options);
-
-   keymap = e_comp_wl_input_keymap_compile(context, names, &keymap_path);
-   eina_stringshare_del(keymap_path);
-   EINA_SAFETY_ON_NULL_GOTO(keymap, cleanup);
-
-   *ctx = context;
-   *map = keymap;
-
-   if (dont_set_e_input_keymap == EINA_FALSE)
+   e_main_ts_begin("\tE_Hwc Ecore_Evas Init");
+   if (!e_hwc_ecore_evas_init())
      {
-        e_input_device_keyboard_cached_context_set(*ctx);
-        e_input_device_keyboard_cached_keymap_set(*map);
+        e_main_ts_end("\ttE_Hwc Ecore_Evas Init Failed");
+        ERR("fail to e_hwc_ecore_evas_init");
+        goto fail;
      }
+   e_main_ts_end("\tE_Hwc Ecore_Evas Init Done");
 
-cleanup:
-   free((char *)names.rules);
-   free((char *)names.model);
-   free((char *)names.layout);
-   if (names.variant) free((char *)names.variant);
-   if (names.options) free((char *)names.options);
+   if (tdm_display_add_output_create_handler(tdisplay, _e_comp_screen_output_create_cb, e_comp_screen)) goto fail;
 
-   TRACE_INPUT_END();
-}
-
-static int
-_e_comp_screen_e_screen_sort_cb(const void *data1, const void *data2)
-{
-   const E_Output *s1 = data1, *s2 = data2;
-   int dif;
+   return EINA_TRUE;
+fail:
+   _e_comp_screen_deinit_outputs(e_comp_screen);
 
-   dif = -(s1->config.priority - s2->config.priority);
-   if (dif == 0)
-     {
-        dif = s1->config.geom.x - s2->config.geom.x;
-        if (dif == 0)
-          dif = s1->config.geom.y - s2->config.geom.y;
-     }
-   return dif;
+   return EINA_FALSE;
 }
 
 static void
@@ -723,25 +820,34 @@ _e_comp_screen_engine_init(void)
    /* check the screen rotation */
    screen_rotation = (e_config->screen_rotation_pre + e_config->screen_rotation_setting) % 360;
 
-   INF("E_COMP_SCREEN: screen_rotation_pre %d and screen_rotation_setting %d",
-       e_config->screen_rotation_pre, e_config->screen_rotation_setting);
+   ELOGF("COMP_SCREEN","screen_rotation_pre %d and screen_rotation_setting %d",
+         NULL, e_config->screen_rotation_pre, e_config->screen_rotation_setting);
 
    /* e_comp_screen new */
+   e_main_ts_begin("\tE_Comp_Screen New");
    e_comp_screen = _e_comp_screen_new(e_comp);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
+   if (!e_comp_screen)
+     {
+        e_main_ts_end("\tE_Comp_Screen New Failed");
+        e_error_message_show(_("Enlightenment cannot create e_comp_screen!\n"));
+        return EINA_FALSE;
+     }
+   e_main_ts_end("\tE_Comp_Screen New Done");
 
    e_comp->e_comp_screen = e_comp_screen;
+   e_comp_screen->rotation_pre = e_config->screen_rotation_pre;
+   e_comp_screen->rotation_setting = e_config->screen_rotation_setting;
    e_comp_screen->rotation = screen_rotation;
 
-   e_main_ts_begin("\tE_Outputs Init");
+   e_main_ts_begin("\tE_Comp_Screen Outputs Init");
    if (!_e_comp_screen_init_outputs(e_comp_screen))
      {
-        e_main_ts_end("\tE_Outputs Init Failed");
+        e_main_ts_end("\tE_Comp_Screen Outputs Init Failed");
         e_error_message_show(_("Enlightenment cannot initialize outputs!\n"));
         _e_comp_screen_engine_deinit();
         return EINA_FALSE;
      }
-   e_main_ts_end("\tE_Outputs Init Done");
+   e_main_ts_end("\tE_Comp_Screen Outputs Init Done");
 
    if (!E_EVENT_SCREEN_CHANGE) E_EVENT_SCREEN_CHANGE = ecore_event_type_new();
 
@@ -755,90 +861,44 @@ _e_comp_screen_engine_init(void)
    return EINA_TRUE;
 }
 
-EINTERN void
-e_comp_screen_e_screens_setup(E_Comp_Screen *e_comp_screen, int rw, int rh)
+static Eina_Bool
+_e_comp_screen_cb_dbus_init_done(void *data, int type, void *event)
 {
-   int i;
-   E_Screen *screen;
-   Eina_List *outputs = NULL, *outputs_rem;
-   Eina_List *e_screens = NULL;
-   Eina_List *l, *ll;
-   E_Output *output, *s2, *s_chosen;
-   Eina_Bool removed;
+   E_DBus_Conn_Init_Done_Event *e = event;
 
-   if (!e_comp_screen->outputs) goto out;
-   // put screens in tmp list
-   EINA_LIST_FOREACH(e_comp_screen->outputs, l, output)
+   if (e->status == E_DBUS_CONN_INIT_SUCCESS && e->conn_type == edbus_conn_type)
      {
-        if ((output->config.enabled) &&
-            (output->config.geom.w > 0) &&
-            (output->config.geom.h > 0))
-          {
-             outputs = eina_list_append(outputs, output);
-          }
+        edbus_conn = e_dbus_conn_connection_ref(edbus_conn_type);
+
+        if (edbus_conn)
+          _e_comp_screen_dbus_init();
      }
-   // remove overlapping screens - if a set of screens overlap, keep the
-   // smallest/lowest res
-   do
-     {
-        removed = EINA_FALSE;
 
-        EINA_LIST_FOREACH(outputs, l, output)
-          {
-             outputs_rem = NULL;
+   ecore_event_handler_del(dbus_init_done_handler);
+   dbus_init_done_handler = NULL;
 
-             EINA_LIST_FOREACH(l->next, ll, s2)
-               {
-                  if (E_INTERSECTS(output->config.geom.x, output->config.geom.y,
-                                   output->config.geom.w, output->config.geom.h,
-                                   s2->config.geom.x, s2->config.geom.y,
-                                   s2->config.geom.w, s2->config.geom.h))
-                    {
-                       if (!outputs_rem)
-                         outputs_rem = eina_list_append(outputs_rem, output);
-                       outputs_rem = eina_list_append(outputs_rem, s2);
-                    }
-               }
-             // we have intersecting screens - choose the lowest res one
-             if (outputs_rem)
-               {
-                  removed = EINA_TRUE;
-                  // find the smallest screen (chosen one)
-                  s_chosen = NULL;
-                  EINA_LIST_FOREACH(outputs_rem, ll, s2)
-                    {
-                       if (!s_chosen) s_chosen = s2;
-                       else
-                         {
-                            if ((s_chosen->config.geom.w *
-                                 s_chosen->config.geom.h) >
-                                (s2->config.geom.w *
-                                 s2->config.geom.h))
-                              s_chosen = s2;
-                         }
-                    }
-                  // remove all from screens but the chosen one
-                  EINA_LIST_FREE(outputs_rem, s2)
-                    {
-                       if (s2 != s_chosen)
-                         outputs = eina_list_remove_list(outputs, l);
-                    }
-                  // break our list walk and try again
-                  break;
-               }
-          }
-     }
-   while (removed);
-   // sort screens by priority etc.
-   outputs = eina_list_sort(outputs, 0, _e_comp_screen_e_screen_sort_cb);
-   i = 0;
-   EINA_LIST_FOREACH(outputs, l, output)
+   return ECORE_CALLBACK_PASS_ON;
+}
+
+EINTERN void
+e_comp_screen_e_screens_setup(E_Comp_Screen *e_comp_screen, int rw, int rh)
+{
+   E_Screen *screen;
+   E_Output *output;
+   Eina_List *e_screens = NULL;
+   Eina_List *l;
+   int i = 0, right_x = 0;
+
+   output = e_comp_screen_primary_output_get(e_comp_screen);
+   /* No pirmary output means that there is no output at the system */
+   if (!output) goto out;
+
+   EINA_LIST_FOREACH(e_comp_screen->outputs, l, output)
      {
         screen = E_NEW(E_Screen, 1);
-        if (!screen) continue;
+        if (!screen) return;
+
         screen->escreen = screen->screen = i;
-        screen->x = output->config.geom.x;
-        screen->y = output->config.geom.y;
 
         if (output->config.rotation % 180)
           {
@@ -851,41 +911,54 @@ e_comp_screen_e_screens_setup(E_Comp_Screen *e_comp_screen, int rw, int rh)
              screen->h = output->config.geom.h;
           }
 
+        if (e_output_connected(output))
+          {
+             output->config.geom.x = right_x;
+             right_x += output->config.geom.w;
+          }
+        else
+          {
+             output->config.geom.x = 0;
+          }
+
+        screen->x = output->config.geom.x;
+        screen->y = output->config.geom.y;
+
         if (output->id) screen->id = strdup(output->id);
 
         e_screens = eina_list_append(e_screens, screen);
-        INF("E INIT: SCREEN: [%i][%i], %ix%i+%i+%i",
-            i, i, screen->w, screen->h, screen->x, screen->y);
+        ELOGF("COMP_SCREEN","E INIT: SCREEN: [%i][%i], %ix%i+%i+%i",
+              NULL, i, i, screen->w, screen->h, screen->x, screen->y);
         i++;
      }
-   eina_list_free(outputs);
-   // if we have NO screens at all (above - i will be 0) AND we have no
-   // existing screens set up in xinerama - then just say root window size
-   // is the entire screen. this should handle the case where you unplug ALL
-   // screens from an existing setup (unplug external monitors and/or close
-   // laptop lid), in which case as long as at least one screen is configured
-   // in xinerama, it will be left-as is until next time we re-eval screen
-   // setup and have at least one screen
-   printf("e_comp_screen_e_screens_setup............... %i %p\n", i, e_comp_screen->e_screens);
-   if ((i == 0) && (!e_comp_screen->e_screens))
-     {
+
+   ELOGF("COMP_SCREEN","e_comp_screen_e_screens_setup............... %i %p\n", NULL, i, e_comp_screen->e_screens);
+
+   ecore_event_add(E_EVENT_SCREEN_CHANGE, NULL, NULL, NULL);
+
+   _e_comp_screen_e_screens_set(e_comp_screen, e_screens);
+
+   return;
 out:
-        screen = E_NEW(E_Screen, 1);
-        if (!screen) return;
-        screen->escreen = screen->screen = 0;
-        screen->x = 0;
-        screen->y = 0;
-        if ((rw > 0) && (rh > 0))
-          screen->w = rw, screen->h = rh;
+   screen = E_NEW(E_Screen, 1);
+   if (!screen) return;
+   screen->escreen = screen->screen = 0;
+   screen->x = 0;
+   screen->y = 0;
+   if ((rw > 0) && (rh > 0))
+     screen->w = rw, screen->h = rh;
+   else
+     {
+        if (e_comp_screen->rotation % 180)
+          ecore_evas_geometry_get(e_comp->ee, NULL, NULL, &screen->h, &screen->w);
         else
-          {
-             if (e_comp_screen->rotation % 180)
-               ecore_evas_geometry_get(e_comp->ee, NULL, NULL, &screen->h, &screen->w);
-             else
-               ecore_evas_geometry_get(e_comp->ee, NULL, NULL, &screen->w, &screen->h);
-          }
-        e_screens = eina_list_append(e_screens, screen);
+          ecore_evas_geometry_get(e_comp->ee, NULL, NULL, &screen->w, &screen->h);
      }
+   e_screens = eina_list_append(e_screens, screen);
+
+   ELOGF("COMP_SCREEN","E INIT: SCREEN: No Physical Screen : [%i][%i], %ix%i+%i+%i",
+         NULL, i, i, screen->w, screen->h, screen->x, screen->y);
+
    _e_comp_screen_e_screens_set(e_comp_screen, e_screens);
 }
 
@@ -897,50 +970,52 @@ e_comp_screen_e_screens_get(E_Comp_Screen *e_comp_screen)
    return e_comp_screen->e_screens;
 }
 
-E_API Eina_Bool
+static void
+_e_comp_screen_cb_output_connect_status_change(void *data, E_Output *output)
+{
+   _e_comp_screen_size_update(e_comp->e_comp_screen);
+}
+
+static void
+_e_comp_screen_cb_output_mode_change(void *data, E_Output *output)
+{
+   _e_comp_screen_size_update(e_comp->e_comp_screen);
+}
+
+EINTERN Eina_Bool
 e_comp_screen_init()
 {
    E_Comp *comp;
-   int w, h;
-   struct xkb_context *ctx = NULL;
-   struct xkb_keymap *map = NULL;
+   int w, h, ptr_x = 0, ptr_y = 0;
 
-   TRACE_DS_BEGIN(E_COMP_SCREEN:INIT);
    if (!(comp = e_comp))
-     {
-        TRACE_DS_END();
-        EINA_SAFETY_ON_NULL_RETURN_VAL(comp, EINA_FALSE);
-     }
-
-   /* keymap */
-   dont_set_e_input_keymap = getenv("NO_E_INPUT_KEYMAP_CACHE") ? EINA_TRUE : EINA_FALSE;
-   dont_use_xkb_cache = getenv("NO_KEYMAP_CACHE") ? EINA_TRUE : EINA_FALSE;
-
-   if (e_config->xkb.use_cache && !dont_use_xkb_cache)
-     {
-        e_main_ts_begin("\tDRM Keymap Init");
-        _e_comp_screen_keymap_set(&ctx, &map);
-        e_main_ts_end("\tDRM Keymap Init Done");
-     }
+     EINA_SAFETY_ON_NULL_RETURN_VAL(comp, EINA_FALSE);
 
+   e_main_ts_begin("\tE_Comp_Screen_Engine Init");
    if (!_e_comp_screen_engine_init())
      {
+        e_main_ts_end("\tE_Comp_Screen_Engine Init Failed");
         ERR("Could not initialize the ecore_evas engine.");
         goto failed_comp_screen;
      }
+   e_main_ts_end("\tE_Comp_Screen_Engine Init Done");
 
+   e_main_ts_begin("\tE_Input Init");
    if (!e_input_init(e_comp->ee))
      {
+        e_main_ts_end("\tE_Input Init Failed");
         ERR("Could not initialize the e_input.");
         goto failed_comp_screen;
      }
+   e_main_ts_end("\tE_Input Init Done");
 
-   e_main_ts("\tE_Comp_Wl Init");
-   if (!e_comp_wl_init())
+   e_main_ts_begin("\tE_Server Init");
+   if (!e_server_init())
      {
-        goto failed_comp_screen_with_ts;
+        e_main_ts_end("\tE_Server Init Failed");
+        goto failed_comp_screen;
      }
-   e_main_ts_end("\tE_Comp_Wl Init Done");
+   e_main_ts_end("\tE_Server Init Done");
 
    /* get the current screen geometry */
    ecore_evas_geometry_get(e_comp->ee, NULL, NULL, &w, &h);
@@ -949,15 +1024,25 @@ e_comp_screen_init()
    e_main_ts_begin("\tE_Comp_Canvas Init");
    if (!e_comp_canvas_init(w, h))
      {
+        e_main_ts_end("\tE_Comp_Canvas Init Failed");
         e_error_message_show(_("Enlightenment cannot initialize outputs!\n"));
-        goto failed_comp_screen_with_ts;
+        goto failed_comp_screen;
      }
    e_main_ts_end("\tE_Comp_Canvas Init Done");
 
+   e_main_ts_begin("\tE_Egl_Sync Init");
+   if (e_egl_sync_init())
+     ELOGF("E_EGL_SYNC", "Enabled the E_Egl_Sync", NULL);
+   e_main_ts_end("\tE_Egl_Sync Init Done");
+
+   e_main_ts_begin("\tE_Linux_Dmabuf Init");
+   e_linux_dmabuf_init(e_comp_wl->wl.disp);
+   e_main_ts_end("\tE_Linux_Dmabuf Init Done");
+
    /* pointer */
-   ecore_evas_pointer_xy_get(e_comp->ee,
-                             &e_comp_wl->ptr.x,
-                             &e_comp_wl->ptr.y);
+   e_input_device_pointer_xy_get(NULL, &ptr_x, &ptr_y);
+   e_comp_wl->ptr.x = wl_fixed_from_int(ptr_x);
+   e_comp_wl->ptr.y = wl_fixed_from_int(ptr_y);
 
    evas_event_feed_mouse_in(e_comp->evas, 0, NULL);
 
@@ -978,93 +1063,83 @@ e_comp_screen_init()
 
    /* FIXME: This is just for testing at the moment....
     * happens to jive with what drm does */
-   e_main_ts_begin("\tE_Comp_WL Keymap Init");
-   e_comp_wl_input_keymap_set(e_comp_wl_input_keymap_default_rules_get(),
-                              e_comp_wl_input_keymap_default_model_get(),
-                              e_comp_wl_input_keymap_default_layout_get(),
-                              e_comp_wl_input_keymap_default_variant_get(),
-                              e_comp_wl_input_keymap_default_options_get(),
-                              ctx, map);
-   e_main_ts_end("\tE_Comp_WL Keymap Init Done");
-
-   /* try to add tizen_video to wayland globals */
-   if (!wl_global_create(e_comp_wl->wl.disp, &tizen_screen_rotation_interface, 1,
-                         NULL, _tz_screen_rotation_cb_bind))
-     {
-        ERR("Could not add tizen_screen_rotation to wayland globals");
-        goto failed_comp_screen;
+
+   if (!e_input_thread_mode_get())
+     {
+        e_main_ts_begin("\tE_Comp_WL Keymap Init");
+        e_comp_wl_input_keymap_init();
+        e_main_ts_begin("\tE_Comp_WL Keymap Init Done");
      }
 
-   if (eldbus_init() == 0)
+   if (!e_screen_rotation_init())
      {
-        ERR("eldbus_init failed");
+        e_main_ts_end("\e_screen_rotation_init Init Failed");
         goto failed_comp_screen;
      }
 
-   _e_comp_screen_dbus_init(NULL);
-
-   tzsr_client_hook_del = e_client_hook_add(E_CLIENT_HOOK_DEL, _tz_screen_rotation_cb_client_del, NULL);
-
-   E_LIST_HANDLER_APPEND(event_handlers, E_INPUT_EVENT_INPUT_DEVICE_ADD, _e_comp_screen_cb_input_device_add, comp);
-   E_LIST_HANDLER_APPEND(event_handlers, E_INPUT_EVENT_INPUT_DEVICE_DEL, _e_comp_screen_cb_input_device_del, comp);
+   if (!e_comp_wl_tizen_hwc_init())
+     {
+        e_main_ts_end("\e_comp_wl_tizen_hwc_init Init Failed");
+        e_error_message_show(_("Enlightenment cannot initialize tizen_hwc!\n"));
+        goto failed_comp_screen;
+     }
 
-   if (e_comp->e_comp_screen->rotation > 0)
+   e_main_ts_begin("\tDBUS Init");
+   dbus_init_done_handler = NULL;
+   if (e_dbus_conn_init() > 0)
      {
-         const Eina_List *l;
-         E_Input_Device *dev;
+        dbus_init_done_handler = ecore_event_handler_add(E_EVENT_DBUS_CONN_INIT_DONE, _e_comp_screen_cb_dbus_init_done, NULL);
+        e_dbus_conn_dbus_init(edbus_conn_type);
+     }
+   e_main_ts_end("\tDBUS Init Done");
 
-         EINA_LIST_FOREACH(e_input_devices_get(), l, dev)
-           {
-               e_input_device_touch_rotation_set(dev, e_comp->e_comp_screen->rotation);
-               e_input_device_rotation_set(dev, e_comp->e_comp_screen->rotation);
+   E_LIST_HANDLER_APPEND(event_handlers, ECORE_EVENT_DEVICE_ADD, _e_comp_screen_cb_input_device_add, comp);
+   E_LIST_HANDLER_PREPEND(event_handlers, ECORE_EVENT_DEVICE_DEL, _e_comp_screen_cb_input_device_del, comp);
 
-               INF("EE Input Device Rotate: %d", e_comp->e_comp_screen->rotation);
-           }
-     }
+   E_OUTPUT_HOOK_APPEND(output_hooks, E_OUTPUT_HOOK_CONNECT_STATUS_CHANGE, _e_comp_screen_cb_output_connect_status_change, comp);
+   E_OUTPUT_HOOK_APPEND(output_hooks, E_OUTPUT_HOOK_MODE_CHANGE, _e_comp_screen_cb_output_mode_change, comp);
 
-   TRACE_DS_END();
+   _e_comp_screen_input_rotation_set(e_comp->e_comp_screen->rotation);
 
    return EINA_TRUE;
 
-failed_comp_screen_with_ts:
-   e_main_ts_end("\tE_Comp_Screen init failed");
 failed_comp_screen:
 
+   e_screen_rotation_shutdown();
+   e_comp_wl_tizen_hwc_shutdown();
    e_input_shutdown();
    _e_comp_screen_engine_deinit();
 
-   TRACE_DS_END();
-
    return EINA_FALSE;
 }
 
-E_API void
+EINTERN void
 e_comp_screen_shutdown()
 {
    if (!e_comp) return;
    if (!e_comp->e_comp_screen) return;
 
+   e_screen_rotation_shutdown();
+   e_comp_wl_tizen_hwc_shutdown();
+
    if (e_comp_screen_iface)
      {
         eldbus_service_interface_unregister(e_comp_screen_iface);
         e_comp_screen_iface = NULL;
      }
 
-   if (e_comp_screen_conn)
+   if (edbus_conn)
      {
-        eldbus_connection_unref(e_comp_screen_conn);
-        e_comp_screen_conn = NULL;
+        e_dbus_conn_connection_unref(edbus_conn);
+        edbus_conn = NULL;
      }
 
-   eldbus_shutdown();
+   e_dbus_conn_shutdown();
 
    _e_comp_screen_deinit_outputs(e_comp->e_comp_screen);
 
-   e_client_hook_del(tzsr_client_hook_del);
-   tzsr_client_hook_del = NULL;
+   E_FREE_LIST(output_hooks, e_output_hook_del);
 
-   dont_set_e_input_keymap = EINA_FALSE;
-   dont_use_xkb_cache = EINA_FALSE;
    E_FREE_LIST(event_handlers, ecore_event_handler_del);
 
    /* delete e_comp_sreen */
@@ -1072,21 +1147,11 @@ e_comp_screen_shutdown()
    e_comp->e_comp_screen = NULL;
 }
 
-E_API Eina_Bool
-e_comp_screen_rotation_setting_set(E_Comp_Screen *e_comp_screen, int rotation)
+static E_Output *
+_e_comp_screen_output_find_primary(E_Comp_Screen *e_comp_screen)
 {
    E_Output *output = NULL, *o;
    const Eina_List *l;
-   int w, h;
-   int screen_rotation;
-   E_Input_Device *dev;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
-   EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation % 90, EINA_FALSE);
-   EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation < 0, EINA_FALSE);
-   EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation > 270, EINA_FALSE);
-
-   if (e_config->screen_rotation_setting == rotation) return EINA_TRUE;
 
    EINA_LIST_FOREACH(e_comp_screen->outputs, l, o)
      {
@@ -1104,17 +1169,31 @@ e_comp_screen_rotation_setting_set(E_Comp_Screen *e_comp_screen, int rotation)
    if (!output)
      {
         ERR("couldn't find the primary output");
-        return EINA_FALSE;
+        return NULL;
      }
 
-   screen_rotation = (e_config->screen_rotation_pre + rotation) % 360;
+   return output;
+}
+
+static Eina_Bool
+_e_comp_screen_rotation_set(E_Comp_Screen *e_comp_screen, int screen_rotation,
+  void (*setter)(E_Comp_Screen *e_comp_screen, int data), int data)
+{
+   E_Output *output = NULL;
+   E_Input_Device *dev;
+   const Eina_List *l;
+   int w, h;
+
+   output = _e_comp_screen_output_find_primary(e_comp_screen);
+   if (!output)
+     return EINA_FALSE;
 
    if (!e_output_rotate(output, screen_rotation))
      return EINA_FALSE;
 
-   /* TODO: need to save e_config->screen_rotation_setting to e_config data file */
-   e_config->screen_rotation_setting = rotation;
    e_comp_screen->rotation = screen_rotation;
+   if (setter)
+      setter(e_comp_screen, data);
 
    ecore_evas_rotation_with_resize_set(e_comp->ee, e_comp_screen->rotation);
    ecore_evas_geometry_get(e_comp->ee, NULL, NULL, &w, &h);
@@ -1128,53 +1207,91 @@ e_comp_screen_rotation_setting_set(E_Comp_Screen *e_comp_screen, int rotation)
          e_input_device_touch_rotation_set(dev, e_comp_screen->rotation);
          e_input_device_rotation_set(dev, e_comp_screen->rotation);
 
-         INF("EE Input Device Rotate: %d", e_comp_screen->rotation);
+         ELOGF("COMP_SCREEN","EE Input Device Rotate: %d", NULL, e_comp_screen->rotation);
      }
 
    if (e_comp_screen_iface)
      {
         eldbus_service_signal_emit(e_comp_screen_iface, E_COMP_SCREEN_SIGNAL_ROTATION_CHANGED, e_comp_screen->rotation);
-        ELOGF("TRANSFORM", "screen-rotation sends signal: %d", NULL, NULL, e_comp_screen->rotation);
+        ELOGF("COMP_SCREEN", "screen-rotation sends signal: %d", NULL, e_comp_screen->rotation);
      }
 
-   INF("EE Rotated and Resized: %d, %dx%d", e_comp_screen->rotation, w, h);
+   ELOGF("COMP_SCREEN","EE Rotated and Resized: %d, %dx%d", NULL, e_comp_screen->rotation, w, h);
 
    return EINA_TRUE;
 }
 
-E_API void
-e_comp_screen_rotation_ignore_output_transform_send(E_Client *ec, Eina_Bool ignore)
+static void
+_e_comp_screen_rotation_pre_setter(E_Comp_Screen *e_comp_screen, int rotation_pre)
+{
+   e_comp_screen->rotation_pre = rotation_pre;
+   ELOGF("COMP_SCREEN","EE RotationPre: %d", NULL, rotation_pre);
+}
+
+EINTERN Eina_Bool
+e_comp_screen_rotation_pre_set(E_Comp_Screen *e_comp_screen, int rotation_pre)
+{
+   int screen_rotation;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation_pre % 90, EINA_FALSE);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation_pre < 0, EINA_FALSE);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation_pre > 270, EINA_FALSE);
+
+   if (e_comp_screen->rotation_pre == rotation_pre) return EINA_TRUE;
+
+   screen_rotation = (rotation_pre + e_comp_screen->rotation_setting) % 360;
+
+   return _e_comp_screen_rotation_set(e_comp_screen, screen_rotation,
+     _e_comp_screen_rotation_pre_setter, rotation_pre);
+}
+
+static void
+_e_comp_screen_rotation_setting_setter(E_Comp_Screen *e_comp_screen, int rotation)
 {
-   E_Comp_Screen_Tzsr *tzsr = _tz_surface_rotation_find(ec);
+   e_comp_screen->rotation_setting = rotation;
+   ELOGF("COMP_SCREEN","EE RotationSetting: %d", NULL, rotation);
+}
+
+E_API Eina_Bool
+e_comp_screen_rotation_setting_set(E_Comp_Screen *e_comp_screen, int rotation)
+{
+   int screen_rotation;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation % 90, EINA_FALSE);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation < 0, EINA_FALSE);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation > 270, EINA_FALSE);
 
-   if (!tzsr) return;
+   if (e_comp_screen->rotation_setting == rotation) return EINA_TRUE;
 
+   screen_rotation = (e_comp_screen->rotation_pre + rotation) % 360;
+
+   return _e_comp_screen_rotation_set(e_comp_screen, screen_rotation,
+     _e_comp_screen_rotation_setting_setter, rotation);
+}
+
+E_API void
+e_comp_screen_rotation_ignore_output_transform_send(E_Client *ec, Eina_Bool ignore)
+{
    /* if client have to considers the output transform */
    if (!ignore)
      {
         /* exception */
         if (e_config->screen_rotation_client_ignore)
           {
-             ELOGF("TRANSFORM", "|tzsr(%p) ignore_output_transform: client_ignore", NULL, ec, tzsr);
+             ELOGF("TRANSFORM", "|ignore_output_transform: client_ignore", ec);
              return;
           }
 
         if (e_policy_client_is_quickpanel(ec))
            {
-              ELOGF("TRANSFORM", "|tzsr(%p) ignore_output_transform: quickpanel", NULL, ec, tzsr);
+              ELOGF("TRANSFORM", "|ignore_output_transform: quickpanel", ec);
               return;
            }
      }
 
-   ELOGF("TRANSFORM", "|tzsr(%p) ignore_output_transform(%d)", NULL, ec, tzsr, ignore);
-
-   tizen_screen_rotation_send_ignore_output_transform(tzsr->resource, ec->comp_data->surface, ignore);
-}
-
-EINTERN Eina_Bool
-e_comp_screen_rotation_ignore_output_transform_watch(E_Client *ec)
-{
-   return (_tz_surface_rotation_find(ec)) ? EINA_TRUE : EINA_FALSE;
+   e_screen_rotation_ignore_output_transform_send(ec, ignore);
 }
 
 EINTERN E_Output *
@@ -1247,15 +1364,21 @@ e_comp_screen_hwc_info_debug(void)
    int output_idx = 0;
    tdm_layer_capability layer_capabilities;
    char layer_cap[4096] = {0, };
+   int i;
+   const tdm_prop *tprops;
+   int count;
 
    INF("HWC: HWC Information ==========================================================");
    EINA_LIST_FOREACH_SAFE(e_comp_screen->outputs, l_o, ll_o, output)
      {
+        tdm_error err = TDM_ERROR_NONE;
+
         if (!output) continue;
 
-        if (e_output_hwc_policy_get(output->output_hwc) == E_OUTPUT_HWC_POLICY_PLANES)
+        if (e_hwc_policy_get(output->hwc) == E_HWC_POLICY_PLANES)
           {
-             tdm_output_get_conn_status(output->toutput, &conn_status);
+             err = tdm_output_get_conn_status(output->toutput, &conn_status);
+             if (err != TDM_ERROR_NONE) continue;
              if (conn_status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED) continue;
 
              INF("HWC: HWC Output(%d):(x, y, w, h)=(%d, %d, %d, %d) Information.",
@@ -1286,8 +1409,268 @@ e_comp_screen_hwc_info_debug(void)
           {
              /* TODO: construct debug info for outputs managed by the hwc-wins */
              INF("HWC: HWC Output(%d) managed by hwc-wins.", ++output_idx);
-             continue;
+
+             if (!e_hwc_windows_get_available_properties(output->hwc, &tprops, &count))
+               {
+                  ERR("e_hwc_windows_get_video_available_properties failed");
+                  return;
+               }
+             INF(">>>>>>>> Available UI props : count = %d", count);
+             for (i = 0; i < count; i++)
+               INF("   [%d] %s, %u", i, tprops[i].name, tprops[i].id);
+
+             if (!e_hwc_windows_get_video_available_properties(output->hwc, &tprops, &count))
+               {
+                  ERR("e_hwc_windows_get_video_available_properties failed");
+                  return;
+               }
+             INF(">>>>>>>> Available VIDEO props : count = %d", count);
+             for (i = 0; i < count; i++)
+               INF("   [%d] %s, %u", i, tprops[i].name, tprops[i].id);
           }
      }
    INF("HWC: =========================================================================");
 }
+
+#define NUM_SW_FORMAT   (sizeof(sw_formats) / sizeof(sw_formats[0]))
+
+static tbm_format sw_formats[] = {
+     TBM_FORMAT_ARGB8888,
+     TBM_FORMAT_XRGB8888,
+     TBM_FORMAT_YUV420,
+     TBM_FORMAT_YVU420,
+};
+
+static tdm_layer *
+_e_comp_screen_video_tdm_layer_get(tdm_output *output)
+{
+   int i, count = 0;
+#ifdef CHECKING_PRIMARY_ZPOS
+   int primary_idx = 0, primary_zpos = 0;
+   tdm_layer *primary_layer;
+#endif
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(output, NULL);
+
+   tdm_output_get_layer_count(output, &count);
+   for (i = 0; i < count; i++)
+     {
+        tdm_layer *layer = tdm_output_get_layer(output, i, NULL);
+        tdm_layer_capability capabilities = 0;
+        EINA_SAFETY_ON_NULL_RETURN_VAL(layer, NULL);
+
+        tdm_layer_get_capabilities(layer, &capabilities);
+        if (capabilities & TDM_LAYER_CAPABILITY_VIDEO)
+          return layer;
+     }
+
+#ifdef CHECKING_PRIMARY_ZPOS
+   tdm_output_get_primary_index(output, &primary_idx);
+   primary_layer = tdm_output_get_layer(output, primary_idx, NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(primary_layer, NULL);
+   tdm_layer_get_zpos(primary_layer, &primary_zpos);
+#endif
+
+   for (i = 0; i < count; i++)
+     {
+        tdm_layer *layer = tdm_output_get_layer(output, i, NULL);
+        tdm_layer_capability capabilities = 0;
+        EINA_SAFETY_ON_NULL_RETURN_VAL(layer, NULL);
+
+        tdm_layer_get_capabilities(layer, &capabilities);
+        if (capabilities & TDM_LAYER_CAPABILITY_OVERLAY)
+          {
+#ifdef CHECKING_PRIMARY_ZPOS
+             int zpos = 0;
+             tdm_layer_get_zpos(layer, &zpos);
+             if (zpos >= primary_zpos) continue;
+#endif
+             return layer;
+          }
+     }
+
+   return NULL;
+}
+
+static E_Output *
+_e_comp_screen_eoutput_get_by_toutput(tdm_output *output)
+{
+   Eina_List *l;
+   E_Output *eo;
+
+   EINA_LIST_FOREACH(e_comp->e_comp_screen->outputs, l, eo)
+      if (eo->toutput == output)
+        return eo;
+
+   return NULL;
+}
+
+E_API Eina_Bool
+e_comp_screen_available_video_formats_get(const tbm_format **formats, int *count)
+{
+   E_Output *output;
+   tdm_output *toutput;
+   tdm_layer *layer;
+   tdm_error error;
+
+   *count = 0;
+
+   if (e_comp_screen_pp_support())
+     {
+        error = tdm_display_get_pp_available_formats(e_comp->e_comp_screen->tdisplay, formats, count);
+        if (error == TDM_ERROR_NONE)
+          return EINA_TRUE;
+     }
+
+   /* get the first output */
+   toutput = tdm_display_get_output(e_comp->e_comp_screen->tdisplay, 0, NULL);
+   if (!toutput)
+     return EINA_FALSE;
+
+   output = _e_comp_screen_eoutput_get_by_toutput(toutput);
+   if (!output)
+     return EINA_FALSE;
+
+   if (e_hwc_policy_get(output->hwc) != E_HWC_POLICY_WINDOWS)
+     {
+        /* get the first suitable layer */
+        layer = _e_comp_screen_video_tdm_layer_get(toutput);
+        if (layer)
+          {
+             tdm_layer_get_available_formats(layer, formats, count);
+          }
+        else
+          {
+             *formats = sw_formats;
+             *count = NUM_SW_FORMAT;
+          }
+     }
+   else
+     {
+        error = tdm_hwc_get_video_supported_formats(output->hwc->thwc, formats, count);
+        if (error != TDM_ERROR_NONE)
+          {
+             *formats = sw_formats;
+             *count = NUM_SW_FORMAT;
+          }
+     }
+
+   return EINA_TRUE;
+}
+
+EINTERN void *
+e_comp_screen_gbm_device_get(E_Comp_Screen *e_comp_screen)
+{
+   int fd;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, NULL);
+
+   if (e_comp_screen->gdevice) return e_comp_screen->gdevice;
+
+   fd = tbm_drm_helper_get_master_fd();
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(fd >= 0, NULL);
+
+   e_comp_screen->gdevice = gbm_create_device(fd);
+   if (!e_comp_screen->gdevice)
+     {
+        ERR("fail to create gbm device");
+        close(fd);
+        return NULL;
+     }
+
+   e_comp_screen->gdevice_fd = fd;
+
+   return e_comp_screen->gdevice;
+}
+
+EINTERN Eina_Bool
+e_comp_screen_size_get(E_Comp_Screen *e_comp_screen, int *w, int *h)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
+
+   if (w) *w = e_comp_screen->w;
+   if (h) *h = e_comp_screen->h;
+
+   return EINA_TRUE;
+}
+static char *
+_e_comp_screen_dpms_to_string(E_OUTPUT_DPMS dpms)
+{
+   switch (dpms)
+     {
+        case E_OUTPUT_DPMS_ON:
+          return "DPMS_ON";
+          break;
+        case E_OUTPUT_DPMS_STANDBY:
+          return "DPMS_STANDBY";
+          break;
+        case E_OUTPUT_DPMS_SUSPEND:
+          return "DPMS_SUSPEND";
+          break;
+        case E_OUTPUT_DPMS_OFF:
+          return "DPMS_OFF";
+          break;
+        default:
+          return "Unknown";
+     }
+}
+
+EINTERN void
+e_comp_screen_debug_info_get(Eldbus_Message_Iter *iter)
+{
+   Eldbus_Message_Iter *line_array;
+   E_Comp_Screen *e_comp_screen = NULL;
+   E_Output *output = NULL;
+   E_Hwc *hwc = NULL;
+   Eina_List *l;
+   char info_str[1024];
+
+   e_comp_screen = e_comp->e_comp_screen;
+
+   eldbus_message_iter_arguments_append(iter, "as", &line_array);
+   if (!e_comp_screen)
+     {
+        eldbus_message_iter_basic_append(line_array,
+                                         's',
+                                         "e_comp_screen not initialized..");
+        eldbus_message_iter_container_close(iter, line_array);
+        return;
+     }
+
+   eldbus_message_iter_basic_append(line_array, 's',
+   "===========================================================================================");
+   eldbus_message_iter_basic_append(line_array, 's',
+   " idx      id           status       dpms     (   x  ,   y  ) ( w    x    h ) ");
+   eldbus_message_iter_basic_append(line_array, 's',
+   "===========================================================================================");
+
+   EINA_LIST_FOREACH(e_comp_screen->outputs, l, output)
+     {
+        if (!output) continue;
+        hwc = output->hwc;
+        if (!output->hwc) continue;
+        if (e_hwc_policy_get(hwc) == E_HWC_POLICY_NONE) continue;
+
+        snprintf(info_str, sizeof(info_str), "%2d %12s %15s %10s   (%5d , %5d) (%5d x %5d)",
+                 output->index, output->id,
+                 output->info.connected ? "connected" : "disconnected",
+                 _e_comp_screen_dpms_to_string(output->dpms),
+                 output->config.geom.x, output->config.geom.y,
+                 output->config.geom.w, output->config.geom.h);
+
+        eldbus_message_iter_basic_append(line_array, 's', info_str);
+     }
+
+   eldbus_message_iter_basic_append(line_array, 's',
+   "===========================================================================================");
+
+   eldbus_message_iter_container_close(iter, line_array);
+}
+
+E_API Eina_List *
+e_comp_screen_outputs_get(E_Comp_Screen *e_comp_screen)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, NULL);
+
+   return e_comp_screen->outputs;
+}