1 /**************************************************************************
5 * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
7 * Contact: Eunchul Kim <chulspro.kim@samsung.com>,
8 * JinYoung Jeon <jy0.jeon@samsung.com>,
9 * Taeheon Kim <th908.kim@samsung.com>,
10 * YoungJun Cho <yj44.cho@samsung.com>,
11 * SooChan Lim <sc1.lim@samsung.com>,
12 * Boram Park <boram1288.park@samsung.com>
14 * Permission is hereby granted, free of charge, to any person obtaining a
15 * copy of this software and associated documentation files (the
16 * "Software"), to deal in the Software without restriction, including
17 * without limitation the rights to use, copy, modify, merge, publish,
18 * distribute, sub license, and/or sell copies of the Software, and to
19 * permit persons to whom the Software is furnished to do so, subject to
20 * the following conditions:
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
27 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
29 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
30 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
31 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
32 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 **************************************************************************/
36 #ifndef _TDM_PRIVATE_TYPES_H_
37 #define _TDM_PRIVATE_TYPES_H_
40 #include <tbm_bufmgr.h>
41 #include <tbm_surface_queue.h>
42 #include <hal/hal-tdm.h>
44 #include "tdm_types.h"
48 #include "tdm_backend.h"
56 /*****************************************************************************
57 * This file defines private Enumerations and Structures for frontend
58 *****************************************************************************/
62 TDM_DEBUG_BUFFER = (1 << 0),
63 TDM_DEBUG_MUTEX = (1 << 1),
64 TDM_DEBUG_EVENT = (1 << 2),
65 TDM_DEBUG_THREAD = (1 << 3),
66 TDM_DEBUG_SERVER = (1 << 4),
67 TDM_DEBUG_VBLANK = (1 << 5),
68 TDM_DEBUG_COMMIT = (1 << 6),
73 TDM_TTRACE_VSYNC = (1 << 0),
74 TDM_TTRACE_CLIENT_VBLANK = (1 << 1),
75 TDM_TTRACE_SERVER_VBLANK = (1 << 2),
76 TDM_TTRACE_VBLANK = (1 << 3),
77 TDM_TTRACE_LAYER = (1 << 4),
78 TDM_TTRACE_PP = (1 << 5),
79 TDM_TTRACE_CAPTURE = (1 << 6),
83 TDM_CAPTURE_TARGET_OUTPUT,
84 TDM_CAPTURE_TARGET_LAYER,
88 TDM_DUMP_FLAG_LAYER = (1 << 0),
89 TDM_DUMP_FLAG_PP = (1 << 1),
90 TDM_DUMP_FLAG_CAPTURE = (1 << 2),
91 TDM_DUMP_FLAG_WINDOW = (1 << 3),
96 TDM_COMMIT_TYPE_OUTPUT,
97 TDM_COMMIT_TYPE_LAYER,
100 typedef struct _tdm_private_module tdm_private_module;
101 typedef struct _tdm_private_display tdm_private_display;
102 typedef struct _tdm_private_output tdm_private_output;
103 typedef struct _tdm_private_voutput tdm_private_voutput;
104 typedef struct _tdm_private_layer tdm_private_layer;
105 typedef struct _tdm_private_hwc tdm_private_hwc;
106 typedef struct _tdm_private_hwc_window tdm_private_hwc_window;
107 typedef struct _tdm_private_pp tdm_private_pp;
108 typedef struct _tdm_private_capture tdm_private_capture;
109 typedef struct _tdm_private_loop tdm_private_loop;
110 typedef struct _tdm_private_server tdm_private_server;
111 typedef struct _tdm_private_thread tdm_private_thread;
112 typedef struct _tdm_private_output_create_handler tdm_private_output_create_handler;
113 typedef struct _tdm_private_output_destroy_handler tdm_private_output_destroy_handler;
114 typedef struct _tdm_private_output_change_handler tdm_private_output_change_handler;
115 typedef struct _tdm_private_output_commit_handler tdm_private_output_commit_handler;
116 typedef struct _tdm_private_output_vblank_handler tdm_private_output_vblank_handler;
117 typedef struct _tdm_private_output_mode_change_handler tdm_private_output_mode_change_handler;
118 typedef struct _tdm_private_layer_commit_handler tdm_private_layer_commit_handler;
119 typedef struct _tdm_private_hwc_commit_handler tdm_private_hwc_commit_handler;
120 typedef struct _tdm_private_voutput_commit_handler tdm_private_voutput_commit_handler;
122 typedef struct _tdm_private_layer_buffer tdm_private_layer_buffer;
124 struct _tdm_private_module {
125 struct list_head link;
127 tdm_private_display *private_display;
129 /* backend module info */
131 tdm_backend_module *module_data;
132 tdm_backend_data *bdata;
134 /* backend function */
135 tdm_display_capability capabilities;
136 tdm_func_display func_display;
137 tdm_func_output func_output;
138 tdm_func_voutput func_voutput;
139 tdm_func_layer func_layer;
140 tdm_func_hwc func_hwc;
141 tdm_func_hwc_window func_hwc_window;
143 tdm_func_capture func_capture;
145 /* backend capability */
146 tdm_caps_display caps_display;
148 tdm_caps_capture caps_capture;
150 /* output, pp list */
151 struct list_head output_list;
152 struct list_head voutput_list;
153 struct list_head pp_list;
154 struct list_head capture_list;
156 /* backend output objects. allocated in backend. freed in frontend. ordered */
157 tdm_output **outputs;
160 tdm_event_loop_source *event_source;
162 /* backend virtual output target buffer type default set for hwc */
163 int use_default_type_bo;
167 hal_tdm_backend *htdm_backend;
168 hal_tdm_display *htdm_dpy;
169 tdm_event_loop_source *htdm_event_source[HAL_TDM_EVENT_SOURCE_MAX];
170 int event_source_num;
173 struct _tdm_private_display {
174 pthread_mutex_t lock;
175 unsigned int init_count;
183 struct list_head module_list;
184 tdm_private_module *dummy_module;
185 tdm_private_module *virtual_module;
186 tdm_private_module *current_module; //setted only when loading
187 tdm_private_module *pp_module; //pp-support backend
188 tdm_private_module *capture_module; //TODO: remove later
190 /* for event handling */
191 tdm_private_loop *private_loop;
193 struct list_head output_create_handler_list;
198 struct _tdm_private_output {
199 struct list_head link;
201 tdm_private_module *private_module;
202 tdm_private_voutput *private_voutput;
207 tdm_private_display *private_display;
209 tdm_caps_output caps;
210 tdm_output *output_backend;
213 tdm_output_dpms current_dpms_value;
214 unsigned int waiting_dpms_change;
215 const tdm_output_mode *current_mode;
217 int regist_vblank_cb;
218 int regist_commit_cb;
219 int regist_change_cb;
222 struct list_head layer_list;
223 struct list_head capture_list;
224 struct list_head vblank_handler_list;
225 struct list_head output_commit_handler_list;
227 /* for layer commit */
228 struct list_head layer_commit_handler_list;
229 struct list_head pending_commit_handler_list;
231 int layer_waiting_vblank;
233 tdm_event_loop_source *vblank_timeout_timer;
234 unsigned int vblank_timeout_timer_expired;
236 struct list_head destroy_handler_list;
237 struct list_head change_handler_list;
241 tdm_info_layer target_buffer_info; /* layer_info for the target_buffer */
243 /* calling a output commit per a vblank */
244 int commit_per_vblank;
245 tdm_commit_type commit_type;
247 /* for ttrace vblank */
248 tdm_vblank *ttrace_vblank;
251 int need_set_target_info;
252 tdm_private_hwc *private_hwc;
255 char name[TDM_NAME_LEN];
256 struct list_head mode_change_request_handler_list;
259 struct _tdm_private_voutput {
260 struct list_head link;
262 tdm_private_module *private_module;
264 int regist_commit_cb;
266 struct list_head voutput_commit_handler_list;
270 tdm_private_display *private_display;
271 tdm_private_output *private_output;
273 tdm_voutput *voutput_backend;
275 char name[TDM_NAME_LEN];
276 tdm_output_mode *modes;
278 unsigned int mmwidth;
279 unsigned int mmheight;
282 int set_voutput_commit;
285 struct _tdm_private_layer {
286 struct list_head link;
288 tdm_private_module *private_module;
292 tdm_private_display *private_display;
293 tdm_private_output *private_output;
296 tdm_layer *layer_backend;
298 /* pending data until committed */
299 unsigned int pending_info_changed;
300 tdm_info_layer pending_info;
301 unsigned int pending_buffer_changed;
302 tbm_surface_h pending_buffer;
304 /* When a buffer is set to a layer, it will be stored to waiting_buffer.
305 * And when a layer is committed, it will be moved to committed_buffer.
306 * Finally when a commit handler is called, it will be moved to showing_buffer.
308 tdm_private_layer_buffer *waiting_buffer;
309 tdm_private_layer_buffer *committed_buffer; /* for output_commit */
310 tdm_private_layer_buffer *showing_buffer;
311 tbm_surface_queue_h buffer_queue;
313 struct list_head capture_list;
316 unsigned int committing;
319 unsigned int fps_count;
322 tbm_surface_h commiting_buffer;
325 struct _tdm_private_hwc {
326 struct list_head link;
328 tdm_private_module *private_module;
333 tdm_private_output *private_output;
335 struct list_head hwc_window_list;
336 struct list_head hwc_commit_handler_list;
338 int regist_commit_cb;
340 tdm_hwc *hwc_backend;
342 tbm_surface_h display_target_buffer;
345 unsigned int fps_count;
348 struct _tdm_private_hwc_window {
349 struct list_head link;
351 tdm_private_module *private_module;
353 tdm_private_hwc *private_hwc;
354 tdm_hwc_window *hwc_window_backend;
356 tbm_surface_h display_buffer;
357 tdm_hwc_window_composition composition_type;
360 struct _tdm_private_pp {
361 struct list_head link;
363 tdm_private_module *private_module;
367 tdm_private_display *private_display;
371 struct list_head pending_buffer_list;
372 struct list_head buffer_list;
377 tdm_pp_done_handler done_func;
378 void *done_user_data;
381 struct _tdm_private_capture {
382 struct list_head link;
383 struct list_head display_link;
385 tdm_private_module *private_module;
389 tdm_capture_target target;
391 tdm_private_display *private_display;
392 tdm_private_output *private_output;
393 tdm_private_layer *private_layer;
395 tdm_capture *capture_module;
397 struct list_head pending_buffer_list;
398 struct list_head buffer_list;
400 tdm_info_capture info;
403 tdm_capture_done_handler done_func;
404 void *done_user_data;
408 * Note that we don't need to (un)lock mutex to use this structure. If there is
409 * no TDM thread, all TDM resources are protected by private_display's mutex.
410 * If there is a TDM thread, this struct will be used only in a TDM thread.
411 * So, we don't need to protect this structure by mutex. Not thread-safe.
413 struct _tdm_private_loop {
414 /* TDM uses wl_event_loop to handle various event sources including the TDM
417 struct wl_display *wl_display;
418 struct wl_event_loop *wl_loop;
420 /* In event loop, all resources are accessed by this dpy.
422 * - DO NOT include other private structure in this structure because this
423 * struct is not protected by mutex.
427 /* for handling TDM client requests */
428 tdm_private_server *private_server;
430 /* To have a TDM event thread. If TDM_THREAD enviroment variable is not set
431 * private_thread is NULL.
433 tdm_private_thread *private_thread;
435 struct list_head source_list;
438 struct _tdm_private_output_vblank_handler {
439 struct list_head link;
441 tdm_private_output *private_output;
444 tdm_output_vblank_handler func;
447 unsigned int sent_to_frontend;
452 struct _tdm_private_output_create_handler {
453 struct list_head link;
455 tdm_private_display *private_display;
456 tdm_output_create_handler func;
462 struct _tdm_private_output_destroy_handler {
463 struct list_head link;
465 tdm_private_output *private_output;
466 tdm_output_destroy_handler func;
472 struct _tdm_private_output_change_handler {
473 struct list_head link;
475 tdm_private_output *private_output;
476 tdm_output_change_handler func;
482 struct _tdm_private_output_commit_handler {
483 struct list_head link;
485 tdm_private_output *private_output;
486 tdm_output_commit_handler func;
492 struct _tdm_private_voutput_commit_handler {
493 struct list_head link;
495 tdm_private_voutput *private_voutput;
496 tdm_voutput_commit_func func;
502 struct _tdm_private_output_mode_change_handler {
503 struct list_head link;
505 tdm_private_output *private_output;
506 tdm_output_mode_change_request_handler func;
510 struct _tdm_private_hwc_commit_handler {
511 struct list_head link;
513 tdm_private_hwc *private_hwc;
514 tdm_hwc_commit_handler func;
521 struct _tdm_private_layer_commit_handler {
522 struct list_head link;
524 tdm_private_layer *private_layer;
525 tdm_layer_commit_handler func;
528 tdm_private_layer_buffer *committed_buffer; /* for layer_commit */
531 struct _tdm_private_layer_buffer {
532 tbm_surface_h buffer;
533 struct list_head link;
536 typedef struct _tdm_buffer_info {
537 tbm_surface_h buffer;
539 /* ref_count for backend */
540 int backend_ref_count;
542 struct list_head release_funcs;
543 struct list_head destroy_funcs;
545 struct list_head *list;
546 struct list_head link;
549 typedef struct _tdm_pp_private_buffer {
552 struct list_head link;
553 struct list_head commit_link;
554 } tdm_pp_private_buffer;
556 typedef struct _tdm_capture_private_buffer {
557 tbm_surface_h buffer;
558 struct list_head link;
559 struct list_head commit_link;
560 } tdm_capture_private_buffer;
564 TDM_THREAD_CB_EXIT, /* special type to exit the tdm-thread */
565 TDM_THREAD_CB_DISPLAY_OUTPUT_CREATE,
566 TDM_THREAD_CB_OUTPUT_DESTROY,
567 TDM_THREAD_CB_OUTPUT_COMMIT,
568 TDM_THREAD_CB_OUTPUT_VBLANK,
569 TDM_THREAD_CB_OUTPUT_STATUS,
570 TDM_THREAD_CB_OUTPUT_DPMS,
571 TDM_THREAD_CB_PP_DONE,
572 TDM_THREAD_CB_CAPTURE_DONE,
573 TDM_THREAD_CB_VBLANK_SW,
574 TDM_THREAD_CB_VBLANK_CREATE,
575 TDM_THREAD_CB_HWC_COMMIT,
576 TDM_THREAD_CB_VOUTPUT_COMMIT,
578 } tdm_thread_cb_type;
580 typedef struct _tdm_thread_cb_base tdm_thread_cb_base;
581 typedef struct _tdm_thread_cb_display_output_create tdm_thread_cb_display_output_create;
582 typedef struct _tdm_thread_cb_output_destroy tdm_thread_cb_output_destroy;
583 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_commit;
584 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_vblank;
585 typedef struct _tdm_thread_cb_output_dpms tdm_thread_cb_output_dpms;
586 typedef struct _tdm_thread_cb_output_status tdm_thread_cb_output_status;
587 typedef struct _tdm_thread_cb_pp_done tdm_thread_cb_pp_done;
588 typedef struct _tdm_thread_cb_capture_done tdm_thread_cb_capture_done;
589 typedef struct _tdm_thread_cb_vblank_sw tdm_thread_cb_vblank_sw;
590 typedef struct _tdm_thread_cb_vblank_create tdm_thread_cb_vblank_create;
591 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_hwc_commit;
592 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_voutput_commit;
594 struct _tdm_thread_cb_base {
595 tdm_thread_cb_type type;
602 struct _tdm_thread_cb_display_output_create {
603 tdm_thread_cb_base base;
607 struct _tdm_thread_cb_output_destroy {
608 tdm_thread_cb_base base;
611 struct _tdm_thread_cb_output_vblank {
612 tdm_thread_cb_base base;
613 unsigned int sequence;
615 unsigned int tv_usec;
618 struct _tdm_thread_cb_output_status {
619 tdm_thread_cb_base base;
620 tdm_output_conn_status status;
623 struct _tdm_thread_cb_output_dpms {
624 tdm_thread_cb_base base;
625 tdm_output_dpms dpms;
628 struct _tdm_thread_cb_pp_done {
629 tdm_thread_cb_base base;
634 struct _tdm_thread_cb_capture_done {
635 tdm_thread_cb_base base;
636 tbm_surface_h buffer;
639 struct _tdm_thread_cb_vblank_sw {
640 tdm_thread_cb_base base;
643 struct _tdm_thread_cb_vblank_create {
644 tdm_thread_cb_base base;
648 struct argument_details {
657 #endif /* _TDM_PRIVATE_TYPES_H_ */