1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef BUFFER_ALLOCATOR_H_ 18 #define BUFFER_ALLOCATOR_H_ 19 20 #include <BufferAllocator/dmabufheap-defs.h> 21 #include <stdbool.h> 22 #include <sys/types.h> 23 24 #ifdef __cplusplus 25 extern "C" { 26 typedef class BufferAllocator BufferAllocator; 27 #else 28 typedef struct BufferAllocator BufferAllocator; 29 #endif 30 31 BufferAllocator* CreateDmabufHeapBufferAllocator(); 32 33 void FreeDmabufHeapBufferAllocator(BufferAllocator* buffer_allocator); 34 35 int DmabufHeapAlloc(BufferAllocator* buffer_allocator, const char* heap_name, size_t len, 36 unsigned int heap_flags, size_t legacy_align); 37 int DmabufHeapAllocSystem(BufferAllocator* buffer_allocator, bool cpu_access, size_t len, 38 unsigned int heap_flags, size_t legacy_align); 39 40 int MapDmabufHeapNameToIonHeap(BufferAllocator* buffer_allocator, const char* heap_name, 41 const char* ion_heap_name, unsigned int ion_heap_flags, 42 unsigned int legacy_ion_heap_mask, unsigned legacy_ion_heap_flags); 43 44 int DmabufHeapCpuSyncStart(BufferAllocator* buffer_allocator, unsigned int dmabuf_fd, 45 SyncType sync_type, int (*legacy_ion_cpu_sync)(int, int, void *), 46 void *legacy_ion_custom_data); 47 48 int DmabufHeapCpuSyncEnd(BufferAllocator* buffer_allocator, unsigned int dmabuf_fd, 49 SyncType sync_type, int (*legacy_ion_cpu_sync)(int, int, void*), 50 void* legacy_ion_custom_data); 51 52 bool CheckIonSupport(); 53 54 #ifdef __cplusplus 55 } 56 #endif 57 58 #endif 59