blob: f48cd9e08db202fbdea46894492d6638abe66a95 [file] [log] [blame]
Chia-I Wu109571a2016-09-05 11:46:36 +08001/*
2 * Copyright 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#ifndef ANDROID_HARDWARE_GRALLOC1_ADAPTER_H
17#define ANDROID_HARDWARE_GRALLOC1_ADAPTER_H
18
19#include <stdbool.h>
20#include <hardware/gralloc.h>
21
22__BEGIN_DECLS
23
24struct gralloc1_adapter_buffer_info {
25 int width;
26 int height;
27 int format;
28 int usage;
29
30 int stride;
31 uint32_t num_flex_planes;
32};
33
34/* This struct must be embedded in the HAL's HAL_MODULE_INFO_SYM and must
35 * follow gralloc_module_t immediately. */
36struct gralloc1_adapter {
37 uint16_t real_module_api_version;
38
39 /* Return true if the buffer is registered. A locally allocated buffer is
40 * always registered.
41 *
42 * This function is called frequently. It must be thread safe just like
43 * other functions are.
44 */
45 bool (*is_registered)(const struct gralloc_module_t* mod,
46 buffer_handle_t buffer);
47
48 /* Set the adapter data for a registered buffer. */
49 void (*set_data)(const struct gralloc_module_t* mod,
50 buffer_handle_t buffer, void* data);
51
52 /* Get the adapter data for a registered buffer. */
53 void* (*get_data)(const struct gralloc_module_t* mod,
54 buffer_handle_t buffer);
55
56 /* Get the buffer info, such as width, height, etc. */
57 void (*get_info)(const struct gralloc_module_t* mod,
58 buffer_handle_t buffer,
59 struct gralloc1_adapter_buffer_info* info);
60
61 /* Get the flexilble layout matching ycbcr. */
62 void (*get_flexible_layout)(const struct gralloc_module_t* mod,
63 buffer_handle_t buffer, const struct android_ycbcr* ycbcr,
64 struct android_flex_layout* layout);
65};
66
67int gralloc1_adapter_device_open(const struct hw_module_t* module,
68 const char* id, struct hw_device_t** device);
69
70__END_DECLS
71
72#endif /* ANDROID_HARDWARE_GRALLOC1_ADAPTER_H */