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>
43 #include "tdm_types.h"
47 #include "tdm_backend.h"
55 /*****************************************************************************
56 * This file defines private Enumerations and Structures for frontend
57 *****************************************************************************/
61 TDM_DEBUG_BUFFER = (1 << 0),
62 TDM_DEBUG_MUTEX = (1 << 1),
63 TDM_DEBUG_EVENT = (1 << 2),
64 TDM_DEBUG_THREAD = (1 << 3),
65 TDM_DEBUG_SERVER = (1 << 4),
66 TDM_DEBUG_VBLANK = (1 << 5),
67 TDM_DEBUG_COMMIT = (1 << 6),
72 TDM_TTRACE_VSYNC = (1 << 0),
73 TDM_TTRACE_CLIENT_VBLANK = (1 << 1),
74 TDM_TTRACE_SERVER_VBLANK = (1 << 2),
75 TDM_TTRACE_VBLANK = (1 << 3),
76 TDM_TTRACE_LAYER = (1 << 4),
77 TDM_TTRACE_PP = (1 << 5),
78 TDM_TTRACE_CAPTURE = (1 << 6),
82 TDM_CAPTURE_TARGET_OUTPUT,
83 TDM_CAPTURE_TARGET_LAYER,
87 TDM_DUMP_FLAG_LAYER = (1 << 0),
88 TDM_DUMP_FLAG_PP = (1 << 1),
89 TDM_DUMP_FLAG_CAPTURE = (1 << 2),
90 TDM_DUMP_FLAG_WINDOW = (1 << 3),
95 TDM_COMMIT_TYPE_OUTPUT,
96 TDM_COMMIT_TYPE_LAYER,
99 typedef struct _tdm_private_module tdm_private_module;
100 typedef struct _tdm_private_display tdm_private_display;
101 typedef struct _tdm_private_output tdm_private_output;
102 typedef struct _tdm_private_layer tdm_private_layer;
103 typedef struct _tdm_private_hwc tdm_private_hwc;
104 typedef struct _tdm_private_hwc_window tdm_private_hwc_window;
105 typedef struct _tdm_private_pp tdm_private_pp;
106 typedef struct _tdm_private_capture tdm_private_capture;
107 typedef struct _tdm_private_loop tdm_private_loop;
108 typedef struct _tdm_private_server tdm_private_server;
109 typedef struct _tdm_private_thread tdm_private_thread;
110 typedef struct _tdm_private_output_create_handler tdm_private_output_create_handler;
111 typedef struct _tdm_private_output_destroy_handler tdm_private_output_destroy_handler;
112 typedef struct _tdm_private_output_change_handler tdm_private_output_change_handler;
113 typedef struct _tdm_private_output_commit_handler tdm_private_output_commit_handler;
114 typedef struct _tdm_private_output_vblank_handler tdm_private_output_vblank_handler;
115 typedef struct _tdm_private_layer_commit_handler tdm_private_layer_commit_handler;
116 typedef struct _tdm_private_hwc_commit_handler tdm_private_hwc_commit_handler;
118 typedef struct _tdm_private_layer_buffer tdm_private_layer_buffer;
120 struct _tdm_private_module {
121 struct list_head link;
123 tdm_private_display *private_display;
125 /* backend module info */
127 tdm_backend_module *module_data;
128 tdm_backend_data *bdata;
130 /* backend function */
131 tdm_display_capability capabilities;
132 tdm_func_display func_display;
133 tdm_func_output func_output;
134 tdm_func_layer func_layer;
135 tdm_func_hwc func_hwc;
136 tdm_func_hwc_window func_hwc_window;
138 tdm_func_capture func_capture;
140 /* backend capability */
141 tdm_caps_display caps_display;
143 tdm_caps_capture caps_capture;
145 /* output, pp list */
146 struct list_head output_list;
147 struct list_head pp_list;
148 struct list_head capture_list;
150 /* backend output objects. allocated in backend. freed in frontend. ordered */
151 tdm_output **outputs;
154 tdm_event_loop_source *event_source;
157 struct _tdm_private_display {
158 pthread_mutex_t lock;
159 unsigned int init_count;
167 struct list_head module_list;
168 tdm_private_module *dummy_module;
169 tdm_private_module *virtual_module;
170 tdm_private_module *current_module; //setted only when loading
171 tdm_private_module *pp_module; //pp-support backend
172 tdm_private_module *capture_module; //TODO: remove later
174 /* for event handling */
175 tdm_private_loop *private_loop;
177 struct list_head output_create_handler_list;
182 struct _tdm_private_output {
183 struct list_head link;
185 tdm_private_module *private_module;
190 tdm_private_display *private_display;
192 tdm_caps_output caps;
193 tdm_output *output_backend;
196 tdm_output_dpms current_dpms_value;
197 unsigned int waiting_dpms_change;
198 const tdm_output_mode *current_mode;
200 int regist_vblank_cb;
201 int regist_commit_cb;
202 int regist_change_cb;
205 struct list_head layer_list;
206 struct list_head capture_list;
207 struct list_head vblank_handler_list;
208 struct list_head output_commit_handler_list;
210 /* for layer commit */
211 struct list_head layer_commit_handler_list;
212 struct list_head pending_commit_handler_list;
214 int layer_waiting_vblank;
216 tdm_event_loop_source *vblank_timeout_timer;
217 unsigned int vblank_timeout_timer_expired;
219 struct list_head destroy_handler_list;
220 struct list_head change_handler_list;
224 tdm_info_layer target_buffer_info; /* layer_info for the target_buffer */
226 /* calling a output commit per a vblank */
227 int commit_per_vblank;
228 tdm_commit_type commit_type;
230 /* for ttrace vblank */
231 tdm_vblank *ttrace_vblank;
234 int need_set_target_info;
235 tdm_private_hwc *private_hwc;
238 struct _tdm_private_layer {
239 struct list_head link;
241 tdm_private_module *private_module;
245 tdm_private_display *private_display;
246 tdm_private_output *private_output;
249 tdm_layer *layer_backend;
251 /* pending data until committed */
252 unsigned int pending_info_changed;
253 tdm_info_layer pending_info;
254 unsigned int pending_buffer_changed;
255 tbm_surface_h pending_buffer;
257 /* When a buffer is set to a layer, it will be stored to waiting_buffer.
258 * And when a layer is committed, it will be moved to committed_buffer.
259 * Finally when a commit handler is called, it will be moved to showing_buffer.
261 tdm_private_layer_buffer *waiting_buffer;
262 tdm_private_layer_buffer *committed_buffer; /* for output_commit */
263 tdm_private_layer_buffer *showing_buffer;
264 tbm_surface_queue_h buffer_queue;
266 struct list_head capture_list;
269 unsigned int committing;
272 unsigned int fps_count;
275 struct _tdm_private_hwc {
276 struct list_head link;
278 tdm_private_module *private_module;
283 tdm_private_output *private_output;
285 struct list_head hwc_window_list;
286 struct list_head hwc_commit_handler_list;
288 int regist_commit_cb;
290 tdm_hwc *hwc_backend;
293 struct _tdm_private_hwc_window {
294 struct list_head link;
296 tdm_private_module *private_module;
298 tdm_private_hwc *private_hwc;
299 tdm_hwc_window *hwc_window_backend;
302 struct _tdm_private_pp {
303 struct list_head link;
305 tdm_private_module *private_module;
309 tdm_private_display *private_display;
313 struct list_head pending_buffer_list;
314 struct list_head buffer_list;
319 tdm_pp_done_handler done_func;
320 void *done_user_data;
323 struct _tdm_private_capture {
324 struct list_head link;
325 struct list_head display_link;
327 tdm_private_module *private_module;
331 tdm_capture_target target;
333 tdm_private_display *private_display;
334 tdm_private_output *private_output;
335 tdm_private_layer *private_layer;
337 tdm_capture *capture_module;
339 struct list_head pending_buffer_list;
340 struct list_head buffer_list;
342 tdm_info_capture info;
345 tdm_capture_done_handler done_func;
346 void *done_user_data;
350 * Note that we don't need to (un)lock mutex to use this structure. If there is
351 * no TDM thread, all TDM resources are protected by private_display's mutex.
352 * If there is a TDM thread, this struct will be used only in a TDM thread.
353 * So, we don't need to protect this structure by mutex. Not thread-safe.
355 struct _tdm_private_loop {
356 /* TDM uses wl_event_loop to handle various event sources including the TDM
359 struct wl_display *wl_display;
360 struct wl_event_loop *wl_loop;
362 /* In event loop, all resources are accessed by this dpy.
364 * - DO NOT include other private structure in this structure because this
365 * struct is not protected by mutex.
369 /* for handling TDM client requests */
370 tdm_private_server *private_server;
372 /* To have a TDM event thread. If TDM_THREAD enviroment variable is not set
373 * private_thread is NULL.
375 tdm_private_thread *private_thread;
377 struct list_head source_list;
380 struct _tdm_private_output_vblank_handler {
381 struct list_head link;
383 tdm_private_output *private_output;
386 tdm_output_vblank_handler func;
389 unsigned int sent_to_frontend;
394 struct _tdm_private_output_create_handler {
395 struct list_head link;
397 tdm_private_display *private_display;
398 tdm_output_create_handler func;
404 struct _tdm_private_output_destroy_handler {
405 struct list_head link;
407 tdm_private_output *private_output;
408 tdm_output_destroy_handler func;
414 struct _tdm_private_output_change_handler {
415 struct list_head link;
417 tdm_private_output *private_output;
418 tdm_output_change_handler func;
424 struct _tdm_private_output_commit_handler {
425 struct list_head link;
427 tdm_private_output *private_output;
428 tdm_output_commit_handler func;
434 struct _tdm_private_hwc_commit_handler {
435 struct list_head link;
437 tdm_private_hwc *private_hwc;
438 tdm_hwc_commit_handler func;
444 struct _tdm_private_layer_commit_handler {
445 struct list_head link;
447 tdm_private_layer *private_layer;
448 tdm_layer_commit_handler func;
451 tdm_private_layer_buffer *committed_buffer; /* for layer_commit */
454 struct _tdm_private_layer_buffer {
455 tbm_surface_h buffer;
456 struct list_head link;
459 typedef struct _tdm_buffer_info {
460 tbm_surface_h buffer;
462 /* ref_count for backend */
463 int backend_ref_count;
465 struct list_head release_funcs;
466 struct list_head destroy_funcs;
468 struct list_head *list;
469 struct list_head link;
472 typedef struct _tdm_pp_private_buffer {
475 struct list_head link;
476 struct list_head commit_link;
477 } tdm_pp_private_buffer;
479 typedef struct _tdm_capture_private_buffer {
480 tbm_surface_h buffer;
481 struct list_head link;
482 struct list_head commit_link;
483 } tdm_capture_private_buffer;
487 TDM_THREAD_CB_EXIT, /* special type to exit the tdm-thread */
488 TDM_THREAD_CB_DISPLAY_OUTPUT_CREATE,
489 TDM_THREAD_CB_OUTPUT_DESTROY,
490 TDM_THREAD_CB_OUTPUT_COMMIT,
491 TDM_THREAD_CB_OUTPUT_VBLANK,
492 TDM_THREAD_CB_OUTPUT_STATUS,
493 TDM_THREAD_CB_OUTPUT_DPMS,
494 TDM_THREAD_CB_PP_DONE,
495 TDM_THREAD_CB_CAPTURE_DONE,
496 TDM_THREAD_CB_VBLANK_SW,
497 TDM_THREAD_CB_VBLANK_CREATE,
498 TDM_THREAD_CB_HWC_COMMIT,
500 } tdm_thread_cb_type;
502 typedef struct _tdm_thread_cb_base tdm_thread_cb_base;
503 typedef struct _tdm_thread_cb_display_output_create tdm_thread_cb_display_output_create;
504 typedef struct _tdm_thread_cb_output_destroy tdm_thread_cb_output_destroy;
505 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_commit;
506 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_vblank;
507 typedef struct _tdm_thread_cb_output_dpms tdm_thread_cb_output_dpms;
508 typedef struct _tdm_thread_cb_output_status tdm_thread_cb_output_status;
509 typedef struct _tdm_thread_cb_pp_done tdm_thread_cb_pp_done;
510 typedef struct _tdm_thread_cb_capture_done tdm_thread_cb_capture_done;
511 typedef struct _tdm_thread_cb_vblank_sw tdm_thread_cb_vblank_sw;
512 typedef struct _tdm_thread_cb_vblank_create tdm_thread_cb_vblank_create;
513 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_hwc_commit;
515 struct _tdm_thread_cb_base {
516 tdm_thread_cb_type type;
523 struct _tdm_thread_cb_display_output_create {
524 tdm_thread_cb_base base;
528 struct _tdm_thread_cb_output_destroy {
529 tdm_thread_cb_base base;
532 struct _tdm_thread_cb_output_vblank {
533 tdm_thread_cb_base base;
534 unsigned int sequence;
536 unsigned int tv_usec;
539 struct _tdm_thread_cb_output_status {
540 tdm_thread_cb_base base;
541 tdm_output_conn_status status;
544 struct _tdm_thread_cb_output_dpms {
545 tdm_thread_cb_base base;
546 tdm_output_dpms dpms;
549 struct _tdm_thread_cb_pp_done {
550 tdm_thread_cb_base base;
555 struct _tdm_thread_cb_capture_done {
556 tdm_thread_cb_base base;
557 tbm_surface_h buffer;
560 struct _tdm_thread_cb_vblank_sw {
561 tdm_thread_cb_base base;
564 struct _tdm_thread_cb_vblank_create {
565 tdm_thread_cb_base base;
569 struct argument_details {
578 #endif /* _TDM_PRIVATE_TYPES_H_ */