1 /* 2 * Copyright (C) 2020 Arm Limited. All rights reserved. 3 * 4 * Copyright 2016 The Android Open Source Project 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #ifndef GRALLOC_COMMON_MAPPER_METADATA_H 20 #define GRALLOC_COMMON_MAPPER_METADATA_H 21 22 #include <inttypes.h> 23 #include "mali_gralloc_log.h" 24 #include "core/mali_gralloc_bufferdescriptor.h" 25 #include "mali_gralloc_buffer.h" 26 27 #include "4.x/gralloc_mapper_hidl_header.h" 28 29 namespace arm 30 { 31 namespace mapper 32 { 33 namespace common 34 { 35 using android::hardware::hidl_vec; 36 using aidl::android::hardware::graphics::common::ExtendableType; 37 38 39 /** 40 * Retrieves a Buffer's metadata value. 41 * 42 * @param handle [in] The private handle of the buffer to query for metadata. 43 * @param metadataType [in] The type of metadata queried. 44 * @param hidl_cb [in] HIDL callback function generating - 45 * error: NONE on success. 46 * UNSUPPORTED on error when reading or unsupported metadata type. 47 * metadata: Vector of bytes representing the metadata value. 48 */ 49 void get_metadata(const private_handle_t *handle, const IMapper::MetadataType &metadataType, IMapper::get_cb hidl_cb); 50 51 /** 52 * Sets a Buffer's metadata value. 53 * 54 * @param handle [in] The private handle of the buffer for which to modify metadata. 55 * @param metadataType [in] The type of metadata to modify. 56 * @param metadata [in] Vector of bytes representing the new value for the metadata associated with the buffer. 57 * 58 * @return Error::NONE on success. 59 * Error::UNSUPPORTED on error when writing or unsupported metadata type. 60 */ 61 Error set_metadata(const private_handle_t *handle, const IMapper::MetadataType &metadataType, 62 const hidl_vec<uint8_t> &metadata); 63 64 /** 65 * Query basic metadata information about a buffer form its descriptor before allocation. 66 * 67 * @param description [in] The buffer descriptor. 68 * @param metadataType [in] The type of metadata to query 69 * @param hidl_cb [in] HIDL callback function generating - 70 * error: NONE on success. 71 * UNSUPPORTED on unsupported metadata type. 72 * metadata: Vector of bytes representing the metadata value. 73 */ 74 void getFromBufferDescriptorInfo(IMapper::BufferDescriptorInfo const &description, 75 IMapper::MetadataType const &metadataType, 76 IMapper::getFromBufferDescriptorInfo_cb hidl_cb); 77 78 } // namespace common 79 } // namespace mapper 80 } // namespace arm 81 82 #endif 83