hwc: use tdm layer commit instead tdm output commit 50/112650/1 accepted/tizen/3.0/common/20170203.150952 accepted/tizen/3.0/ivi/20170203.022727 accepted/tizen/3.0/mobile/20170203.022157 accepted/tizen/3.0/tv/20170203.022327 accepted/tizen/3.0/wearable/20170203.022542 accepted/tizen/common/20170202.175210 accepted/tizen/ivi/20170203.023249 accepted/tizen/mobile/20170203.023122 accepted/tizen/tv/20170203.023149 accepted/tizen/wearable/20170203.023220 submit/tizen/20170202.112833 submit/tizen_3.0/20170202.112845
authorChangyeon Lee <cyeon.lee@samsung.com>
Wed, 25 Jan 2017 12:42:39 +0000 (21:42 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Thu, 2 Feb 2017 06:09:22 +0000 (15:09 +0900)
Change-Id: I518cc0a562aead7d843072562ab51b44c3c6ba4c

src/bin/e_output.c
src/bin/e_plane.c
src/bin/e_plane.h
src/bin/e_plane_renderer.c

index b5688d840965732ebb74f934add3428fd280a833..3c3f7c4cddc0909ce313d3d425df05c89254a31e 100644 (file)
@@ -67,62 +67,6 @@ _e_output_update_fps()
      }
 }
 
-static void
-_e_output_commit_hanler(tdm_output *output, unsigned int sequence,
-                                  unsigned int tv_sec, unsigned int tv_usec,
-                                  void *user_data)
-{
-   Eina_List *data_list = user_data;
-   E_Plane_Commit_Data *data = NULL;
-   Eina_List *l, *ll;
-
-   _e_output_update_fps();
-
-   TRACE_DS_ASYNC_END((unsigned int)output, [OUTPUT:COMMIT~HANDLER]);
-
-   EINA_LIST_FOREACH_SAFE(data_list, l, ll, data)
-     {
-        data_list = eina_list_remove_list(data_list, l);
-        e_plane_commit_data_release(data);
-        data = NULL;
-     }
-}
-
-static Eina_Bool
-_e_output_commit(E_Output *output)
-{
-   Eina_List *data_list = NULL;
-   E_Plane_Commit_Data *data = NULL;
-   E_Plane *plane = NULL;
-   Eina_List *l, *ll;
-   tdm_error error;
-
-   EINA_LIST_REVERSE_FOREACH(output->planes, l, plane)
-     {
-        data = e_plane_commit_data_aquire(plane);
-        if (!data) continue;
-        data_list = eina_list_append(data_list, data);
-     }
-
-   TRACE_DS_ASYNC_BEGIN((unsigned int)output->toutput, [OUTPUT:COMMIT~HANDLER]);
-
-   error = tdm_output_commit(output->toutput, 0, _e_output_commit_hanler, data_list);
-   if (error != TDM_ERROR_NONE)
-     {
-        ERR("fail to tdm_output_commit");
-        TRACE_DS_ASYNC_END((unsigned int)output->toutput, [OUTPUT:COMMIT~HANDLER]);
-        EINA_LIST_FOREACH_SAFE(data_list, l, ll, data)
-          {
-             data_list = eina_list_remove_list(data_list, l);
-             e_plane_commit_data_release(data);
-             data = NULL;
-          }
-        return EINA_FALSE;
-     }
-
-   return EINA_TRUE;
-}
-
 EINTERN Eina_Bool
 e_output_init(void)
 {
@@ -814,7 +758,7 @@ e_output_commit(E_Output *output)
 {
    E_Plane *plane = NULL;
    Eina_List *l;
-   Eina_Bool commitable = EINA_FALSE;
+   Eina_Bool fb_commit = EINA_FALSE;
    Eina_Bool fb_hwc_on = EINA_FALSE;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(output, EINA_FALSE);
@@ -825,54 +769,41 @@ e_output_commit(E_Output *output)
         return EINA_FALSE;
      }
 
-   EINA_LIST_FOREACH(output->planes, l, plane)
-     {
-        if (e_plane_is_fb_target(plane))
-          {
-             if (plane->ec)
-                fb_hwc_on = EINA_TRUE;
-
-             break;
-          }
-     }
-
    /* set planes */
-   EINA_LIST_REVERSE_FOREACH(output->planes, l, plane)
+   EINA_LIST_FOREACH(output->planes, l, plane)
      {
-        if (e_plane_fetch(plane))
-         {
-            if (output->dpms == E_OUTPUT_DPMS_OFF)
-              {
-                 e_plane_unfetch(plane);
-                 continue;
-              }
+        if (e_plane_is_fb_target(plane) && plane->ec)
+           fb_hwc_on = EINA_TRUE;
 
-            if (!commitable) commitable = EINA_TRUE;
-         }
-
-       if (fb_hwc_on && plane->need_to_unset_commit && !commitable)
-          commitable = EINA_TRUE;
-     }
+        if (!e_plane_fetch(plane)) continue;
 
-   /* commit output */
-   if (commitable)
-     {
-        if (!_e_output_commit(output))
+        if (output->dpms == E_OUTPUT_DPMS_OFF)
           {
-             ERR("fail to _e_output_commit.");
-
-             /* unset planes */
-             EINA_LIST_REVERSE_FOREACH(output->planes, l, plane)
-               e_plane_unfetch(plane);
+              e_plane_unfetch(plane);
+              continue;
+          }
 
-             return EINA_FALSE;
+        if (e_plane_is_fb_target(plane))
+          {
+              _e_output_update_fps();
+              fb_commit = EINA_TRUE;
           }
+        else
+          {
+              if (plane->need_to_unset_commit)
+                {
+                  if (!fb_hwc_on && !fb_commit)
+                      continue;
+                }
+          }
+
+        if (!e_plane_commit(plane))
+          ERR("fail to e_plane_commit");
      }
 
    return EINA_TRUE;
 }
 
