mirror of
https://github.com/nyanmisaka/mpp.git
synced 2026-01-24 03:00:40 +01:00
refactor[hal_m2vd]: Fix hal_api usage
Change-Id: I60e6b7cd649b42249f7904016b39aa96fefd09d5 Signed-off-by: Yandong Lin <yandong.lin@rock-chips.com>
This commit is contained in:
parent
01d86b2880
commit
f46b504317
7 changed files with 78 additions and 58 deletions
|
|
@ -25,15 +25,6 @@ extern "C" {
|
|||
|
||||
extern const MppHalApi hal_api_m2vd;
|
||||
|
||||
MPP_RET hal_m2vd_init (void *hal, MppHalCfg *cfg);
|
||||
MPP_RET hal_m2vd_deinit (void *hal);
|
||||
MPP_RET hal_m2vd_gen_regs (void *hal, HalTaskInfo *task);
|
||||
MPP_RET hal_m2vd_start (void *hal, HalTaskInfo *task);
|
||||
MPP_RET hal_m2vd_wait (void *hal, HalTaskInfo *task);
|
||||
MPP_RET hal_m2vd_reset (void *hal);
|
||||
MPP_RET hal_m2vd_flush (void *hal);
|
||||
MPP_RET hal_m2vd_control (void *hal, MpiCmd cmd_type, void *param);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -30,39 +30,53 @@ RK_U32 m2vh_debug = 0;
|
|||
static MPP_RET hal_m2vd_gen_regs(void *hal, HalTaskInfo *task)
|
||||
{
|
||||
M2vdHalCtx *self = (M2vdHalCtx *)hal;
|
||||
return self->hal_api.reg_gen (hal, task);
|
||||
|
||||
if (NULL == self || NULL == self->hal_api || NULL == self->hal_api->reg_gen)
|
||||
return MPP_ERR_NULL_PTR;
|
||||
|
||||
return self->hal_api->reg_gen(hal, task);
|
||||
}
|
||||
|
||||
static MPP_RET hal_m2vd_start(void *hal, HalTaskInfo *task)
|
||||
{
|
||||
M2vdHalCtx *self = (M2vdHalCtx *)hal;
|
||||
return self->hal_api.start(hal, task);
|
||||
|
||||
if (NULL == self || NULL == self->hal_api || NULL == self->hal_api->start)
|
||||
return MPP_ERR_NULL_PTR;
|
||||
|
||||
return self->hal_api->start(hal, task);
|
||||
}
|
||||
|
||||
static MPP_RET hal_m2vd_wait(void *hal, HalTaskInfo *task)
|
||||
{
|
||||
M2vdHalCtx *self = (M2vdHalCtx *)hal;
|
||||
return self->hal_api.wait(hal, task);
|
||||
|
||||
if (NULL == self || NULL == self->hal_api || NULL == self->hal_api->wait)
|
||||
return MPP_ERR_NULL_PTR;
|
||||
|
||||
return self->hal_api->wait(hal, task);
|
||||
}
|
||||
|
||||
static MPP_RET hal_m2vd_deinit(void *hal)
|
||||
{
|
||||
M2vdHalCtx *self = (M2vdHalCtx *)hal;
|
||||
return self->hal_api.deinit(hal);
|
||||
|
||||
if (NULL == self || NULL == self->hal_api || NULL == self->hal_api->deinit)
|
||||
return MPP_ERR_NULL_PTR;
|
||||
|
||||
return self->hal_api->deinit(hal);
|
||||
}
|
||||
|
||||
static MPP_RET hal_m2vd_init (void *hal, MppHalCfg *cfg)
|
||||
static MPP_RET hal_m2vd_init(void *hal, MppHalCfg *cfg)
|
||||
{
|
||||
M2vdHalCtx *self = (M2vdHalCtx *)hal;
|
||||
MppHalApi *p_api = NULL;
|
||||
VpuHwMode hw_mode = MODE_NULL;
|
||||
RK_U32 hw_flag = 0;
|
||||
|
||||
if (self == NULL)
|
||||
return MPP_ERR_VALUE;
|
||||
memset(self, 0, sizeof(M2vdHalCtx));
|
||||
if (NULL == self || NULL == cfg)
|
||||
return MPP_ERR_NULL_PTR;
|
||||
|
||||
p_api = &self->hal_api;
|
||||
memset(self, 0, sizeof(M2vdHalCtx));
|
||||
|
||||
mpp_env_get_u32("m2vh_debug", &m2vh_debug, 0);
|
||||
|
||||
|
|
@ -74,31 +88,20 @@ static MPP_RET hal_m2vd_init (void *hal, MppHalCfg *cfg)
|
|||
|
||||
switch (hw_mode) {
|
||||
case VDPU2_MODE:
|
||||
p_api->init = hal_m2vd_vdpu2_init;
|
||||
p_api->deinit = hal_m2vd_vdpu2_deinit;
|
||||
p_api->reg_gen = hal_m2vd_vdpu2_gen_regs;
|
||||
p_api->start = hal_m2vd_vdpu2_start;
|
||||
p_api->wait = hal_m2vd_vdpu2_wait;
|
||||
p_api->reset = NULL;
|
||||
p_api->flush = NULL;
|
||||
p_api->control = NULL;
|
||||
self->hal_api = &hal_m2vd_vdpu2;
|
||||
break;
|
||||
case VDPU1_MODE:
|
||||
p_api->init = hal_m2vd_vdpu1_init;
|
||||
p_api->deinit = hal_m2vd_vdpu1_deinit;
|
||||
p_api->reg_gen = hal_m2vd_vdpu1_gen_regs;
|
||||
p_api->start = hal_m2vd_vdpu1_start;
|
||||
p_api->wait = hal_m2vd_vdpu1_wait;
|
||||
p_api->reset = NULL;
|
||||
p_api->flush = NULL;
|
||||
p_api->control = NULL;
|
||||
self->hal_api = &hal_m2vd_vdpu1;
|
||||
break;
|
||||
default:
|
||||
mpp_err("unknow vpu mode %d.", hw_mode);
|
||||
return MPP_ERR_INIT;
|
||||
}
|
||||
|
||||
return p_api->init(hal, cfg);;
|
||||
if (NULL == self->hal_api || NULL == self->hal_api->init)
|
||||
return MPP_ERR_NULL_PTR;
|
||||
|
||||
return self->hal_api->init(hal, cfg);
|
||||
}
|
||||
|
||||
const MppHalApi hal_api_m2vd = {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ typedef enum M2VDPicStruct_e {
|
|||
} M2VDPicStruct;
|
||||
|
||||
typedef struct M2vdHalCtx_t {
|
||||
MppHalApi hal_api;
|
||||
const MppHalApi *hal_api;
|
||||
MppBufSlots packet_slots;
|
||||
MppBufSlots frame_slots;
|
||||
void *regs;
|
||||
|
|
@ -76,4 +76,4 @@ typedef struct M2vdHalCtx_t {
|
|||
RK_U32 reg_len;
|
||||
} M2vdHalCtx;
|
||||
|
||||
#endif // HAL_M2VD_BASE_H
|
||||
#endif // HAL_M2VD_BASE_H
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@
|
|||
#include "hal_m2vd_vdpu1_reg.h"
|
||||
#include "hal_m2vd_vpu1.h"
|
||||
|
||||
MPP_RET hal_m2vd_vdpu1_init(void *hal, MppHalCfg *cfg)
|
||||
static MPP_RET hal_m2vd_vdpu1_deinit(void *hal);
|
||||
static MPP_RET hal_m2vd_vdpu1_init(void *hal, MppHalCfg *cfg)
|
||||
{
|
||||
MPP_RET ret = MPP_OK;
|
||||
M2vdHalCtx *ctx = (M2vdHalCtx *)hal;
|
||||
|
|
@ -80,7 +81,7 @@ __ERR_RET:
|
|||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET hal_m2vd_vdpu1_deinit(void *hal)
|
||||
static MPP_RET hal_m2vd_vdpu1_deinit(void *hal)
|
||||
{
|
||||
MPP_RET ret = MPP_OK;
|
||||
M2vdHalCtx *p = (M2vdHalCtx *)hal;
|
||||
|
|
@ -142,7 +143,7 @@ static MPP_RET hal_m2vd_vdpu1_init_hwcfg(M2vdHalCtx *ctx)
|
|||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_m2vd_vdpu1_gen_regs(void *hal, HalTaskInfo *task)
|
||||
static MPP_RET hal_m2vd_vdpu1_gen_regs(void *hal, HalTaskInfo *task)
|
||||
{
|
||||
MPP_RET ret = MPP_OK;
|
||||
|
||||
|
|
@ -257,7 +258,7 @@ MPP_RET hal_m2vd_vdpu1_gen_regs(void *hal, HalTaskInfo *task)
|
|||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET hal_m2vd_vdpu1_start(void *hal, HalTaskInfo *task)
|
||||
static MPP_RET hal_m2vd_vdpu1_start(void *hal, HalTaskInfo *task)
|
||||
{
|
||||
MPP_RET ret = MPP_OK;
|
||||
M2vdHalCtx *ctx = (M2vdHalCtx *)hal;
|
||||
|
|
@ -299,7 +300,7 @@ MPP_RET hal_m2vd_vdpu1_start(void *hal, HalTaskInfo *task)
|
|||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET hal_m2vd_vdpu1_wait(void *hal, HalTaskInfo *task)
|
||||
static MPP_RET hal_m2vd_vdpu1_wait(void *hal, HalTaskInfo *task)
|
||||
{
|
||||
MPP_RET ret = MPP_OK;
|
||||
M2vdHalCtx *ctx = (M2vdHalCtx *)hal;
|
||||
|
|
@ -318,3 +319,19 @@ MPP_RET hal_m2vd_vdpu1_wait(void *hal, HalTaskInfo *task)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
const MppHalApi hal_m2vd_vdpu1 = {
|
||||
.name = "m2vd_vdpu1",
|
||||
.type = MPP_CTX_DEC,
|
||||
.coding = MPP_VIDEO_CodingMPEG2,
|
||||
.ctx_size = sizeof(M2vdHalCtx),
|
||||
.flag = 0,
|
||||
.init = hal_m2vd_vdpu1_init,
|
||||
.deinit = hal_m2vd_vdpu1_deinit,
|
||||
.reg_gen = hal_m2vd_vdpu1_gen_regs,
|
||||
.start = hal_m2vd_vdpu1_start,
|
||||
.wait = hal_m2vd_vdpu1_wait,
|
||||
.reset = NULL,
|
||||
.flush = NULL,
|
||||
.control = NULL,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@
|
|||
#include "hal_m2vd_vpu2.h"
|
||||
#include "hal_m2vd_api.h"
|
||||
|
||||
MPP_RET hal_m2vd_vdpu2_init(void *hal, MppHalCfg *cfg)
|
||||
static MPP_RET hal_m2vd_vdpu2_deinit(void *hal);
|
||||
static MPP_RET hal_m2vd_vdpu2_init(void *hal, MppHalCfg *cfg)
|
||||
{
|
||||
MPP_RET ret = MPP_OK;
|
||||
M2vdHalCtx *p = (M2vdHalCtx *)hal;
|
||||
|
|
@ -102,7 +103,7 @@ __ERR_RET:
|
|||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET hal_m2vd_vdpu2_deinit(void *hal)
|
||||
static MPP_RET hal_m2vd_vdpu2_deinit(void *hal)
|
||||
{
|
||||
MPP_RET ret = MPP_OK;
|
||||
M2vdHalCtx *p = (M2vdHalCtx *)hal;
|
||||
|
|
@ -191,7 +192,7 @@ static MPP_RET hal_m2vd_vdpu2_init_hwcfg(M2vdHalCtx *ctx)
|
|||
return MPP_OK;
|
||||
}
|
||||
|
||||
MPP_RET hal_m2vd_vdpu2_gen_regs(void *hal, HalTaskInfo *task)
|
||||
static MPP_RET hal_m2vd_vdpu2_gen_regs(void *hal, HalTaskInfo *task)
|
||||
{
|
||||
MPP_RET ret = MPP_OK;
|
||||
|
||||
|
|
@ -327,7 +328,7 @@ MPP_RET hal_m2vd_vdpu2_gen_regs(void *hal, HalTaskInfo *task)
|
|||
|
||||
}
|
||||
|
||||
MPP_RET hal_m2vd_vdpu2_start(void *hal, HalTaskInfo *task)
|
||||
static MPP_RET hal_m2vd_vdpu2_start(void *hal, HalTaskInfo *task)
|
||||
{
|
||||
MPP_RET ret = MPP_OK;
|
||||
M2vdHalCtx *ctx = (M2vdHalCtx *)hal;
|
||||
|
|
@ -372,7 +373,7 @@ MPP_RET hal_m2vd_vdpu2_start(void *hal, HalTaskInfo *task)
|
|||
return ret;
|
||||
}
|
||||
|
||||
MPP_RET hal_m2vd_vdpu2_wait(void *hal, HalTaskInfo *task)
|
||||
static MPP_RET hal_m2vd_vdpu2_wait(void *hal, HalTaskInfo *task)
|
||||
{
|
||||
MPP_RET ret = MPP_OK;
|
||||
M2vdHalCtx *ctx = (M2vdHalCtx *)hal;
|
||||
|
|
@ -404,3 +405,19 @@ MPP_RET hal_m2vd_vdpu2_wait(void *hal, HalTaskInfo *task)
|
|||
m2vh_dbg_func("leave\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
const MppHalApi hal_m2vd_vdpu2 = {
|
||||
.name = "m2vd_vdpu2",
|
||||
.type = MPP_CTX_DEC,
|
||||
.coding = MPP_VIDEO_CodingMPEG2,
|
||||
.ctx_size = sizeof(M2vdHalCtx),
|
||||
.flag = 0,
|
||||
.init = hal_m2vd_vdpu2_init,
|
||||
.deinit = hal_m2vd_vdpu2_deinit,
|
||||
.reg_gen = hal_m2vd_vdpu2_gen_regs,
|
||||
.start = hal_m2vd_vdpu2_start,
|
||||
.wait = hal_m2vd_vdpu2_wait,
|
||||
.reset = NULL,
|
||||
.flush = NULL,
|
||||
.control = NULL,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -23,11 +23,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
MPP_RET hal_m2vd_vdpu1_init (void *hal, MppHalCfg *cfg);
|
||||
MPP_RET hal_m2vd_vdpu1_deinit (void *hal);
|
||||
MPP_RET hal_m2vd_vdpu1_gen_regs(void *hal, HalTaskInfo *task);
|
||||
MPP_RET hal_m2vd_vdpu1_start (void *hal, HalTaskInfo *task);
|
||||
MPP_RET hal_m2vd_vdpu1_wait (void *hal, HalTaskInfo *task);
|
||||
extern const MppHalApi hal_m2vd_vdpu1;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,11 +23,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
MPP_RET hal_m2vd_vdpu2_init (void *hal, MppHalCfg *cfg);
|
||||
MPP_RET hal_m2vd_vdpu2_deinit (void *hal);
|
||||
MPP_RET hal_m2vd_vdpu2_gen_regs(void *hal, HalTaskInfo *task);
|
||||
MPP_RET hal_m2vd_vdpu2_start (void *hal, HalTaskInfo *task);
|
||||
MPP_RET hal_m2vd_vdpu2_wait (void *hal, HalTaskInfo *task);
|
||||
extern const MppHalApi hal_m2vd_vdpu2;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue