implementation
[platform/core/uifw/libtdm.git] / src / tdm_private_types.h
index cc234c0..365ea7d 100644 (file)
@@ -9,7 +9,7 @@
  *          Taeheon Kim <th908.kim@samsung.com>,
  *          YoungJun Cho <yj44.cho@samsung.com>,
  *          SooChan Lim <sc1.lim@samsung.com>,
- *          Boram Park <sc1.lim@samsung.com>
+ *          Boram Park <boram1288.park@samsung.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the
@@ -60,10 +60,11 @@ enum {
        TDM_DEBUG_NONE,
        TDM_DEBUG_BUFFER    = (1 << 0),
        TDM_DEBUG_MUTEX     = (1 << 1),
-       TDM_DEBUG_THREAD    = (1 << 2),
-       TDM_DEBUG_SERVER    = (1 << 3),
-       TDM_DEBUG_VBLANK    = (1 << 4),
-       TDM_DEBUG_COMMIT    = (1 << 5),
+       TDM_DEBUG_EVENT     = (1 << 2),
+       TDM_DEBUG_THREAD    = (1 << 3),
+       TDM_DEBUG_SERVER    = (1 << 4),
+       TDM_DEBUG_VBLANK    = (1 << 5),
+       TDM_DEBUG_COMMIT    = (1 << 6),
 };
 
 enum {
@@ -95,42 +96,43 @@ typedef enum {
        TDM_COMMIT_TYPE_LAYER,
 } tdm_commit_type;
 
+typedef struct _tdm_private_module tdm_private_module;
 typedef struct _tdm_private_display tdm_private_display;
 typedef struct _tdm_private_output tdm_private_output;
 typedef struct _tdm_private_layer tdm_private_layer;
+typedef struct _tdm_private_hwc tdm_private_hwc;
 typedef struct _tdm_private_hwc_window tdm_private_hwc_window;
 typedef struct _tdm_private_pp tdm_private_pp;
 typedef struct _tdm_private_capture tdm_private_capture;
 typedef struct _tdm_private_loop tdm_private_loop;
 typedef struct _tdm_private_server tdm_private_server;
 typedef struct _tdm_private_thread tdm_private_thread;
-typedef struct _tdm_private_vblank_handler tdm_private_vblank_handler;
+typedef struct _tdm_private_output_create_handler tdm_private_output_create_handler;
+typedef struct _tdm_private_output_destroy_handler tdm_private_output_destroy_handler;
 typedef struct _tdm_private_output_change_handler tdm_private_output_change_handler;
 typedef struct _tdm_private_output_commit_handler tdm_private_output_commit_handler;
+typedef struct _tdm_private_output_vblank_handler tdm_private_output_vblank_handler;
 typedef struct _tdm_private_layer_commit_handler tdm_private_layer_commit_handler;
-typedef struct _tdm_private_hwc_window_commit_handler tdm_private_hwc_window_commit_handler;
-typedef struct _tdm_private_output_hwc_target_buffer_window_commit_handler tdm_private_output_hwc_target_buffer_commit_handler;
+typedef struct _tdm_private_hwc_commit_handler tdm_private_hwc_commit_handler;
 
 typedef struct _tdm_private_layer_buffer tdm_private_layer_buffer;
 
-struct _tdm_private_display {
-       pthread_mutex_t lock;
-       unsigned int init_count;
+struct _tdm_private_module {
+       struct list_head link;
+
+       tdm_private_display *private_display;
 
        /* backend module info */
        void *module;
        tdm_backend_module *module_data;
        tdm_backend_data *bdata;
 
-#ifdef INIT_BUFMGR
-       tbm_bufmgr bufmgr;
-#endif
-
        /* backend function */
        tdm_display_capability capabilities;
        tdm_func_display func_display;
        tdm_func_output func_output;
        tdm_func_layer func_layer;
+       tdm_func_hwc func_hwc;
        tdm_func_hwc_window func_hwc_window;
        tdm_func_pp func_pp;
        tdm_func_capture func_capture;
@@ -145,13 +147,33 @@ struct _tdm_private_display {
        struct list_head pp_list;
        struct list_head capture_list;
 
-       void **outputs_ptr;
+       /* backend output objects. allocated in backend. freed in frontend. ordered */
+       tdm_output **outputs;
+
+       int fd;
+       tdm_event_loop_source *event_source;
+};
+
+struct _tdm_private_display {
+       pthread_mutex_t lock;
+       unsigned int init_count;
+
+       double stamp;
+
+#ifdef INIT_BUFMGR
+       tbm_bufmgr bufmgr;
+#endif
+
+       struct list_head module_list;
+       tdm_private_module *dummy_module;
+       tdm_private_module *current_module;  //setted only when loading
+       tdm_private_module *pp_module;       //pp-support backend
+       tdm_private_module *capture_module;  //TODO: remove later
 
        /* for event handling */
        tdm_private_loop *private_loop;
 
-       /* output order */
-       tdm_output **outputs;
+       struct list_head output_create_handler_list;
 
        int print_fps;
 };
@@ -159,6 +181,8 @@ struct _tdm_private_display {
 struct _tdm_private_output {
        struct list_head link;
 
+       tdm_private_module *private_module;
+
        int index;
        double stamp;
 
@@ -178,7 +202,6 @@ struct _tdm_private_output {
        int regist_dpms_cb;
 
        struct list_head layer_list;
-       struct list_head hwc_window_list;
        struct list_head capture_list;
        struct list_head vblank_handler_list;
        struct list_head output_commit_handler_list;
@@ -190,23 +213,13 @@ struct _tdm_private_output {
        int layer_waiting_vblank;
 
        tdm_event_loop_source *vblank_timeout_timer;
+       unsigned int vblank_timeout_timer_expired;
 
-       /* seperate list for multi-thread*/
-       struct list_head change_handler_list_main;
-       struct list_head change_handler_list_sub;
+       struct list_head destroy_handler_list;
+       struct list_head change_handler_list;
 
        void **layers_ptr;
 
-       /* TODO: temp solution for handling DPMS things in sub-htread */
-       tdm_event_loop_source *dpms_changed_timer;
-
-       struct {
-               /* look at the tdm_output_set_need_revalidate_handler() declaration for the details */
-               tdm_output_need_validate_handler hndl;
-               int event_fd;
-               tdm_event_loop_source *event_source;
-       } need_validate;
-
        tdm_info_layer target_buffer_info; /* layer_info for the target_buffer */
 
        /* calling a output commit per a vblank */
@@ -218,11 +231,14 @@ struct _tdm_private_output {
 
        /* hwc */
        int need_set_target_info;
+       tdm_private_hwc *private_hwc;
 };
 
 struct _tdm_private_layer {
        struct list_head link;
 
+       tdm_private_module *private_module;
+
        int index;
 
        tdm_private_display *private_display;
@@ -255,25 +271,43 @@ struct _tdm_private_layer {
        unsigned int fps_count;
 };
 
-struct _tdm_private_hwc_window {
+struct _tdm_private_hwc {
        struct list_head link;
 
+       tdm_private_module *private_module;
+
        int index;
+       double stamp;
 
-       tdm_private_display *private_display;
        tdm_private_output *private_output;
 
+       struct list_head hwc_window_list;
+       struct list_head hwc_commit_handler_list;
+
+       int regist_commit_cb;
+
+       tdm_hwc *hwc_backend;
+};
+
+struct _tdm_private_hwc_window {
+       struct list_head link;
+
+       tdm_private_module *private_module;
+
+       tdm_private_hwc *private_hwc;
        tdm_hwc_window *hwc_window_backend;
 };
 
 struct _tdm_private_pp {
        struct list_head link;
 
+       tdm_private_module *private_module;
+
        double stamp;
 
        tdm_private_display *private_display;
 
-       tdm_pp *pp_backend;
+       tdm_pp *pp_module;
 
        struct list_head pending_buffer_list;
        struct list_head buffer_list;
@@ -289,6 +323,8 @@ struct _tdm_private_capture {
        struct list_head link;
        struct list_head display_link;
 
+       tdm_private_module *private_module;
+
        double stamp;
 
        tdm_capture_target target;
@@ -297,7 +333,7 @@ struct _tdm_private_capture {
        tdm_private_output *private_output;
        tdm_private_layer *private_layer;
 
-       tdm_capture *capture_backend;
+       tdm_capture *capture_module;
 
        struct list_head pending_buffer_list;
        struct list_head buffer_list;
@@ -322,9 +358,6 @@ struct _tdm_private_loop {
        struct wl_display *wl_display;
        struct wl_event_loop *wl_loop;
 
-       int backend_fd;
-       tdm_event_loop_source *backend_source;
-
        /* In event loop, all resources are accessed by this dpy.
         * CAUTION:
         * - DO NOT include other private structure in this structure because this
@@ -339,9 +372,11 @@ struct _tdm_private_loop {
         * private_thread is NULL.
         */
        tdm_private_thread *private_thread;
+
+       struct list_head source_list;
 };
 
-struct _tdm_private_vblank_handler {
+struct _tdm_private_output_vblank_handler {
        struct list_head link;
 
        tdm_private_output *private_output;
@@ -355,6 +390,26 @@ struct _tdm_private_vblank_handler {
        pid_t owner_tid;
 };
 
+struct _tdm_private_output_create_handler {
+       struct list_head link;
+
+       tdm_private_display *private_display;
+       tdm_output_create_handler func;
+       void *user_data;
+
+       pid_t owner_tid;
+};
+
+struct _tdm_private_output_destroy_handler {
+       struct list_head link;
+
+       tdm_private_output *private_output;
+       tdm_output_destroy_handler func;
+       void *user_data;
+
+       pid_t owner_tid;
+};
+
 struct _tdm_private_output_change_handler {
        struct list_head link;
 
@@ -375,16 +430,14 @@ struct _tdm_private_output_commit_handler {
        pid_t owner_tid;
 };
 
-struct _tdm_private_hwc_window_commit_handler {
-       tdm_private_hwc_window *private_hwc_window;
-       tdm_hwc_window_commit_handler func;
-       void *user_data;
-};
+struct _tdm_private_hwc_commit_handler {
+       struct list_head link;
 
-struct _tdm_private_output_hwc_target_buffer_window_commit_handler {
-       tdm_private_output *private_output;
-       tdm_output_hwc_target_buffer_commit_handler func;
+       tdm_private_hwc *private_hwc;
+       tdm_hwc_commit_handler func;
        void *user_data;
+
+       pid_t owner_tid;
 };
 
 struct _tdm_private_layer_commit_handler {
@@ -430,6 +483,9 @@ typedef struct _tdm_capture_private_buffer {
 
 typedef enum {
        TDM_THREAD_CB_NONE,
+       TDM_THREAD_CB_EXIT,             /* special type to exit the tdm-thread */
+       TDM_THREAD_CB_DISPLAY_OUTPUT_CREATE,
+       TDM_THREAD_CB_OUTPUT_DESTROY,
        TDM_THREAD_CB_OUTPUT_COMMIT,
        TDM_THREAD_CB_OUTPUT_VBLANK,
        TDM_THREAD_CB_OUTPUT_STATUS,
@@ -438,66 +494,70 @@ typedef enum {
        TDM_THREAD_CB_CAPTURE_DONE,
        TDM_THREAD_CB_VBLANK_SW,
        TDM_THREAD_CB_VBLANK_CREATE,
-       TDM_THREAD_CB_NEED_VALIDATE,
+       TDM_THREAD_CB_HWC_COMMIT,
+       TDM_THREAD_CB_MAX,
 } tdm_thread_cb_type;
 
 typedef struct _tdm_thread_cb_base tdm_thread_cb_base;
+typedef struct _tdm_thread_cb_display_output_create tdm_thread_cb_display_output_create;
+typedef struct _tdm_thread_cb_output_destroy tdm_thread_cb_output_destroy;
 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_commit;
 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_vblank;
-typedef struct _tdm_thread_cb_output_status tdm_thread_cb_output_status;
 typedef struct _tdm_thread_cb_output_dpms tdm_thread_cb_output_dpms;
+typedef struct _tdm_thread_cb_output_status tdm_thread_cb_output_status;
 typedef struct _tdm_thread_cb_pp_done tdm_thread_cb_pp_done;
 typedef struct _tdm_thread_cb_capture_done tdm_thread_cb_capture_done;
 typedef struct _tdm_thread_cb_vblank_sw tdm_thread_cb_vblank_sw;
 typedef struct _tdm_thread_cb_vblank_create tdm_thread_cb_vblank_create;
-typedef struct _tdm_thread_cb_need_validate tdm_thread_cb_need_validate;
+typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_hwc_commit;
 
 struct _tdm_thread_cb_base {
        tdm_thread_cb_type type;
        unsigned int length;
+       double object_stamp;
+       void *data;
+       unsigned int sync;
+};
+
+struct _tdm_thread_cb_display_output_create {
+       tdm_thread_cb_base base;
+       tdm_output *output;
+};
+
+struct _tdm_thread_cb_output_destroy {
+       tdm_thread_cb_base base;
 };
 
 struct _tdm_thread_cb_output_vblank {
        tdm_thread_cb_base base;
-       double output_stamp;
        unsigned int sequence;
        unsigned int tv_sec;
        unsigned int tv_usec;
-       void *user_data;
 };
 
 struct _tdm_thread_cb_output_status {
        tdm_thread_cb_base base;
-       double output_stamp;
        tdm_output_conn_status status;
-       void *user_data;
 };
 
 struct _tdm_thread_cb_output_dpms {
        tdm_thread_cb_base base;
-       double output_stamp;
        tdm_output_dpms dpms;
-       void *user_data;
 };
 
 struct _tdm_thread_cb_pp_done {
        tdm_thread_cb_base base;
-       double pp_stamp;
        tbm_surface_h src;
        tbm_surface_h dst;
-       void *user_data;
 };
 
 struct _tdm_thread_cb_capture_done {
        tdm_thread_cb_base base;
-       double capture_stamp;
        tbm_surface_h buffer;
-       void *user_data;
 };
 
 struct _tdm_thread_cb_vblank_sw {
        tdm_thread_cb_base base;
-       double vblank_stamp;
 };
 
 struct _tdm_thread_cb_vblank_create {
@@ -505,11 +565,6 @@ struct _tdm_thread_cb_vblank_create {
        double vblank_stamp;
 };
 
-struct _tdm_thread_cb_need_validate {
-       tdm_thread_cb_base base;
-       tdm_private_output *o;
-};
-
 struct argument_details {
        char type;
        int nullable;