add timeout logs (1000ms)
[platform/core/uifw/libtdm.git] / src / tdm_hwc_window.c
index 0fffd7d..40820ce 100644 (file)
 #include "config.h"
 #endif
 
-#include "tdm.h"
-#include "tdm_backend.h"
 #include "tdm_private.h"
-#include "tdm_helper.h"
 
 #define COUNT_MAX   10
 
@@ -87,11 +84,13 @@ tdm_hwc_window_get_tbm_buffer_queue(tdm_hwc_window *hwc_window, tdm_error *error
        func_hwc_window = &private_display->func_hwc_window;
 
        if (!func_hwc_window->hwc_window_get_tbm_buffer_queue) {
+               /* LCOV_EXCL_START */
                _pthread_mutex_unlock(&private_display->lock);
                TDM_ERR("not implemented!!");
                if (error)
                        *error = TDM_ERROR_NOT_IMPLEMENTED;
                return NULL;
+               /* LCOV_EXCL_STOP */
        }
 
        queue = func_hwc_window->hwc_window_get_tbm_buffer_queue(private_hwc_window->hwc_window_backend, error);
@@ -102,7 +101,7 @@ tdm_hwc_window_get_tbm_buffer_queue(tdm_hwc_window *hwc_window, tdm_error *error
 }
 
 EXTERN tdm_error
-tdm_hwc_window_set_zpos(tdm_hwc_window *hwc_window, uint32_t zpos)
+tdm_hwc_window_set_zpos(tdm_hwc_window *hwc_window, int32_t zpos)
 {
        tdm_func_hwc_window *func_hwc_window = NULL;
 
@@ -113,9 +112,11 @@ tdm_hwc_window_set_zpos(tdm_hwc_window *hwc_window, uint32_t zpos)
        func_hwc_window = &private_display->func_hwc_window;
 
        if (!func_hwc_window->hwc_window_set_zpos) {
+               /* LCOV_EXCL_START */
                _pthread_mutex_unlock(&private_display->lock);
                TDM_ERR("not implemented!!");
                return TDM_ERROR_NOT_IMPLEMENTED;
+               /* LCOV_EXCL_STOP */
        }
 
        ret = func_hwc_window->hwc_window_set_zpos(private_hwc_window->hwc_window_backend, zpos);
@@ -134,15 +135,19 @@ tdm_hwc_window_set_composition_type(tdm_hwc_window *hwc_window,
        tdm_func_hwc_window *func_hwc_window = NULL;
 
        HWC_WINDOW_FUNC_ENTRY();
+       TDM_RETURN_VAL_IF_FAIL(composition_type >= TDM_COMPOSITION_NONE, TDM_ERROR_INVALID_PARAMETER);
+       TDM_RETURN_VAL_IF_FAIL(composition_type <= TDM_COMPOSITION_VIDEO, TDM_ERROR_INVALID_PARAMETER);
 
        _pthread_mutex_lock(&private_display->lock);
 
        func_hwc_window = &private_display->func_hwc_window;
 
        if (!func_hwc_window->hwc_window_set_composition_type) {
+               /* LCOV_EXCL_START */
                _pthread_mutex_unlock(&private_display->lock);
                TDM_ERR("not implemented!!");
                return TDM_ERROR_NOT_IMPLEMENTED;
+               /* LCOV_EXCL_STOP */
        }
 
        ret = func_hwc_window->hwc_window_set_composition_type(private_hwc_window->hwc_window_backend, composition_type);
@@ -158,15 +163,19 @@ tdm_hwc_window_set_buffer_damage(tdm_hwc_window *hwc_window, tdm_hwc_region dama
        tdm_func_hwc_window *func_hwc_window = NULL;
 
        HWC_WINDOW_FUNC_ENTRY();
+       if (damage.num_rects > 0)
+               TDM_RETURN_VAL_IF_FAIL(damage.rects != NULL, TDM_ERROR_INVALID_PARAMETER);
 
        _pthread_mutex_lock(&private_display->lock);
 
        func_hwc_window = &private_display->func_hwc_window;
 
        if (!func_hwc_window->hwc_window_set_buffer_damage) {
+               /* LCOV_EXCL_START */
                _pthread_mutex_unlock(&private_display->lock);
                TDM_ERR("not implemented!!");
                return TDM_ERROR_NOT_IMPLEMENTED;
+               /* LCOV_EXCL_STOP */
        }
 
        ret = func_hwc_window->hwc_window_set_buffer_damage(private_hwc_window->hwc_window_backend, damage);
@@ -192,9 +201,11 @@ tdm_hwc_window_set_info(tdm_hwc_window *hwc_window, tdm_hwc_window_info *info)
        func_hwc_window = &private_display->func_hwc_window;
 
        if (!func_hwc_window->hwc_window_set_info) {
+               /* LCOV_EXCL_START */
                _pthread_mutex_unlock(&private_display->lock);
                TDM_ERR("not implemented!!");
                return TDM_ERROR_NOT_IMPLEMENTED;
+               /* LCOV_EXCL_STOP */
        }
 
        if (info->src_config.format)
@@ -218,6 +229,7 @@ tdm_hwc_window_set_info(tdm_hwc_window *hwc_window, tdm_hwc_window_info *info)
        return ret;
 }
 
+/* LCOV_EXCL_START */
 static void
 _tdm_window_dump_buffer(tdm_hwc_window *hwc_window, tbm_surface_h buffer)
 {
@@ -225,7 +237,7 @@ _tdm_window_dump_buffer(tdm_hwc_window *hwc_window, tbm_surface_h buffer)
        tdm_private_output *private_output = private_window->private_output;
        unsigned int pipe;
        uint32_t zpos;
-       char fname[PATH_MAX];
+       char fname[TDM_PATH_LEN];
 
        pipe = private_output->pipe;
        zpos = private_window->zpos;
@@ -237,6 +249,7 @@ _tdm_window_dump_buffer(tdm_hwc_window *hwc_window, tbm_surface_h buffer)
 
        return;
 }
+/* LCOV_EXCL_STOP */
 
 EXTERN tdm_error
 tdm_hwc_window_set_buffer(tdm_hwc_window *hwc_window, tbm_surface_h buffer)
@@ -248,24 +261,30 @@ tdm_hwc_window_set_buffer(tdm_hwc_window *hwc_window, tbm_surface_h buffer)
        _pthread_mutex_lock(&private_display->lock);
 
        if ((tdm_debug_dump & TDM_DUMP_FLAG_WINDOW) && buffer) {
+               /* LCOV_EXCL_START */
                char str[TDM_PATH_LEN];
                static int i;
                snprintf(str, TDM_PATH_LEN, "window_%d_%d_%03d",
                                 private_output->index, private_hwc_window->zpos, i++);
                tdm_helper_dump_buffer_str(buffer, tdm_debug_dump_dir, str);
+               /* LCOV_EXCL_STOP */
        }
 
        func_hwc_window = &private_display->func_hwc_window;
 
        if (!func_hwc_window->hwc_window_set_buffer) {
+               /* LCOV_EXCL_START */
                _pthread_mutex_unlock(&private_display->lock);
                TDM_ERR("not implemented!!");
                return TDM_ERROR_NOT_IMPLEMENTED;
+               /* LCOV_EXCL_STOP */
        }
 
        /* dump buffer */
+       /* LCOV_EXCL_START */
        if (tdm_dump_enable && buffer)
                _tdm_window_dump_buffer(hwc_window, buffer);
+       /* LCOV_EXCL_STOP */
 
        ret = func_hwc_window->hwc_window_set_buffer(private_hwc_window->hwc_window_backend, buffer);
 
@@ -275,7 +294,7 @@ tdm_hwc_window_set_buffer(tdm_hwc_window *hwc_window, tbm_surface_h buffer)
 }
 
 INTERN tdm_hwc_window *
-tdm_hwc_window_create_internal(tdm_private_output *private_output,
+tdm_hwc_window_create_internal(tdm_private_output *private_output, int is_video,
                                                                   tdm_error *error)
 {
        tdm_private_display *private_display = private_output->private_display;
@@ -286,27 +305,49 @@ tdm_hwc_window_create_internal(tdm_private_output *private_output,
 
        TDM_RETURN_VAL_IF_FAIL(TDM_MUTEX_IS_LOCKED(), NULL);
 
-       if (!func_output->output_hwc_create_window) {
-               if (error)
-                       *error = TDM_ERROR_BAD_MODULE;
-               return NULL;
-       }
+       if (!is_video) {
+               if (!func_output->output_hwc_create_window) {
+                       /* LCOV_EXCL_START */
+                       if (error)
+                               *error = TDM_ERROR_BAD_MODULE;
+                       return NULL;
+                       /* LCOV_EXCL_STOP */
+               }
 
-       hwc_window_backend = func_output->output_hwc_create_window(
+               hwc_window_backend = func_output->output_hwc_create_window(
                                                 private_output->output_backend, &ret);
-       if (ret != TDM_ERROR_NONE) {
-               if (error)
-                       *error = ret;
-               return NULL;
+               if (ret != TDM_ERROR_NONE) {
+                       if (error)
+                               *error = ret;
+                       return NULL;
+               }
+       } else {
+               if (!func_output->output_hwc_create_video_window) {
+                       /* LCOV_EXCL_START */
+                       if (error)
+                               *error = TDM_ERROR_NOT_IMPLEMENTED;
+                       return NULL;
+                       /* LCOV_EXCL_STOP */
+               }
+
+               hwc_window_backend = func_output->output_hwc_create_video_window(
+                                                private_output->output_backend, &ret);
+               if (ret != TDM_ERROR_NONE) {
+                       if (error)
+                               *error = ret;
+                       return NULL;
+               }
        }
 
-       private_hwc_window = calloc(1, sizeof(tdm_private_capture));
+       private_hwc_window = calloc(1, sizeof(tdm_private_hwc_window));
        if (!private_hwc_window) {
+               /* LCOV_EXCL_START */
                TDM_ERR("failed: alloc memory");
                func_output->output_hwc_destroy_window(private_output->output_backend, hwc_window_backend);
                if (error)
                        *error = TDM_ERROR_OUT_OF_MEMORY;
                return NULL;
+               /* LCOV_EXCL_STOP */
        }
 
        LIST_ADD(&private_hwc_window->link, &private_output->hwc_window_list);
@@ -359,9 +400,11 @@ tdm_hwc_window_set_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flags)
        func_hwc_window = &private_display->func_hwc_window;
 
        if (!func_hwc_window->hwc_window_set_flags) {
+               /* LCOV_EXCL_START */
                _pthread_mutex_unlock(&private_display->lock);
                TDM_ERR("not implemented!!");
                return TDM_ERROR_NOT_IMPLEMENTED;
+               /* LCOV_EXCL_STOP */
        }
 
        ret = func_hwc_window->hwc_window_set_flags(private_hwc_window->hwc_window_backend, flags);
@@ -383,9 +426,11 @@ tdm_hwc_window_unset_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flags
        func_hwc_window = &private_display->func_hwc_window;
 
        if (!func_hwc_window->hwc_window_unset_flags) {
+               /* LCOV_EXCL_START */
                _pthread_mutex_unlock(&private_display->lock);
                TDM_ERR("not implemented!!");
                return TDM_ERROR_NOT_IMPLEMENTED;
+               /* LCOV_EXCL_STOP */
        }
 
        ret = func_hwc_window->hwc_window_unset_flags(private_hwc_window->hwc_window_backend, flags);
@@ -410,9 +455,11 @@ tdm_hwc_window_video_get_capability(tdm_hwc_window *hwc_window,
        func_hwc_window = &private_display->func_hwc_window;
 
        if (!func_hwc_window->hwc_window_video_get_capability) {
+               /* LCOV_EXCL_START */
                _pthread_mutex_unlock(&private_display->lock);
                TDM_ERR("not implemented!!");
                return TDM_ERROR_NOT_IMPLEMENTED;
+               /* LCOV_EXCL_STOP */
        }
 
        ret = func_hwc_window->hwc_window_video_get_capability(private_hwc_window->hwc_window_backend,
@@ -424,29 +471,88 @@ tdm_hwc_window_video_get_capability(tdm_hwc_window *hwc_window,
 }
 
 EXTERN tdm_error
-tdm_hwc_window_video_get_supported_format(tdm_hwc_window *hwc_window,
-                                                                                 const tbm_format **formats,
-                                                                                 int *count)
+tdm_hwc_window_video_get_available_properties(tdm_hwc_window *hwc_window,
+                                                                                         const tdm_prop **props, int *count)
 {
        tdm_func_hwc_window *func_hwc_window = NULL;
 
        HWC_WINDOW_FUNC_ENTRY();
 
-       TDM_RETURN_VAL_IF_FAIL(formats != NULL, TDM_ERROR_INVALID_PARAMETER);
+       TDM_RETURN_VAL_IF_FAIL(props != NULL, TDM_ERROR_INVALID_PARAMETER);
        TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
 
        _pthread_mutex_lock(&private_display->lock);
 
        func_hwc_window = &private_display->func_hwc_window;
 
-       if (!func_hwc_window->hwc_window_video_get_supported_format) {
+       if (!func_hwc_window->hwc_window_video_get_available_properties) {
+               /* LCOV_EXCL_START */
+               _pthread_mutex_unlock(&private_display->lock);
+               TDM_ERR("not implemented!!");
+               return TDM_ERROR_NOT_IMPLEMENTED;
+               /* LCOV_EXCL_STOP */
+       }
+
+       ret = func_hwc_window->hwc_window_video_get_available_properties(private_hwc_window->hwc_window_backend,
+                                                                                                                                        props, count);
+
+       _pthread_mutex_unlock(&private_display->lock);
+
+       return ret;
+}
+
+EXTERN tdm_error
+tdm_hwc_window_video_get_property(tdm_hwc_window *hwc_window,
+                                                                       unsigned int id, tdm_value *value)
+{
+       tdm_func_hwc_window *func_hwc_window = NULL;
+
+       HWC_WINDOW_FUNC_ENTRY();
+
+       TDM_RETURN_VAL_IF_FAIL(value != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+       _pthread_mutex_lock(&private_display->lock);
+
+       func_hwc_window = &private_display->func_hwc_window;
+
+       if (!func_hwc_window->hwc_window_video_get_property) {
+               /* LCOV_EXCL_START */
+               _pthread_mutex_unlock(&private_display->lock);
+               TDM_ERR("not implemented!!");
+               return TDM_ERROR_NOT_IMPLEMENTED;
+               /* LCOV_EXCL_STOP */
+       }
+
+       ret = func_hwc_window->hwc_window_video_get_property(private_hwc_window->hwc_window_backend,
+                                                                                                                id, value);
+
+       _pthread_mutex_unlock(&private_display->lock);
+
+       return ret;
+}
+
+EXTERN tdm_error
+tdm_hwc_window_video_set_property(tdm_hwc_window *hwc_window,
+                                                                       unsigned int id, tdm_value value)
+{
+       tdm_func_hwc_window *func_hwc_window = NULL;
+
+       HWC_WINDOW_FUNC_ENTRY();
+
+       _pthread_mutex_lock(&private_display->lock);
+
+       func_hwc_window = &private_display->func_hwc_window;
+
+       if (!func_hwc_window->hwc_window_video_set_property) {
+               /* LCOV_EXCL_START */
                _pthread_mutex_unlock(&private_display->lock);
                TDM_ERR("not implemented!!");
                return TDM_ERROR_NOT_IMPLEMENTED;
+               /* LCOV_EXCL_STOP */
        }
 
-       ret = func_hwc_window->hwc_window_video_get_supported_format(private_hwc_window->hwc_window_backend,
-                                                                                                                                formats, count);
+       ret = func_hwc_window->hwc_window_video_set_property(private_hwc_window->hwc_window_backend,
+                                                                                                                id, value);
 
        _pthread_mutex_unlock(&private_display->lock);