1 /*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef ANDROID_FB_INTERFACE_H
18 #define ANDROID_FB_INTERFACE_H
19
20
21 #include <onelib>
22 #include <there/somelib.h>
23 #include "mylib.h"
24
25 __BEGIN_DECLS
26
27 // comments
28
29 #define MY_DEFINE 1 \
30 + 1
31 #define META(thing1, thing2) thing1 + thing2
32 #define VERSION HARDWARE_MODULE_API_VERSION(0, 1)
33 #define ONE 1 /* got to
34 get rid of magic numbers */
35
36 /* test */
37 /** test */
38 /* test **/
39 /* test / ** ** / test */
40 /* test //// ***** test /****/
41
42 #define a 1l
43 #define b 1l + 2ll
44 #define c 1ul + 1l
45 #define d 2 + 1l
46 #define e 3 + 1ll
47 #define f 4 + 3ul
48 #define g 1l + 3
49 #define h 32u
50 #define i 64ull
51 #define j 2 + a
52 #define k 1u
53 #define l k + 1l
54
55 /*****************************************************************************/
56 typedef enum {
57 A = 47,
58 /* B is a very important value */
59 B,
60 #ifdef UNHAPPY
61 C = 1 + test(19) + test2[21],
62 #endif
63 D = 1 ? 1 : 2
64 } onehere;
65
to_string(T value)66 inline std::string to_string(T value) { return to_string(static_cast<E>(value)); }
67
68 const res_t RESULT_ACCESS_DENIED = ~2 | -1;
69 const res_t RESULT_INVALID_PARAMETER = 54;
70
71 #ifdef __cplusplus
72 extern "C" {
73 #endif
74
fun1()75 static void fun1() { }
76
77 typedef int my_int_type;
78 typedef my_int_type my_type_two;
79
80 namespace MyNamespace {
fun1()81 static void fun1() { }
fun2()82 static void fun2() { }
83 }
84
85 #ifdef __cplusplus
86 }
87 #endif
88
fun3()89 static void fun3() { test; }
fun4()90 static void fun4() { test; }
91
92 #undef ONE
93
94 /*****************************************************************************/
95 typedef void (*no_arg_fun)(void);
96
97 typedef int (*other_fun)(int j);
98
99 typedef void (*alarm_cb)(void *data);
100
101 typedef void (*special_types)(const native_handle_t* a, int b);
102
103 typedef foo_t bar_t;
104
105 struct baz_t;
106
107 typedef pthread_t (* fun_with_funs)(void (*my_fun)(void *), void* arg);
108
109 int (*global_fun_1)(struct framebuffer_device_t* dev, int enable);
110 int (*global_fun_2)(struct framebuffer_device_t* dev, int enable);
111
112 typedef struct framebuffer_device_t {
113 /**
114 * Common methods of the framebuffer device.
115 */
116 struct hw_device_t common;
117
118 typedef enum another_here {
119 A = 3 | 4,
120 B,
121 C = 4
122 } another_here;
123
124 /* anon struct */
125 struct {
126 float b;
127 };
128
129 struct not_type_defd {
130 double latitude[];
131 double halfLongitude;
132 };
133
134 char here;
135
136 /* flags describing some attributes of the framebuffer */
137 const uint32_t flags;
138
139 /* dimensions of the framebuffer in pixels */
140 const uint32_t width;
141 const uint32_t height;
142
143 /* frambuffer stride in pixels */
144 const int stride;
145
146 /* framebuffer pixel format */
147 const int format_type;
148
149 /* resolution of the framebuffer's display panel in pixel per inch*/
150 const float xdpi;
151 const float ydpi;
152
153 /* framebuffer's display panel refresh rate in frames per second */
154 const float fps;
155
156 /* min swap interval supported by this framebuffer */
157 const int minSwapInterval;
158
159 /* max swap interval supported by this framebuffer */
160 const int maxSwapInterval;
161
162 /* Number of framebuffers supported*/
163 const int numFramebuffers;
164
165 int reserved[7];
166
167 /*
168 * requests a specific swap-interval (same definition than EGL)
169 *
170 * Returns 0 on success or -errno on error.
171 */
172 int (*setSwapInterval)(struct framebuffer_device_t* window,
173 int interval);
174
175 /*
176 * This hook is OPTIONAL.
177 *
178 * It is non NULL If the framebuffer driver supports "update-on-demand"
179 * and the given rectangle is the area of the screen that gets
180 * updated during (*post)().
181 *
182 * This is useful on devices that are able to DMA only a portion of
183 * the screen to the display panel, upon demand -- as opposed to
184 * constantly refreshing the panel 60 times per second, for instance.
185 *
186 * Only the area defined by this rectangle is guaranteed to be valid, that
187 * is, the driver is not allowed to post anything outside of this
188 * rectangle.
189 *
190 * The rectangle evaluated during (*post)() and specifies which area
191 * of the buffer passed in (*post)() shall to be posted.
192 *
193 * return -EINVAL if width or height <=0, or if left or top < 0
194 */
195 int (*setUpdateRect)(struct framebuffer_device_t* window,
196 int left, int top, int width, int height);
197
198 /*
199 * Post <buffer> to the display (display it on the screen)
200 * The buffer must have been allocated with the
201 * GRALLOC_USAGE_HW_FB usage flag.
202 * buffer must be the same width and height as the display and must NOT
203 * be locked.
204 *
205 * The buffer is shown during the next VSYNC.
206 *
207 * If the same buffer is posted again (possibly after some other buffer),
208 * post() will block until the the first post is completed.
209 *
210 * Internally, post() is expected to lock the buffer so that a
211 * subsequent call to gralloc_module_t::(*lock)() with USAGE_RENDER or
212 * USAGE_*_WRITE will block until it is safe; that is typically once this
213 * buffer is shown and another buffer has been posted.
214 *
215 * Returns 0 on success or -errno on error.
216 */
217 int (*post)(struct framebuffer_device_t* dev, buffer_handle_t buffer);
218
219
220 /*
221 * The (*compositionComplete)() method must be called after the
222 * compositor has finished issuing GL commands for client buffers.
223 */
224
225 int (*compositionComplete)(struct framebuffer_device_t* dev);
226
227 /*
228 * This hook is OPTIONAL.
229 *
230 * If non NULL it will be caused by SurfaceFlinger on dumpsys
231 */
232 void (*dump)(struct framebuffer_device_t* dev, char *buff, int buff_len);
233
234 /*
235 * (*enableScreen)() is used to either blank (enable=0) or
236 * unblank (enable=1) the screen this framebuffer is attached to.
237 *
238 * Returns 0 on success or -errno on error.
239 */
240 int (*enableScreen)(struct framebuffer_device_t* dev, int enable);
241
242 void* reserved_proc[6];
243
244 } framebuffer_device_t;
245
246 typedef int context_hub_callback(uint32_t hub_id, const struct hub_message_t *rxed_msg, void *cookie);
247
248 typedef struct my_other_t {
249
250 int a;
251 int b[];
252 int c[3];
253 int d[][];
254 int e[3][];
255 int f[3][5];
256 int g[4+4][6 * 6][];
257 int h[1][2][][3][4][5][6][7][8];
258
259 unsigned int i;
260 unsigned int8_t j;
261 unsigned int16_t k;
262 unsigned int32_t l;
263 unsigned int64_t m;
264 unsigned int32_t * n;
265 const unsigned int32_t *** o;
266 unsigned p;
267 short q;
268 long r;
269 unsigned short s;
270 unsigned long t;
271 unsigned char u;
272 char v;
273
274 int (*store_meta_data_in_buffers)(struct camera_device *, int enable);
275
276 typedef void (*scan_result_callback)(bt_bdaddr_t* bda, int rssi, vector<uint8_t> adv_data);
277
278 pthread_t (* gps_create_thread)(const char* name, void (*start)(void *), void* arg);
279
280 int (*p1)(struct framebuffer_device_t* dev);
281
282 void (*p2)(struct framebuffer_device_t* dev, char *buff, int buff_len);
283
284 int (*p3)(struct framebuffer_device_t* dev, int enable[3][4][5]);
285
286
287 int (*get_supported_activities_list)(struct activity_recognition_module* module,
288 char const* const* *activity_list);
289
290 int (*read_energy_info)();
291 void (*reserved_procs[16 - 4])(void);
292
293 } my_other_t;
294
295 #define another 4
296
297 typedef struct {
298 /** set to sizeof(GpsCallbacks_v1) */
299 size_t size;
300 myWierdSize mySize;
301 wchar_t MyWideChar;
302
303 gps_location_callback location_cb;
304 gps_status_callback status_cb;
305 gps_sv_status_callback sv_status_cb;
306 gps_nmea_callback nmea_cb;
307 gps_set_capabilities set_capabilities_cb;
308 gps_acquire_wakelock acquire_wakelock_cb;
309 gps_release_wakelock release_wakelock_cb;
310 gps_create_thread create_thread_cb;
311 gps_request_utc_time request_utc_time_cb;
312 } __attribute__((packed)) GpsCallbacks_v1;
313
314 typedef struct one_name {
315 float a;
316 } another_name;
317
318 typedef struct this_t {
319 int hello;
320 } this_t;
321
322 typedef union that_t {
323 float a;
324 float c;
325 } that_t;
326
327 /**
328 * return the frame size (number of bytes per sample) of an output stream.
329 */
audio_stream_out_frame_size(const struct audio_stream_out * s)330 static inline size_t audio_stream_out_frame_size(const struct audio_stream_out *s)
331 {
332 size_t chan_samp_sz;
333 audio_format_t format = s->common.get_format(&s->common);
334
335 if (audio_has_proportional_frames(format)) {
336 chan_samp_sz = audio_bytes_per_sample(format);
337 return audio_channel_count_from_out_mask(s->common.get_channels(&s->common)) * chan_samp_sz;
338 }
339
340 return sizeof(int8_t);
341 }
342
343 /* effective and commanding */
344 enum effect_command_e {
345 EFFECT_CMD_INIT, // initialize effect engine
346 EFFECT_CMD_SET_CONFIG, // configure effect engine (see effect_config_t)
347 EFFECT_CMD_RESET, // reset effect engine
348 EFFECT_CMD_ENABLE, // enable effect process
349 EFFECT_CMD_DISABLE, // disable effect process
350 EFFECT_CMD_SET_PARAM, // set parameter immediately (see effect_param_t)
351 EFFECT_CMD_SET_PARAM_DEFERRED, // set parameter deferred
352 EFFECT_CMD_SET_PARAM_COMMIT, // commit previous set parameter deferred
353 EFFECT_CMD_GET_PARAM, // get parameter
354 EFFECT_CMD_SET_DEVICE, // set audio device (see audio.h, audio_devices_t)
355 EFFECT_CMD_SET_VOLUME, // set volume
356 EFFECT_CMD_SET_AUDIO_MODE, // set the audio mode (normal, ring, ...)
357 EFFECT_CMD_SET_CONFIG_REVERSE, // configure effect engine reverse stream(see effect_config_t)
358 EFFECT_CMD_SET_INPUT_DEVICE, // set capture device (see audio.h, audio_devices_t)
359 EFFECT_CMD_GET_CONFIG, // read effect engine configuration
360 EFFECT_CMD_GET_CONFIG_REVERSE, // read configure effect engine reverse stream configuration
361 EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS,// get all supported configurations for a feature.
362 EFFECT_CMD_GET_FEATURE_CONFIG, // get current feature configuration
363 EFFECT_CMD_SET_FEATURE_CONFIG, // set current feature configuration
364 EFFECT_CMD_SET_AUDIO_SOURCE, // set the audio source (see audio.h, audio_source_t)
365 EFFECT_CMD_OFFLOAD, // set if effect thread is an offload one,
366 // send the ioHandle of the effect thread
367 EFFECT_CMD_FIRST_PROPRIETARY = 0x10000 // first proprietary command code
368 };
369
370
371 namespace myspace {
372 enum class enum_class : int32_t {
373 great,
374 };
375 } // namespace myspace
376
377 enum struct enum_struct {
378 great,
379 };
380
381
382 __END_DECLS
383
384 #endif
385