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_change_handler tdm_private_output_change_handler;
111 typedef struct _tdm_private_output_commit_handler tdm_private_output_commit_handler;
112 typedef struct _tdm_private_output_vblank_handler tdm_private_output_vblank_handler;
113 typedef struct _tdm_private_layer_commit_handler tdm_private_layer_commit_handler;
114 typedef struct _tdm_private_hwc_commit_handler tdm_private_hwc_commit_handler;
116 typedef struct _tdm_private_layer_buffer tdm_private_layer_buffer;
118 struct _tdm_private_module {
119 struct list_head link;
121 tdm_private_display *private_display;
123 /* backend module info */
125 tdm_backend_module *module_data;
126 tdm_backend_data *bdata;
128 /* backend function */
129 tdm_display_capability capabilities;
130 tdm_func_display func_display;
131 tdm_func_output func_output;
132 tdm_func_layer func_layer;
133 tdm_func_hwc func_hwc;
134 tdm_func_hwc_window func_hwc_window;
136 tdm_func_capture func_capture;
138 /* backend capability */
139 tdm_caps_display caps_display;
141 tdm_caps_capture caps_capture;
143 /* output, pp list */
144 struct list_head output_list;
145 struct list_head pp_list;
146 struct list_head capture_list;
148 /* backend output objects. allocated in backend. freed in frontend. ordered */
149 tdm_output **outputs;
152 tdm_event_loop_source *event_source;
155 struct _tdm_private_display {
156 pthread_mutex_t lock;
157 unsigned int init_count;
165 struct list_head module_list;
166 tdm_private_module *current_module; //setted only when loading
167 tdm_private_module *pp_module; //pp-support backend
168 tdm_private_module *capture_module; //TODO: remove later
170 /* for event handling */
171 tdm_private_loop *private_loop;
176 struct _tdm_private_output {
177 struct list_head link;
179 tdm_private_module *private_module;
184 tdm_private_display *private_display;
186 tdm_caps_output caps;
187 tdm_output *output_backend;
190 tdm_output_dpms current_dpms_value;
191 unsigned int waiting_dpms_change;
192 const tdm_output_mode *current_mode;
194 int regist_vblank_cb;
195 int regist_commit_cb;
196 int regist_change_cb;
199 struct list_head layer_list;
200 struct list_head capture_list;
201 struct list_head vblank_handler_list;
202 struct list_head output_commit_handler_list;
204 /* for layer commit */
205 struct list_head layer_commit_handler_list;
206 struct list_head pending_commit_handler_list;
208 int layer_waiting_vblank;
210 tdm_event_loop_source *vblank_timeout_timer;
211 unsigned int vblank_timeout_timer_expired;
213 struct list_head change_handler_list;
217 tdm_info_layer target_buffer_info; /* layer_info for the target_buffer */
219 /* calling a output commit per a vblank */
220 int commit_per_vblank;
221 tdm_commit_type commit_type;
223 /* for ttrace vblank */
224 tdm_vblank *ttrace_vblank;
227 int need_set_target_info;
228 tdm_private_hwc *private_hwc;
231 struct _tdm_private_layer {
232 struct list_head link;
234 tdm_private_module *private_module;
238 tdm_private_display *private_display;
239 tdm_private_output *private_output;
242 tdm_layer *layer_backend;
244 /* pending data until committed */
245 unsigned int pending_info_changed;
246 tdm_info_layer pending_info;
247 unsigned int pending_buffer_changed;
248 tbm_surface_h pending_buffer;
250 /* When a buffer is set to a layer, it will be stored to waiting_buffer.
251 * And when a layer is committed, it will be moved to committed_buffer.
252 * Finally when a commit handler is called, it will be moved to showing_buffer.
254 tdm_private_layer_buffer *waiting_buffer;
255 tdm_private_layer_buffer *committed_buffer; /* for output_commit */
256 tdm_private_layer_buffer *showing_buffer;
257 tbm_surface_queue_h buffer_queue;
259 struct list_head capture_list;
262 unsigned int committing;
265 unsigned int fps_count;
268 struct _tdm_private_hwc {
269 struct list_head link;
271 tdm_private_module *private_module;
276 tdm_private_output *private_output;
278 struct list_head hwc_window_list;
279 struct list_head hwc_commit_handler_list;
281 int regist_commit_cb;
283 tdm_hwc *hwc_backend;
286 struct _tdm_private_hwc_window {
287 struct list_head link;
289 tdm_private_module *private_module;
291 tdm_private_hwc *private_hwc;
292 tdm_hwc_window *hwc_window_backend;
295 struct _tdm_private_pp {
296 struct list_head link;
298 tdm_private_module *private_module;
302 tdm_private_display *private_display;
306 struct list_head pending_buffer_list;
307 struct list_head buffer_list;
312 tdm_pp_done_handler done_func;
313 void *done_user_data;
316 struct _tdm_private_capture {
317 struct list_head link;
318 struct list_head display_link;
320 tdm_private_module *private_module;
324 tdm_capture_target target;
326 tdm_private_display *private_display;
327 tdm_private_output *private_output;
328 tdm_private_layer *private_layer;
330 tdm_capture *capture_module;
332 struct list_head pending_buffer_list;
333 struct list_head buffer_list;
335 tdm_info_capture info;
338 tdm_capture_done_handler done_func;
339 void *done_user_data;
343 * Note that we don't need to (un)lock mutex to use this structure. If there is
344 * no TDM thread, all TDM resources are protected by private_display's mutex.
345 * If there is a TDM thread, this struct will be used only in a TDM thread.
346 * So, we don't need to protect this structure by mutex. Not thread-safe.
348 struct _tdm_private_loop {
349 /* TDM uses wl_event_loop to handle various event sources including the TDM
352 struct wl_display *wl_display;
353 struct wl_event_loop *wl_loop;
355 /* In event loop, all resources are accessed by this dpy.
357 * - DO NOT include other private structure in this structure because this
358 * struct is not protected by mutex.
362 /* for handling TDM client requests */
363 tdm_private_server *private_server;
365 /* To have a TDM event thread. If TDM_THREAD enviroment variable is not set
366 * private_thread is NULL.
368 tdm_private_thread *private_thread;
370 struct list_head source_list;
373 struct _tdm_private_output_vblank_handler {
374 struct list_head link;
376 tdm_private_output *private_output;
379 tdm_output_vblank_handler func;
382 unsigned int sent_to_frontend;
387 struct _tdm_private_output_change_handler {
388 struct list_head link;
390 tdm_private_output *private_output;
391 tdm_output_change_handler func;
397 struct _tdm_private_output_commit_handler {
398 struct list_head link;
400 tdm_private_output *private_output;
401 tdm_output_commit_handler func;
407 struct _tdm_private_hwc_commit_handler {
408 struct list_head link;
410 tdm_private_hwc *private_hwc;
411 tdm_hwc_commit_handler func;
417 struct _tdm_private_layer_commit_handler {
418 struct list_head link;
420 tdm_private_layer *private_layer;
421 tdm_layer_commit_handler func;
424 tdm_private_layer_buffer *committed_buffer; /* for layer_commit */
427 struct _tdm_private_layer_buffer {
428 tbm_surface_h buffer;
429 struct list_head link;
432 typedef struct _tdm_buffer_info {
433 tbm_surface_h buffer;
435 /* ref_count for backend */
436 int backend_ref_count;
438 struct list_head release_funcs;
439 struct list_head destroy_funcs;
441 struct list_head *list;
442 struct list_head link;
445 typedef struct _tdm_pp_private_buffer {
448 struct list_head link;
449 struct list_head commit_link;
450 } tdm_pp_private_buffer;
452 typedef struct _tdm_capture_private_buffer {
453 tbm_surface_h buffer;
454 struct list_head link;
455 struct list_head commit_link;
456 } tdm_capture_private_buffer;
460 TDM_THREAD_CB_EXIT, /* special type to exit the tdm-thread */
461 TDM_THREAD_CB_OUTPUT_COMMIT,
462 TDM_THREAD_CB_OUTPUT_VBLANK,
463 TDM_THREAD_CB_OUTPUT_STATUS,
464 TDM_THREAD_CB_OUTPUT_DPMS,
465 TDM_THREAD_CB_PP_DONE,
466 TDM_THREAD_CB_CAPTURE_DONE,
467 TDM_THREAD_CB_VBLANK_SW,
468 TDM_THREAD_CB_VBLANK_CREATE,
469 TDM_THREAD_CB_HWC_COMMIT,
471 } tdm_thread_cb_type;
473 typedef struct _tdm_thread_cb_base tdm_thread_cb_base;
474 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_commit;
475 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_vblank;
476 typedef struct _tdm_thread_cb_output_dpms tdm_thread_cb_output_dpms;
477 typedef struct _tdm_thread_cb_output_status tdm_thread_cb_output_status;
478 typedef struct _tdm_thread_cb_pp_done tdm_thread_cb_pp_done;
479 typedef struct _tdm_thread_cb_capture_done tdm_thread_cb_capture_done;
480 typedef struct _tdm_thread_cb_vblank_sw tdm_thread_cb_vblank_sw;
481 typedef struct _tdm_thread_cb_vblank_create tdm_thread_cb_vblank_create;
482 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_hwc_commit;
484 struct _tdm_thread_cb_base {
485 tdm_thread_cb_type type;
492 struct _tdm_thread_cb_output_vblank {
493 tdm_thread_cb_base base;
494 unsigned int sequence;
496 unsigned int tv_usec;
499 struct _tdm_thread_cb_output_status {
500 tdm_thread_cb_base base;
501 tdm_output_conn_status status;
504 struct _tdm_thread_cb_output_dpms {
505 tdm_thread_cb_base base;
506 tdm_output_dpms dpms;
509 struct _tdm_thread_cb_pp_done {
510 tdm_thread_cb_base base;
515 struct _tdm_thread_cb_capture_done {
516 tdm_thread_cb_base base;
517 tbm_surface_h buffer;
520 struct _tdm_thread_cb_vblank_sw {
521 tdm_thread_cb_base base;
524 struct _tdm_thread_cb_vblank_create {
525 tdm_thread_cb_base base;
529 struct argument_details {
538 #endif /* _TDM_PRIVATE_TYPES_H_ */