19762338dSopenharmony_ci/* 29762338dSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 39762338dSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 49762338dSopenharmony_ci * you may not use this file except in compliance with the License. 59762338dSopenharmony_ci * You may obtain a copy of the License at 69762338dSopenharmony_ci * 79762338dSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 89762338dSopenharmony_ci * 99762338dSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 109762338dSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 119762338dSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 129762338dSopenharmony_ci * See the License for the specific language governing permissions and 139762338dSopenharmony_ci * limitations under the License. 149762338dSopenharmony_ci */ 159762338dSopenharmony_ci 169762338dSopenharmony_ci#ifndef LIB_DMA_BUF_HEAP_H 179762338dSopenharmony_ci#define LIB_DMA_BUF_HEAP_H 189762338dSopenharmony_ci 199762338dSopenharmony_ci#include <stdlib.h> 209762338dSopenharmony_ci#include <linux/dma-buf.h> 219762338dSopenharmony_ci#include <linux/dma-heap.h> 229762338dSopenharmony_ci 239762338dSopenharmony_ci#undef LOG_TAG 249762338dSopenharmony_ci#define LOG_TAG "dmabufheap" 259762338dSopenharmony_ci 269762338dSopenharmony_ci#ifdef __cplusplus 279762338dSopenharmony_ci#if __cplusplus 289762338dSopenharmony_ciextern "C" { 299762338dSopenharmony_ci#endif /* End of #if __cplusplus */ 309762338dSopenharmony_ci#endif /* End of #ifdef __cplusplus */ 319762338dSopenharmony_ci 329762338dSopenharmony_citypedef enum { 339762338dSopenharmony_ci DMA_BUF_HEAP_BUF_SYNC_RW = DMA_BUF_SYNC_RW, 349762338dSopenharmony_ci DMA_BUF_HEAP_BUF_SYNC_READ = DMA_BUF_SYNC_READ, 359762338dSopenharmony_ci DMA_BUF_HEAP_BUF_SYNC_WRITE = DMA_BUF_SYNC_WRITE, 369762338dSopenharmony_ci} DmabufHeapBufferSyncType; 379762338dSopenharmony_ci 389762338dSopenharmony_citypedef struct { 399762338dSopenharmony_ci unsigned int fd; 409762338dSopenharmony_ci size_t size; 419762338dSopenharmony_ci unsigned int heapFlags; 429762338dSopenharmony_ci} DmabufHeapBuffer; 439762338dSopenharmony_ci 449762338dSopenharmony_ciint DmabufHeapOpen(const char *heapName); 459762338dSopenharmony_ci 469762338dSopenharmony_ciint DmabufHeapClose(unsigned int fd); 479762338dSopenharmony_ci 489762338dSopenharmony_ciint DmabufHeapBufferAlloc(unsigned int heapFd, DmabufHeapBuffer *buffer); 499762338dSopenharmony_ci 509762338dSopenharmony_ciint DmabufHeapBufferFree(DmabufHeapBuffer *buffer); 519762338dSopenharmony_ci 529762338dSopenharmony_ciint DmabufHeapBufferSyncStart(unsigned int bufferFd, DmabufHeapBufferSyncType syncType); 539762338dSopenharmony_ci 549762338dSopenharmony_ciint DmabufHeapBufferSyncEnd(unsigned int bufferFd, DmabufHeapBufferSyncType syncType); 559762338dSopenharmony_ci 569762338dSopenharmony_ci#ifdef __cplusplus 579762338dSopenharmony_ci#if __cplusplus 589762338dSopenharmony_ci} 599762338dSopenharmony_ci#endif /* End of #if __cplusplus */ 609762338dSopenharmony_ci#endif /* End of #ifdef __cplusplus */ 619762338dSopenharmony_ci 629762338dSopenharmony_ci#endif /* LIB_DMA_BUF_HEAP_H */