-
 E_API E_Output *
 e_output_find(const char *id)
 {
index 4374ef4541cafdbd60e319c23338d1219bbac328..d5b86ebe5502bfdf2ec7381db8185c2a9407b90f 100644 (file)
@@ -93,7 +93,7 @@ _e_plane_surface_unset(E_Plane *plane)
    tdm_error error;
 
    if (plane_trace_debug)
-       ELOGF("E_PLANE", "Unset  Plane(%p)", NULL, NULL, plane);
+       ELOGF("E_PLANE", "Unset   Plane(%p)", NULL, NULL, plane);
 
    error = tdm_layer_unset_buffer(tlayer);
    if (error != TDM_ERROR_NONE)
@@ -269,7 +269,7 @@ _e_plane_surface_set(E_Plane *plane, tbm_surface_h tsurface)
 
    if (plane_trace_debug)
      {
-        ELOGF("E_PLANE", "Set  Plane(%p)  tsurface(%p) (%dx%d,[%d,%d,%d,%d]=>[%d,%d,%d,%d])",
+        ELOGF("E_PLANE", "Set     Plane(%p)     tsurface(%p) (%dx%d,[%d,%d,%d,%d]=>[%d,%d,%d,%d])",
               NULL, NULL, plane, tsurface,
               plane->info.src_config.size.h, plane->info.src_config.size.h,
               plane->info.src_config.pos.x, plane->info.src_config.pos.y,
@@ -736,7 +736,7 @@ e_plane_fetch(E_Plane *plane)
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(plane, EINA_FALSE);
 
-   if (plane->pending_commit_data)
+   if (plane->pending_commit)
       return EINA_FALSE;
 
    if (plane->is_fb && !plane->ec)
@@ -825,6 +825,68 @@ e_plane_unfetch(E_Plane *plane)
      }
 }
 
+static void
+_e_plane_vblank_handler(tdm_output *output, unsigned int sequence,
+                                  unsigned int tv_sec, unsigned int tv_usec,
+                                  void *user_data)
+{
+   E_Plane *plane = (E_Plane *)user_data;
+
+   EINA_SAFETY_ON_NULL_RETURN(plane);
+
+   plane->pending_commit = EINA_FALSE;
+}
+
+static void
+_e_plane_commit_hanler(tdm_layer *layer, unsigned int sequence,
+                                  unsigned int tv_sec, unsigned int tv_usec,
+                                  void *user_data)
+{
+   E_Plane_Commit_Data *data = (E_Plane_Commit_Data *)user_data;
+
+   EINA_SAFETY_ON_NULL_RETURN(data);
+
+   TRACE_DS_ASYNC_END((unsigned int)layer, [PLANE:COMMIT~HANDLER]);
+
+   e_plane_commit_data_release(data);
+}
+
+EINTERN Eina_Bool
+e_plane_commit(E_Plane *plane)
+{
+   E_Plane_Commit_Data *data = NULL;
+   tdm_error error = TDM_ERROR_NONE;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(plane, EINA_FALSE);
+
+   data = e_plane_commit_data_aquire(plane);
+
+   if (!data) return EINA_TRUE;
+
+   TRACE_DS_ASYNC_BEGIN((unsigned int)plane->tlayer, [PLANE:COMMIT~HANDLER]);
+
+   if (plane_trace_debug)
+     ELOGF("E_PLANE", "Commit  Plane(%p)     tsurface(%p) tqueue(%p) data(%p)",
+           NULL, NULL, plane, data->tsurface, plane->renderer ? plane->renderer->tqueue : NULL, data);
+
+   error = tdm_layer_commit(plane->tlayer, _e_plane_commit_hanler, data);
+   if (error != TDM_ERROR_NONE)
+     {
+        ERR("fail to tdm_layer_commit plane:%p, zpos:%d", plane, plane->zpos);
+        e_plane_commit_data_release(data);
+        return EINA_FALSE;
+     }
+
+   error = tdm_output_wait_vblank(plane->output->toutput, 1, 0, _e_plane_vblank_handler, (void *)plane);
+   if (error != TDM_ERROR_NONE)
+     {
+        ERR("fail to tdm_output_wait_vblank plane:%p, zpos:%d", plane, plane->zpos);
+        return EINA_FALSE;
+     }
+
+   return EINA_TRUE;
+}
+
 EINTERN E_Plane_Commit_Data *
 e_plane_commit_data_aquire(E_Plane *plane)
 {
@@ -838,7 +900,7 @@ e_plane_commit_data_aquire(E_Plane *plane)
         data->plane = plane;
         data->tsurface = NULL;
         data->ec = NULL;
-        plane->pending_commit_data = data;
+        plane->pending_commit = EINA_TRUE;
         plane->need_to_unset_commit = EINA_FALSE;
 
         return data;
@@ -860,7 +922,7 @@ e_plane_commit_data_aquire(E_Plane *plane)
 
         /* set the update_exist to be false */
         e_plane_renderer_update_exist_set(plane->renderer, EINA_FALSE);
-        plane->pending_commit_data = data;
+        plane->pending_commit = EINA_TRUE;
 
         return data;
      }
@@ -877,7 +939,7 @@ e_plane_commit_data_aquire(E_Plane *plane)
 
              /* set the update_exist to be false */
              e_plane_renderer_update_exist_set(plane->renderer, EINA_FALSE);
-             plane->pending_commit_data = data;
+             plane->pending_commit = EINA_TRUE;
 
              /* send frame event enlightenment dosen't send frame evnet in nocomp */
              e_pixmap_image_clear(plane->ec->pixmap, 1);
@@ -906,7 +968,6 @@ e_plane_commit_data_release(E_Plane_Commit_Data *data)
 
    if (!tsurface)
      {
-        plane->pending_commit_data = NULL;
         e_comp_wl_buffer_reference(&plane->displaying_buffer_ref, NULL);
         if (plane->displaying_buffer_tsurface)
           {
@@ -1015,7 +1076,6 @@ e_plane_commit_data_release(E_Plane_Commit_Data *data)
         e_comp_wl_buffer_reference(&data->buffer_ref, NULL);
      }
 
-   plane->pending_commit_data = NULL;
    tbm_surface_internal_unref(tsurface);
    free(data);
 }
index b72419e31ea354c42e4c603f301b214d5ab3f0c3..5deec6380de5c6d0235226b6b3104ad40f0a5099 100644 (file)
@@ -64,7 +64,7 @@ struct _E_Plane
    E_Output             *output;
 
    unsigned int          buffer_flags;
-   E_Plane_Commit_Data  *pending_commit_data;
+   Eina_Bool             pending_commit;
    Eina_Bool             need_to_unset_commit;
 
    /* true if plane's ec is set or unset.
@@ -103,6 +103,7 @@ EINTERN Eina_Bool            e_plane_is_reserved(E_Plane *plane);
 EINTERN void                 e_plane_reserved_set(E_Plane *plane, Eina_Bool set);
 EINTERN void                 e_plane_hwc_trace_debug(Eina_Bool onoff);
 EINTERN Eina_Bool            e_plane_render(E_Plane *plane);
+EINTERN Eina_Bool            e_plane_commit(E_Plane *plane);
 
 E_API Eina_Bool              e_plane_type_set(E_Plane *plane, E_Plane_Type type);
 E_API E_Plane_Type           e_plane_type_get(E_Plane *plane);
index 98412e9bfecd2b64c20d38568ca0dec83f18c875..4924ed5c0e1e617ea9d244bd4ec317f81455e9ea 100644 (file)
@@ -1471,7 +1471,7 @@ e_plane_renderer_surface_queue_release(E_Plane_Renderer *renderer, tbm_surface_h
      {
         E_Client *ec = renderer->ec;
         if (ec)
-          ELOGF("E_PLANE_RENDERER", "Release Renderer(%p)     wl_buffer(%p) tsurface(%p) tqueue(%p) wl_buffer_ref(%p)",
+          ELOGF("E_PLANE_RENDERER", "Release Renderer(%p)  wl_buffer(%p) tsurface(%p) tqueue(%p) wl_buffer_ref(%p)",
                 ec->pixmap, ec, renderer, _get_wl_buffer(ec), tsurface, renderer->tqueue, _get_wl_buffer_ref(ec));
         else
           ELOGF("E_PLANE_RENDERER", "Release Renderer(%p)  tsurface(%p) tqueue(%p)",