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 *current_module; //setted only when loading
170 tdm_private_module *pp_module; //pp-support backend
171 tdm_private_module *capture_module; //TODO: remove later
173 /* for event handling */
174 tdm_private_loop *private_loop;
176 struct list_head output_create_handler_list;
181 struct _tdm_private_output {
182 struct list_head link;
184 tdm_private_module *private_module;
189 tdm_private_display *private_display;
191 tdm_caps_output caps;
192 tdm_output *output_backend;
195 tdm_output_dpms current_dpms_value;
196 unsigned int waiting_dpms_change;
197 const tdm_output_mode *current_mode;
199 int regist_vblank_cb;
200 int regist_commit_cb;
201 int regist_change_cb;
204 struct list_head layer_list;
205 struct list_head capture_list;
206 struct list_head vblank_handler_list;
207 struct list_head output_commit_handler_list;
209 /* for layer commit */
210 struct list_head layer_commit_handler_list;
211 struct list_head pending_commit_handler_list;
213 int layer_waiting_vblank;
215 tdm_event_loop_source *vblank_timeout_timer;
216 unsigned int vblank_timeout_timer_expired;
218 struct list_head destroy_handler_list;
219 struct list_head change_handler_list;
223 tdm_info_layer target_buffer_info; /* layer_info for the target_buffer */
225 /* calling a output commit per a vblank */
226 int commit_per_vblank;
227 tdm_commit_type commit_type;
229 /* for ttrace vblank */
230 tdm_vblank *ttrace_vblank;
233 int need_set_target_info;
234 tdm_private_hwc *private_hwc;
237 struct _tdm_private_layer {
238 struct list_head link;
240 tdm_private_module *private_module;
244 tdm_private_display *private_display;
245 tdm_private_output *private_output;
248 tdm_layer *layer_backend;
250 /* pending data until committed */
251 unsigned int pending_info_changed;
252 tdm_info_layer pending_info;
253 unsigned int pending_buffer_changed;
254 tbm_surface_h pending_buffer;
256 /* When a buffer is set to a layer, it will be stored to waiting_buffer.
257 * And when a layer is committed, it will be moved to committed_buffer.
258 * Finally when a commit handler is called, it will be moved to showing_buffer.
260 tdm_private_layer_buffer *waiting_buffer;
261 tdm_private_layer_buffer *committed_buffer; /* for output_commit */
262 tdm_private_layer_buffer *showing_buffer;
263 tbm_surface_queue_h buffer_queue;
265 struct list_head capture_list;
268 unsigned int committing;
271 unsigned int fps_count;
274 struct _tdm_private_hwc {
275 struct list_head link;
277 tdm_private_module *private_module;
282 tdm_private_output *private_output;
284 struct list_head hwc_window_list;
285 struct list_head hwc_commit_handler_list;
287 int regist_commit_cb;
289 tdm_hwc *hwc_backend;
292 struct _tdm_private_hwc_window {
293 struct list_head link;
295 tdm_private_module *private_module;
297 tdm_private_hwc *private_hwc;
298 tdm_hwc_window *hwc_window_backend;
301 struct _tdm_private_pp {
302 struct list_head link;
304 tdm_private_module *private_module;
308 tdm_private_display *private_display;
312 struct list_head pending_buffer_list;
313 struct list_head buffer_list;
318 tdm_pp_done_handler done_func;
319 void *done_user_data;
322 struct _tdm_private_capture {
323 struct list_head link;
324 struct list_head display_link;
326 tdm_private_module *private_module;
330 tdm_capture_target target;
332 tdm_private_display *private_display;
333 tdm_private_output *private_output;
334 tdm_private_layer *private_layer;
336 tdm_capture *capture_module;
338 struct list_head pending_buffer_list;
339 struct list_head buffer_list;
341 tdm_info_capture info;
344 tdm_capture_done_handler done_func;
345 void *done_user_data;
349 * Note that we don't need to (un)lock mutex to use this structure. If there is
350 * no TDM thread, all TDM resources are protected by private_display's mutex.
351 * If there is a TDM thread, this struct will be used only in a TDM thread.
352 * So, we don't need to protect this structure by mutex. Not thread-safe.
354 struct _tdm_private_loop {
355 /* TDM uses wl_event_loop to handle various event sources including the TDM
358 struct wl_display *wl_display;
359 struct wl_event_loop *wl_loop;
361 /* In event loop, all resources are accessed by this dpy.
363 * - DO NOT include other private structure in this structure because this
364 * struct is not protected by mutex.
368 /* for handling TDM client requests */
369 tdm_private_server *private_server;
371 /* To have a TDM event thread. If TDM_THREAD enviroment variable is not set
372 * private_thread is NULL.
374 tdm_private_thread *private_thread;
376 struct list_head source_list;
379 struct _tdm_private_output_vblank_handler {
380 struct list_head link;
382 tdm_private_output *private_output;
385 tdm_output_vblank_handler func;
388 unsigned int sent_to_frontend;
393 struct _tdm_private_output_create_handler {
394 struct list_head link;
396 tdm_private_display *private_display;
397 tdm_output_create_handler func;
403 struct _tdm_private_output_destroy_handler {
404 struct list_head link;
406 tdm_private_output *private_output;
407 tdm_output_destroy_handler func;
413 struct _tdm_private_output_change_handler {
414 struct list_head link;
416 tdm_private_output *private_output;
417 tdm_output_change_handler func;
423 struct _tdm_private_output_commit_handler {
424 struct list_head link;
426 tdm_private_output *private_output;
427 tdm_output_commit_handler func;
433 struct _tdm_private_hwc_commit_handler {
434 struct list_head link;
436 tdm_private_hwc *private_hwc;
437 tdm_hwc_commit_handler func;
443 struct _tdm_private_layer_commit_handler {
444 struct list_head link;
446 tdm_private_layer *private_layer;
447 tdm_layer_commit_handler func;
450 tdm_private_layer_buffer *committed_buffer; /* for layer_commit */
453 struct _tdm_private_layer_buffer {
454 tbm_surface_h buffer;
455 struct list_head link;
458 typedef struct _tdm_buffer_info {
459 tbm_surface_h buffer;
461 /* ref_count for backend */
462 int backend_ref_count;
464 struct list_head release_funcs;
465 struct list_head destroy_funcs;
467 struct list_head *list;
468 struct list_head link;
471 typedef struct _tdm_pp_private_buffer {
474 struct list_head link;
475 struct list_head commit_link;
476 } tdm_pp_private_buffer;
478 typedef struct _tdm_capture_private_buffer {
479 tbm_surface_h buffer;
480 struct list_head link;
481 struct list_head commit_link;
482 } tdm_capture_private_buffer;
486 TDM_THREAD_CB_EXIT, /* special type to exit the tdm-thread */
487 TDM_THREAD_CB_DISPLAY_OUTPUT_CREATE,
488 TDM_THREAD_CB_OUTPUT_DESTROY,
489 TDM_THREAD_CB_OUTPUT_COMMIT,
490 TDM_THREAD_CB_OUTPUT_VBLANK,
491 TDM_THREAD_CB_OUTPUT_STATUS,
492 TDM_THREAD_CB_OUTPUT_DPMS,
493 TDM_THREAD_CB_PP_DONE,
494 TDM_THREAD_CB_CAPTURE_DONE,
495 TDM_THREAD_CB_VBLANK_SW,
496 TDM_THREAD_CB_VBLANK_CREATE,
497 TDM_THREAD_CB_HWC_COMMIT,
499 } tdm_thread_cb_type;
501 typedef struct _tdm_thread_cb_base tdm_thread_cb_base;
502 typedef struct _tdm_thread_cb_display_output_create tdm_thread_cb_display_output_create;
503 typedef struct _tdm_thread_cb_output_destroy tdm_thread_cb_output_destroy;
504 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_commit;
505 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_vblank;
506 typedef struct _tdm_thread_cb_output_dpms tdm_thread_cb_output_dpms;
507 typedef struct _tdm_thread_cb_output_status tdm_thread_cb_output_status;
508 typedef struct _tdm_thread_cb_pp_done tdm_thread_cb_pp_done;
509 typedef struct _tdm_thread_cb_capture_done tdm_thread_cb_capture_done;
510 typedef struct _tdm_thread_cb_vblank_sw tdm_thread_cb_vblank_sw;
511 typedef struct _tdm_thread_cb_vblank_create tdm_thread_cb_vblank_create;
512 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_hwc_commit;
514 struct _tdm_thread_cb_base {
515 tdm_thread_cb_type type;
522 struct _tdm_thread_cb_display_output_create {
523 tdm_thread_cb_base base;
527 struct _tdm_thread_cb_output_destroy {
528 tdm_thread_cb_base base;
531 struct _tdm_thread_cb_output_vblank {
532 tdm_thread_cb_base base;
533 unsigned int sequence;
535 unsigned int tv_usec;
538 struct _tdm_thread_cb_output_status {
539 tdm_thread_cb_base base;
540 tdm_output_conn_status status;
543 struct _tdm_thread_cb_output_dpms {
544 tdm_thread_cb_base base;
545 tdm_output_dpms dpms;
548 struct _tdm_thread_cb_pp_done {
549 tdm_thread_cb_base base;
554 struct _tdm_thread_cb_capture_done {
555 tdm_thread_cb_base base;
556 tbm_surface_h buffer;
559 struct _tdm_thread_cb_vblank_sw {
560 tdm_thread_cb_base base;
563 struct _tdm_thread_cb_vblank_create {
564 tdm_thread_cb_base base;
568 struct argument_details {
577 #endif /* _TDM_PRIVATE_TYPES_H_ */