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_voutput tdm_private_voutput;
103 typedef struct _tdm_private_layer tdm_private_layer;
104 typedef struct _tdm_private_hwc tdm_private_hwc;
105 typedef struct _tdm_private_hwc_window tdm_private_hwc_window;
106 typedef struct _tdm_private_pp tdm_private_pp;
107 typedef struct _tdm_private_capture tdm_private_capture;
108 typedef struct _tdm_private_loop tdm_private_loop;
109 typedef struct _tdm_private_server tdm_private_server;
110 typedef struct _tdm_private_thread tdm_private_thread;
111 typedef struct _tdm_private_output_create_handler tdm_private_output_create_handler;
112 typedef struct _tdm_private_output_destroy_handler tdm_private_output_destroy_handler;
113 typedef struct _tdm_private_output_change_handler tdm_private_output_change_handler;
114 typedef struct _tdm_private_output_commit_handler tdm_private_output_commit_handler;
115 typedef struct _tdm_private_output_vblank_handler tdm_private_output_vblank_handler;
116 typedef struct _tdm_private_output_mode_change_handler tdm_private_output_mode_change_handler;
117 typedef struct _tdm_private_layer_commit_handler tdm_private_layer_commit_handler;
118 typedef struct _tdm_private_hwc_commit_handler tdm_private_hwc_commit_handler;
119 typedef struct _tdm_private_voutput_commit_handler tdm_private_voutput_commit_handler;
121 typedef struct _tdm_private_layer_buffer tdm_private_layer_buffer;
123 struct _tdm_private_module {
124 struct list_head link;
126 tdm_private_display *private_display;
128 /* backend module info */
130 tdm_backend_module *module_data;
131 tdm_backend_data *bdata;
133 /* backend function */
134 tdm_display_capability capabilities;
135 tdm_func_display func_display;
136 tdm_func_output func_output;
137 tdm_func_voutput func_voutput;
138 tdm_func_layer func_layer;
139 tdm_func_hwc func_hwc;
140 tdm_func_hwc_window func_hwc_window;
142 tdm_func_capture func_capture;
144 /* backend capability */
145 tdm_caps_display caps_display;
147 tdm_caps_capture caps_capture;
149 /* output, pp list */
150 struct list_head output_list;
151 struct list_head voutput_list;
152 struct list_head pp_list;
153 struct list_head capture_list;
155 /* backend output objects. allocated in backend. freed in frontend. ordered */
156 tdm_output **outputs;
159 tdm_event_loop_source *event_source;
162 struct _tdm_private_display {
163 pthread_mutex_t lock;
164 unsigned int init_count;
172 struct list_head module_list;
173 tdm_private_module *dummy_module;
174 tdm_private_module *virtual_module;
175 tdm_private_module *current_module; //setted only when loading
176 tdm_private_module *pp_module; //pp-support backend
177 tdm_private_module *capture_module; //TODO: remove later
179 /* for event handling */
180 tdm_private_loop *private_loop;
182 struct list_head output_create_handler_list;
187 struct _tdm_private_output {
188 struct list_head link;
190 tdm_private_module *private_module;
191 tdm_private_voutput *private_voutput;
196 tdm_private_display *private_display;
198 tdm_caps_output caps;
199 tdm_output *output_backend;
202 tdm_output_dpms current_dpms_value;
203 unsigned int waiting_dpms_change;
204 const tdm_output_mode *current_mode;
206 int regist_vblank_cb;
207 int regist_commit_cb;
208 int regist_change_cb;
211 struct list_head layer_list;
212 struct list_head capture_list;
213 struct list_head vblank_handler_list;
214 struct list_head output_commit_handler_list;
216 /* for layer commit */
217 struct list_head layer_commit_handler_list;
218 struct list_head pending_commit_handler_list;
220 int layer_waiting_vblank;
222 tdm_event_loop_source *vblank_timeout_timer;
223 unsigned int vblank_timeout_timer_expired;
225 struct list_head destroy_handler_list;
226 struct list_head change_handler_list;
230 tdm_info_layer target_buffer_info; /* layer_info for the target_buffer */
232 /* calling a output commit per a vblank */
233 int commit_per_vblank;
234 tdm_commit_type commit_type;
236 /* for ttrace vblank */
237 tdm_vblank *ttrace_vblank;
240 int need_set_target_info;
241 tdm_private_hwc *private_hwc;
244 char name[TDM_NAME_LEN];
245 struct list_head mode_change_request_handler_list;
248 struct _tdm_private_voutput {
249 struct list_head link;
251 tdm_private_module *private_module;
253 int regist_commit_cb;
255 struct list_head voutput_commit_handler_list;
259 tdm_private_display *private_display;
260 tdm_private_output *private_output;
262 tdm_voutput *voutput_backend;
264 char name[TDM_NAME_LEN];
265 tdm_output_mode *modes;
267 unsigned int mmwidth;
268 unsigned int mmheight;
271 int set_voutput_commit;
274 struct _tdm_private_layer {
275 struct list_head link;
277 tdm_private_module *private_module;
281 tdm_private_display *private_display;
282 tdm_private_output *private_output;
285 tdm_layer *layer_backend;
287 /* pending data until committed */
288 unsigned int pending_info_changed;
289 tdm_info_layer pending_info;
290 unsigned int pending_buffer_changed;
291 tbm_surface_h pending_buffer;
293 /* When a buffer is set to a layer, it will be stored to waiting_buffer.
294 * And when a layer is committed, it will be moved to committed_buffer.
295 * Finally when a commit handler is called, it will be moved to showing_buffer.
297 tdm_private_layer_buffer *waiting_buffer;
298 tdm_private_layer_buffer *committed_buffer; /* for output_commit */
299 tdm_private_layer_buffer *showing_buffer;
300 tbm_surface_queue_h buffer_queue;
302 struct list_head capture_list;
305 unsigned int committing;
308 unsigned int fps_count;
311 tbm_surface_h commiting_buffer;
314 struct _tdm_private_hwc {
315 struct list_head link;
317 tdm_private_module *private_module;
322 tdm_private_output *private_output;
324 struct list_head hwc_window_list;
325 struct list_head hwc_commit_handler_list;
327 int regist_commit_cb;
329 tdm_hwc *hwc_backend;
332 struct _tdm_private_hwc_window {
333 struct list_head link;
335 tdm_private_module *private_module;
337 tdm_private_hwc *private_hwc;
338 tdm_hwc_window *hwc_window_backend;
341 struct _tdm_private_pp {
342 struct list_head link;
344 tdm_private_module *private_module;
348 tdm_private_display *private_display;
352 struct list_head pending_buffer_list;
353 struct list_head buffer_list;
358 tdm_pp_done_handler done_func;
359 void *done_user_data;
362 struct _tdm_private_capture {
363 struct list_head link;
364 struct list_head display_link;
366 tdm_private_module *private_module;
370 tdm_capture_target target;
372 tdm_private_display *private_display;
373 tdm_private_output *private_output;
374 tdm_private_layer *private_layer;
376 tdm_capture *capture_module;
378 struct list_head pending_buffer_list;
379 struct list_head buffer_list;
381 tdm_info_capture info;
384 tdm_capture_done_handler done_func;
385 void *done_user_data;
389 * Note that we don't need to (un)lock mutex to use this structure. If there is
390 * no TDM thread, all TDM resources are protected by private_display's mutex.
391 * If there is a TDM thread, this struct will be used only in a TDM thread.
392 * So, we don't need to protect this structure by mutex. Not thread-safe.
394 struct _tdm_private_loop {
395 /* TDM uses wl_event_loop to handle various event sources including the TDM
398 struct wl_display *wl_display;
399 struct wl_event_loop *wl_loop;
401 /* In event loop, all resources are accessed by this dpy.
403 * - DO NOT include other private structure in this structure because this
404 * struct is not protected by mutex.
408 /* for handling TDM client requests */
409 tdm_private_server *private_server;
411 /* To have a TDM event thread. If TDM_THREAD enviroment variable is not set
412 * private_thread is NULL.
414 tdm_private_thread *private_thread;
416 struct list_head source_list;
419 struct _tdm_private_output_vblank_handler {
420 struct list_head link;
422 tdm_private_output *private_output;
425 tdm_output_vblank_handler func;
428 unsigned int sent_to_frontend;
433 struct _tdm_private_output_create_handler {
434 struct list_head link;
436 tdm_private_display *private_display;
437 tdm_output_create_handler func;
443 struct _tdm_private_output_destroy_handler {
444 struct list_head link;
446 tdm_private_output *private_output;
447 tdm_output_destroy_handler func;
453 struct _tdm_private_output_change_handler {
454 struct list_head link;
456 tdm_private_output *private_output;
457 tdm_output_change_handler func;
463 struct _tdm_private_output_commit_handler {
464 struct list_head link;
466 tdm_private_output *private_output;
467 tdm_output_commit_handler func;
473 struct _tdm_private_voutput_commit_handler {
474 struct list_head link;
476 tdm_private_voutput *private_voutput;
477 tdm_voutput_commit_func func;
483 struct _tdm_private_output_mode_change_handler {
484 struct list_head link;
486 tdm_private_output *private_output;
487 tdm_output_mode_change_request_handler func;
491 struct _tdm_private_hwc_commit_handler {
492 struct list_head link;
494 tdm_private_hwc *private_hwc;
495 tdm_hwc_commit_handler func;
501 struct _tdm_private_layer_commit_handler {
502 struct list_head link;
504 tdm_private_layer *private_layer;
505 tdm_layer_commit_handler func;
508 tdm_private_layer_buffer *committed_buffer; /* for layer_commit */
511 struct _tdm_private_layer_buffer {
512 tbm_surface_h buffer;
513 struct list_head link;
516 typedef struct _tdm_buffer_info {
517 tbm_surface_h buffer;
519 /* ref_count for backend */
520 int backend_ref_count;
522 struct list_head release_funcs;
523 struct list_head destroy_funcs;
525 struct list_head *list;
526 struct list_head link;
529 typedef struct _tdm_pp_private_buffer {
532 struct list_head link;
533 struct list_head commit_link;
534 } tdm_pp_private_buffer;
536 typedef struct _tdm_capture_private_buffer {
537 tbm_surface_h buffer;
538 struct list_head link;
539 struct list_head commit_link;
540 } tdm_capture_private_buffer;
544 TDM_THREAD_CB_EXIT, /* special type to exit the tdm-thread */
545 TDM_THREAD_CB_DISPLAY_OUTPUT_CREATE,
546 TDM_THREAD_CB_OUTPUT_DESTROY,
547 TDM_THREAD_CB_OUTPUT_COMMIT,
548 TDM_THREAD_CB_OUTPUT_VBLANK,
549 TDM_THREAD_CB_OUTPUT_STATUS,
550 TDM_THREAD_CB_OUTPUT_DPMS,
551 TDM_THREAD_CB_PP_DONE,
552 TDM_THREAD_CB_CAPTURE_DONE,
553 TDM_THREAD_CB_VBLANK_SW,
554 TDM_THREAD_CB_VBLANK_CREATE,
555 TDM_THREAD_CB_HWC_COMMIT,
556 TDM_THREAD_CB_VOUTPUT_COMMIT,
558 } tdm_thread_cb_type;
560 typedef struct _tdm_thread_cb_base tdm_thread_cb_base;
561 typedef struct _tdm_thread_cb_display_output_create tdm_thread_cb_display_output_create;
562 typedef struct _tdm_thread_cb_output_destroy tdm_thread_cb_output_destroy;
563 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_commit;
564 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_vblank;
565 typedef struct _tdm_thread_cb_output_dpms tdm_thread_cb_output_dpms;
566 typedef struct _tdm_thread_cb_output_status tdm_thread_cb_output_status;
567 typedef struct _tdm_thread_cb_pp_done tdm_thread_cb_pp_done;
568 typedef struct _tdm_thread_cb_capture_done tdm_thread_cb_capture_done;
569 typedef struct _tdm_thread_cb_vblank_sw tdm_thread_cb_vblank_sw;
570 typedef struct _tdm_thread_cb_vblank_create tdm_thread_cb_vblank_create;
571 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_hwc_commit;
572 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_voutput_commit;
574 struct _tdm_thread_cb_base {
575 tdm_thread_cb_type type;
582 struct _tdm_thread_cb_display_output_create {
583 tdm_thread_cb_base base;
587 struct _tdm_thread_cb_output_destroy {
588 tdm_thread_cb_base base;
591 struct _tdm_thread_cb_output_vblank {
592 tdm_thread_cb_base base;
593 unsigned int sequence;
595 unsigned int tv_usec;
598 struct _tdm_thread_cb_output_status {
599 tdm_thread_cb_base base;
600 tdm_output_conn_status status;
603 struct _tdm_thread_cb_output_dpms {
604 tdm_thread_cb_base base;
605 tdm_output_dpms dpms;
608 struct _tdm_thread_cb_pp_done {
609 tdm_thread_cb_base base;
614 struct _tdm_thread_cb_capture_done {
615 tdm_thread_cb_base base;
616 tbm_surface_h buffer;
619 struct _tdm_thread_cb_vblank_sw {
620 tdm_thread_cb_base base;
623 struct _tdm_thread_cb_vblank_create {
624 tdm_thread_cb_base base;
628 struct argument_details {
637 #endif /* _TDM_PRIVATE_TYPES_H_ */