1 /* 2 * Copyright 2020 The Chromium OS Authors. All rights reserved. 3 * Use of this source code is governed by a BSD-style license that can be 4 * found in the LICENSE file. 5 */ 6 7 #include <android/hardware/graphics/mapper/4.0/IMapper.h> 8 9 #include "cros_gralloc/cros_gralloc_driver.h" 10 #include "cros_gralloc/cros_gralloc_handle.h" 11 12 class CrosGralloc4Mapper : public android::hardware::graphics::mapper::V4_0::IMapper { 13 public: 14 CrosGralloc4Mapper(); 15 ~CrosGralloc4Mapper(); 16 17 android::hardware::Return<void> createDescriptor(const BufferDescriptorInfo& description, 18 createDescriptor_cb hidlCb) override; 19 20 android::hardware::Return<void> importBuffer(const android::hardware::hidl_handle& rawHandle, 21 importBuffer_cb hidlCb) override; 22 23 android::hardware::Return<android::hardware::graphics::mapper::V4_0::Error> freeBuffer( 24 void* rawHandle) override; 25 26 android::hardware::Return<android::hardware::graphics::mapper::V4_0::Error> validateBufferSize( 27 void* rawHandle, const BufferDescriptorInfo& descriptor, uint32_t stride) override; 28 29 android::hardware::Return<void> getTransportSize(void* rawHandle, 30 getTransportSize_cb hidlCb) override; 31 32 android::hardware::Return<void> lock(void* rawHandle, uint64_t cpuUsage, 33 const Rect& accessRegion, 34 const android::hardware::hidl_handle& acquireFence, 35 lock_cb hidlCb) override; 36 37 android::hardware::Return<void> unlock(void* rawHandle, unlock_cb hidlCb) override; 38 39 android::hardware::Return<void> flushLockedBuffer(void* rawHandle, 40 flushLockedBuffer_cb hidlCb) override; 41 42 android::hardware::Return<android::hardware::graphics::mapper::V4_0::Error> rereadLockedBuffer( 43 void* rawHandle) override; 44 45 android::hardware::Return<void> isSupported(const BufferDescriptorInfo& descriptor, 46 isSupported_cb hidlCb) override; 47 48 android::hardware::Return<void> get(void* rawHandle, const MetadataType& metadataType, 49 get_cb hidlCb) override; 50 51 android::hardware::Return<android::hardware::graphics::mapper::V4_0::Error> set( 52 void* rawHandle, const MetadataType& metadataType, 53 const android::hardware::hidl_vec<uint8_t>& metadata) override; 54 55 android::hardware::Return<void> getFromBufferDescriptorInfo( 56 const BufferDescriptorInfo& descriptor, const MetadataType& metadataType, 57 getFromBufferDescriptorInfo_cb hidlCb) override; 58 59 android::hardware::Return<void> listSupportedMetadataTypes( 60 listSupportedMetadataTypes_cb hidlCb) override; 61 62 android::hardware::Return<void> dumpBuffer(void* rawHandle, dumpBuffer_cb hidlCb) override; 63 android::hardware::Return<void> dumpBuffers(dumpBuffers_cb hidlCb) override; 64 65 android::hardware::Return<void> getReservedRegion(void* rawHandle, 66 getReservedRegion_cb hidlCb) override; 67 68 private: 69 android::hardware::Return<void> get(cros_gralloc_handle_t crosHandle, 70 const MetadataType& metadataType, get_cb hidlCb); 71 72 android::hardware::Return<void> dumpBuffer(cros_gralloc_handle_t crosHandle, 73 dumpBuffer_cb hidlCb); 74 75 int getResolvedDrmFormat(android::hardware::graphics::common::V1_2::PixelFormat pixelFormat, 76 uint64_t bufferUsage, uint32_t* outDrmFormat); 77 78 cros_gralloc_driver* mDriver = nullptr; 79 }; 80 81 extern "C" android::hardware::graphics::mapper::V4_0::IMapper* HIDL_FETCH_IMapper(const char* name); 82