• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef LIB_DMA_BUF_HEAP_H
17 #define LIB_DMA_BUF_HEAP_H
18 
19 #include <stdlib.h>
20 #include <linux/dma-buf.h>
21 #include <linux/dma-heap.h>
22 
23 #undef LOG_TAG
24 #define LOG_TAG "dmabufheap"
25 
26 #ifdef __cplusplus
27 #if __cplusplus
28 extern "C" {
29 #endif /* End of #if __cplusplus */
30 #endif /* End of #ifdef __cplusplus */
31 
32 typedef enum {
33     DMA_BUF_HEAP_BUF_SYNC_RW = DMA_BUF_SYNC_RW,
34     DMA_BUF_HEAP_BUF_SYNC_READ = DMA_BUF_SYNC_READ,
35     DMA_BUF_HEAP_BUF_SYNC_WRITE = DMA_BUF_SYNC_WRITE,
36 } DmabufHeapBufferSyncType;
37 
38 typedef struct {
39     unsigned int fd;
40     size_t size;
41     unsigned int heapFlags;
42 } DmabufHeapBuffer;
43 
44 int DmabufHeapOpen(const char *heapName);
45 
46 int DmabufHeapClose(unsigned int fd);
47 
48 int DmabufHeapBufferAlloc(unsigned int heapFd, DmabufHeapBuffer *buffer);
49 
50 int DmabufHeapBufferFree(DmabufHeapBuffer *buffer);
51 
52 int DmabufHeapBufferSyncStart(unsigned int bufferFd, DmabufHeapBufferSyncType syncType);
53 
54 int DmabufHeapBufferSyncEnd(unsigned int bufferFd, DmabufHeapBufferSyncType syncType);
55 
56 #ifdef __cplusplus
57 #if __cplusplus
58 }
59 #endif /* End of #if __cplusplus */
60 #endif /* End of #ifdef __cplusplus */
61 
62 #endif /* LIB_DMA_BUF_HEAP_H */