blob: 9a45444874cb99c418a9b3f8be20145354fcf00e [file] [log] [blame]
Chia-I Wue78aa1b2016-09-05 11:46:36 +08001/*
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
17package android.hardware.graphics.allocator@2.0;
18
Chia-I Wu1c457272016-11-17 10:11:32 +080019import android.hardware.graphics.common@1.0::PixelFormat;
20
Chia-I Wue78aa1b2016-09-05 11:46:36 +080021interface IAllocator {
22 enum Capability : int32_t {
23 /* reserved */
24 INVALID = 0,
25
26 /*
27 * testAllocate will always return UNDEFINED unless this capability
28 * is supported.
29 */
30 TEST_ALLOCATE = 1,
Craig Donner0b00adf2016-10-20 17:12:58 -070031
32 /*
33 * layerCount must be 1 unless this capability is supported.
34 */
35 LAYERED_BUFFERS = 2,
Chia-I Wue78aa1b2016-09-05 11:46:36 +080036 };
37
38 struct BufferDescriptorInfo {
39 /*
Craig Donner0b00adf2016-10-20 17:12:58 -070040 * The width specifies how many columns of pixels must be in the
Chia-I Wue78aa1b2016-09-05 11:46:36 +080041 * allocated buffer, but does not necessarily represent the offset in
42 * columns between the same column in adjacent rows. The rows may be
43 * padded.
44 */
45 uint32_t width;
46
47 /*
Craig Donner0b00adf2016-10-20 17:12:58 -070048 * The height specifies how many rows of pixels must be in the
Chia-I Wue78aa1b2016-09-05 11:46:36 +080049 * allocated buffer.
50 */
51 uint32_t height;
52
Craig Donner0b00adf2016-10-20 17:12:58 -070053 /*
54 * The number of image layers that must be in the allocated buffer.
55 */
56 uint32_t layerCount;
57
Chia-I Wue78aa1b2016-09-05 11:46:36 +080058 /* Buffer pixel format. */
59 PixelFormat format;
60
61 /*
62 * Buffer producer usage mask; valid flags can be found in the
63 * definition of ProducerUsage.
64 */
65 uint64_t producerUsageMask;
66
67 /*
68 * Buffer consumer usage mask; valid flags can be found in the
69 * definition of ConsumerUsage.
70 */
71 uint64_t consumerUsageMask;
72 };
73
74 /*
75 * Provides a list of supported capabilities (as described in the
76 * definition of Capability above). This list must not change after
77 * initialization.
78 *
79 * @return capabilities is a list of supported capabilities.
80 */
Chia-I Wubc46dac2016-11-22 06:36:43 +080081 @entry
82 @exit
83 @callflow(next="*")
Chia-I Wue78aa1b2016-09-05 11:46:36 +080084 getCapabilities() generates (vec<Capability> capabilities);
85
86 /*
87 * Retrieves implementation-defined debug information, which will be
88 * displayed during, for example, `dumpsys SurfaceFlinger`.
89 *
90 * @return debugInfo is a string of debug information.
91 */
Chia-I Wubc46dac2016-11-22 06:36:43 +080092 @entry
93 @exit
94 @callflow(next="*")
Chia-I Wue78aa1b2016-09-05 11:46:36 +080095 dumpDebugInfo() generates (string debugInfo);
96
97 /*
98 * Creates a new, opaque buffer descriptor.
99 *
100 * @param descriptorInfo specifies the attributes of the buffer
101 * descriptor.
102 * @return error is NONE upon success. Otherwise,
103 * BAD_VALUE when any attribute in descriptorInfo is invalid.
104 * NO_RESOURCES when no more descriptors can currently be created.
105 * @return descriptor is the newly created buffer descriptor.
106 */
Chia-I Wubc46dac2016-11-22 06:36:43 +0800107 @entry
108 @callflow(next="*")
Chia-I Wue78aa1b2016-09-05 11:46:36 +0800109 createDescriptor(BufferDescriptorInfo descriptorInfo)
110 generates (Error error,
111 BufferDescriptor descriptor);
112
113 /*
114 * Destroys an existing buffer descriptor.
115 *
116 * @param descriptor is the descriptor to destroy.
117 * @return error is either NONE or BAD_DESCRIPTOR.
118 */
Chia-I Wubc46dac2016-11-22 06:36:43 +0800119 @exit
120 @callflow(next="*")
Chia-I Wue78aa1b2016-09-05 11:46:36 +0800121 destroyDescriptor(BufferDescriptor descriptor) generates (Error error);
122
123 /*
124 * Tests whether a buffer allocation can succeed, ignoring potential
125 * resource contention which might lead to a NO_RESOURCES error.
126 *
127 * @param descriptors is a list of buffer descriptors.
128 * @return error is NONE or NOT_SHARED upon success;
129 * NONE when buffers can be created and share a backing store.
130 * NOT_SHARED when buffers can be created but require more than a
131 * backing store.
132 * Otherwise,
133 * BAD_DESCRIPTOR when any of the descriptors is invalid.
134 * UNSUPPORTED when any of the descriptors can never be satisfied.
135 * UNDEFINED when TEST_ALLOCATE is not listed in getCapabilities.
136 */
Chia-I Wubc46dac2016-11-22 06:36:43 +0800137 @callflow(next="allocate")
Chia-I Wue78aa1b2016-09-05 11:46:36 +0800138 testAllocate(vec<BufferDescriptor> descriptors) generates (Error error);
139
140 /*
141 * Attempts to allocate a list of buffers sharing a backing store.
142 *
143 * Each buffer will correspond to one of the descriptors passed into the
144 * function and will hold a reference to its backing store. If the device
145 * is unable to share the backing store between the buffers, it must
146 * attempt to allocate the buffers with different backing stores and
147 * return NOT_SHARED if it is successful.
148 *
149 * @param descriptors is the buffer descriptors to attempt to allocate.
150 * @return error is NONE or NOT_SHARED upon success;
151 * NONE when buffers can be created and share a backing store.
152 * NOT_SHARED when buffers can be created but require more than a
153 * backing store.
154 * Otherwise,
155 * BAD_DESCRIPTOR when any of the descriptors is invalid.
156 * UNSUPPORTED when any of the descriptors can never be satisfied.
157 * NO_RESOURCES when any of the buffers cannot be created at this
158 * time.
159 * @return buffers is the allocated buffers.
160 */
Chia-I Wubc46dac2016-11-22 06:36:43 +0800161 @callflow(next="exportHandle")
Chia-I Wue78aa1b2016-09-05 11:46:36 +0800162 allocate(vec<BufferDescriptor> descriptors)
163 generates (Error error,
164 vec<Buffer> buffers);
165
166 /*
167 * Frees a buffer.
168 *
169 * @param buffer is the buffer to be freed.
170 * @return error is NONE upon success. Otherwise,
171 * BAD_BUFFER when the buffer is invalid.
172 */
Chia-I Wubc46dac2016-11-22 06:36:43 +0800173 @exit
174 @callflow(next="*")
Chia-I Wue78aa1b2016-09-05 11:46:36 +0800175 free(Buffer buffer) generates (Error error);
176
177 /*
178 * Exports a buffer for use in other client libraries or for cross-process
179 * sharing.
180 *
181 * The exported handle is a handle to the backing store of the buffer, not
182 * to the buffer itself. It however may not hold any reference to the
183 * backing store and may be considered invalid by client libraries. To use
184 * it and, in most cases, to save it for later use, a client must make a
185 * clone of the handle and have the cloned handle hold a reference to the
186 * backing store. Such a cloned handle will stay valid even after the
187 * original buffer is freed. Refer to native_handle_clone and IMapper for
188 * how a handle is cloned and how a reference is added.
189 *
190 * @param descriptor is the descriptor used to allocate the buffer.
191 * @param buffer is the buffer to be exported.
192 * @return error is NONE upon success. Otherwise,
193 * BAD_DESCRIPTOR when the descriptor is invalid.
194 * BAD_BUFFER when the buffer is invalid.
195 * BAD_VALUE when descriptor and buffer do not match.
196 * NO_RESOURCES when the buffer cannot be exported at this time.
197 * @return bufferHandle is the exported handle.
198 */
Chia-I Wubc46dac2016-11-22 06:36:43 +0800199 @callflow(next="free")
Chia-I Wue78aa1b2016-09-05 11:46:36 +0800200 exportHandle(BufferDescriptor descriptor,
201 Buffer buffer)
202 generates (Error error,
203 handle bufferHandle);
204};