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 <sc1.lim@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_THREAD = (1 << 2),
64 TDM_DEBUG_SERVER = (1 << 3),
65 TDM_DEBUG_VBLANK = (1 << 4),
66 TDM_DEBUG_COMMIT = (1 << 5),
71 TDM_TTRACE_VSYNC = (1 << 0),
72 TDM_TTRACE_CLIENT_VBLANK = (1 << 1),
73 TDM_TTRACE_SERVER_VBLANK = (1 << 2),
74 TDM_TTRACE_VBLANK = (1 << 3),
75 TDM_TTRACE_LAYER = (1 << 4),
76 TDM_TTRACE_PP = (1 << 5),
77 TDM_TTRACE_CAPTURE = (1 << 6),
81 TDM_CAPTURE_TARGET_OUTPUT,
82 TDM_CAPTURE_TARGET_LAYER,
86 TDM_DUMP_FLAG_LAYER = (1 << 0),
87 TDM_DUMP_FLAG_PP = (1 << 1),
88 TDM_DUMP_FLAG_CAPTURE = (1 << 2),
89 TDM_DUMP_FLAG_WINDOW = (1 << 3),
94 TDM_COMMIT_TYPE_OUTPUT,
95 TDM_COMMIT_TYPE_LAYER,
98 typedef struct _tdm_private_display tdm_private_display;
99 typedef struct _tdm_private_output tdm_private_output;
100 typedef struct _tdm_private_layer tdm_private_layer;
101 typedef struct _tdm_private_hwc_window tdm_private_hwc_window;
102 typedef struct _tdm_private_pp tdm_private_pp;
103 typedef struct _tdm_private_capture tdm_private_capture;
104 typedef struct _tdm_private_loop tdm_private_loop;
105 typedef struct _tdm_private_server tdm_private_server;
106 typedef struct _tdm_private_thread tdm_private_thread;
107 typedef struct _tdm_private_vblank_handler tdm_private_vblank_handler;
108 typedef struct _tdm_private_output_commit_handler tdm_private_output_commit_handler;
109 typedef struct _tdm_private_layer_commit_handler tdm_private_layer_commit_handler;
110 typedef struct _tdm_private_change_handler tdm_private_change_handler;
111 typedef struct _tdm_private_layer_buffer tdm_private_layer_buffer;
113 struct _tdm_private_display {
114 pthread_mutex_t lock;
115 unsigned int init_count;
117 /* backend module info */
119 tdm_backend_module *module_data;
120 tdm_backend_data *bdata;
126 /* backend function */
127 tdm_display_capability capabilities;
128 tdm_func_display func_display;
129 tdm_func_output func_output;
130 tdm_func_layer func_layer;
131 tdm_func_hwc_window func_hwc_window;
133 tdm_func_capture func_capture;
135 /* backend capability */
136 tdm_caps_display caps_display;
138 tdm_caps_capture caps_capture;
140 /* output, pp list */
141 struct list_head output_list;
142 struct list_head pp_list;
143 struct list_head capture_list;
147 /* for event handling */
148 tdm_private_loop *private_loop;
151 tdm_output **outputs;
156 struct _tdm_private_output {
157 struct list_head link;
162 tdm_private_display *private_display;
164 tdm_caps_output caps;
165 tdm_output *output_backend;
168 tdm_output_dpms current_dpms_value;
169 unsigned int waiting_dpms_change;
170 const tdm_output_mode *current_mode;
172 int regist_vblank_cb;
173 int regist_commit_cb;
174 int regist_change_cb;
177 struct list_head layer_list;
178 struct list_head hwc_window_list;
179 struct list_head capture_list;
180 struct list_head vblank_handler_list;
181 struct list_head output_commit_handler_list;
183 /* for layer commit */
184 struct list_head layer_commit_handler_list;
185 struct list_head pending_commit_handler_list;
187 int layer_waiting_vblank;
189 tdm_event_loop_source *vblank_timeout_timer;
191 /* seperate list for multi-thread*/
192 struct list_head change_handler_list_main;
193 struct list_head change_handler_list_sub;
197 /* TODO: temp solution for handling DPMS things in sub-htread */
198 tdm_event_loop_source *dpms_changed_timer;
201 /* look at the tdm_output_set_need_revalidate_handler() declaration for the details */
202 tdm_output_need_validate_handler hndl;
204 tdm_event_loop_source *event_source;
207 /* calling a output commit per a vblank */
208 int commit_per_vblank;
209 tdm_commit_type commit_type;
211 /* for ttrace vblank */
212 tdm_vblank *ttrace_vblank;
215 struct _tdm_private_layer {
216 struct list_head link;
220 tdm_private_display *private_display;
221 tdm_private_output *private_output;
224 tdm_layer *layer_backend;
226 /* pending data until committed */
227 unsigned int pending_info_changed;
228 tdm_info_layer pending_info;
229 unsigned int pending_buffer_changed;
230 tbm_surface_h pending_buffer;
232 /* When a buffer is set to a layer, it will be stored to waiting_buffer.
233 * And when a layer is committed, it will be moved to committed_buffer.
234 * Finally when a commit handler is called, it will be moved to showing_buffer.
236 tdm_private_layer_buffer *waiting_buffer;
237 tdm_private_layer_buffer *committed_buffer; /* for output_commit */
238 tdm_private_layer_buffer *showing_buffer;
239 tbm_surface_queue_h buffer_queue;
241 struct list_head capture_list;
244 unsigned int committing;
247 unsigned int fps_count;
250 struct _tdm_private_hwc_window {
251 struct list_head link;
256 tdm_private_display *private_display;
257 tdm_private_output *private_output;
259 tdm_hwc_window *hwc_window_backend;
262 struct _tdm_private_pp {
263 struct list_head link;
267 tdm_private_display *private_display;
271 struct list_head pending_buffer_list;
272 struct list_head buffer_list;
277 tdm_pp_done_handler done_func;
278 void *done_user_data;
281 struct _tdm_private_capture {
282 struct list_head link;
283 struct list_head display_link;
287 tdm_capture_target target;
289 tdm_private_display *private_display;
290 tdm_private_output *private_output;
291 tdm_private_layer *private_layer;
293 tdm_capture *capture_backend;
295 struct list_head pending_buffer_list;
296 struct list_head buffer_list;
298 tdm_info_capture info;
301 tdm_capture_done_handler done_func;
302 void *done_user_data;
306 * Note that we don't need to (un)lock mutex to use this structure. If there is
307 * no TDM thread, all TDM resources are protected by private_display's mutex.
308 * If there is a TDM thread, this struct will be used only in a TDM thread.
309 * So, we don't need to protect this structure by mutex. Not thread-safe.
311 struct _tdm_private_loop {
312 /* TDM uses wl_event_loop to handle various event sources including the TDM
315 struct wl_display *wl_display;
316 struct wl_event_loop *wl_loop;
319 tdm_event_loop_source *backend_source;
321 /* In event loop, all resources are accessed by this dpy.
323 * - DO NOT include other private structure in this structure because this
324 * struct is not protected by mutex.
328 /* for handling TDM client requests */
329 tdm_private_server *private_server;
331 /* To have a TDM event thread. If TDM_THREAD enviroment variable is not set
332 * private_thread is NULL.
334 tdm_private_thread *private_thread;
337 struct _tdm_private_vblank_handler {
338 struct list_head link;
340 tdm_private_output *private_output;
343 tdm_output_vblank_handler func;
346 unsigned int sent_to_frontend;
351 struct _tdm_private_output_commit_handler {
352 struct list_head link;
354 tdm_private_output *private_output;
355 tdm_output_commit_handler func;
361 struct _tdm_private_layer_commit_handler {
362 struct list_head link;
364 tdm_private_layer *private_layer;
365 tdm_layer_commit_handler func;
368 tdm_private_layer_buffer *committed_buffer; /* for layer_commit */
371 struct _tdm_private_change_handler {
372 struct list_head link;
374 tdm_private_output *private_output;
375 tdm_output_change_handler func;
381 struct _tdm_private_layer_buffer {
382 tbm_surface_h buffer;
383 struct list_head link;
386 typedef struct _tdm_buffer_info {
387 tbm_surface_h buffer;
389 /* ref_count for backend */
390 int backend_ref_count;
392 struct list_head release_funcs;
393 struct list_head destroy_funcs;
395 struct list_head *list;
396 struct list_head link;
399 typedef struct _tdm_pp_private_buffer {
402 struct list_head link;
403 struct list_head commit_link;
404 } tdm_pp_private_buffer;
406 typedef struct _tdm_capture_private_buffer {
407 tbm_surface_h buffer;
408 struct list_head link;
409 struct list_head commit_link;
410 } tdm_capture_private_buffer;
414 TDM_THREAD_CB_OUTPUT_COMMIT,
415 TDM_THREAD_CB_OUTPUT_VBLANK,
416 TDM_THREAD_CB_OUTPUT_STATUS,
417 TDM_THREAD_CB_OUTPUT_DPMS,
418 TDM_THREAD_CB_PP_DONE,
419 TDM_THREAD_CB_CAPTURE_DONE,
420 TDM_THREAD_CB_VBLANK_SW,
421 TDM_THREAD_CB_VBLANK_CREATE,
422 TDM_THREAD_CB_NEED_VALIDATE,
423 } tdm_thread_cb_type;
425 typedef struct _tdm_thread_cb_base tdm_thread_cb_base;
426 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_commit;
427 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_vblank;
428 typedef struct _tdm_thread_cb_output_status tdm_thread_cb_output_status;
429 typedef struct _tdm_thread_cb_output_dpms tdm_thread_cb_output_dpms;
430 typedef struct _tdm_thread_cb_pp_done tdm_thread_cb_pp_done;
431 typedef struct _tdm_thread_cb_capture_done tdm_thread_cb_capture_done;
432 typedef struct _tdm_thread_cb_vblank_sw tdm_thread_cb_vblank_sw;
433 typedef struct _tdm_thread_cb_vblank_create tdm_thread_cb_vblank_create;
434 typedef struct _tdm_thread_cb_need_validate tdm_thread_cb_need_validate;
436 struct _tdm_thread_cb_base {
437 tdm_thread_cb_type type;
441 struct _tdm_thread_cb_output_vblank {
442 tdm_thread_cb_base base;
444 unsigned int sequence;
446 unsigned int tv_usec;
450 struct _tdm_thread_cb_output_status {
451 tdm_thread_cb_base base;
453 tdm_output_conn_status status;
457 struct _tdm_thread_cb_output_dpms {
458 tdm_thread_cb_base base;
460 tdm_output_dpms dpms;
464 struct _tdm_thread_cb_pp_done {
465 tdm_thread_cb_base base;
472 struct _tdm_thread_cb_capture_done {
473 tdm_thread_cb_base base;
474 double capture_stamp;
475 tbm_surface_h buffer;
479 struct _tdm_thread_cb_vblank_sw {
480 tdm_thread_cb_base base;
484 struct _tdm_thread_cb_vblank_create {
485 tdm_thread_cb_base base;
489 struct _tdm_thread_cb_need_validate {
490 tdm_thread_cb_base base;
491 tdm_private_output *o;
494 struct argument_details {
503 #endif /* _TDM_PRIVATE_TYPES_H_ */