add tdm_caps_display
[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_display
50 {
51     tdm_display_capability capabilities;
52
53     /* -1: not defined */
54     int max_layer_count;
55 } tdm_caps_display;
56
57 typedef struct _tdm_caps_output
58 {
59     tdm_output_conn_status status;
60     tdm_output_type type;
61     unsigned int type_id;
62
63     unsigned int mode_count;
64     tdm_output_mode **modes;
65
66     unsigned int prop_count;
67     tdm_prop *props;
68
69     unsigned int mmWidth;
70     unsigned int mmHeight;
71     unsigned int subpixel;
72
73     /* -1: not defined */
74     int min_w;
75     int min_h;
76     int max_w;
77     int max_h;
78     int preferred_align;
79 } tdm_caps_output;
80
81 typedef struct _tdm_caps_layer
82 {
83     tdm_layer_capability capabilities;
84     unsigned int zpos;  /* if VIDEO layer, zpos is -1 */
85
86     unsigned int format_count;
87     tbm_format *formats;
88
89     unsigned int prop_count;
90     tdm_prop *props;
91 } tdm_caps_layer;
92
93 typedef struct _tdm_caps_pp
94 {
95     tdm_pp_capability capabilities;
96
97     unsigned int format_count;
98     tbm_format *formats;
99
100     unsigned int prop_count;
101     tdm_prop *props;
102
103     /* -1: not defined */
104     int min_w;
105     int min_h;
106     int max_w;
107     int max_h;
108     int preferred_align;
109 } tdm_caps_pp;
110
111 typedef struct _tdm_caps_capture
112 {
113     tdm_capture_capability capabilities;
114
115     unsigned int format_count;
116     tbm_format *formats;
117
118     /* -1: not defined */
119     int min_w;
120     int min_h;
121     int max_w;
122     int max_h;
123     int preferred_align;
124 } tdm_caps_capture;
125
126 typedef struct _tdm_func_display
127 {
128     tdm_error    (*display_get_capabilitiy)(tdm_backend_data *bdata, tdm_caps_display *caps); /* init */
129     tdm_error    (*display_get_pp_capability)(tdm_backend_data *bdata, tdm_caps_pp *caps); /* init */
130     tdm_error    (*display_get_capture_capability)(tdm_backend_data *bdata, tdm_caps_capture *caps); /* init */
131     tdm_output **(*display_get_outputs)(tdm_backend_data *bdata, int *count, tdm_error *error); /* init */
132     tdm_error    (*display_get_fd)(tdm_backend_data *bdata, int *fd);
133     tdm_error    (*display_handle_events)(tdm_backend_data *bdata);
134     tdm_pp*      (*display_create_pp)(tdm_backend_data *bdata, tdm_error *error);
135
136     tdm_error    (*output_get_capability)(tdm_output *output, tdm_caps_output *caps); /* init */
137     tdm_layer  **(*output_get_layers)(tdm_output *output, int *count, tdm_error *error); /* init */
138     tdm_error    (*output_set_property)(tdm_output *output, unsigned int id, tdm_value value);
139     tdm_error    (*output_get_property)(tdm_output *output, unsigned int id, tdm_value *value);
140     tdm_error    (*output_wait_vblank)(tdm_output *output, int interval, int sync, void *user_data);
141     tdm_error    (*output_set_vblank_handler)(tdm_output *output, tdm_output_vblank_handler func);
142     tdm_error    (*output_commit)(tdm_output *output, int sync, void *user_data);
143     tdm_error    (*output_set_commit_handler)(tdm_output *output, tdm_output_commit_handler func);
144     tdm_error    (*output_set_dpms)(tdm_output *output, tdm_output_dpms dpms_value);
145     tdm_error    (*output_get_dpms)(tdm_output *output, tdm_output_dpms *dpms_value);
146     tdm_error    (*output_set_mode)(tdm_output *output, tdm_output_mode *mode);
147     tdm_error    (*output_get_mode)(tdm_output *output, const tdm_output_mode **mode);
148     tdm_capture *(*output_create_capture)(tdm_output *output, tdm_error *error);
149
150     tdm_error    (*layer_get_capability)(tdm_layer *layer, tdm_caps_layer *caps); /* init */
151     tdm_error    (*layer_set_property)(tdm_layer *layer, unsigned int id, tdm_value value);
152     tdm_error    (*layer_get_property)(tdm_layer *layer, unsigned int id, tdm_value *value);
153     tdm_error    (*layer_set_info)(tdm_layer *layer, tdm_info_layer *info);
154     tdm_error    (*layer_get_info)(tdm_layer *layer, tdm_info_layer *info);
155     tdm_error    (*layer_set_buffer)(tdm_layer *layer, tbm_surface_h buffer);
156     tdm_error    (*layer_unset_buffer)(tdm_layer *layer);
157     tdm_capture *(*layer_create_capture)(tdm_layer *layer, tdm_error *error);
158 } tdm_func_display;
159
160 typedef void (*tdm_pp_done_handler)(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst, void *user_data);
161
162 typedef struct _tdm_func_pp
163 {
164     void         (*pp_destroy)(tdm_pp *pp); /* init */
165     tdm_error    (*pp_set_property)(tdm_pp *pp, unsigned int id, tdm_value value);
166     tdm_error    (*pp_get_property)(tdm_pp *pp, unsigned int id, tdm_value *value);
167     tdm_error    (*pp_set_info)(tdm_pp *pp, tdm_info_pp *info);
168     tdm_error    (*pp_attach)(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst);
169     tdm_error    (*pp_commit)(tdm_pp *pp); /* init */
170     tdm_error    (*pp_set_done_handler)(tdm_pp *pp, tdm_pp_done_handler func, void *user_data);
171 } tdm_func_pp;
172
173 typedef void (*tdm_capture_done_handler)(tdm_capture *capture, tbm_surface_h buffer, void *user_data);
174
175 typedef struct _tdm_func_capture
176 {
177     void         (*capture_destroy)(tdm_capture *capture); /* init */
178     tdm_error    (*capture_set_info)(tdm_capture *capture, tdm_info_capture *info);
179     tdm_error    (*capture_attach)(tdm_capture *capture, tbm_surface_h buffer);
180     tdm_error    (*capture_commit)(tdm_capture *capture); /* init */
181     tdm_error    (*capture_set_done_handler)(tdm_capture *capture, tdm_capture_done_handler func, void *user_data);
182 } tdm_func_capture;
183
184 #define TDM_BACKEND_MINOR_VERSION_MASK  0x0000FFFF
185 #define TDM_BACKEND_MAJOR_VERSION_MASK  0xFFFF0000
186 #define TDM_BACKEND_GET_ABI_MINOR(v)    ((v) & TDM_BACKEND_MINOR_VERSION_MASK)
187 #define TDM_BACKEND_GET_ABI_MAJOR(v)    (((v) & TDM_BACKEND_MAJOR_VERSION_MASK) >> 16)
188
189 #define SET_TDM_BACKEND_ABI_VERSION(major, minor) \
190         (((major) << 16) & TDM_BACKEND_MAJOR_VERSION_MASK) | \
191         ((major) & TDM_BACKEND_MINOR_VERSION_MASK)
192 #define TDM_BACKEND_ABI_VERSION     SET_TDM_BACKEND_ABI_VERSION(1, 1)
193
194 typedef struct _tdm_backend_module
195 {
196     const char *name;
197     const char *vendor;
198     unsigned long abi_version;
199
200     tdm_backend_data* (*init)(tdm_display *dpy, tdm_error *error);
201     void (*deinit)(tdm_backend_data *bdata);
202 } tdm_backend_module;
203
204 tdm_error tdm_backend_register_func_display(tdm_display *dpy, tdm_func_display *func_display);
205 tdm_error tdm_backend_register_func_pp(tdm_display *dpy, tdm_func_pp *func_pp);
206 tdm_error tdm_backend_register_func_capture(tdm_display *dpy, tdm_func_capture *func_capture);
207
208 #ifdef __cplusplus
209 }
210 #endif
211
212 #endif /* _TDM_BACKEND_H_ */