Implementation of TDM_HWC
[platform/adaptation/nexell/libtdm-nexell.git] / src / tdm_nexell.c
index a38e294..23c95d3 100644 (file)
@@ -218,6 +218,7 @@ tdm_nexell_deinit(tdm_backend_data *bdata)
 #endif
 
        tdm_nexell_display_destroy_output_list(nexell_data);
+       tdm_nexell_data_destroy_buffer_list(nexell_data);
 
        if (nexell_data->plane_res)
                drmModeFreePlaneResources(nexell_data->plane_res);
@@ -238,10 +239,19 @@ tdm_nexell_init(tdm_display *dpy, tdm_error *error)
        tdm_func_display nexell_func_display;
        tdm_func_output nexell_func_output;
        tdm_func_layer nexell_func_layer;
+       tdm_func_hwc nexell_func_hwc;
+       tdm_func_hwc_window nexell_func_hwc_window;
 #ifdef ENABLE_PP
        tdm_func_pp nexell_func_pp;
 #endif
        tdm_error ret;
+       char *str;
+
+#define TDM_CHANGE_DEBUG_LOGLEVEL
+#ifdef TDM_CHANGE_DEBUG_LOGLEVEL
+       // show DBG log level
+       tdm_log_set_debug_level(4);
+#endif
 
        if (!dpy) {
                TDM_ERR("display is null");
@@ -265,6 +275,15 @@ tdm_nexell_init(tdm_display *dpy, tdm_error *error)
                return NULL;
        }
 
+       str = getenv("TDM_HWC");
+       if (str) {
+               char *end;
+               nexell_data->hwc_mode = strtol(str, &end, 10);;
+       }
+
+       /* enable the tdm_hwc */
+       nexell_data->hwc_mode = 1;
+
        LIST_INITHEAD(&nexell_data->output_list);
        LIST_INITHEAD(&nexell_data->buffer_list);
 
@@ -289,10 +308,47 @@ tdm_nexell_init(tdm_display *dpy, tdm_error *error)
        nexell_func_output.output_get_dpms = nexell_output_get_dpms;
        nexell_func_output.output_set_mode = nexell_output_set_mode;
        nexell_func_output.output_get_mode = nexell_output_get_mode;
+       nexell_func_output.output_set_mirror = NULL;
+       nexell_func_output.output_unset_mirror = NULL;
 #ifdef HAVE_UDEV
        nexell_func_output.output_set_status_handler = nexell_output_set_status_handler;
 #endif
 
+       if (nexell_data->hwc_mode) {
+               nexell_func_output.output_get_hwc = nexell_output_get_hwc;
+
+               memset(&nexell_func_hwc, 0, sizeof(nexell_func_hwc));
+               nexell_func_hwc.hwc_create_window = nexell_hwc_create_window;
+               nexell_func_hwc.hwc_get_video_supported_formats = nexell_hwc_get_video_supported_formats;
+               nexell_func_hwc.hwc_get_video_available_properties = NULL;
+               nexell_func_hwc.hwc_get_capabilities = nexell_hwc_get_capabilities;
+               nexell_func_hwc.hwc_get_available_properties = nexell_hwc_get_available_properties;
+               nexell_func_hwc.hwc_get_client_target_buffer_queue = nexell_hwc_get_client_target_buffer_queue;
+               nexell_func_hwc.hwc_set_client_target_buffer = nexell_hwc_set_client_target_buffer;
+               nexell_func_hwc.hwc_set_client_target_acquire_fence = NULL;
+               nexell_func_hwc.hwc_validate = nexell_hwc_validate;
+               nexell_func_hwc.hwc_get_changed_composition_types = nexell_hwc_get_changed_composition_types;
+               nexell_func_hwc.hwc_accept_validation = nexell_hwc_accept_validation;
+               nexell_func_hwc.hwc_commit = nexell_hwc_commit;
+               nexell_func_hwc.hwc_set_commit_handler = nexell_hwc_set_commit_handler;
+               nexell_func_hwc.hwc_get_commit_fence = NULL;
+               nexell_func_hwc.hwc_get_release_fences = NULL;
+
+               memset(&nexell_func_hwc_window, 0, sizeof(nexell_func_hwc_window));
+               nexell_func_hwc_window.hwc_window_destroy = nexell_hwc_window_destroy;
+               nexell_func_hwc_window.hwc_window_acquire_buffer_queue = nexell_hwc_window_acquire_buffer_queue;
+               nexell_func_hwc_window.hwc_window_release_buffer_queue = nexell_hwc_window_release_buffer_queue;
+               nexell_func_hwc_window.hwc_window_set_composition_type = nexell_hwc_window_set_composition_type;
+               nexell_func_hwc_window.hwc_window_set_buffer_damage = nexell_hwc_window_set_buffer_damage;
+               nexell_func_hwc_window.hwc_window_set_info = nexell_hwc_window_set_info;
+               nexell_func_hwc_window.hwc_window_set_buffer = nexell_hwc_window_set_buffer;
+               nexell_func_hwc_window.hwc_window_set_property = nexell_hwc_window_set_property;
+               nexell_func_hwc_window.hwc_window_get_property = nexell_hwc_window_get_property;
+               nexell_func_hwc_window.hwc_window_get_constraints = nexell_hwc_window_get_constraints;
+               nexell_func_hwc_window.hwc_window_set_name = nexell_hwc_window_set_name;
+               nexell_func_hwc_window.hwc_window_set_cursor_image = nexell_hwc_window_set_cursor_image;
+       }
+
        memset(&nexell_func_layer, 0, sizeof(nexell_func_layer));
        nexell_func_layer.layer_get_capability = nexell_layer_get_capability;
        nexell_func_layer.layer_set_property = nexell_layer_set_property;
@@ -319,6 +375,16 @@ tdm_nexell_init(tdm_display *dpy, tdm_error *error)
        if (ret != TDM_ERROR_NONE)
                goto failed;
 
+       if (nexell_data->hwc_mode) {
+               ret = tdm_backend_register_func_hwc(dpy, &nexell_func_hwc);
+               if (ret != TDM_ERROR_NONE)
+                       goto failed;
+
+               ret = tdm_backend_register_func_hwc_window(dpy, &nexell_func_hwc_window);
+               if (ret != TDM_ERROR_NONE)
+                       goto failed;
+       }
+
        ret = tdm_backend_register_func_layer(dpy, &nexell_func_layer);
        if (ret != TDM_ERROR_NONE)
                goto failed;
@@ -412,7 +478,7 @@ failed:
 tdm_backend_module tdm_backend_module_data = {
        "drm",
        "Samsung",
-       TDM_BACKEND_SET_ABI_VERSION(1, 1),
+       TDM_BACKEND_SET_ABI_VERSION(2, 0),
        tdm_nexell_init,
        tdm_nexell_deinit
 };