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_VBLANK = (1 << 0),
72 TDM_TTRACE_CLIENT = (1 << 1),
73 TDM_TTRACE_LAYER = (1 << 2),
74 TDM_TTRACE_PP = (1 << 3),
75 TDM_TTRACE_CAPTURE = (1 << 4),
79 TDM_CAPTURE_TARGET_OUTPUT,
80 TDM_CAPTURE_TARGET_LAYER,
84 TDM_DUMP_FLAG_LAYER = (1 << 0),
85 TDM_DUMP_FLAG_PP = (1 << 1),
86 TDM_DUMP_FLAG_CAPTURE = (1 << 2),
87 TDM_DUMP_FLAG_WINDOW = (1 << 3),
92 TDM_COMMIT_TYPE_OUTPUT,
93 TDM_COMMIT_TYPE_LAYER,
96 typedef struct _tdm_private_display tdm_private_display;
97 typedef struct _tdm_private_output tdm_private_output;
98 typedef struct _tdm_private_layer tdm_private_layer;
99 typedef struct _tdm_private_hwc_window tdm_private_hwc_window;
100 typedef struct _tdm_private_pp tdm_private_pp;
101 typedef struct _tdm_private_capture tdm_private_capture;
102 typedef struct _tdm_private_loop tdm_private_loop;
103 typedef struct _tdm_private_server tdm_private_server;
104 typedef struct _tdm_private_thread tdm_private_thread;
105 typedef struct _tdm_private_vblank_handler tdm_private_vblank_handler;
106 typedef struct _tdm_private_output_commit_handler tdm_private_output_commit_handler;
107 typedef struct _tdm_private_layer_commit_handler tdm_private_layer_commit_handler;
108 typedef struct _tdm_private_change_handler tdm_private_change_handler;
109 typedef struct _tdm_private_layer_buffer tdm_private_layer_buffer;
111 struct _tdm_private_display {
112 pthread_mutex_t lock;
113 unsigned int init_count;
115 /* backend module info */
117 tdm_backend_module *module_data;
118 tdm_backend_data *bdata;
124 /* backend function */
125 tdm_display_capability capabilities;
126 tdm_func_display func_display;
127 tdm_func_output func_output;
128 tdm_func_layer func_layer;
129 tdm_func_hwc_window func_hwc_window;
131 tdm_func_capture func_capture;
133 /* backend capability */
134 tdm_caps_display caps_display;
136 tdm_caps_capture caps_capture;
138 /* output, pp list */
139 struct list_head output_list;
140 struct list_head pp_list;
141 struct list_head capture_list;
145 /* for event handling */
146 tdm_private_loop *private_loop;
149 tdm_output **outputs;
154 struct _tdm_private_output {
155 struct list_head link;
160 tdm_private_display *private_display;
162 tdm_caps_output caps;
163 tdm_output *output_backend;
166 tdm_output_dpms current_dpms_value;
167 unsigned int waiting_dpms_change;
168 const tdm_output_mode *current_mode;
170 int regist_vblank_cb;
171 int regist_commit_cb;
172 int regist_change_cb;
175 struct list_head layer_list;
176 struct list_head hwc_window_list;
177 struct list_head capture_list;
178 struct list_head vblank_handler_list;
179 struct list_head output_commit_handler_list;
181 /* for layer commit */
182 struct list_head layer_commit_handler_list;
183 struct list_head pending_commit_handler_list;
185 int layer_waiting_vblank;
187 /* seperate list for multi-thread*/
188 struct list_head change_handler_list_main;
189 struct list_head change_handler_list_sub;
193 /* TODO: temp solution for handling DPMS things in sub-htread */
194 tdm_event_loop_source *dpms_changed_timer;
197 /* look at the tdm_output_set_need_revalidate_handler() declaration for the details */
198 tdm_output_need_validate_handler hndl;
200 tdm_event_loop_source *event_source;
203 /* calling a output commit per a vblank */
204 int commit_per_vblank;
205 tdm_commit_type commit_type;
207 /* for ttrace vblank */
208 tdm_vblank *ttrace_vblank;
211 struct _tdm_private_layer {
212 struct list_head link;
216 tdm_private_display *private_display;
217 tdm_private_output *private_output;
220 tdm_layer *layer_backend;
222 /* pending data until committed */
223 unsigned int pending_info_changed;
224 tdm_info_layer pending_info;
225 unsigned int pending_buffer_changed;
226 tbm_surface_h pending_buffer;
228 /* When a buffer is set to a layer, it will be stored to waiting_buffer.
229 * And when a layer is committed, it will be moved to committed_buffer.
230 * Finally when a commit handler is called, it will be moved to showing_buffer.
232 tdm_private_layer_buffer *waiting_buffer;
233 tdm_private_layer_buffer *committed_buffer; /* for output_commit */
234 tdm_private_layer_buffer *showing_buffer;
235 tbm_surface_queue_h buffer_queue;
237 struct list_head capture_list;
240 unsigned int committing;
243 unsigned int fps_count;
246 struct _tdm_private_hwc_window {
247 struct list_head link;
252 tdm_private_display *private_display;
253 tdm_private_output *private_output;
255 tdm_hwc_window *hwc_window_backend;
258 struct _tdm_private_pp {
259 struct list_head link;
263 tdm_private_display *private_display;
267 struct list_head pending_buffer_list;
268 struct list_head buffer_list;
273 tdm_pp_done_handler done_func;
274 void *done_user_data;
277 struct _tdm_private_capture {
278 struct list_head link;
279 struct list_head display_link;
283 tdm_capture_target target;
285 tdm_private_display *private_display;
286 tdm_private_output *private_output;
287 tdm_private_layer *private_layer;
289 tdm_capture *capture_backend;
291 struct list_head pending_buffer_list;
292 struct list_head buffer_list;
294 tdm_info_capture info;
297 tdm_capture_done_handler done_func;
298 void *done_user_data;
302 * Note that we don't need to (un)lock mutex to use this structure. If there is
303 * no TDM thread, all TDM resources are protected by private_display's mutex.
304 * If there is a TDM thread, this struct will be used only in a TDM thread.
305 * So, we don't need to protect this structure by mutex. Not thread-safe.
307 struct _tdm_private_loop {
308 /* TDM uses wl_event_loop to handle various event sources including the TDM
311 struct wl_display *wl_display;
312 struct wl_event_loop *wl_loop;
315 tdm_event_loop_source *backend_source;
317 /* In event loop, all resources are accessed by this dpy.
319 * - DO NOT include other private structure in this structure because this
320 * struct is not protected by mutex.
324 /* for handling TDM client requests */
325 tdm_private_server *private_server;
327 /* To have a TDM event thread. If TDM_THREAD enviroment variable is not set
328 * private_thread is NULL.
330 tdm_private_thread *private_thread;
333 struct _tdm_private_vblank_handler {
334 struct list_head link;
336 tdm_private_output *private_output;
339 tdm_output_vblank_handler func;
345 struct _tdm_private_output_commit_handler {
346 struct list_head link;
348 tdm_private_output *private_output;
349 tdm_output_commit_handler func;
355 struct _tdm_private_layer_commit_handler {
356 struct list_head link;
358 tdm_private_layer *private_layer;
359 tdm_layer_commit_handler func;
362 tdm_private_layer_buffer *committed_buffer; /* for layer_commit */
365 struct _tdm_private_change_handler {
366 struct list_head link;
368 tdm_private_output *private_output;
369 tdm_output_change_handler func;
375 struct _tdm_private_layer_buffer {
376 tbm_surface_h buffer;
377 struct list_head link;
380 typedef struct _tdm_buffer_info {
381 tbm_surface_h buffer;
383 /* ref_count for backend */
384 int backend_ref_count;
386 struct list_head release_funcs;
387 struct list_head destroy_funcs;
389 struct list_head *list;
390 struct list_head link;
393 typedef struct _tdm_pp_private_buffer {
396 struct list_head link;
397 struct list_head commit_link;
398 } tdm_pp_private_buffer;
400 typedef struct _tdm_capture_private_buffer {
401 tbm_surface_h buffer;
402 struct list_head link;
403 struct list_head commit_link;
404 } tdm_capture_private_buffer;
408 TDM_THREAD_CB_OUTPUT_COMMIT,
409 TDM_THREAD_CB_OUTPUT_VBLANK,
410 TDM_THREAD_CB_OUTPUT_STATUS,
411 TDM_THREAD_CB_OUTPUT_DPMS,
412 TDM_THREAD_CB_PP_DONE,
413 TDM_THREAD_CB_CAPTURE_DONE,
414 TDM_THREAD_CB_VBLANK_SW,
415 TDM_THREAD_CB_VBLANK_CREATE,
416 TDM_THREAD_CB_NEED_VALIDATE,
417 } tdm_thread_cb_type;
419 typedef struct _tdm_thread_cb_base tdm_thread_cb_base;
420 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_commit;
421 typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_vblank;
422 typedef struct _tdm_thread_cb_output_status tdm_thread_cb_output_status;
423 typedef struct _tdm_thread_cb_output_dpms tdm_thread_cb_output_dpms;
424 typedef struct _tdm_thread_cb_pp_done tdm_thread_cb_pp_done;
425 typedef struct _tdm_thread_cb_capture_done tdm_thread_cb_capture_done;
426 typedef struct _tdm_thread_cb_vblank_sw tdm_thread_cb_vblank_sw;
427 typedef struct _tdm_thread_cb_vblank_create tdm_thread_cb_vblank_create;
428 typedef struct _tdm_thread_cb_need_validate tdm_thread_cb_need_validate;
430 struct _tdm_thread_cb_base {
431 tdm_thread_cb_type type;
435 struct _tdm_thread_cb_output_vblank {
436 tdm_thread_cb_base base;
438 unsigned int sequence;
440 unsigned int tv_usec;
444 struct _tdm_thread_cb_output_status {
445 tdm_thread_cb_base base;
447 tdm_output_conn_status status;
451 struct _tdm_thread_cb_output_dpms {
452 tdm_thread_cb_base base;
454 tdm_output_dpms dpms;
458 struct _tdm_thread_cb_pp_done {
459 tdm_thread_cb_base base;
466 struct _tdm_thread_cb_capture_done {
467 tdm_thread_cb_base base;
468 double capture_stamp;
469 tbm_surface_h buffer;
473 struct _tdm_thread_cb_vblank_sw {
474 tdm_thread_cb_base base;
478 struct _tdm_thread_cb_vblank_create {
479 tdm_thread_cb_base base;
483 struct _tdm_thread_cb_need_validate {
484 tdm_thread_cb_base base;
485 tdm_private_output *o;
488 struct argument_details {
497 #endif /* _TDM_PRIVATE_TYPES_H_ */