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 GRALLOC_COMMON_ALLOCATOR_H 19 #define GRALLOC_COMMON_ALLOCATOR_H 20 21 #include "4.x/gralloc_allocator_hidl_header.h" 22 23 #include <functional> 24 25 #include "core/mali_gralloc_bufferdescriptor.h" 26 #include "BufferDescriptor.h" 27 28 namespace arm 29 { 30 namespace allocator 31 { 32 namespace common 33 { 34 35 using android::hardware::hidl_handle; 36 using android::hardware::hidl_vec; 37 38 /* 39 * Allocates buffers with the properties specified by the descriptor 40 * 41 * @param bufferDescriptor: Specifies the properties of the buffers to allocate. 42 * @param count: Number of buffers to allocate. 43 * @param hidl_cb [in] HIDL callback function generating - 44 * error : NONE upon success. Otherwise, 45 * BAD_DESCRIPTOR when the descriptor is invalid. 46 * NO_RESOURCES when the allocation cannot be fulfilled 47 * UNSUPPORTED when any of the property encoded in the descriptor 48 * is not supported 49 * stride: Number of pixels between two consecutive rows of the 50 * buffers, when the concept of consecutive rows is defined. 51 * buffers: An array of raw handles to the newly allocated buffers 52 * @param fb_allocator [in] function to use for allocation of buffers with GRALLOC_USAGE_HW_FB 53 */ 54 void allocate(const buffer_descriptor_t &bufferDescriptor, uint32_t count, IAllocator::allocate_cb hidl_cb, 55 std::function<int(const buffer_descriptor_t *, buffer_handle_t *)> fb_allocator = nullptr); 56 57 } // namespace common 58 } // namespace allocator 59 } // namespace arm 60 61 #endif /* GRALLOC_COMMON_ALLOCATOR_H */ 62