mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-05 09:06:50 +08:00
[mpp_hal]: add hal_h264d_api to mpp_hal
git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@207 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -65,7 +65,7 @@ MPP_RET h264d_parser(void *decoder, MppPacket pkt, HalDecTask *task)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const MppDecParser api_h264d_parser = {
|
const MppDecParser api_h264d_parser = {
|
||||||
"h264d",
|
"h264d_parser",
|
||||||
MPP_VIDEO_CodingAVC,
|
MPP_VIDEO_CodingAVC,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@@ -72,7 +72,6 @@ struct MppDec_t {
|
|||||||
const MppDecParser *parser_api;
|
const MppDecParser *parser_api;
|
||||||
void *parser_ctx;
|
void *parser_ctx;
|
||||||
|
|
||||||
const MppHalApi *hal_api;
|
|
||||||
MppHal hal_ctx;
|
MppHal hal_ctx;
|
||||||
|
|
||||||
// common resource
|
// common resource
|
||||||
|
@@ -160,7 +160,7 @@ void *mpp_dec_hal_thread(void *data)
|
|||||||
* hal thread wait for dxva interface intput firt
|
* hal thread wait for dxva interface intput firt
|
||||||
*/
|
*/
|
||||||
hal->lock();
|
hal->lock();
|
||||||
if (0 == hal_task_get_hnd(dec->tasks, 1, &task_hnd))
|
if (hal_task_get_hnd(dec->tasks, 1, &task_hnd))
|
||||||
hal->wait();
|
hal->wait();
|
||||||
hal->unlock();
|
hal->unlock();
|
||||||
|
|
||||||
|
@@ -36,6 +36,8 @@ struct HalTaskImpl_t {
|
|||||||
struct HalTaskGroupImpl_t {
|
struct HalTaskGroupImpl_t {
|
||||||
struct list_head list_unused;
|
struct list_head list_unused;
|
||||||
struct list_head list_used;
|
struct list_head list_used;
|
||||||
|
RK_U32 count_unused;
|
||||||
|
RK_U32 count_used;
|
||||||
Mutex *lock;
|
Mutex *lock;
|
||||||
MppCtxType type;
|
MppCtxType type;
|
||||||
HalTaskImpl *node;
|
HalTaskImpl *node;
|
||||||
@@ -48,6 +50,11 @@ static size_t get_task_size(HalTaskGroupImpl *group)
|
|||||||
|
|
||||||
MPP_RET hal_task_group_init(HalTaskGroup *group, MppCtxType type, RK_U32 count)
|
MPP_RET hal_task_group_init(HalTaskGroup *group, MppCtxType type, RK_U32 count)
|
||||||
{
|
{
|
||||||
|
if (NULL == group || 0 == count) {
|
||||||
|
mpp_err_f("found invalid input group %p count %d\n", group, count);
|
||||||
|
return MPP_ERR_UNKNOW;
|
||||||
|
}
|
||||||
|
|
||||||
HalTaskGroupImpl *p = mpp_malloc_size(HalTaskGroupImpl,
|
HalTaskGroupImpl *p = mpp_malloc_size(HalTaskGroupImpl,
|
||||||
sizeof(HalTaskGroupImpl) + count * sizeof(HalTaskImpl));
|
sizeof(HalTaskGroupImpl) + count * sizeof(HalTaskImpl));
|
||||||
if (NULL == p) {
|
if (NULL == p) {
|
||||||
@@ -67,12 +74,18 @@ MPP_RET hal_task_group_init(HalTaskGroup *group, MppCtxType type, RK_U32 count)
|
|||||||
p->node[i].group = p;
|
p->node[i].group = p;
|
||||||
list_add_tail(&p->node[i].list, &p->list_unused);
|
list_add_tail(&p->node[i].list, &p->list_unused);
|
||||||
}
|
}
|
||||||
|
p->count_unused = count;
|
||||||
*group = p;
|
*group = p;
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPP_RET hal_task_group_deinit(HalTaskGroup group)
|
MPP_RET hal_task_group_deinit(HalTaskGroup group)
|
||||||
{
|
{
|
||||||
|
if (NULL == group) {
|
||||||
|
mpp_err_f("found NULL input group\n");
|
||||||
|
return MPP_ERR_NULL_PTR;
|
||||||
|
}
|
||||||
|
|
||||||
HalTaskGroupImpl *p = (HalTaskGroupImpl *)group;
|
HalTaskGroupImpl *p = (HalTaskGroupImpl *)group;
|
||||||
if (p->lock) {
|
if (p->lock) {
|
||||||
delete p->lock;
|
delete p->lock;
|
||||||
@@ -84,6 +97,11 @@ MPP_RET hal_task_group_deinit(HalTaskGroup group)
|
|||||||
|
|
||||||
MPP_RET hal_task_get_hnd(HalTaskGroup group, RK_U32 used, HalTaskHnd *hnd)
|
MPP_RET hal_task_get_hnd(HalTaskGroup group, RK_U32 used, HalTaskHnd *hnd)
|
||||||
{
|
{
|
||||||
|
if (NULL == group || NULL == hnd) {
|
||||||
|
mpp_err_f("found NULL input group %p hnd %d\n", group, hnd);
|
||||||
|
return MPP_ERR_NULL_PTR;
|
||||||
|
}
|
||||||
|
|
||||||
HalTaskGroupImpl *p = (HalTaskGroupImpl *)group;
|
HalTaskGroupImpl *p = (HalTaskGroupImpl *)group;
|
||||||
Mutex::Autolock auto_lock(p->lock);
|
Mutex::Autolock auto_lock(p->lock);
|
||||||
struct list_head *head = (used) ? (&p->list_used) : (&p->list_unused);
|
struct list_head *head = (used) ? (&p->list_used) : (&p->list_unused);
|
||||||
@@ -99,12 +117,27 @@ MPP_RET hal_task_get_hnd(HalTaskGroup group, RK_U32 used, HalTaskHnd *hnd)
|
|||||||
|
|
||||||
MPP_RET hal_task_set_used(HalTaskHnd hnd, RK_U32 used)
|
MPP_RET hal_task_set_used(HalTaskHnd hnd, RK_U32 used)
|
||||||
{
|
{
|
||||||
|
if (NULL == hnd) {
|
||||||
|
mpp_err_f("found NULL input\n");
|
||||||
|
return MPP_ERR_NULL_PTR;
|
||||||
|
}
|
||||||
|
|
||||||
HalTaskImpl *impl = (HalTaskImpl *)hnd;
|
HalTaskImpl *impl = (HalTaskImpl *)hnd;
|
||||||
HalTaskGroupImpl *group = impl->group;
|
HalTaskGroupImpl *group = impl->group;
|
||||||
Mutex::Autolock auto_lock(group->lock);
|
Mutex::Autolock auto_lock(group->lock);
|
||||||
struct list_head *head = (used) ? (&group->list_used) : (&group->list_unused);
|
struct list_head *head = (used) ? (&group->list_used) : (&group->list_unused);
|
||||||
list_del_init(&impl->list);
|
list_del_init(&impl->list);
|
||||||
list_add_tail(&impl->list, head);
|
list_add_tail(&impl->list, head);
|
||||||
|
if (impl->used)
|
||||||
|
group->count_used--;
|
||||||
|
else
|
||||||
|
group->count_unused--;
|
||||||
|
if (used)
|
||||||
|
group->count_used++;
|
||||||
|
else
|
||||||
|
group->count_unused++;
|
||||||
|
|
||||||
|
impl->used = used;
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -332,7 +332,7 @@ extern "C" {
|
|||||||
|
|
||||||
extern const MppHalApi api_h264d_hal;
|
extern const MppHalApi api_h264d_hal;
|
||||||
|
|
||||||
MPP_RET hal_h264d_init (void **hal, MppHalCfg *cfg);
|
MPP_RET hal_h264d_init (void *hal, MppHalCfg *cfg);
|
||||||
MPP_RET hal_h264d_deinit (void *hal);
|
MPP_RET hal_h264d_deinit (void *hal);
|
||||||
MPP_RET hal_h264d_gen_regs(void *hal, HalTask *task);
|
MPP_RET hal_h264d_gen_regs(void *hal, HalTask *task);
|
||||||
MPP_RET hal_h264d_start (void *hal, HalTask *task);
|
MPP_RET hal_h264d_start (void *hal, HalTask *task);
|
||||||
|
@@ -33,7 +33,10 @@ typedef struct MppHalCfg_t {
|
|||||||
} MppHalCfg;
|
} MppHalCfg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
RK_U32 ctx_size;
|
char *name;
|
||||||
|
MppCodingType coding;
|
||||||
|
RK_U32 ctx_size;
|
||||||
|
RK_U32 flag;
|
||||||
|
|
||||||
MPP_RET (*init)(void *ctx, MppHalCfg *cfg);
|
MPP_RET (*init)(void *ctx, MppHalCfg *cfg);
|
||||||
MPP_RET (*deinit)(void *ctx);
|
MPP_RET (*deinit)(void *ctx);
|
||||||
|
@@ -18,21 +18,33 @@
|
|||||||
|
|
||||||
#include "mpp_mem.h"
|
#include "mpp_mem.h"
|
||||||
#include "mpp_log.h"
|
#include "mpp_log.h"
|
||||||
|
#include "mpp_common.h"
|
||||||
|
|
||||||
#include "mpp.h"
|
#include "mpp.h"
|
||||||
#include "mpp_hal.h"
|
#include "mpp_hal.h"
|
||||||
#include "mpp_frame_impl.h"
|
#include "mpp_frame_impl.h"
|
||||||
|
|
||||||
typedef struct {
|
#include "hal_h264d_api.h"
|
||||||
MppCodingType mCoding;
|
|
||||||
|
|
||||||
void *mHalCtx;
|
/*
|
||||||
MppHalApi *api;
|
* all hardware api static register here
|
||||||
|
*/
|
||||||
|
static const MppHalApi *hw_apis[] = {
|
||||||
|
&api_h264d_hal,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
MppCtxType type;
|
||||||
|
MppCodingType coding;
|
||||||
|
|
||||||
|
void *ctx;
|
||||||
|
const MppHalApi *api;
|
||||||
|
|
||||||
HalTaskGroup tasks;
|
HalTaskGroup tasks;
|
||||||
RK_U32 task_count;
|
RK_U32 task_count;
|
||||||
} MppHalImpl;
|
} MppHalImpl;
|
||||||
|
|
||||||
|
|
||||||
MPP_RET mpp_hal_init(MppHal *ctx, MppHalCfg *cfg)
|
MPP_RET mpp_hal_init(MppHal *ctx, MppHalCfg *cfg)
|
||||||
{
|
{
|
||||||
if (NULL == ctx || NULL == cfg) {
|
if (NULL == ctx || NULL == cfg) {
|
||||||
@@ -47,18 +59,36 @@ MPP_RET mpp_hal_init(MppHal *ctx, MppHalCfg *cfg)
|
|||||||
return MPP_ERR_MALLOC;
|
return MPP_ERR_MALLOC;
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg->task_count = 2;
|
RK_U32 i;
|
||||||
MPP_RET ret = hal_task_group_init(&cfg->tasks, cfg->type, cfg->task_count);
|
for (i = 0; i < MPP_ARRAY_ELEMS(hw_apis); i++) {
|
||||||
if (ret) {
|
if (cfg->coding == hw_apis[i]->coding) {
|
||||||
mpp_err_f("hal_task_group_init failed ret %d\n", ret);
|
// TODO: task count should be considered according to hardware feature
|
||||||
mpp_free(p);
|
cfg->task_count = 2;
|
||||||
return MPP_ERR_MALLOC;
|
p->type = cfg->type;
|
||||||
|
p->coding = cfg->coding;
|
||||||
|
p->api = hw_apis[i];
|
||||||
|
p->task_count = cfg->task_count;
|
||||||
|
p->ctx = mpp_malloc_size(void, p->api->ctx_size);
|
||||||
|
p->api->init(p->ctx, cfg);
|
||||||
|
|
||||||
|
MPP_RET ret = hal_task_group_init(&p->tasks, p->type, p->task_count);
|
||||||
|
if (ret) {
|
||||||
|
mpp_err_f("hal_task_group_init failed ret %d\n", ret);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg->tasks = p->tasks;
|
||||||
|
*ctx = p;
|
||||||
|
return MPP_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p->tasks = cfg->tasks;
|
mpp_err_f("could not found coding type %d\n", cfg->coding);
|
||||||
p->task_count = cfg->task_count;
|
if (p->ctx)
|
||||||
*ctx = p;
|
mpp_free(p->ctx);
|
||||||
return MPP_OK;
|
mpp_free(p);
|
||||||
|
|
||||||
|
return MPP_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPP_RET mpp_hal_deinit(MppHal ctx)
|
MPP_RET mpp_hal_deinit(MppHal ctx)
|
||||||
@@ -69,7 +99,10 @@ MPP_RET mpp_hal_deinit(MppHal ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MppHalImpl *p = (MppHalImpl*)ctx;
|
MppHalImpl *p = (MppHalImpl*)ctx;
|
||||||
hal_task_group_deinit(p->tasks);
|
if (p->ctx)
|
||||||
|
mpp_free(p->ctx);
|
||||||
|
if (p->tasks)
|
||||||
|
hal_task_group_deinit(p->tasks);
|
||||||
mpp_free(p);
|
mpp_free(p);
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
@@ -19,48 +19,63 @@
|
|||||||
#include "hal_h264d_api.h"
|
#include "hal_h264d_api.h"
|
||||||
|
|
||||||
|
|
||||||
MPP_RET hal_h264d_init(void **hal, MppHalCfg *cfg)
|
MPP_RET hal_h264d_init(void *hal, MppHalCfg *cfg)
|
||||||
{
|
{
|
||||||
|
(void)hal;
|
||||||
|
(void)cfg;
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPP_RET hal_h264d_deinit(void *hal)
|
MPP_RET hal_h264d_deinit(void *hal)
|
||||||
{
|
{
|
||||||
|
(void)hal;
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPP_RET hal_h264d_gen_regs(void *hal, HalTask *task)
|
MPP_RET hal_h264d_gen_regs(void *hal, HalTask *task)
|
||||||
{
|
{
|
||||||
|
(void)hal;
|
||||||
|
(void)task;
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
MPP_RET hal_h264d_start(void *hal, HalTask *task)
|
MPP_RET hal_h264d_start(void *hal, HalTask *task)
|
||||||
{
|
{
|
||||||
|
(void)hal;
|
||||||
|
(void)task;
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPP_RET hal_h264d_wait(void *hal, HalTask *task)
|
MPP_RET hal_h264d_wait(void *hal, HalTask *task)
|
||||||
{
|
{
|
||||||
|
(void)hal;
|
||||||
|
(void)task;
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPP_RET hal_h264d_reset(void *hal)
|
MPP_RET hal_h264d_reset(void *hal)
|
||||||
{
|
{
|
||||||
|
(void)hal;
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPP_RET hal_h264d_flush(void *hal)
|
MPP_RET hal_h264d_flush(void *hal)
|
||||||
{
|
{
|
||||||
|
(void)hal;
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPP_RET hal_h264d_control(void *hal, RK_S32 cmd_type, void *param)
|
MPP_RET hal_h264d_control(void *hal, RK_S32 cmd_type, void *param)
|
||||||
{
|
{
|
||||||
|
(void)hal;
|
||||||
|
(void)cmd_type;
|
||||||
|
(void)param;
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const MppHalApi api_h264d_hal = {
|
const MppHalApi api_h264d_hal = {
|
||||||
|
"h264d_rkdec",
|
||||||
|
MPP_VIDEO_CodingAVC,
|
||||||
|
0,
|
||||||
0,
|
0,
|
||||||
hal_h264d_init,
|
hal_h264d_init,
|
||||||
hal_h264d_deinit,
|
hal_h264d_deinit,
|
||||||
@@ -71,3 +86,4 @@ const MppHalApi api_h264d_hal = {
|
|||||||
hal_h264d_flush,
|
hal_h264d_flush,
|
||||||
hal_h264d_control,
|
hal_h264d_control,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user