Naseer Ahmed | e36f224 | 2017-12-01 15:33:56 -0500 | [diff] [blame] | 1 | /* |
Ashish Kumar | f04c3de | 2018-08-01 14:45:14 +0530 | [diff] [blame] | 2 | * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved. |
Naseer Ahmed | e36f224 | 2017-12-01 15:33:56 -0500 | [diff] [blame] | 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are |
| 6 | * met: |
| 7 | * * Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * * Redistributions in binary form must reproduce the above |
| 10 | * copyright notice, this list of conditions and the following |
| 11 | * disclaimer in the documentation and/or other materials provided |
| 12 | * with the distribution. |
| 13 | * * Neither the name of The Linux Foundation nor the names of its |
| 14 | * contributors may be used to endorse or promote products derived |
| 15 | * from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 27 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | #ifndef __QTIMAPPER_H__ |
| 31 | #define __QTIMAPPER_H__ |
| 32 | |
| 33 | #include <hidl/MQDescriptor.h> |
| 34 | #include <hidl/Status.h> |
Tharaga Balachandran | f7e62a3 | 2019-06-06 11:33:29 -0400 | [diff] [blame^] | 35 | #include <vendor/qti/hardware/display/mapper/2.0/IQtiMapper.h> |
Naseer Ahmed | e36f224 | 2017-12-01 15:33:56 -0500 | [diff] [blame] | 36 | |
Tharaga Balachandran | f7e62a3 | 2019-06-06 11:33:29 -0400 | [diff] [blame^] | 37 | #include "QtiMapperExtensions.h" |
Naseer Ahmed | e36f224 | 2017-12-01 15:33:56 -0500 | [diff] [blame] | 38 | #include "gr_buf_mgr.h" |
| 39 | namespace vendor { |
| 40 | namespace qti { |
| 41 | namespace hardware { |
| 42 | namespace display { |
| 43 | namespace mapper { |
Naseer Ahmed | e36f224 | 2017-12-01 15:33:56 -0500 | [diff] [blame] | 44 | namespace implementation { |
| 45 | |
Tharaga Balachandran | f7e62a3 | 2019-06-06 11:33:29 -0400 | [diff] [blame^] | 46 | using ::android::sp; |
Naseer Ahmed | e36f224 | 2017-12-01 15:33:56 -0500 | [diff] [blame] | 47 | using ::android::hardware::hidl_array; |
| 48 | using ::android::hardware::hidl_handle; |
| 49 | using ::android::hardware::hidl_memory; |
| 50 | using ::android::hardware::hidl_string; |
| 51 | using ::android::hardware::hidl_vec; |
Tharaga Balachandran | f7e62a3 | 2019-06-06 11:33:29 -0400 | [diff] [blame^] | 52 | using ::android::hardware::Return; |
| 53 | using ::android::hardware::Void; |
| 54 | using ::android::hardware::graphics::common::V1_1::PixelFormat; |
| 55 | using ::android::hardware::graphics::mapper::V2_0::Error; |
| 56 | using ::android::hardware::graphics::mapper::V2_0::IMapper; |
| 57 | using ::android::hardware::graphics::mapper::V2_0::YCbCrLayout; |
Naseer Ahmed | e36f224 | 2017-12-01 15:33:56 -0500 | [diff] [blame] | 58 | using ::android::hidl::base::V1_0::DebugInfo; |
| 59 | using ::android::hidl::base::V1_0::IBase; |
Naseer Ahmed | e36f224 | 2017-12-01 15:33:56 -0500 | [diff] [blame] | 60 | using gralloc::BufferManager; |
Tharaga Balachandran | f7e62a3 | 2019-06-06 11:33:29 -0400 | [diff] [blame^] | 61 | using ::vendor::qti::hardware::display::mapper::V2_0::IQtiMapper; |
| 62 | using ::vendor::qti::hardware::display::mapperextensions::V1_0::IQtiMapperExtensions; |
| 63 | using ::vendor::qti::hardware::display::mapperextensions::V1_0::implementation::QtiMapperExtensions; |
Naseer Ahmed | e36f224 | 2017-12-01 15:33:56 -0500 | [diff] [blame] | 64 | |
Naseer Ahmed | 920d71b | 2018-03-08 16:54:28 -0500 | [diff] [blame] | 65 | using IMapper_2_1 = android::hardware::graphics::mapper::V2_1::IMapper; |
| 66 | using BufferDescriptorInfo_2_0 = |
| 67 | android::hardware::graphics::mapper::V2_0::IMapper::BufferDescriptorInfo; |
| 68 | using BufferDescriptorInfo_2_1 = |
| 69 | android::hardware::graphics::mapper::V2_1::IMapper::BufferDescriptorInfo; |
| 70 | using IMapperBufferDescriptor = android::hardware::graphics::mapper::V2_0::BufferDescriptor; |
| 71 | |
Ashish Kumar | f04c3de | 2018-08-01 14:45:14 +0530 | [diff] [blame] | 72 | class QtiMapper : public IQtiMapper { |
Naseer Ahmed | e36f224 | 2017-12-01 15:33:56 -0500 | [diff] [blame] | 73 | public: |
| 74 | QtiMapper(); |
| 75 | // Methods from ::android::hardware::graphics::mapper::V2_0::IMapper follow. |
Naseer Ahmed | 920d71b | 2018-03-08 16:54:28 -0500 | [diff] [blame] | 76 | Return<void> createDescriptor(const BufferDescriptorInfo_2_0 &descriptor_info, |
Naseer Ahmed | e36f224 | 2017-12-01 15:33:56 -0500 | [diff] [blame] | 77 | createDescriptor_cb hidl_cb) override; |
| 78 | Return<void> importBuffer(const hidl_handle &raw_handle, importBuffer_cb hidl_cb) override; |
| 79 | Return<Error> freeBuffer(void *buffer) override; |
| 80 | Return<void> lock(void *buffer, uint64_t cpu_usage, const IMapper::Rect &access_region, |
| 81 | const hidl_handle &acquire_fence, lock_cb hidl_cb) override; |
| 82 | Return<void> lockYCbCr(void *buffer, uint64_t cpu_usage, const IMapper::Rect &access_region, |
| 83 | const hidl_handle &acquire_fence, lockYCbCr_cb hidl_cb) override; |
| 84 | Return<void> unlock(void *buffer, unlock_cb hidl_cb) override; |
Naseer Ahmed | 036d57d | 2018-03-02 15:42:45 -0500 | [diff] [blame] | 85 | |
Naseer Ahmed | 920d71b | 2018-03-08 16:54:28 -0500 | [diff] [blame] | 86 | // Methods from ::android::hardware::graphics::mapper::V2_1::IMapper follow. |
| 87 | Return<Error> validateBufferSize(void* buffer, |
| 88 | const BufferDescriptorInfo_2_1& descriptorInfo, |
| 89 | uint32_t stride) override; |
| 90 | Return<void> getTransportSize(void* buffer, IMapper_2_1::getTransportSize_cb hidl_cb) override; |
| 91 | Return<void> createDescriptor_2_1(const BufferDescriptorInfo_2_1& descriptorInfo, |
| 92 | createDescriptor_2_1_cb _hidl_cb) override; |
Naseer Ahmed | e36f224 | 2017-12-01 15:33:56 -0500 | [diff] [blame] | 93 | |
Tharaga Balachandran | f7e62a3 | 2019-06-06 11:33:29 -0400 | [diff] [blame^] | 94 | Return<void> getMapperExtensions(getMapperExtensions_cb hidl_cb); |
| 95 | sp<mapperextensions::V1_0::IQtiMapperExtensions> extensions_ = nullptr; |
Ashish Kumar | 28fa16f | 2019-02-22 05:24:02 +0530 | [diff] [blame] | 96 | |
Naseer Ahmed | e36f224 | 2017-12-01 15:33:56 -0500 | [diff] [blame] | 97 | private: |
| 98 | BufferManager *buf_mgr_ = nullptr; |
Naseer Ahmed | 920d71b | 2018-03-08 16:54:28 -0500 | [diff] [blame] | 99 | Error CreateDescriptor(const BufferDescriptorInfo_2_1& descriptor_info, |
| 100 | IMapperBufferDescriptor * descriptor); |
Naseer Ahmed | e36f224 | 2017-12-01 15:33:56 -0500 | [diff] [blame] | 101 | bool ValidDescriptor(const IMapper::BufferDescriptorInfo &bd); |
| 102 | bool GetFenceFd(const hidl_handle &fence_handle, int *outFenceFd); |
| 103 | void WaitFenceFd(int fence_fd); |
| 104 | Error LockBuffer(void *buffer, uint64_t usage, const hidl_handle &acquire_fence); |
| 105 | }; |
| 106 | |
Naseer Ahmed | 920d71b | 2018-03-08 16:54:28 -0500 | [diff] [blame] | 107 | extern "C" IMapper_2_1 *HIDL_FETCH_IMapper(const char *name); |
Ashish Kumar | f04c3de | 2018-08-01 14:45:14 +0530 | [diff] [blame] | 108 | extern "C" IQtiMapper *HIDL_FETCH_IQtiMapper(const char *name); |
| 109 | |
Naseer Ahmed | e36f224 | 2017-12-01 15:33:56 -0500 | [diff] [blame] | 110 | } // namespace implementation |
Naseer Ahmed | e36f224 | 2017-12-01 15:33:56 -0500 | [diff] [blame] | 111 | } // namespace mapper |
| 112 | } // namespace display |
| 113 | } // namespace hardware |
| 114 | } // namespace qti |
| 115 | } // namespace vendor |
| 116 | |
| 117 | #endif // __QTIMAPPER_H__ |