xref: /rockchip-linux_mpp/osal/inc/mpp_allocator.h (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
1 /* SPDX-License-Identifier: Apache-2.0 OR MIT */
2 /*
3  * Copyright (c) 2015 Rockchip Electronics Co., Ltd.
4  */
5 
6 #ifndef __MPP_ALLOCATOR_H__
7 #define __MPP_ALLOCATOR_H__
8 
9 #include "mpp_buffer.h"
10 
11 typedef enum MppAllocFlagType_e {
12     MPP_ALLOC_FLAG_NONE         = 0,
13     MPP_ALLOC_FLAG_DMA32        = (1 << 0),
14     MPP_ALLOC_FLAG_CACHABLE     = (1 << 1),
15     MPP_ALLOC_FLAG_CMA          = (1 << 2),
16     MPP_ALLOC_FLAG_TYPE_MASK    = MPP_ALLOC_FLAG_CMA | MPP_ALLOC_FLAG_CACHABLE | MPP_ALLOC_FLAG_DMA32,
17     MPP_ALLOC_FLAG_TYPE_NB,
18 } MppAllocFlagType;
19 
20 typedef void *MppAllocator;
21 
22 typedef struct MppAllocatorApi_t {
23     RK_U32  size;
24     RK_U32  version;
25 
26     MPP_RET (*alloc)(MppAllocator allocator, MppBufferInfo *data);
27     MPP_RET (*free)(MppAllocator allocator, MppBufferInfo *data);
28     MPP_RET (*import)(MppAllocator allocator, MppBufferInfo *data);
29     MPP_RET (*release)(MppAllocator allocator, MppBufferInfo *data);
30     MPP_RET (*mmap)(MppAllocator allocator, MppBufferInfo *data);
31 } MppAllocatorApi;
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /* NOTE: flag may be updated by allocator */
38 MPP_RET mpp_allocator_get(MppAllocator *allocator, MppAllocatorApi **api,
39                           MppBufferType type, MppAllocFlagType flag);
40 MPP_RET mpp_allocator_put(MppAllocator *allocator);
41 MppAllocFlagType mpp_allocator_get_flags(const MppAllocator allocator);
42 
43 #ifdef __cplusplus
44 }
45 #endif
46 
47 #endif /*__MPP_ALLOCATOR_H__*/
48