first draft
[platform/core/uifw/libtdm.git] / include / tdm_backend.h
1 /**************************************************************************
2
3 libtdm
4
5 Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
6
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>
13
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:
21
22 The above copyright notice and this permission notice (including the
23 next paragraph) shall be included in all copies or substantial portions
24 of the Software.
25
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.
33
34 **************************************************************************/
35
36 #ifndef _TDM_BACKEND_H_
37 #define _TDM_BACKEND_H_
38
39 #include <tbm_surface.h>
40
41 #include "tdm_types.h"
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46
47 typedef void tdm_backend_data;
48
49 typedef struct _tdm_caps_output
50 {
51     tdm_output_conn_status status;
52     tdm_output_type type;
53     unsigned int type_id;
54
55     unsigned int mode_count;
56     tdm_output_mode **modes;
57
58     unsigned int prop_count;
59     tdm_prop *props;
60
61     unsigned int mmWidth;
62     unsigned int mmHeight;
63     unsigned int subpixel;
64
65     /* -1: not defined */
66     int min_w;
67     int min_h;
68     int max_w;
69     int max_h;
70     int preferred_align;
71 } tdm_caps_output;
72
73 typedef struct _tdm_caps_layer
74 {
75     tdm_layer_capability capabilities;
76     unsigned int zpos;  /* if VIDEO layer, zpos is -1 */
77
78     unsigned int format_count;
79     tbm_format *formats;
80
81     unsigned int prop_count;
82     tdm_prop *props;
83 } tdm_caps_layer;
84
85 typedef struct _tdm_caps_pp
86 {
87     tdm_pp_capability capabilities;
88
89     unsigned int format_count;
90     tbm_format *formats;
91
92     unsigned int prop_count;
93     tdm_prop *props;
94
95     /* -1: not defined */
96     int min_w;
97     int min_h;
98     int max_w;
99     int max_h;
100     int preferred_align;
101 } tdm_caps_pp;
102
103 typedef struct _tdm_caps_capture
104 {
105     tdm_capture_capability capabilities;
106
107     unsigned int format_count;
108     tbm_format *formats;
109
110     /* -1: not defined */
111     int min_w;
112     int min_h;
113     int max_w;
114     int max_h;
115     int preferred_align;
116 } tdm_caps_capture;
117
118 typedef struct _tdm_func_display
119 {
120     tdm_error    (*display_get_capabilitiy)(tdm_backend_data *bdata, tdm_display_capability *capabilities); /* init */
121     tdm_error    (*display_get_pp_capability)(tdm_backend_data *bdata, tdm_caps_pp *caps); /* init */
122     tdm_error    (*display_get_capture_capability)(tdm_backend_data *bdata, tdm_caps_capture *caps); /* init */
123     tdm_output **(*display_get_outputs)(tdm_backend_data *bdata, int *count, tdm_error *error); /* init */
124     tdm_error    (*display_get_fd)(tdm_backend_data *bdata, int *fd);
125     tdm_error    (*display_handle_events)(tdm_backend_data *bdata);
126     tdm_pp*      (*display_create_pp)(tdm_backend_data *bdata, tdm_error *error);
127
128     tdm_error    (*output_get_capability)(tdm_output *output, tdm_caps_output *caps); /* init */
129     tdm_layer  **(*output_get_layers)(tdm_output *output, int *count, tdm_error *error); /* init */
130     tdm_error    (*output_set_property)(tdm_output *output, unsigned int id, tdm_value value);
131     tdm_error    (*output_get_property)(tdm_output *output, unsigned int id, tdm_value *value);
132     tdm_error    (*output_wait_vblank)(tdm_output *output, int interval, int sync, void *user_data);
133     tdm_error    (*output_set_vblank_handler)(tdm_output *output, tdm_output_vblank_handler func);
134     tdm_error    (*output_commit)(tdm_output *output, int sync, void *user_data);
135     tdm_error    (*output_set_commit_handler)(tdm_output *output, tdm_output_commit_handler func);
136     tdm_error    (*output_set_dpms)(tdm_output *output, tdm_output_dpms dpms_value);
137     tdm_error    (*output_get_dpms)(tdm_output *output, tdm_output_dpms *dpms_value);
138     tdm_error    (*output_set_mode)(tdm_output *output, tdm_output_mode *mode);
139     tdm_error    (*output_get_mode)(tdm_output *output, const tdm_output_mode **mode);
140     tdm_capture *(*output_create_capture)(tdm_output *output, tdm_error *error);
141
142     tdm_error    (*layer_get_capability)(tdm_layer *layer, tdm_caps_layer *caps); /* init */
143     tdm_error    (*layer_set_property)(tdm_layer *layer, unsigned int id, tdm_value value);
144     tdm_error    (*layer_get_property)(tdm_layer *layer, unsigned int id, tdm_value *value);
145     tdm_error    (*layer_set_info)(tdm_layer *layer, tdm_info_layer *info);
146     tdm_error    (*layer_get_info)(tdm_layer *layer, tdm_info_layer *info);
147     tdm_error    (*layer_set_buffer)(tdm_layer *layer, tbm_surface_h buffer);
148     tdm_error    (*layer_unset_buffer)(tdm_layer *layer);
149     tdm_capture *(*layer_create_capture)(tdm_layer *layer, tdm_error *error);
150 } tdm_func_display;
151
152 typedef void (*tdm_pp_done_handler)(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst, void *user_data);
153
154 typedef struct _tdm_func_pp
155 {
156     void         (*pp_destroy)(tdm_pp *pp); /* init */
157     tdm_error    (*pp_set_property)(tdm_pp *pp, unsigned int id, tdm_value value);
158     tdm_error    (*pp_get_property)(tdm_pp *pp, unsigned int id, tdm_value *value);
159     tdm_error    (*pp_set_info)(tdm_pp *pp, tdm_info_pp *info);
160     tdm_error    (*pp_attach)(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst);
161     tdm_error    (*pp_commit)(tdm_pp *pp); /* init */
162     tdm_error    (*pp_set_done_handler)(tdm_pp *pp, tdm_pp_done_handler func, void *user_data);
163 } tdm_func_pp;
164
165 typedef void (*tdm_capture_done_handler)(tdm_capture *capture, tbm_surface_h buffer, void *user_data);
166
167 typedef struct _tdm_func_capture
168 {
169     void         (*capture_destroy)(tdm_capture *capture); /* init */
170     tdm_error    (*capture_set_info)(tdm_capture *capture, tdm_info_capture *info);
171     tdm_error    (*capture_attach)(tdm_capture *capture, tbm_surface_h buffer);
172     tdm_error    (*capture_commit)(tdm_capture *capture); /* init */
173     tdm_error    (*capture_set_done_handler)(tdm_capture *capture, tdm_capture_done_handler func, void *user_data);
174 } tdm_func_capture;
175
176 #define TDM_BACKEND_MINOR_VERSION_MASK  0x0000FFFF
177 #define TDM_BACKEND_MAJOR_VERSION_MASK  0xFFFF0000
178 #define TDM_BACKEND_GET_ABI_MINOR(v)    ((v) & TDM_BACKEND_MINOR_VERSION_MASK)
179 #define TDM_BACKEND_GET_ABI_MAJOR(v)    (((v) & TDM_BACKEND_MAJOR_VERSION_MASK) >> 16)
180
181 #define SET_TDM_BACKEND_ABI_VERSION(major, minor) \
182         (((major) << 16) & TDM_BACKEND_MAJOR_VERSION_MASK) | \
183         ((major) & TDM_BACKEND_MINOR_VERSION_MASK)
184 #define TDM_BACKEND_ABI_VERSION     SET_TDM_BACKEND_ABI_VERSION(1, 1)
185
186 typedef struct _tdm_backend_module
187 {
188     const char *name;
189     const char *vendor;
190     unsigned long abi_version;
191
192     tdm_backend_data* (*init)(tdm_display *dpy, tdm_error *error);
193     void (*deinit)(tdm_backend_data *bdata);
194 } tdm_backend_module;
195
196 tdm_error tdm_backend_register_func_display(tdm_display *dpy, tdm_func_display *func_display);
197 tdm_error tdm_backend_register_func_pp(tdm_display *dpy, tdm_func_pp *func_pp);
198 tdm_error tdm_backend_register_func_capture(tdm_display *dpy, tdm_func_capture *func_capture);
199
200 #ifdef __cplusplus
201 }
202 #endif
203
204 #endif /* _TDM_BACKEND_H_ */