mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-06 09:36:49 +08:00
fix[allocator]: Fix misc buffer group flag issue
The default misc buffer group do not have the flag. We need to seperate the default misc group with different flag. Signed-off-by: Herman Chen <herman.chen@rock-chips.com> Change-Id: I14941eedfe9c06ec978a12061ba33e12495aa038
This commit is contained in:
@@ -59,7 +59,7 @@ private:
|
|||||||
RK_U32 total_max;
|
RK_U32 total_max;
|
||||||
|
|
||||||
// misc group for internal / externl buffer with different type
|
// misc group for internal / externl buffer with different type
|
||||||
RK_U32 misc[MPP_BUFFER_MODE_BUTT][MPP_BUFFER_TYPE_BUTT];
|
RK_U32 misc[MPP_BUFFER_MODE_BUTT][MPP_BUFFER_TYPE_BUTT][MPP_ALLOCATOR_WITH_FLAG_NUM];
|
||||||
RK_U32 misc_count;
|
RK_U32 misc_count;
|
||||||
/* preset allocator apis */
|
/* preset allocator apis */
|
||||||
MppAllocator mAllocator[MPP_BUFFER_TYPE_BUTT][MPP_ALLOCATOR_WITH_FLAG_NUM];
|
MppAllocator mAllocator[MPP_BUFFER_TYPE_BUTT][MPP_ALLOCATOR_WITH_FLAG_NUM];
|
||||||
@@ -895,7 +895,7 @@ MppBufferService::MppBufferService()
|
|||||||
total_max(0),
|
total_max(0),
|
||||||
misc_count(0)
|
misc_count(0)
|
||||||
{
|
{
|
||||||
RK_S32 i, j;
|
RK_S32 i, j, k;
|
||||||
|
|
||||||
INIT_LIST_HEAD(&mListGroup);
|
INIT_LIST_HEAD(&mListGroup);
|
||||||
INIT_LIST_HEAD(&mListOrphan);
|
INIT_LIST_HEAD(&mListOrphan);
|
||||||
@@ -905,7 +905,8 @@ MppBufferService::MppBufferService()
|
|||||||
// NOTE: Do not create misc group at beginning. Only create on when needed.
|
// NOTE: Do not create misc group at beginning. Only create on when needed.
|
||||||
for (i = 0; i < MPP_BUFFER_MODE_BUTT; i++)
|
for (i = 0; i < MPP_BUFFER_MODE_BUTT; i++)
|
||||||
for (j = 0; j < MPP_BUFFER_TYPE_BUTT; j++)
|
for (j = 0; j < MPP_BUFFER_TYPE_BUTT; j++)
|
||||||
misc[i][j] = 0;
|
for (k = 0; k < MPP_ALLOCATOR_WITH_FLAG_NUM; k++)
|
||||||
|
misc[i][j][k] = 0;
|
||||||
|
|
||||||
for (i = 0; i < (RK_S32)HASH_SIZE(mHashGroup); i++)
|
for (i = 0; i < (RK_S32)HASH_SIZE(mHashGroup); i++)
|
||||||
INIT_HLIST_HEAD(&mHashGroup[i]);
|
INIT_HLIST_HEAD(&mHashGroup[i]);
|
||||||
@@ -915,7 +916,7 @@ MppBufferService::MppBufferService()
|
|||||||
|
|
||||||
MppBufferService::~MppBufferService()
|
MppBufferService::~MppBufferService()
|
||||||
{
|
{
|
||||||
RK_S32 i, j;
|
RK_S32 i, j, k;
|
||||||
|
|
||||||
finalizing = 1;
|
finalizing = 1;
|
||||||
|
|
||||||
@@ -923,13 +924,12 @@ MppBufferService::~MppBufferService()
|
|||||||
if (misc_count) {
|
if (misc_count) {
|
||||||
mpp_log_f("cleaning misc group\n");
|
mpp_log_f("cleaning misc group\n");
|
||||||
for (i = 0; i < MPP_BUFFER_MODE_BUTT; i++)
|
for (i = 0; i < MPP_BUFFER_MODE_BUTT; i++)
|
||||||
for (j = 0; j < MPP_BUFFER_TYPE_BUTT; j++) {
|
for (j = 0; j < MPP_BUFFER_TYPE_BUTT; j++)
|
||||||
RK_U32 id = misc[i][j];
|
for (k = 0; k < MPP_ALLOCATOR_WITH_FLAG_NUM; k++) {
|
||||||
|
RK_U32 id = MPP_FETCH_AND(&misc[i][j][k], 0);
|
||||||
|
|
||||||
if (id) {
|
if (id)
|
||||||
put_group(__FUNCTION__, get_group_by_id(id));
|
put_group(__FUNCTION__, get_group_by_id(id));
|
||||||
misc[i][j] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -996,6 +996,22 @@ RK_U32 MppBufferService::get_group_id()
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static RK_U32 type_to_flag(MppBufferType type)
|
||||||
|
{
|
||||||
|
RK_U32 flag = MPP_ALLOC_FLAG_NONE;
|
||||||
|
|
||||||
|
if (type & MPP_BUFFER_FLAGS_DMA32)
|
||||||
|
flag += MPP_ALLOC_FLAG_DMA32;
|
||||||
|
|
||||||
|
if (type & MPP_BUFFER_FLAGS_CACHABLE)
|
||||||
|
flag += MPP_ALLOC_FLAG_CACHABLE;
|
||||||
|
|
||||||
|
if (type & MPP_BUFFER_FLAGS_CONTIG)
|
||||||
|
flag += MPP_ALLOC_FLAG_CMA;
|
||||||
|
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
MppBufferGroupImpl *MppBufferService::get_group(const char *tag, const char *caller,
|
MppBufferGroupImpl *MppBufferService::get_group(const char *tag, const char *caller,
|
||||||
MppBufferMode mode, MppBufferType type,
|
MppBufferMode mode, MppBufferType type,
|
||||||
RK_U32 is_misc)
|
RK_U32 is_misc)
|
||||||
@@ -1018,14 +1034,7 @@ MppBufferGroupImpl *MppBufferService::get_group(const char *tag, const char *cal
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type & MPP_BUFFER_FLAGS_DMA32)
|
flag = type_to_flag(type);
|
||||||
flag += MPP_ALLOC_FLAG_DMA32;
|
|
||||||
|
|
||||||
if (type & MPP_BUFFER_FLAGS_CACHABLE)
|
|
||||||
flag += MPP_ALLOC_FLAG_CACHABLE;
|
|
||||||
|
|
||||||
if (type & MPP_BUFFER_FLAGS_CONTIG)
|
|
||||||
flag += MPP_ALLOC_FLAG_CMA;
|
|
||||||
|
|
||||||
p->flags = (MppAllocFlagType)flag;
|
p->flags = (MppAllocFlagType)flag;
|
||||||
|
|
||||||
@@ -1095,7 +1104,7 @@ MppBufferGroupImpl *MppBufferService::get_group(const char *tag, const char *cal
|
|||||||
buf_grp_add_log(p, GRP_CREATE, caller);
|
buf_grp_add_log(p, GRP_CREATE, caller);
|
||||||
|
|
||||||
if (is_misc) {
|
if (is_misc) {
|
||||||
misc[mode][buffer_type] = id;
|
misc[mode][buffer_type][flag] = id;
|
||||||
p->is_misc = 1;
|
p->is_misc = 1;
|
||||||
misc_count++;
|
misc_count++;
|
||||||
}
|
}
|
||||||
@@ -1105,14 +1114,17 @@ MppBufferGroupImpl *MppBufferService::get_group(const char *tag, const char *cal
|
|||||||
|
|
||||||
RK_U32 MppBufferService::get_misc(MppBufferMode mode, MppBufferType type)
|
RK_U32 MppBufferService::get_misc(MppBufferMode mode, MppBufferType type)
|
||||||
{
|
{
|
||||||
|
RK_U32 flag = type_to_flag(type);
|
||||||
|
|
||||||
type = (MppBufferType)(type & MPP_BUFFER_TYPE_MASK);
|
type = (MppBufferType)(type & MPP_BUFFER_TYPE_MASK);
|
||||||
if (type == MPP_BUFFER_TYPE_NORMAL)
|
if (type == MPP_BUFFER_TYPE_NORMAL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
mpp_assert(mode < MPP_BUFFER_MODE_BUTT);
|
mpp_assert(mode < MPP_BUFFER_MODE_BUTT);
|
||||||
mpp_assert(type < MPP_BUFFER_TYPE_BUTT);
|
mpp_assert(type < MPP_BUFFER_TYPE_BUTT);
|
||||||
|
mpp_assert(flag < MPP_ALLOC_FLAG_TYPE_NB);
|
||||||
|
|
||||||
return misc[mode][type];
|
return misc[mode][type][flag];
|
||||||
}
|
}
|
||||||
|
|
||||||
void MppBufferService::put_group(const char *caller, MppBufferGroupImpl *p)
|
void MppBufferService::put_group(const char *caller, MppBufferGroupImpl *p)
|
||||||
@@ -1179,6 +1191,7 @@ void MppBufferService::destroy_group(MppBufferGroupImpl *group)
|
|||||||
{
|
{
|
||||||
MppBufferMode mode = group->mode;
|
MppBufferMode mode = group->mode;
|
||||||
MppBufferType type = group->type;
|
MppBufferType type = group->type;
|
||||||
|
RK_U32 flag = type_to_flag(type);
|
||||||
RK_U32 id = group->group_id;
|
RK_U32 id = group->group_id;
|
||||||
|
|
||||||
mpp_assert(group->count_used == 0);
|
mpp_assert(group->count_used == 0);
|
||||||
@@ -1202,8 +1215,8 @@ void MppBufferService::destroy_group(MppBufferGroupImpl *group)
|
|||||||
mpp_mem_pool_put(mpp_buf_grp_pool, group);
|
mpp_mem_pool_put(mpp_buf_grp_pool, group);
|
||||||
group_count--;
|
group_count--;
|
||||||
|
|
||||||
if (id == misc[mode][type]) {
|
if (id == misc[mode][type][flag]) {
|
||||||
misc[mode][type] = 0;
|
misc[mode][type][flag] = 0;
|
||||||
misc_count--;
|
misc_count--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -366,6 +366,7 @@ static MppAllocFlagType os_allocator_dma_heap_flags(void *ctx)
|
|||||||
|
|
||||||
os_allocator allocator_dma_heap = {
|
os_allocator allocator_dma_heap = {
|
||||||
.type = MPP_BUFFER_TYPE_DMA_HEAP,
|
.type = MPP_BUFFER_TYPE_DMA_HEAP,
|
||||||
|
.name = "dma_heap",
|
||||||
.open = os_allocator_dma_heap_open,
|
.open = os_allocator_dma_heap_open,
|
||||||
.close = os_allocator_dma_heap_close,
|
.close = os_allocator_dma_heap_close,
|
||||||
.alloc = os_allocator_dma_heap_alloc,
|
.alloc = os_allocator_dma_heap_alloc,
|
||||||
|
@@ -34,8 +34,6 @@
|
|||||||
#include "mpp_common.h"
|
#include "mpp_common.h"
|
||||||
#include "mpp_runtime.h"
|
#include "mpp_runtime.h"
|
||||||
|
|
||||||
static RK_U32 drm_debug = 0;
|
|
||||||
|
|
||||||
#define DRM_FUNCTION (0x00000001)
|
#define DRM_FUNCTION (0x00000001)
|
||||||
#define DRM_DEVICE (0x00000002)
|
#define DRM_DEVICE (0x00000002)
|
||||||
#define DRM_IOCTL (0x00000004)
|
#define DRM_IOCTL (0x00000004)
|
||||||
@@ -45,6 +43,8 @@ static RK_U32 drm_debug = 0;
|
|||||||
#define drm_dbg_dev(fmt, ...) drm_dbg(DRM_DEVICE, fmt, ## __VA_ARGS__)
|
#define drm_dbg_dev(fmt, ...) drm_dbg(DRM_DEVICE, fmt, ## __VA_ARGS__)
|
||||||
#define drm_dbg_ioctl(fmt, ...) drm_dbg(DRM_IOCTL, fmt, ## __VA_ARGS__)
|
#define drm_dbg_ioctl(fmt, ...) drm_dbg(DRM_IOCTL, fmt, ## __VA_ARGS__)
|
||||||
|
|
||||||
|
static RK_U32 drm_debug = 0;
|
||||||
|
|
||||||
/* memory type definitions. */
|
/* memory type definitions. */
|
||||||
enum drm_rockchip_gem_mem_type {
|
enum drm_rockchip_gem_mem_type {
|
||||||
/* Physically Continuous memory. */
|
/* Physically Continuous memory. */
|
||||||
@@ -152,8 +152,8 @@ static int drm_alloc(int fd, size_t len, size_t align, RK_U32 *handle, RK_U32 fl
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
*handle = dmcb.handle;
|
*handle = dmcb.handle;
|
||||||
drm_dbg_func("dev %d alloc aligned %d flags %x handle %d size %lld\n", fd,
|
drm_dbg_func("dev %d alloc aligned %d flags %x|%x handle %d size %lld\n", fd,
|
||||||
align, dmcb.flags, dmcb.handle, dmcb.size);
|
align, flags, dmcb.flags, dmcb.handle, dmcb.size);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -265,7 +265,7 @@ static MPP_RET os_allocator_drm_import(void *ctx, MppBufferInfo *data)
|
|||||||
RK_S32 fd_ext = data->fd;
|
RK_S32 fd_ext = data->fd;
|
||||||
MPP_RET ret = MPP_OK;
|
MPP_RET ret = MPP_OK;
|
||||||
|
|
||||||
drm_dbg_func("enter dev %d\n", p->drm_device);
|
drm_dbg_func("enter dev %d fd %d\n", p->drm_device, fd_ext);
|
||||||
|
|
||||||
mpp_assert(fd_ext > 0);
|
mpp_assert(fd_ext > 0);
|
||||||
|
|
||||||
@@ -277,7 +277,7 @@ static MPP_RET os_allocator_drm_import(void *ctx, MppBufferInfo *data)
|
|||||||
ret = MPP_NOK;
|
ret = MPP_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
drm_dbg_func("leave dev %d\n", p->drm_device);
|
drm_dbg_func("leave dev %d fd %d -> %d\n", p->drm_device, fd_ext, data->fd);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -375,6 +375,7 @@ static MppAllocFlagType os_allocator_drm_flags(void *ctx)
|
|||||||
|
|
||||||
os_allocator allocator_drm = {
|
os_allocator allocator_drm = {
|
||||||
.type = MPP_BUFFER_TYPE_DRM,
|
.type = MPP_BUFFER_TYPE_DRM,
|
||||||
|
.name = "drm",
|
||||||
.open = os_allocator_drm_open,
|
.open = os_allocator_drm_open,
|
||||||
.close = os_allocator_drm_close,
|
.close = os_allocator_drm_close,
|
||||||
.alloc = os_allocator_drm_alloc,
|
.alloc = os_allocator_drm_alloc,
|
||||||
|
@@ -150,6 +150,7 @@ static MppAllocFlagType os_allocator_ext_dma_flags(void *ctx)
|
|||||||
|
|
||||||
os_allocator allocator_ext_dma = {
|
os_allocator allocator_ext_dma = {
|
||||||
.type = MPP_BUFFER_TYPE_EXT_DMA,
|
.type = MPP_BUFFER_TYPE_EXT_DMA,
|
||||||
|
.name = "ext_dma",
|
||||||
.open = allocator_ext_dma_open,
|
.open = allocator_ext_dma_open,
|
||||||
.close = allocator_ext_dma_close,
|
.close = allocator_ext_dma_close,
|
||||||
.alloc = allocator_ext_dma_alloc,
|
.alloc = allocator_ext_dma_alloc,
|
||||||
|
@@ -491,6 +491,7 @@ static MppAllocFlagType os_allocator_ion_flags(void *ctx)
|
|||||||
|
|
||||||
os_allocator allocator_ion = {
|
os_allocator allocator_ion = {
|
||||||
.type = MPP_BUFFER_TYPE_ION,
|
.type = MPP_BUFFER_TYPE_ION,
|
||||||
|
.name = "ion",
|
||||||
.open = allocator_ion_open,
|
.open = allocator_ion_open,
|
||||||
.close = allocator_ion_close,
|
.close = allocator_ion_close,
|
||||||
.alloc = allocator_ion_alloc,
|
.alloc = allocator_ion_alloc,
|
||||||
|
@@ -116,6 +116,7 @@ static MppAllocFlagType os_allocator_std_flags(void *ctx)
|
|||||||
|
|
||||||
os_allocator allocator_std = {
|
os_allocator allocator_std = {
|
||||||
.type = MPP_BUFFER_TYPE_NORMAL,
|
.type = MPP_BUFFER_TYPE_NORMAL,
|
||||||
|
.name = "std",
|
||||||
.open = allocator_std_open,
|
.open = allocator_std_open,
|
||||||
.close = allocator_std_close,
|
.close = allocator_std_close,
|
||||||
.alloc = allocator_std_alloc,
|
.alloc = allocator_std_alloc,
|
||||||
|
@@ -12,6 +12,7 @@ typedef MPP_RET (*OsAllocatorFunc)(void *ctx, MppBufferInfo *info);
|
|||||||
|
|
||||||
typedef struct os_allocator_t {
|
typedef struct os_allocator_t {
|
||||||
MppBufferType type;
|
MppBufferType type;
|
||||||
|
const char *name;
|
||||||
|
|
||||||
MPP_RET (*open)(void **ctx, size_t alignment, MppAllocFlagType flags);
|
MPP_RET (*open)(void **ctx, size_t alignment, MppAllocFlagType flags);
|
||||||
MPP_RET (*close)(void *ctx);
|
MPP_RET (*close)(void *ctx);
|
||||||
|
Reference in New Issue
Block a user