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 #ifndef ANDROID_HARDWARE_GRAPHICS_MAPPER_V4_x_GRALLOC_MAPPER_H 19 #define ANDROID_HARDWARE_GRAPHICS_MAPPER_V4_x_GRALLOC_MAPPER_H 20 21 #include "hidl_common/Mapper.h" 22 23 namespace arm 24 { 25 namespace mapper 26 { 27 28 using android::hardware::Return; 29 using android::hardware::hidl_handle; 30 using android::hardware::hidl_vec; 31 32 class GrallocMapper : public IMapper 33 { 34 public: 35 /** 36 * IMapper constructor. All the state information required for the Gralloc 37 * private module is populated in its default constructor. Gralloc 4.x specific 38 * state information can be populated here. 39 */ 40 GrallocMapper(); 41 42 /** 43 * IMapper destructor. All the resources aquired for Gralloc private module 44 * (in the IMapper context) are released 45 */ 46 ~GrallocMapper(); 47 48 /* Override the public IMapper 4.0 interface */ 49 Return<void> createDescriptor(const BufferDescriptorInfo &descriptorInfo, createDescriptor_cb hidl_cb) override; 50 51 Return<void> importBuffer(const hidl_handle &rawHandle, importBuffer_cb hidl_cb) override; 52 53 Return<hidl::Error> freeBuffer(void *buffer) override; 54 55 Return<hidl::Error> validateBufferSize(void *buffer, const IMapper::BufferDescriptorInfo &descriptorInfo, 56 uint32_t stride) override; 57 58 Return<void> getTransportSize(void *buffer, getTransportSize_cb _hidl_cb) override; 59 60 Return<void> lock(void *buffer, uint64_t cpuUsage, const IMapper::Rect &accessRegion, 61 const hidl_handle &acquireFence, lock_cb hidl_cb) override; 62 63 Return<void> unlock(void *buffer, unlock_cb hidl_cb) override; 64 65 Return<void> flushLockedBuffer(void *buffer, flushLockedBuffer_cb hidl_cb) override; 66 67 Return<hidl::Error> rereadLockedBuffer(void *buffer) override; 68 69 Return<void> isSupported(const IMapper::BufferDescriptorInfo &description, isSupported_cb hidl_cb) override; 70 71 Return<void> get(void *buffer, const MetadataType &metadataType, IMapper::get_cb hidl_cb) override; 72 73 Return<hidl::Error> set(void *buffer, const MetadataType &metadataType, const hidl_vec<uint8_t> &metadata) override; 74 75 Return<void> getFromBufferDescriptorInfo(BufferDescriptorInfo const &description, MetadataType const &metadataType, 76 getFromBufferDescriptorInfo_cb hidl_cb) override; 77 78 Return<void> listSupportedMetadataTypes(listSupportedMetadataTypes_cb _hidl_cb) override; 79 80 Return<void> dumpBuffer(void *buffer, dumpBuffer_cb _hidl_cb) override; 81 82 Return<void> dumpBuffers(dumpBuffers_cb _hidl_cb) override; 83 84 Return<void> getReservedRegion(void *buffer, getReservedRegion_cb _hidl_cb) override; 85 }; 86 87 } // namespace mapper 88 } // namespace arm 89 90 #endif // ANDROID_HARDWARE_GRAPHICS_MAPPER_V4_x_GRALLOC_MAPPER_H 91