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