e_video_hwc: enhance pp restriction 02/225502/2
authorJunkyeong Kim <jk0430.kim@samsung.com>
Thu, 20 Feb 2020 09:08:11 +0000 (18:08 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Mon, 24 Feb 2020 00:38:28 +0000 (09:38 +0900)
check pp minw, minh values also.
check pp preferred vertical align if it is supported.(not supported case this value is -1)

Change-Id: If17b0298e7e536dda6105c45dc3b48b91a68995a
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
src/bin/video/iface/e_video_hwc.c
src/bin/video/iface/e_video_hwc.h

index dbaeacd9ce4e76816d607a9f34e881675ab90d37..a9e8965e2bb09d6947eaad9debb1f3b967e90bdd 100644 (file)
@@ -282,6 +282,7 @@ _e_video_hwc_pp_create(tdm_display *display, void *user_data)
                                      &pp->minw, &pp->minh,
                                      &pp->maxw, &pp->maxh,
                                      &pp->align);
+   tdm_display_get_pp_preferred_align_vertical(display, &pp->align_vertical);
 
    err = tdm_display_get_pp_capabilities(display, &caps);
    if (err == TDM_ERROR_NONE)
@@ -403,18 +404,79 @@ _e_video_hwc_pp_buffer_cb_free(E_Comp_Wl_Video_Buf *vbuf, void *data)
    evh->pp_buffer_list = eina_list_remove(evh->pp_buffer_list, vbuf);
 }
 
+static int
+_e_video_hwc_pp_gcd_get(int x, int y)
+{
+   int temp = 0;
+
+   while (y > 0)
+     {
+        temp = y;
+        y = x % y;
+        x = temp;
+     }
+
+   return x;
+}
+
+static void
+_e_video_hwc_pp_aligned_value_get(E_Video_Hwc *evh, int *aligned_width, int *aligned_height)
+{
+   int width_align = 0;
+
+   if (evh->pp->minw != -1)
+     {
+        if (evh->pp->minw > *aligned_width)
+          *aligned_width = evh->pp->minw;
+     }
+
+   if (evh->pp->minh != -1)
+     {
+        if (evh->pp->minh > *aligned_height)
+          *aligned_height = evh->pp->minh;
+     }
+
+   if (evh->pp->align > 0)
+     {
+        if (evh->output_align != -1)
+          {
+             if (evh->output_align >= evh->pp->align)
+               width_align = _e_video_hwc_pp_gcd_get(evh->output_align, evh->pp->align);
+             else
+               width_align = _e_video_hwc_pp_gcd_get(evh->pp->align, evh->output_align);
+
+             width_align = evh->output_align * evh->pp->align / width_align;
+          }
+        else
+          {
+             width_align = evh->pp->align;
+          }
+     }
+   else
+     {
+        if (evh->output_align != -1)
+          width_align = evh->output_align;
+        else
+          width_align = *aligned_width;
+     }
+
+   *aligned_width = ROUNDUP(*aligned_width, width_align);
+
+   if (evh->pp->align_vertical != -1)
+     *aligned_height = ROUNDUP(*aligned_height, evh->pp->align_vertical);
+
+}
+
 static E_Comp_Wl_Video_Buf *
 _e_video_hwc_pp_buffer_get(E_Video_Hwc *evh, int width, int height)
 {
    E_Comp_Wl_Video_Buf *vbuf;
    Eina_List *l;
    int i = 0;
-   int aligned_width;
+   int aligned_width = width;
+   int aligned_height = height;
 
-   if (evh->output_align != -1)
-     aligned_width = ROUNDUP(width, evh->output_align);
-   else
-     aligned_width = width;
+   _e_video_hwc_pp_aligned_value_get(evh, &aligned_width, &aligned_height);
 
    if (evh->pp_buffer_list)
      {
@@ -422,13 +484,13 @@ _e_video_hwc_pp_buffer_get(E_Video_Hwc *evh, int width, int height)
         EINA_SAFETY_ON_NULL_RETURN_VAL(vbuf, NULL);
 
         /* if we need bigger pp_buffers, destroy all pp_buffers and create */
-        if (aligned_width > vbuf->width_from_pitch || height != vbuf->height)
+        if (aligned_width > vbuf->width_from_pitch || aligned_height != vbuf->height)
           {
              Eina_List *ll;
 
              VIN("pp buffer changed: %dx%d => %dx%d", evh->ec,
                  vbuf->width_from_pitch, vbuf->height,
-                 aligned_width, height);
+                 aligned_width, aligned_height);
 
              EINA_LIST_FOREACH_SAFE(evh->pp_buffer_list, l, ll, vbuf)
                {
@@ -448,7 +510,7 @@ _e_video_hwc_pp_buffer_get(E_Video_Hwc *evh, int width, int height)
      {
         for (i = 0; i < BUFFER_MAX_COUNT; i++)
           {
-             vbuf = e_comp_wl_video_buffer_alloc(aligned_width, height, evh->pp_tbmfmt, EINA_TRUE);
+             vbuf = e_comp_wl_video_buffer_alloc(aligned_width, aligned_height, evh->pp_tbmfmt, EINA_TRUE);
              EINA_SAFETY_ON_NULL_RETURN_VAL(vbuf, NULL);
 
              e_comp_wl_video_buffer_free_func_add(vbuf, _e_video_hwc_pp_buffer_cb_free, evh);
@@ -457,7 +519,7 @@ _e_video_hwc_pp_buffer_get(E_Video_Hwc *evh, int width, int height)
           }
 
         VIN("pp buffer created: %dx%d, %c%c%c%c", evh->ec,
-            vbuf->width_from_pitch, height, FOURCC_STR(evh->pp_tbmfmt));
+            vbuf->width_from_pitch, aligned_height, FOURCC_STR(evh->pp_tbmfmt));
 
         evh->next_buffer = evh->pp_buffer_list;
      }
index a04cdc0f46e90872755376f9fbbbf7c375c46974..898400aa65c6578f13232646e02aaba1a5005d8a 100644 (file)
@@ -35,6 +35,7 @@ struct _E_Video_Hwc_PP
 
    int minw, minh, maxw, maxh;
    int align;
+   int align_vertical;
 
    Eina_Bool scanout;
 };