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