tdm: add pepper_tdm_output_get_display_buffer_queue function 79/263879/1
authorSooChan Lim <sc1.lim@samsung.com>
Mon, 13 Sep 2021 05:22:39 +0000 (14:22 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Mon, 13 Sep 2021 06:18:46 +0000 (15:18 +0900)
This funtion provides tbm_surface_queue_h from pepper_tdm_output.

Change-Id: I40fa58f6cec73d5af9127f52627eacc6efcd1772

src/lib/tdm/pepper-tdm.h
src/lib/tdm/tdm-output.c

index d88fb91..90b2698 100644 (file)
@@ -30,6 +30,7 @@
 #define PEPPER_TDM_H
 
 #include <pepper.h>
+#include <tbm_surface_queue.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -56,6 +57,8 @@ pepper_tdm_output_get_pepper_output(pepper_tdm_output_t *output);
 PEPPER_API pepper_bool_t
 pepper_tdm_output_get_pixel_size(pepper_tdm_output_t *output, uint32_t *w, uint32_t *h);
 
+PEPPER_API tbm_surface_queue_h
+pepper_tdm_output_get_display_buffer_queue(pepper_tdm_output_t *output);
 
 #ifdef __cplusplus
 }
index 69fc489..8011fa3 100644 (file)
@@ -922,4 +922,53 @@ pepper_tdm_output_get_pixel_size(pepper_tdm_output_t *output,
        return PEPPER_TRUE;
 }
 
+static void
+__tdm_output_destroy_display_buffer_queue(pepper_tdm_output_t *output)
+{
+       if (!output->tbm_surface_queue)
+               return;
+
+       if (!output->hwc)
+               tbm_surface_queue_destroy(output->tbm_surface_queue);
+
+       output->tbm_surface_queue = NULL;
+}
+
+PEPPER_API tbm_surface_queue_h
+pepper_tdm_output_get_display_buffer_queue(pepper_tdm_output_t *output)
+{
+       pepper_tdm_hwc_t *hwc;
+       tbm_surface_queue_h tsurface_queue;
+       tdm_error err = TDM_ERROR_NONE;
+       pepper_bool_t ret = PEPPER_FALSE;
+       unsigned int w, h;
+
+       if (output->tbm_surface_queue)
+               return output->tbm_surface_queue;
+
+       ret = pepper_tdm_output_get_pixel_size(output, &w, &h);
+       PEPPER_CHECK(ret == PEPPER_TRUE, return NULL,
+                               "pepper_tdm_output_get_pixel_size() failed.\n");
+
+       if (output->hwc) {
+               hwc = output->hwc;
+               tsurface_queue = tdm_hwc_get_client_target_buffer_queue(hwc->thwc, &err);
+               PEPPER_CHECK(tsurface_queue, goto error,
+                                       "tdm_hwc_get_client_target_buffer_queue() failed.\n");
+       } else {
+               tsurface_queue = tbm_surface_queue_create(3, w, h,
+                                                                                               TBM_FORMAT_XBGR8888, TBM_BO_SCANOUT);
+               PEPPER_CHECK(tsurface_queue, goto error,
+                                               "tbm_surface_queue_create() failed.\n");
+       }
+
+       output->tbm_surface_queue = tsurface_queue;
+
+       return tsurface_queue;
+
+error:
+       __tdm_output_destroy_display_buffer_queue(output);
+
+       return NULL;
+}