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