chore[kmpp_obj]: Add from objs device macro

Combine kernel objdef and userspace objdef process.

Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
Signed-off-by: Yanjun Liao <yanjun.liao@rock-chips.com>
Change-Id: Icf1ad03af8df3d1450138d3a9161b2dd20bb59f5
This commit is contained in:
Herman Chen
2025-05-28 17:38:00 +08:00
parent 301d85254f
commit fddfc9db2e
3 changed files with 31 additions and 36 deletions

View File

@@ -102,6 +102,8 @@ typedef struct KmppObjDefImpl_t {
/* userspace objdef */
MppCfgObj cfg;
MppMemPool pool;
/* object define from kernel or userspace */
rk_s32 is_kobj;
rk_s32 flag_base;
rk_s32 flag_max_pos;
rk_s32 buf_size;
@@ -418,15 +420,31 @@ rk_s32 kmpp_objdef_put(KmppObjDef def)
rk_s32 ret = rk_nok;
if (impl) {
impl->ref_cnt--;
if (!impl->ref_cnt) {
if (impl->is_kobj) {
impl->ref_cnt--;
if (!impl->ref_cnt) {
if (impl->trie) {
ret = mpp_trie_deinit(impl->trie);
impl->trie = NULL;
}
}
} else {
if (impl->cfg) {
mpp_cfg_put_all(impl->cfg);
impl->cfg = NULL;
/* When init with MppCfgObj the trie is associated to the MppCfgObj */
impl->trie = NULL;
}
if (impl->trie) {
ret = mpp_trie_deinit(impl->trie);
impl->trie = NULL;
}
if (impl->pool) {
mpp_mem_pool_deinit(impl->pool);
impl->pool = NULL;
}
mpp_free(impl);
}
ret = rk_ok;
}
@@ -469,34 +487,6 @@ rk_s32 kmpp_objdef_register(KmppObjDef *def, rk_s32 size, const char *name)
return rk_ok;
}
rk_s32 kmpp_objdef_unregister(KmppObjDef def)
{
KmppObjDefImpl *impl = (KmppObjDefImpl *)def;
rk_s32 ret = rk_nok;
if (impl) {
if (impl->cfg) {
mpp_cfg_put_all(impl->cfg);
impl->cfg = NULL;
/* When init with MppCfgObj the trie is associated to the MppCfgObj */
impl->trie = NULL;
}
if (impl->trie) {
ret = mpp_trie_deinit(impl->trie);
impl->trie = NULL;
}
if (impl->pool) {
mpp_mem_pool_deinit(impl->pool);
impl->pool = NULL;
}
mpp_free(impl);
ret = rk_ok;
}
return ret;
}
rk_s32 kmpp_objdef_add_cfg_root(KmppObjDef def, MppCfgObj root)
{
KmppObjDefImpl *impl = (KmppObjDefImpl *)def;
@@ -639,7 +629,7 @@ rk_s32 kmpp_objdef_get(KmppObjDef *def, const char *name)
info = mpp_trie_get_info(p->trie, name);
if (!info) {
mpp_loge_f("failed to get objdef %s\n", name);
obj_dbg_flow("failed to get kernel objdef %s\n", name);
return rk_nok;
}
@@ -647,6 +637,7 @@ rk_s32 kmpp_objdef_get(KmppObjDef *def, const char *name)
KmppObjDefImpl *impl = &p->defs[info->index];
impl->ref_cnt++;
impl->is_kobj = 1;
*def = impl;
return rk_ok;