blob: 03dfef1e3fc69aba4dbca73e3f6c875627f413c4 [file] [log] [blame]
Marissa Wall65341642019-06-20 13:21:06 -07001/*
2 * Copyright 2019 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.mapper@4.0;
18
19import android.hardware.graphics.common@1.2::BufferUsage;
20import android.hardware.graphics.common@1.2::PixelFormat;
21import android.hardware.graphics.common@1.2::Rect;
22
23interface IMapper {
24 struct BufferDescriptorInfo {
25 /**
Marissa Wallbf9f6d32019-11-05 14:58:52 -080026 * The name of the buffer. Useful for debugging/tracing.
27 */
28 string name;
29
30 /**
Marissa Wall65341642019-06-20 13:21:06 -070031 * The width specifies how many columns of pixels must be in the
32 * allocated buffer, but does not necessarily represent the offset in
33 * columns between the same column in adjacent rows. The rows may be
34 * padded.
35 */
36 uint32_t width;
37
Marissa Wall88d87fa2019-11-05 14:57:51 -080038 /**
39 * The height specifies how many rows of pixels must be in the
40 * allocated buffer.
41 */
Marissa Wall65341642019-06-20 13:21:06 -070042 uint32_t height;
43
Marissa Wall88d87fa2019-11-05 14:57:51 -080044 /**
45 * The number of image layers that must be in the allocated buffer.
46 */
Marissa Wall65341642019-06-20 13:21:06 -070047 uint32_t layerCount;
48
Marissa Wall88d87fa2019-11-05 14:57:51 -080049 /**
50 * Buffer pixel format.
51 */
Marissa Wall65341642019-06-20 13:21:06 -070052 PixelFormat format;
53
54 /**
55 * Buffer usage mask; valid flags can be found in the definition of
56 * BufferUsage.
57 */
58 bitfield<BufferUsage> usage;
Marissa Walld36e1272019-11-26 11:33:32 -080059
60 /**
61 * The size in bytes of the reserved region associated with the buffer.
62 * See getReservedRegion for more information.
63 */
64 uint64_t reservedSize;
Marissa Wall65341642019-06-20 13:21:06 -070065 };
66
67 struct Rect {
68 int32_t left;
69 int32_t top;
70 int32_t width;
71 int32_t height;
72 };
73
74 /**
75 * Creates a buffer descriptor. The descriptor can be used with IAllocator
76 * to allocate buffers.
77 *
78 * Since the buffer descriptor fully describes a buffer, any device
79 * dependent or device independent checks must be performed here whenever
Marissa Walld36e1272019-11-26 11:33:32 -080080 * possible. When layered buffers are not supported, this function must
81 * return `UNSUPPORTED` if `description.layers` is great than 1. This
82 * function may return `UNSUPPORTED` if `description.reservedSize` is
83 * larger than a page.
Marissa Wall65341642019-06-20 13:21:06 -070084 *
85 * @param description Attributes of the descriptor.
86 * @return error Error status of the call, which may be
87 * - `NONE` upon success.
88 * - `BAD_VALUE` if any of the specified attributes are invalid or
89 * inconsistent.
90 * - `NO_RESOURCES` if the creation cannot be fullfilled due to
91 * unavailability of resources.
92 * - `UNSUPPORTED` when any of the specified attributes are not
93 * supported.
94 * @return descriptor Newly created buffer descriptor.
95 */
96 createDescriptor(BufferDescriptorInfo description)
97 generates (Error error,
98 BufferDescriptor descriptor);
99
100 /**
101 * Imports a raw buffer handle to create an imported buffer handle for use
102 * with the rest of the mapper or with other in-process libraries.
103 *
104 * A buffer handle is considered raw when it is cloned (e.g., with
105 * `native_handle_clone()`) from another buffer handle locally, or when it
106 * is received from another HAL server/client or another process. A raw
107 * buffer handle must not be used to access the underlying graphic
108 * buffer. It must be imported to create an imported handle first.
109 *
110 * This function must at least validate the raw handle before creating the
111 * imported handle. It must also support importing the same raw handle
112 * multiple times to create multiple imported handles. The imported handle
113 * must be considered valid everywhere in the process, including in
114 * another instance of the mapper.
115 *
116 * Because of passthrough HALs, a raw buffer handle received from a HAL
117 * may actually have been imported in the process. importBuffer() must treat
118 * such a handle as if it is raw and must not return `BAD_BUFFER`. The
119 * returned handle is independent from the input handle as usual, and
120 * freeBuffer() must be called on it when it is no longer needed.
121 *
122 * @param rawHandle Raw buffer handle to import.
123 * @return error Error status of the call, which may be
124 * - `NONE` upon success.
125 * - `BAD_BUFFER` if the raw handle is invalid.
126 * - `NO_RESOURCES` if the raw handle cannot be imported due to
127 * unavailability of resources.
128 * @return buffer Imported buffer handle that has the type
129 * `buffer_handle_t` which is a handle type.
130 */
131 importBuffer(handle rawHandle) generates (Error error, pointer buffer);
132
133 /**
134 * Frees a buffer handle. Buffer handles returned by importBuffer() must be
135 * freed with this function when no longer needed.
136 *
137 * This function must free up all resources allocated by importBuffer() for
138 * the imported handle. For example, if the imported handle was created
139 * with `native_handle_create()`, this function must call
140 * `native_handle_close()` and `native_handle_delete()`.
141 *
142 * @param buffer Imported buffer handle.
143 * @return error Error status of the call, which may be
144 * - `NONE` upon success.
145 * - `BAD_BUFFER` if the buffer is invalid.
146 */
147 freeBuffer(pointer buffer) generates (Error error);
148
149 /**
150 * Validates that the buffer can be safely accessed by a caller who assumes
151 * the specified @p description and @p stride. This must at least validate
152 * that the buffer size is large enough. Validating the buffer against
153 * individual buffer attributes is optional.
154 *
155 * @param buffer Buffer to validate against.
156 * @param description Attributes of the buffer.
157 * @param stride Stride returned by IAllocator::allocate().
158 * @return error Error status of the call, which may be
159 * - `NONE` upon success.
160 * - `BAD_BUFFER` if the buffer is invalid.
161 * - `BAD_VALUE` if the buffer cannot be safely accessed.
162 */
163 validateBufferSize(pointer buffer,
164 BufferDescriptorInfo description,
165 uint32_t stride)
166 generates (Error error);
167
168 /**
169 * Calculates the transport size of a buffer. An imported buffer handle is a
170 * raw buffer handle with the process-local runtime data appended. This
171 * function, for example, allows a caller to omit the process-local runtime
172 * data at the tail when serializing the imported buffer handle.
173 *
174 * Note that a client might or might not omit the process-local runtime data
175 * when sending an imported buffer handle. The mapper must support both
176 * cases on the receiving end.
177 *
178 * @param buffer Buffer to get the transport size from.
179 * @return error Error status of the call, which may be
180 * - `NONE` upon success.
181 * - `BAD_BUFFER` if the buffer is invalid.
182 * @return numFds The number of file descriptors needed for transport.
183 * @return numInts The number of integers needed for transport.
184 */
185 getTransportSize(pointer buffer)
186 generates (Error error,
187 uint32_t numFds,
188 uint32_t numInts);
189
190 /**
191 * Locks the given buffer for the specified CPU usage.
192 *
193 * Locking the same buffer simultaneously from multiple threads is
194 * permitted, but if any of the threads attempt to lock the buffer for
195 * writing, the behavior is undefined, except that it must not cause
196 * process termination or block the client indefinitely. Leaving the
197 * buffer content in an indeterminate state or returning an error are both
198 * acceptable.
199 *
200 * 1D buffers (width = size in bytes, height = 1, pixel_format = BLOB) must
201 * "lock in place". The buffers must be directly accessible via mapping.
202 *
203 * The client must not modify the content of the buffer outside of
204 * @p accessRegion, and the device need not guarantee that content outside
205 * of @p accessRegion is valid for reading. The result of reading or writing
206 * outside of @p accessRegion is undefined, except that it must not cause
207 * process termination.
208 *
Marissa Wall9c5ebfc2019-11-05 14:59:27 -0800209 * This function can lock both single-planar and multi-planar formats. The caller
210 * should use get() to get information about the buffer they are locking.
211 * get() can be used to get information about the planes, offsets, stride,
212 * etc.
213 *
214 * This function must also work on buffers with
215 * `AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_*` if supported by the device, as well
216 * as with any other formats requested by multimedia codecs when they are
217 * configured with a flexible-YUV-compatible color format.
218 *
Marissa Wall65341642019-06-20 13:21:06 -0700219 * On success, @p data must be filled with a pointer to the locked buffer
220 * memory. This address will represent the top-left corner of the entire
221 * buffer, even if @p accessRegion does not begin at the top-left corner.
222 *
Marissa Wallaa181ae2019-10-14 13:17:17 -0700223 * The locked buffer must adhere to the format requested at allocation time
224 * in the BufferDescriptorInfo.
225 *
Marissa Wall65341642019-06-20 13:21:06 -0700226 * @param buffer Buffer to lock.
227 * @param cpuUsage CPU usage flags to request. See +ndk
228 * libnativewindow#AHardwareBuffer_UsageFlags for possible values.
229 * @param accessRegion Portion of the buffer that the client intends to
230 * access.
231 * @param acquireFence Handle containing a file descriptor referring to a
232 * sync fence object, which will be signaled when it is safe for the
233 * mapper to lock the buffer. @p acquireFence may be an empty fence if
234 * it is already safe to lock.
235 * @return error Error status of the call, which may be
236 * - `NONE` upon success.
237 * - `BAD_BUFFER` if the buffer is invalid or is incompatible with this
238 * function.
239 * - `BAD_VALUE` if @p cpuUsage is 0, contains non-CPU usage flags, or
Marissa Walla6a2af82019-11-06 12:49:23 -0800240 * is incompatible with the buffer. Also if the @p accessRegion is
241 * outside the bounds of the buffer or the accessRegion is invalid.
Marissa Wall65341642019-06-20 13:21:06 -0700242 * - `NO_RESOURCES` if the buffer cannot be locked at this time. Note
243 * that locking may succeed at a later time.
244 * @return data CPU-accessible pointer to the buffer data.
Marissa Wall65341642019-06-20 13:21:06 -0700245 */
246 lock(pointer buffer,
247 uint64_t cpuUsage,
248 Rect accessRegion,
249 handle acquireFence)
250 generates (Error error,
Marissa Wall9c5ebfc2019-11-05 14:59:27 -0800251 pointer data);
Marissa Wall65341642019-06-20 13:21:06 -0700252
253 /**
254 * Unlocks a buffer to indicate all CPU accesses to the buffer have
255 * completed.
256 *
257 * @param buffer Buffer to unlock.
258 * @return error Error status of the call, which may be
259 * - `NONE` upon success.
260 * - `BAD_BUFFER` if the buffer is invalid or not locked.
261 * @return releaseFence Handle containing a file descriptor referring to a
262 * sync fence object. The sync fence object will be signaled when the
263 * mapper has completed any pending work. @p releaseFence may be an
264 * empty fence.
265 */
266 unlock(pointer buffer) generates (Error error, handle releaseFence);
267
268 /**
Marissa Wall2c45bb12019-10-18 13:31:36 -0700269 * Flushes the contents of a locked buffer.
270 *
271 * This function flushes the CPUs caches for the range of all the buffer's
272 * planes and metadata. This should behave similarly to unlock() except the
273 * buffer should remain mapped to the CPU.
274 *
275 * The client is still responsible for calling unlock() when it is done
276 * with all CPU accesses to the buffer.
277 *
278 * If non-CPU blocks are simultaneously writing the buffer, the locked
279 * copy should still be flushed but what happens is undefined except that
280 * it should not cause any crashes.
281 *
282 * @param buffer Buffer to flush.
283 * @return error Error status of the call, which may be
284 * - `NONE` upon success.
285 * - `BAD_BUFFER` if the buffer is invalid or not locked.
286 * @return releaseFence Handle containing a file descriptor referring to a
287 * sync fence object. The sync fence object will be signaled when the
288 * mapper has completed any pending work. @p releaseFence may be an
289 * empty fence.
290 */
291 flushLockedBuffer(pointer buffer) generates (Error error, handle releaseFence);
292
293 /**
294 * Rereads the contents of a locked buffer.
295 *
296 * This should fetch the most recent copy of the locked buffer.
297 *
298 * It may reread locked copies of the buffer in other processes.
299 *
300 * The client is still responsible for calling unlock() when it is done
301 * with all CPU accesses to the buffer.
302 *
303 * @param buffer Buffer to reread.
304 * @return error Error status of the call, which may be
305 * - `NONE` upon success.
306 * - `BAD_BUFFER` if the buffer is invalid or not locked.
307 * - `NO_RESOURCES` if the buffer cannot be reread at this time. Note
308 * that rereading may succeed at a later time.
309 */
310 rereadLockedBuffer(pointer buffer) generates(Error error);
311
312 /**
Marissa Wall65341642019-06-20 13:21:06 -0700313 * Test whether the given BufferDescriptorInfo is allocatable.
314 *
315 * If this function returns true, it means that a buffer with the given
316 * description can be allocated on this implementation, unless resource
317 * exhaustion occurs. If this function returns false, it means that the
318 * allocation of the given description will never succeed.
319 *
320 * @param description the description of the buffer
321 * @return supported whether the description is supported
322 */
323 isSupported(BufferDescriptorInfo description)
324 generates (Error error,
325 bool supported);
326
Marissa Wall88d87fa2019-11-05 14:57:51 -0800327
328 /**
329 * Description for get(...), set(...) and getFromBufferDescriptorInfo(...)
330 *
331 * ------------ Overview -----------------------------------
332 * Gralloc 4 adds support for getting and setting buffer metadata on a buffer.
333 *
334 * To get buffer metadata, the client passes in a buffer handle and a token that
335 * represents the type of buffer metadata they would like to get. IMapper returns
336 * a byte stream that contains the buffer metadata. To set the buffer metadata, the
337 * client passes in a buffer handle and a token that represents the type of buffer
338 * metadata they would like to set and a byte stream that contains the buffer metadata
339 * they are setting.
340 *
341 * Buffer metadata is global for a buffer. When the metadata is set on the buffer
342 * in a process, the updated metadata should be available to all other processes.
343 * Please see "Storing and Propagating Metadata" below for more details.
344 *
345 * The getter and setter functions have been optimized for easy vendor extension.
346 * They do not require a formal HIDL extension to add support for getting and setting
347 * vendor defined buffer metadata. In order to allow easy extension, the types used
348 * here are not typical HIDL types. See "Buffer Metadata Token" and
349 * "Buffer Metadata Stream" below for more details.
350 *
351 * ------------ Storing and Propagating Metadata -----------
352 * Buffer metadata must be global. Any changes to the metadata must be propagated
353 * to all other processes immediately. Vendors may chose how they would like support
354 * this functionality.
355 *
356 * We recommend supporting this functionality by allocating an extra page of shared
357 * memory and storing it in the buffer's native_handle_t. The buffer metadata can
358 * be stored in the extra page of shared memory. Set operations are automatically
359 * propagated to all other processes.
360 *
361 * ------------ Buffer Metadata Synchronization ------------
362 * There are no explicit buffer metadata synchronization primitives. Many devices
363 * before gralloc 4 already support getting and setting of global buffer metadata
364 * with no explicit synchronization primitives. Adding synchronization primitives
365 * would just add unnecessary complexity.
366 *
367 * The general rule is if a process has permission to write to a buffer, they
368 * have permission to write to the buffer's metadata. If a process has permission
369 * to read from a buffer, they have permission to read the buffer's metadata.
370 *
371 * There is one exception to this rule. Fences CANNOT be used to protect a buffer's
Marissa Wall0129f432019-11-18 12:48:24 -0800372 * metadata. A process should finish writing to a buffer's metadata before
Marissa Wall88d87fa2019-11-05 14:57:51 -0800373 * sending the buffer to another process that will read or write to the buffer.
374 * This exception is needed because sometimes userspace needs to read the
375 * buffer's metadata before the buffer's contents are ready.
376 *
377 * As a simple example: an app renders to a buffer and then displays the buffer.
378 * In this example when the app renders to the buffer, both the buffer and its
379 * metadata need to be updated. The app's process queues up its work on the GPU
380 * and gets back an acquire fence. The app's process must update the buffer's
381 * metadata before enqueuing the buffer to SurfaceFlinger. The app process CANNOT
382 * update the buffer's metadata after enqueuing the buffer. When HardwareComposer
383 * receives the buffer, it is immediately safe to read the buffer's metadata
384 * and use it to program the display driver. To read the buffer's contents,
385 * display driver must still wait on the acquire fence.
386 *
387 * ------------ Buffer Metadata Token ----------------------
388 * In order to allow arbitrary vendor defined metadata, we could not use a
389 * HIDL enum as the buffer metadata token. Extending a HIDL enum requires a full
390 * HIDL extension. We also could not use a simple non-HIDL enum because vendor
391 * defined enums from different vendors could collide. Instead we have defined
392 * a struct that has a string representing the enum type and an int that
393 * represents the enum value. The string protects different enum values from
394 * colliding.
395 *
396 * The token struct (MetadataType) is defined as a HIDL struct since it
397 * is passed into a HIDL function. The standard buffer metadata types are NOT
398 * defined as a HIDL enum because it would have required a new IMapper version
399 * just to add future standard buffer metadata types. By putting the enum in the
400 * stable AIDL (hardware/interfaces/graphics/common/aidl/android/hardware/
401 * graphics/common/StandardMetadataType.aidl), vendors will be able to optionally
402 * choose to support future standard buffer metadata types without upgrading
403 * HIDL versions. For more information see the description of "struct MetadataType".
404 *
405 * ------------ Buffer Metadata Stream ---------------------
406 * The buffer metadata is get and set as a byte stream (vec<uint8_t>). By getting
407 * and setting buffer metadata as a byte stream, vendors can use the standard
408 * getters and setter functions defined here. Vendors do NOT need to add their own
409 * getters and setter functions for each new type of buffer metadata.
410 *
411 * Converting buffer metadata into a byte stream can be non-trivial. For the standard
412 * buffer metadata types defined in StandardMetadataType.aidl, there are also
413 * support functions that will encode the buffer metadata into a byte stream
414 * and decode the buffer metadata from a byte stream. We STRONGLY recommend using
415 * these support functions. The framework will use them when getting and setting
416 * metadata. The support functions are defined in
417 * frameworks/native/libs/gralloc/types/include/gralloctypes/Gralloc4.h.
418 */
419
420 /**
421 * MetadataType represents the different types of buffer metadata that could be
422 * associated with a buffer. It is used by IMapper to help get and set buffer metadata
423 * on the buffer's native handle.
424 *
425 * Standard buffer metadata will have the name field set to
426 * "android.hardware.graphics.common.StandardMetadataType" and will contain values
427 * from StandardMetadataType.aidl.
428 *
429 * This struct should be "extended" by devices that use a proprietary or non-standard
430 * buffer metadata. To extend the struct, first create a custom @VendorStability vendor
431 * AIDL interface that defines the new type(s) you would like to support. Set the
432 * struct's name field to the custom aidl interface's name
433 * (eg. "vendor.mycompanyname.graphics.common.MetadataType"). Set the struct's value
434 * field to the custom @VendorStabilty vendor AIDL interface.
435 *
436 * Each company should create their own StandardMetadataType.aidl extension. The name
437 * field prevents values from different companies from colliding.
438 */
439 struct MetadataType {
440 string name;
441 int64_t value;
442 };
443
444 /**
445 * Gets the buffer metadata for a given MetadataType.
446 *
447 * Buffer metadata can be changed after allocation so clients should avoid "caching"
448 * the buffer metadata. For example, if the video resolution changes and the buffers
449 * are not reallocated, several buffer metadata values may change without warning.
450 * Clients should not expect the values to be constant. They should requery them every
451 * frame. The only exception is buffer metadata that is determined at allocation
452 * time. For StandardMetadataType values, only BUFFER_ID, NAME, WIDTH,
453 * HEIGHT, LAYER_COUNT, PIXEL_FORMAT_REQUESTED and USAGE are safe to cache because
454 * they are determined at allocation time.
455 *
456 * @param buffer Buffer containing desired metadata
457 * @param metadataType MetadataType for the metadata value being queried
458 * @return error Error status of the call, which may be
459 * - `NONE` upon success.
460 * - `BAD_BUFFER` if the raw handle is invalid.
461 * - `NO_RESOURCES` if the get cannot be fullfilled due to unavailability of
462 * resources.
463 * - `UNSUPPORTED` when metadataType is unknown/unsupported.
464 * IMapper must support getting all StandardMetadataType.aidl values defined
465 * at the time the device first launches.
466 * @return metadata Vector of bytes representing the buffer metadata associated with
467 * the MetadataType.
468 */
469 get(pointer buffer, MetadataType metadataType)
470 generates (Error error,
471 vec<uint8_t> metadata);
472
473 /**
474 * Sets the global value for a given MetadataType.
475 *
476 * Metadata fields are not required to be settable. This function can
477 * return Error::UNSUPPORTED whenever it doesn't support setting a
478 * particular Metadata field.
479 *
480 * The framework may attempt to set the following StandardMetadataType
Joseph Murphy20102da2019-12-17 19:58:51 +0000481 * values: DATASPACE, PER_FRAME_METADATA, PER_FRAME_METADATA_BLOB and BLEND_MODE.
Marissa Wall88d87fa2019-11-05 14:57:51 -0800482 * We strongly encourage everyone to support setting as many of those fields as
483 * possible. If a device's Composer implementation supports a field, it should be
484 * supported here. Over time these metadata fields will be moved out of
485 * Composer/BufferQueue/etc. and into the buffer's Metadata fields.
486 * If a device's IMapper doesn't support setting those Metadata fields,
487 * eventually the device may not longer be able to support these fields.
488 *
489 * @param buffer Buffer receiving desired metadata
490 * @param metadataType MetadataType for the metadata value being set
491 * @param metadata Vector of bytes representing the value associated with
492 * @return error Error status of the call, which may be
493 * - `NONE` upon success.
494 * - `BAD_BUFFER` if the raw handle is invalid.
495 * - `BAD_VALUE` when the field is constant and can never be set (such as
496 * BUFFER_ID, NAME, WIDTH, HEIGHT, LAYER_COUNT, PIXEL_FORMAT_REQUESTED and
497 * USAGE)
498 * - `NO_RESOURCES` if the set cannot be fullfilled due to unavailability of
499 * resources.
500 * - `UNSUPPORTED` when metadataType is unknown/unsupported or setting
501 * it is unsupported. Unsupported should also be returned if the metadata
502 * is malformed.
503 */
504 set(pointer buffer, MetadataType metadataType, vec<uint8_t> metadata)
505 generates (Error error);
506
507 /**
508 * Given a BufferDescriptorInfo, gets the starting value of a given
509 * MetadataType. This can be used to query basic information about a buffer
510 * before the buffer is allocated.
511 *
512 * @param description Attributes of the descriptor.
513 * @param metadataType MetadataType for the metadata value being queried
514 * @return error Error status of the call, which may be
515 * - `NONE` upon success.
516 * - `BAD_VALUE` if any of the specified BufferDescriptorInfo attributes
517 * are invalid.
518 * - `NO_RESOURCES` if the get cannot be fullfilled due to unavailability of
519 * resources.
520 * - `UNSUPPORTED` when any of the description attributes are unsupported or
521 * if the metadataType is unknown/unsupported. This should also be
522 * returned if the requested metadata is not defined until a buffer has been
523 * allocated.
524 * @return metadata Vector of bytes representing the value associated with
525 * the MetadataType value.
526 */
527 getFromBufferDescriptorInfo(BufferDescriptorInfo description,
528 MetadataType metadataType)
529 generates (Error error,
530 vec<uint8_t> metadata);
Marissa Wall0001a5d2019-11-11 10:50:05 -0800531
532 struct MetadataTypeDescription {
533 MetadataType metadataType;
534 /**
535 * description should contain a string representation of the MetadataType.
536 *
537 * For example: "MyExampleMetadataType is a 64-bit timestamp in nanoseconds
538 * that indicates when a buffer is decoded. It is set by the media HAL after
539 * a buffer is decoded. It is used by the display HAL for hardware
540 * synchronization".
541 *
542 * This field is required for any non-StandardMetadataTypes.
543 */
544 string description;
545 /**
546 * isGettable represents if the MetadataType can be get.
547 */
548 bool isGettable;
549 /**
550 * isSettable represents if the MetadataType can be set.
551 */
552 bool isSettable;
553 };
554
555 /**
556 * Lists all the MetadataTypes supported by IMapper as well as a description
557 * of each supported MetadataType. For StandardMetadataTypes, the description
558 * string can be left empty.
559 *
560 * @return error Error status of the call, which may be
561 * - `NONE` upon success.
562 * - `NO_RESOURCES` if the get cannot be fullfilled due to unavailability of
563 * resources.
564 * @return descriptions Vector of MetadataTypeDescriptions that represent the
565 * MetadataTypes supported by the device.
566 */
567 listSupportedMetadataTypes()
568 generates (Error error, vec<MetadataTypeDescription> descriptions);
Marissa Wall0cf07562019-11-07 09:17:43 -0800569
570 struct MetadataDump {
571 /**
572 * The type of metadata being dumped.
573 */
574 MetadataType metadataType;
575 /**
576 * The byte stream representation of the metadata. If the metadata is not
577 * gettable, the vector must be empty.
578 */
579 vec<uint8_t> metadata;
580 };
581
582 struct BufferDump {
583 /**
584 * A vector of all the metadata that is being dumped for a particular buffer.
585 */
586 vec<MetadataDump> metadataDump;
587 };
588
589 /**
590 * Dumps a buffer's metadata.
591 *
592 * @param buffer Buffer that is being dumped
593 * @return error Error status of the call, which may be
594 * - `NONE` upon success.
595 * - `BAD_BUFFER` if the raw handle is invalid.
596 * - `NO_RESOURCES` if the get cannot be fullfilled due to unavailability of
597 * resources.
598 * @return bufferDump Struct representing the metadata being dumped
599 */
600 dumpBuffer(pointer buffer)
601 generates (Error error, BufferDump bufferDump);
602
603 /**
604 * Dumps the metadata for all the buffers in the current process.
605 *
606 * @return error Error status of the call, which may be
607 * - `NONE` upon success.
608 * - `NO_RESOURCES` if the get cannot be fullfilled due to unavailability of
609 * resources.
610 * @return bufferDumps Vector of structs representing the buffers being dumped
611 */
612 dumpBuffers()
613 generates (Error error, vec<BufferDump> bufferDumps);
Marissa Walld36e1272019-11-26 11:33:32 -0800614
615 /**
616 * Returns the region of shared memory associated with the buffer that is
617 * reserved for client use.
618 *
619 * The shared memory may be allocated from any shared memory allocator.
620 * The shared memory must be CPU-accessible and virtually contiguous. The
621 * starting address must be word-aligned.
622 *
623 * This function may only be called after importBuffer() has been called by the
624 * client. The reserved region must remain accessible until freeBuffer() has
625 * been called. After freeBuffer() has been called, the client must not access
626 * the reserved region.
627 *
628 * This reserved memory may be used in future versions of Android to
629 * help clients implement backwards compatible features without requiring
630 * IAllocator/IMapper updates.
631 *
632 * @param buffer Imported buffer handle.
633 * @return error Error status of the call, which may be
634 * - `NONE` upon success.
635 * - `BAD_BUFFER` if the buffer is invalid.
636 * @return reservedRegion CPU-accessible pointer to the reserved region
637 * @return reservedSize the size of the reservedRegion that was requested
638 * in the BufferDescriptorInfo.
639 */
640 getReservedRegion(pointer buffer)
641 generates (Error error,
642 pointer reservedRegion,
643 uint64_t reservedSize);
Marissa Wall65341642019-06-20 13:21:06 -0700644};
645