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_output_hwc_target_buffer_window_commit_handler tdm_private_output_hwc_target_buffer_commit_handler;
110 typedef struct _tdm_private_layer_commit_handler tdm_private_layer_commit_handler;
111 typedef struct _tdm_private_hwc_window_commit_handler tdm_private_hwc_window_commit_handler;
112 typedef struct _tdm_private_change_handler tdm_private_change_handler;
113 typedef struct _tdm_private_layer_buffer tdm_private_layer_buffer;
115 struct _tdm_private_display {
116 pthread_mutex_t lock;
117 unsigned int init_count;
119 /* backend module info */
121 tdm_backend_module *module_data;
122 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_window func_hwc_window;
135 tdm_func_capture func_capture;
137 /* backend capability */
138 tdm_caps_display caps_display;
140 tdm_caps_capture caps_capture;
142 /* output, pp list */
143 struct list_head output_list;
144 struct list_head pp_list;
145 struct list_head capture_list;
149 /* for event handling */
150 tdm_private_loop *private_loop;
153 tdm_output **outputs;
158 struct _tdm_private_output {
159 struct list_head link;
164 tdm_private_display *private_display;
166 tdm_caps_output caps;
167 tdm_output *output_backend;
170 tdm_output_dpms current_dpms_value;
171 unsigned int waiting_dpms_change;
172 const tdm_output_mode *current_mode;
174 int regist_vblank_cb;
175 int regist_commit_cb;
176 int regist_change_cb;
179 struct list_head layer_list;
180 struct list_head hwc_window_list;
181 struct list_head capture_list;
182 struct list_head vblank_handler_list;
183 struct list_head output_commit_handler_list;
185 /* for layer commit */
186 struct list_head layer_commit_handler_list;
187 struct list_head pending_commit_handler_list;
189 int layer_waiting_vblank;
191 tdm_event_loop_source *vblank_timeout_timer;
193 /* seperate list for multi-thread*/
194 struct list_head change_handler_list_main;
195 struct list_head change_handler_list_sub;
199 /* TODO: temp solution for handling DPMS things in sub-htread */
200 tdm_event_loop_source *dpms_changed_timer;
203 /* look at the tdm_output_set_need_revalidate_handler() declaration for the details */
204 tdm_output_need_validate_handler hndl;
206 tdm_event_loop_source *event_source;
209 /* calling a output commit per a vblank */
210 int commit_per_vblank;
211 tdm_commit_type commit_type;
213 /* for ttrace vblank */
214 tdm_vblank *ttrace_vblank;
217 struct _tdm_private_layer {
218 struct list_head link;
222 tdm_private_display *private_display;
223 tdm_private_output *private_output;
226 tdm_layer *layer_backend;
228 /* pending data until committed */
229 unsigned int pending_info_changed;
230 tdm_info_layer pending_info;
231 unsigned int pending_buffer_changed;
232 tbm_surface_h pending_buffer;
234 /* When a buffer is set to a layer, it will be stored to waiting_buffer.
235 * And when a layer is committed, it will be moved to committed_buffer.
236 * Finally when a commit handler is called, it will be moved to showing_buffer.
238 tdm_private_layer_buffer *waiting_buffer;
239 tdm_private_layer_buffer *committed_buffer; /* for output_commit */
240 tdm_private_layer_buffer *showing_buffer;
241 tbm_surface_queue_h buffer_queue;
243 struct list_head capture_list;
246 unsigned int committing;
249 unsigned int fps_count;
252 struct _tdm_private_hwc_window {
253 struct list_head link;
257 tdm_private_display *private_display;
258 tdm_private_output *private_output;
261 tdm_hwc_window_info info;
262 tbm_surface_h buffer;
264 tdm_hwc_window *hwc_window_backend;
267 struct _tdm_private_pp {
268 struct list_head link;
272 tdm_private_display *private_display;
276 struct list_head pending_buffer_list;
277 struct list_head buffer_list;
282 tdm_pp_done_handler done_func;
283 void *done_user_data;
286 struct _tdm_private_capture {
287 struct list_head link;
288 struct list_head display_link;
292 tdm_capture_target target;
294 tdm_private_display *private_display;
295 tdm_private_output *private_output;
296 tdm_private_layer *private_layer;
298 tdm_capture *capture_backend;
300 struct list_head pending_buffer_list;
301 struct list_head buffer_list;
303 tdm_info_capture info;
306 tdm_capture_done_handler done_func;
307 void *done_user_data;
311 * Note that we don't need to (un)lock mutex to use this structure. If there is
312 * no TDM thread, all TDM resources are protected by private_display's mutex.
313 * If there is a TDM thread, this struct will be used only in a TDM thread.
314 * So, we don't need to protect this structure by mutex. Not thread-safe.
316 struct _tdm_private_loop {
317 /* TDM uses wl_event_loop to handle various event sources including the TDM
320 struct wl_display *wl_display;
321 struct wl_event_loop *wl_loop;
324 tdm_event_loop_source *backend_source;
326 /* In event loop, all resources are accessed by this dpy.
328 * - DO NOT include other private structure in this structure because this
329 * struct is not protected by mutex.
333 /* for handling TDM client requests */
334 tdm_private_server *private_server;
336 /* To have a TDM event thread. If TDM_THREAD enviroment variable is not set
337 * private_thread is NULL.
339 tdm_private_thread *private_thread;
342 struct _tdm_private_vblank_handler {
343 struct list_head link;
345 tdm_private_output *private_output;
348 tdm_output_vblank_handler func;
351 unsigned int sent_to_frontend;
356 struct _tdm_private_output_commit_handler {
357 struct list_head link;
359 tdm_private_output *private_output;
360 tdm_output_commit_handler func;
366 struct _tdm_private_output_hwc_target_buffer_window_commit_handler {
367 tdm_private_output *private_output;
368 tdm_output_hwc_target_buffer_commit_handler func;
372 struct _tdm_private_layer_commit_handler {
373 struct list_head link;
375 tdm_private_layer *private_layer;
376 tdm_layer_commit_handler func;
379 tdm_private_layer_buffer *committed_buffer; /* for layer_commit */
382 struct _tdm_private_hwc_window_commit_handler {
383 tdm_private_hwc_window *private_hwc_window;
384 tdm_hwc_window_commit_handler func;
388 struct _tdm_private_change_handler {
389 struct list_head link;
391 tdm_private_output *private_output;
392 tdm_output_change_handler func;
398 struct _tdm_private_layer_buffer {
399 tbm_surface_h buffer;
400 struct list_head link;
403 typedef struct _tdm_buffer_info {
404 tbm_surface_h buffer;
406 /* ref_count for backend */
407 int backend_ref_count;
409 struct list_head release_funcs;
410 struct list_head destroy_funcs;
412 struct list_head *list;
413 struct list_head link;
416 typedef struct _tdm_pp_private_buffer {
419 struct list_head link;
420 struct list_head commit_link;
421 } tdm_pp_private_buffer;
423 typedef struct _tdm_capture_private_buffer {
424 tbm_surface_h buffer;
425 struct list_head link;
426 struct list_head commit_link;
427 } tdm_capture_private_buffer;
431 TDM_THREAD_CB_OUTPUT_COMMIT,
432 TDM_THREAD_CB_OUTPUT_VBLANK,
433 TDM_THREAD_CB_OUTPUT_STATUS,
434 TDM_THREAD_CB_OUTPUT_DPMS,
435 TDM_THREAD_CB_PP_DONE,
436 TDM_THREAD_CB_CAPTURE_DONE,
437 TDM_THREAD_CB_VBLANK_SW,
438 TDM_THREAD_CB_VBLANK_CREATE,
439 TDM_THREAD_CB_NEED_VALIDATE,
440 } tdm_thread_cb_type;
442 typedef struct _tdm_thread_cb_base tdm_thread_cb_base;
443 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_commit;
444 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_vblank;
445 typedef struct _tdm_thread_cb_output_status tdm_thread_cb_output_status;
446 typedef struct _tdm_thread_cb_output_dpms tdm_thread_cb_output_dpms;
447 typedef struct _tdm_thread_cb_pp_done tdm_thread_cb_pp_done;
448 typedef struct _tdm_thread_cb_capture_done tdm_thread_cb_capture_done;
449 typedef struct _tdm_thread_cb_vblank_sw tdm_thread_cb_vblank_sw;
450 typedef struct _tdm_thread_cb_vblank_create tdm_thread_cb_vblank_create;
451 typedef struct _tdm_thread_cb_need_validate tdm_thread_cb_need_validate;
453 struct _tdm_thread_cb_base {
454 tdm_thread_cb_type type;
458 struct _tdm_thread_cb_output_vblank {
459 tdm_thread_cb_base base;
461 unsigned int sequence;
463 unsigned int tv_usec;
467 struct _tdm_thread_cb_output_status {
468 tdm_thread_cb_base base;
470 tdm_output_conn_status status;
474 struct _tdm_thread_cb_output_dpms {
475 tdm_thread_cb_base base;
477 tdm_output_dpms dpms;
481 struct _tdm_thread_cb_pp_done {
482 tdm_thread_cb_base base;
489 struct _tdm_thread_cb_capture_done {
490 tdm_thread_cb_base base;
491 double capture_stamp;
492 tbm_surface_h buffer;
496 struct _tdm_thread_cb_vblank_sw {
497 tdm_thread_cb_base base;
501 struct _tdm_thread_cb_vblank_create {
502 tdm_thread_cb_base base;
506 struct _tdm_thread_cb_need_validate {
507 tdm_thread_cb_base base;
508 tdm_private_output *o;
511 struct argument_details {
520 #endif /* _TDM_PRIVATE_TYPES_H_ */