mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-18 15:10:39 +08:00
[alloctor]: add flags for alloctor
Each of the different alloctor has different alloctor modes, such as allocating physical continuous memory, secure memory, etc. Change-Id: Ib032689f0cfd36b494843dcc176a22c6c9587b6a Signed-off-by: Rimon Xu <rimon.xu@rock-chips.com>
This commit is contained in:
@@ -78,6 +78,7 @@ static inline void *drm_mmap(void *addr, size_t length, int prot, int flags,
|
||||
typedef struct {
|
||||
RK_U32 alignment;
|
||||
RK_S32 drm_device;
|
||||
RK_U32 flags;
|
||||
} allocator_ctx_drm;
|
||||
|
||||
static const char *dev_drm = "/dev/dri/card0";
|
||||
@@ -144,7 +145,7 @@ static int drm_fd_to_handle(int fd, int map_fd, RK_U32 *handle, RK_U32 flags)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int drm_alloc(int fd, size_t len, size_t align, RK_U32 *handle)
|
||||
static int drm_alloc(int fd, size_t len, size_t align, RK_U32 *handle, RK_U32 flags)
|
||||
{
|
||||
int ret;
|
||||
struct drm_mode_create_dumb dmcb;
|
||||
@@ -155,6 +156,7 @@ static int drm_alloc(int fd, size_t len, size_t align, RK_U32 *handle)
|
||||
dmcb.bpp = 8;
|
||||
dmcb.width = (len + align - 1) & (~(align - 1));
|
||||
dmcb.height = 1;
|
||||
dmcb.flags = flags;
|
||||
|
||||
if (handle == NULL)
|
||||
return -EINVAL;
|
||||
@@ -179,7 +181,7 @@ static int drm_free(int fd, RK_U32 handle)
|
||||
return drm_ioctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &data);
|
||||
}
|
||||
|
||||
static MPP_RET os_allocator_drm_open(void **ctx, size_t alignment)
|
||||
static MPP_RET os_allocator_drm_open(void **ctx, MppAllocatorCfg *cfg)
|
||||
{
|
||||
RK_S32 fd;
|
||||
allocator_ctx_drm *p;
|
||||
@@ -212,7 +214,8 @@ static MPP_RET os_allocator_drm_open(void **ctx, size_t alignment)
|
||||
/*
|
||||
* default drm use cma, do nothing here
|
||||
*/
|
||||
p->alignment = alignment;
|
||||
p->alignment = cfg->alignment;
|
||||
p->flags = cfg->flags;
|
||||
p->drm_device = fd;
|
||||
*ctx = p;
|
||||
}
|
||||
@@ -235,7 +238,7 @@ static MPP_RET os_allocator_drm_alloc(void *ctx, MppBufferInfo *info)
|
||||
p = (allocator_ctx_drm *)ctx;
|
||||
drm_dbg(DRM_FUNCTION, "alignment %d size %d", p->alignment, info->size);
|
||||
ret = drm_alloc(p->drm_device, info->size, p->alignment,
|
||||
(RK_U32 *)&info->hnd);
|
||||
(RK_U32 *)&info->hnd, p->flags);
|
||||
if (ret) {
|
||||
mpp_err("os_allocator_drm_alloc drm_alloc failed ret %d\n", ret);
|
||||
return ret;
|
||||
|
@@ -27,7 +27,7 @@ typedef struct {
|
||||
size_t alignment;
|
||||
} allocator_ctx;
|
||||
|
||||
static MPP_RET allocator_ext_dma_open(void **ctx, size_t alignment)
|
||||
static MPP_RET allocator_ext_dma_open(void **ctx, MppAllocatorCfg *cfg)
|
||||
{
|
||||
MPP_RET ret = MPP_OK;
|
||||
allocator_ctx *p = NULL;
|
||||
@@ -42,7 +42,7 @@ static MPP_RET allocator_ext_dma_open(void **ctx, size_t alignment)
|
||||
mpp_err_f("failed to allocate context\n");
|
||||
ret = MPP_ERR_MALLOC;
|
||||
} else {
|
||||
p->alignment = alignment;
|
||||
p->alignment = cfg->alignment;
|
||||
}
|
||||
|
||||
*ctx = p;
|
||||
|
@@ -267,7 +267,7 @@ static RK_S32 ion_heap_id = -1;
|
||||
static RK_U32 ion_heap_mask = ION_HEAP_SYSTEM_MASK;
|
||||
static pthread_mutex_t lock;
|
||||
|
||||
static MPP_RET allocator_ion_open(void **ctx, size_t alignment)
|
||||
static MPP_RET allocator_ion_open(void **ctx, MppAllocatorCfg *cfg)
|
||||
{
|
||||
RK_S32 fd;
|
||||
allocator_ctx_ion *p;
|
||||
@@ -329,7 +329,7 @@ static MPP_RET allocator_ion_open(void **ctx, size_t alignment)
|
||||
mpp_log("using ion heap %s\n", heap_name);
|
||||
}
|
||||
pthread_mutex_unlock(&lock);
|
||||
p->alignment = alignment;
|
||||
p->alignment = cfg->alignment;
|
||||
p->ion_device = fd;
|
||||
*ctx = p;
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ typedef struct {
|
||||
RK_S32 fd_count;
|
||||
} allocator_ctx;
|
||||
|
||||
static MPP_RET allocator_std_open(void **ctx, size_t alignment)
|
||||
static MPP_RET allocator_std_open(void **ctx, MppAllocatorCfg *cfg)
|
||||
{
|
||||
MPP_RET ret = MPP_OK;
|
||||
allocator_ctx *p = NULL;
|
||||
@@ -42,7 +42,7 @@ static MPP_RET allocator_std_open(void **ctx, size_t alignment)
|
||||
mpp_err_f("failed to allocate context\n");
|
||||
ret = MPP_ERR_MALLOC;
|
||||
} else
|
||||
p->alignment = alignment;
|
||||
p->alignment = cfg->alignment;
|
||||
|
||||
p->fd_count = 0;
|
||||
|
||||
|
Reference in New Issue
Block a user