[mpp_device]: move dev_fd in mppDevCtx

In order to separate the hardware and decoding protocols
more clearly, all API must be implemented in context.

Change-Id: I9f8128c5399149699b2e0a03bfa72ff902c25b87
Signed-off-by: Rimon Xu <rimon.xu@rock-chips.com>
Signed-off-by: Ding Wei <leo.ding@rock-chips.com>
This commit is contained in:
Rimon Xu
2018-04-28 11:07:04 +08:00
parent a1d76b96ce
commit ed620a310b
33 changed files with 478 additions and 329 deletions

View File

@@ -408,7 +408,6 @@ typedef struct H264eMbRcCtx_t {
typedef struct H264eHalContext_t { typedef struct H264eHalContext_t {
MppHalApi api; MppHalApi api;
RK_S32 vpu_fd;
IOInterruptCB int_cb; IOInterruptCB int_cb;
MppDevCtx dev_ctx; MppDevCtx dev_ctx;
h264e_feedback feedback; h264e_feedback feedback;

View File

@@ -115,13 +115,16 @@ MPP_RET hal_avsd_init(void *decoder, MppHalCfg *cfg)
p_hal->init_cb = cfg->hal_int_cb; p_hal->init_cb = cfg->hal_int_cb;
//!< mpp_device_init //!< mpp_device_init
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (p_hal->vpu_socket <= 0) { MppDevCfg dev_cfg = {
p_hal->vpu_socket = mpp_device_init(&p_hal->dev_ctx, MPP_CTX_DEC, MPP_VIDEO_CodingAVS); .type = MPP_CTX_DEC, /* type */
if (p_hal->vpu_socket <= 0) { .coding = MPP_VIDEO_CodingAVS, /* coding */
mpp_err("p_hal->vpu_socket <= 0\n"); .platform = 0, /* platform */
ret = MPP_ERR_UNKNOW; .pp_enable = 0, /* pp_enable */
goto __FAILED; };
} ret = mpp_device_init(&p_hal->dev_ctx, &dev_cfg);
if (ret) {
mpp_err("mpp_device_init failed. ret: %d\n", ret);
return ret;
} }
#endif #endif
//< get buffer group //< get buffer group
@@ -176,8 +179,11 @@ MPP_RET hal_avsd_deinit(void *decoder)
//!< mpp_device_init //!< mpp_device_init
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (p_hal->vpu_socket >= 0) { if (p_hal->dev_ctx) {
mpp_device_deinit(p_hal->vpu_socket); ret = mpp_device_deinit(p_hal->dev_ctx);
if (MPP_OK != ret) {
mpp_err("mpp_device_deinit failed. ret: %d\n", ret);
}
} }
#endif #endif
if (p_hal->mv_buf) { if (p_hal->mv_buf) {
@@ -245,7 +251,7 @@ MPP_RET hal_avsd_start(void *decoder, HalTaskInfo *task)
p_hal->frame_no++; p_hal->frame_no++;
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (mpp_device_send_reg(p_hal->vpu_socket, p_hal->p_regs, AVSD_REGISTERS)) { if (mpp_device_send_reg(p_hal->dev_ctx, p_hal->p_regs, AVSD_REGISTERS)) {
ret = MPP_ERR_VPUHW; ret = MPP_ERR_VPUHW;
mpp_err_f("Avs decoder FlushRegs fail. \n"); mpp_err_f("Avs decoder FlushRegs fail. \n");
} }
@@ -275,7 +281,7 @@ MPP_RET hal_avsd_wait(void *decoder, HalTaskInfo *task)
goto __SKIP_HARD; goto __SKIP_HARD;
} }
#ifdef RKPLATFORM #ifdef RKPLATFORM
mpp_device_wait_reg(p_hal->vpu_socket, p_hal->p_regs, AVSD_REGISTERS); mpp_device_wait_reg(p_hal->dev_ctx, p_hal->p_regs, AVSD_REGISTERS);
#endif #endif
__SKIP_HARD: __SKIP_HARD:

View File

@@ -102,7 +102,6 @@ typedef struct avsd_hal_ctx_t {
MppBufferGroup buf_group; MppBufferGroup buf_group;
IOInterruptCB init_cb; IOInterruptCB init_cb;
MppDevCtx dev_ctx; MppDevCtx dev_ctx;
RK_S32 vpu_socket;
AvsdSyntax_t syn; AvsdSyntax_t syn;
RK_U32 *p_regs; RK_U32 *p_regs;
MppBuffer mv_buf; MppBuffer mv_buf;

View File

@@ -174,14 +174,16 @@ MPP_RET hal_h264d_init(void *hal, MppHalCfg *cfg)
mpp_env_get_u32("rkv_h264d_debug", &rkv_h264d_hal_debug, 0); mpp_env_get_u32("rkv_h264d_debug", &rkv_h264d_hal_debug, 0);
//!< mpp_device_init //!< mpp_device_init
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (p_hal->vpu_socket <= 0) { MppDevCfg dev_cfg = {
mpp_device_control(&p_hal->dev_ctx, MPP_DEV_SET_HARD_PLATFORM, &hard_platform); .type = MPP_CTX_DEC, /* type */
p_hal->vpu_socket = mpp_device_init(&p_hal->dev_ctx, MPP_CTX_DEC, MPP_VIDEO_CodingAVC); .coding = MPP_VIDEO_CodingAVC, /* coding */
if (p_hal->vpu_socket <= 0) { .platform = hard_platform, /* platform */
mpp_err("p_hal->vpu_socket <= 0\n"); .pp_enable = 0, /* pp_enable */
ret = MPP_ERR_UNKNOW; };
goto __FAILED; ret = mpp_device_init(&p_hal->dev_ctx, &dev_cfg);
} if (ret) {
mpp_err("mpp_device_init failed ret: %d\n", ret);
goto __FAILED;
} }
#endif #endif
//< get buffer group //< get buffer group
@@ -219,8 +221,11 @@ MPP_RET hal_h264d_deinit(void *hal)
FUN_CHECK(ret = p_hal->hal_api.deinit(hal)); FUN_CHECK(ret = p_hal->hal_api.deinit(hal));
//!< mpp_device_init //!< mpp_device_init
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (p_hal->vpu_socket >= 0) { if (p_hal->dev_ctx) {
mpp_device_deinit(p_hal->vpu_socket); ret = mpp_device_deinit(p_hal->dev_ctx);
if (MPP_OK != ret) {
mpp_err("mpp_device_deinit failed. ret: %d\n", ret);
}
} }
#endif #endif
if (p_hal->buf_group) { if (p_hal->buf_group) {

View File

@@ -125,7 +125,6 @@ typedef struct h264d_hal_ctx_t {
MppBufSlots packet_slots; MppBufSlots packet_slots;
MppBufferGroup buf_group; MppBufferGroup buf_group;
MppBuffer cabac_buf; MppBuffer cabac_buf;
RK_S32 vpu_socket;
IOInterruptCB init_cb; IOInterruptCB init_cb;
MppDevCtx dev_ctx; MppDevCtx dev_ctx;
} H264dHalCtx_t; } H264dHalCtx_t;

View File

@@ -658,7 +658,7 @@ MPP_RET rkv_h264d_start(void *hal, HalTaskInfo *task)
p_regs[1] |= 0x00000061; // run hardware, enable buf_empty_en p_regs[1] |= 0x00000061; // run hardware, enable buf_empty_en
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (mpp_device_send_reg(p_hal->vpu_socket, (RK_U32 *)p_regs, DEC_RKV_REGISTERS)) { if (mpp_device_send_reg(p_hal->dev_ctx, (RK_U32 *)p_regs, DEC_RKV_REGISTERS)) {
ret = MPP_ERR_VPUHW; ret = MPP_ERR_VPUHW;
H264D_ERR("H264 RKV FlushRegs fail. \n"); H264D_ERR("H264 RKV FlushRegs fail. \n");
} }
@@ -690,7 +690,7 @@ MPP_RET rkv_h264d_wait(void *hal, HalTaskInfo *task)
#ifdef RKPLATFORM #ifdef RKPLATFORM
{ {
RK_S32 wait_ret = -1; RK_S32 wait_ret = -1;
wait_ret = mpp_device_wait_reg(p_hal->vpu_socket, (RK_U32 *)p_hal->regs, DEC_RKV_REGISTERS); wait_ret = mpp_device_wait_reg(p_hal->dev_ctx, (RK_U32 *)p_hal->regs, DEC_RKV_REGISTERS);
if (wait_ret) { if (wait_ret) {
ret = MPP_ERR_VPUHW; ret = MPP_ERR_VPUHW;
H264D_ERR("H264 RKV FlushRegs fail. \n"); H264D_ERR("H264 RKV FlushRegs fail. \n");

View File

@@ -831,7 +831,7 @@ MPP_RET vdpu1_h264d_start(void *hal, HalTaskInfo *task)
p_regs->SwReg57.sw_paral_bus = 1; p_regs->SwReg57.sw_paral_bus = 1;
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (mpp_device_send_reg(p_hal->vpu_socket, (RK_U32 *)p_hal->regs, if (mpp_device_send_reg(p_hal->dev_ctx, (RK_U32 *)p_hal->regs,
DEC_VDPU1_REGISTERS)) { DEC_VDPU1_REGISTERS)) {
ret = MPP_ERR_VPUHW; ret = MPP_ERR_VPUHW;
mpp_err_f("H264 VDPU1 FlushRegs fail, pid=%d, hal_frame_no=%d. \n", mpp_err_f("H264 VDPU1 FlushRegs fail, pid=%d, hal_frame_no=%d. \n",
@@ -863,7 +863,7 @@ MPP_RET vdpu1_h264d_wait(void *hal, HalTaskInfo *task)
#ifdef RKPLATFORM #ifdef RKPLATFORM
{ {
RK_S32 wait_ret = -1; RK_S32 wait_ret = -1;
wait_ret = mpp_device_wait_reg(p_hal->vpu_socket, (RK_U32 *)p_hal->regs, wait_ret = mpp_device_wait_reg(p_hal->dev_ctx, (RK_U32 *)p_hal->regs,
DEC_VDPU1_REGISTERS); DEC_VDPU1_REGISTERS);
if (wait_ret) { if (wait_ret) {
ret = MPP_ERR_VPUHW; ret = MPP_ERR_VPUHW;

View File

@@ -791,7 +791,7 @@ MPP_RET vdpu2_h264d_start(void *hal, HalTaskInfo *task)
p_regs->sw57.inter_dblspeed = 1; p_regs->sw57.inter_dblspeed = 1;
p_regs->sw57.intra_dblspeed = 1; p_regs->sw57.intra_dblspeed = 1;
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (mpp_device_send_reg(p_hal->vpu_socket, (RK_U32 *)p_hal->regs, if (mpp_device_send_reg(p_hal->dev_ctx, (RK_U32 *)p_hal->regs,
DEC_VDPU_REGISTERS)) { DEC_VDPU_REGISTERS)) {
ret = MPP_ERR_VPUHW; ret = MPP_ERR_VPUHW;
mpp_err("H264 VDPU FlushRegs fail, pid=%d.\n", getpid()); mpp_err("H264 VDPU FlushRegs fail, pid=%d.\n", getpid());
@@ -820,7 +820,7 @@ MPP_RET vdpu2_h264d_wait(void *hal, HalTaskInfo *task)
#ifdef RKPLATFORM #ifdef RKPLATFORM
{ {
RK_S32 wait_ret = -1; RK_S32 wait_ret = -1;
wait_ret = mpp_device_wait_reg(p_hal->vpu_socket, (RK_U32 *)p_hal->regs, wait_ret = mpp_device_wait_reg(p_hal->dev_ctx, (RK_U32 *)p_hal->regs,
DEC_VDPU_REGISTERS); DEC_VDPU_REGISTERS);
if (wait_ret) { if (wait_ret) {
ret = MPP_ERR_VPUHW; ret = MPP_ERR_VPUHW;

View File

@@ -60,7 +60,6 @@ typedef struct h265d_reg_buf {
void* hw_regs; void* hw_regs;
} h265d_reg_buf_t; } h265d_reg_buf_t;
typedef struct h265d_reg_context { typedef struct h265d_reg_context {
RK_S32 vpu_socket;
MppBufSlots slots; MppBufSlots slots;
MppBufSlots packet_slots; MppBufSlots packet_slots;
MppBufferGroup group; MppBufferGroup group;
@@ -436,12 +435,16 @@ MPP_RET hal_h265d_init(void *hal, MppHalCfg *cfg)
reg_cxt->packet_slots = cfg->packet_slots; reg_cxt->packet_slots = cfg->packet_slots;
///<- mpp_device_init ///<- mpp_device_init
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (reg_cxt->vpu_socket <= 0) { MppDevCfg dev_cfg = {
reg_cxt->vpu_socket = mpp_device_init(&reg_cxt->dev_ctx, MPP_CTX_DEC, MPP_VIDEO_CodingHEVC); .type = MPP_CTX_DEC, /* type */
if (reg_cxt->vpu_socket <= 0) { .coding = MPP_VIDEO_CodingHEVC, /* coding */
mpp_err("reg_cxt->vpu_socket <= 0\n"); .platform = 0, /* platform */
return MPP_ERR_UNKNOW; .pp_enable = 0, /* pp_enable */
} };
ret = mpp_device_init(&reg_cxt->dev_ctx, &dev_cfg);
if (ret) {
mpp_err("mpp_device_init failed. ret: %d\n", ret);
return ret;
} }
#endif #endif
if (reg_cxt->group == NULL) { if (reg_cxt->group == NULL) {
@@ -479,13 +482,15 @@ MPP_RET hal_h265d_deinit(void *hal)
{ {
RK_S32 ret = 0; RK_S32 ret = 0;
h265d_reg_context_t *reg_cxt = ( h265d_reg_context_t *)hal; h265d_reg_context_t *reg_cxt = (h265d_reg_context_t *)hal;
///<- mpp_device_init ///<- mpp_device_init
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (reg_cxt->vpu_socket >= 0) { if (reg_cxt->dev_ctx) {
mpp_device_deinit(reg_cxt->vpu_socket); ret = mpp_device_deinit(reg_cxt->dev_ctx);
if (MPP_OK != ret) {
mpp_err("mpp_device_deinit failed. ret: %d\n", ret);
}
} }
#endif #endif
@@ -1523,7 +1528,7 @@ MPP_RET hal_h265d_start(void *hal, HalTaskInfo *task)
} }
#ifdef RKPLATFORM #ifdef RKPLATFORM
// 68 is the nb of uint32_t // 68 is the nb of uint32_t
ret = mpp_device_send_reg(reg_cxt->vpu_socket, (RK_U32*)hw_regs, 78); ret = mpp_device_send_reg(reg_cxt->dev_ctx, (RK_U32*)hw_regs, 78);
if (ret != 0) { if (ret != 0) {
mpp_err("RK_HEVC_DEC: ERROR: mpp_device_send_reg Failed!!!\n"); mpp_err("RK_HEVC_DEC: ERROR: mpp_device_send_reg Failed!!!\n");
return MPP_ERR_VPUHW; return MPP_ERR_VPUHW;
@@ -1551,7 +1556,7 @@ MPP_RET hal_h265d_wait(void *hal, HalTaskInfo *task)
hw_regs = ( H265d_REGS_t *)reg_cxt->hw_regs; hw_regs = ( H265d_REGS_t *)reg_cxt->hw_regs;
} }
p = (RK_U8*)hw_regs; p = (RK_U8*)hw_regs;
ret = mpp_device_wait_reg(reg_cxt->vpu_socket, (RK_U32*)hw_regs, 78); ret = mpp_device_wait_reg(reg_cxt->dev_ctx, (RK_U32*)hw_regs, 78);
if (hw_regs->sw_interrupt.sw_dec_error_sta if (hw_regs->sw_interrupt.sw_dec_error_sta
|| hw_regs->sw_interrupt.sw_dec_empty_sta) { || hw_regs->sw_interrupt.sw_dec_empty_sta) {

View File

@@ -74,7 +74,6 @@ typedef struct vp9_dec_last_info {
} vp9_dec_last_info_t; } vp9_dec_last_info_t;
typedef struct hal_vp9_context { typedef struct hal_vp9_context {
RK_S32 vpu_socket;
MppBufSlots slots; MppBufSlots slots;
MppBufSlots packet_slots; MppBufSlots packet_slots;
MppDevCtx dev_ctx; MppDevCtx dev_ctx;
@@ -132,13 +131,18 @@ MPP_RET hal_vp9d_init(void *hal, MppHalCfg *cfg)
reg_cxt->packet_slots = cfg->packet_slots; reg_cxt->packet_slots = cfg->packet_slots;
///<- mpp_device_init ///<- mpp_device_init
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (reg_cxt->vpu_socket <= 0) { MppDevCfg dev_cfg = {
reg_cxt->vpu_socket = mpp_device_init(&reg_cxt->dev_ctx, MPP_CTX_DEC, MPP_VIDEO_CodingVP9); .type = MPP_CTX_DEC, /* type */
if (reg_cxt->vpu_socket <= 0) { .coding = MPP_VIDEO_CodingVP9, /* coding */
mpp_err("vp9 reg_cxt->vpu_socket <= 0\n"); .platform = 0, /* platform */
return MPP_ERR_UNKNOW; .pp_enable = 0, /* pp_enable */
} };
ret = mpp_device_init(&reg_cxt->dev_ctx, &dev_cfg);
if (ret) {
mpp_err("mpp_device_init failed. ret: %d\n", ret);
return ret;
} }
#endif #endif
if (reg_cxt->group == NULL) { if (reg_cxt->group == NULL) {
@@ -206,8 +210,11 @@ MPP_RET hal_vp9d_deinit(void *hal)
MPP_RET ret = MPP_OK; MPP_RET ret = MPP_OK;
hal_vp9_context_t *reg_cxt = (hal_vp9_context_t *)hal; hal_vp9_context_t *reg_cxt = (hal_vp9_context_t *)hal;
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (reg_cxt->vpu_socket >= 0) { if (reg_cxt->dev_ctx) {
mpp_device_deinit(reg_cxt->vpu_socket); ret = mpp_device_deinit(reg_cxt->dev_ctx);
if (MPP_OK != ret) {
mpp_err("mpp_device_deinit failed. ret: %d\n", ret);
}
} }
#endif #endif
if (reg_cxt->probe_base) { if (reg_cxt->probe_base) {
@@ -841,7 +848,7 @@ MPP_RET hal_vp9d_start(void *hal, HalTaskInfo *task)
} }
#ifdef RKPLATFORM #ifdef RKPLATFORM
#if 1 #if 1
ret = mpp_device_send_reg(reg_cxt->vpu_socket, (RK_U32*)hw_regs, sizeof(VP9_REGS) / 4); // 68 is the nb of uint32_t ret = mpp_device_send_reg(reg_cxt->dev_ctx, (RK_U32*)hw_regs, sizeof(VP9_REGS) / 4); // 68 is the nb of uint32_t
if (ret != 0) { if (ret != 0) {
mpp_err("VP9H_DBG_REG: ERROR: mpp_device_send_reg Failed!!!\n"); mpp_err("VP9H_DBG_REG: ERROR: mpp_device_send_reg Failed!!!\n");
return MPP_ERR_VPUHW; return MPP_ERR_VPUHW;
@@ -869,7 +876,8 @@ MPP_RET hal_vp9d_wait(void *hal, HalTaskInfo *task)
VP9_REGS *hw_regs = (VP9_REGS*)reg_cxt->hw_regs; VP9_REGS *hw_regs = (VP9_REGS*)reg_cxt->hw_regs;
RK_U8* p = (RK_U8*)hw_regs; RK_U8* p = (RK_U8*)hw_regs;
ret = mpp_device_wait_reg(reg_cxt->vpu_socket, (RK_U32*)hw_regs, sizeof(VP9_REGS) / 4); ret = mpp_device_wait_reg(reg_cxt->dev_ctx, (RK_U32*)hw_regs, sizeof(VP9_REGS) / 4);
for (i = 0; i < sizeof(VP9_REGS) / 4; i++) { for (i = 0; i < sizeof(VP9_REGS) / 4; i++) {
if (i == 1) { if (i == 1) {
vp9h_dbg(VP9H_DBG_REG, "RK_VP9_DEC: regs[%02d]=%08X\n", i, *((RK_U32*)p)); vp9h_dbg(VP9H_DBG_REG, "RK_VP9_DEC: regs[%02d]=%08X\n", i, *((RK_U32*)p));

View File

@@ -305,6 +305,7 @@ static void h264e_rkv_reference_init( void *dpb, H264eHalParam *par)
MPP_RET hal_h264e_rkv_init(void *hal, MppHalCfg *cfg) MPP_RET hal_h264e_rkv_init(void *hal, MppHalCfg *cfg)
{ {
RK_U32 k = 0; RK_U32 k = 0;
MPP_RET ret = MPP_OK;
H264eHalContext *ctx = (H264eHalContext *)hal; H264eHalContext *ctx = (H264eHalContext *)hal;
H264eRkvDpbCtx *dpb_ctx = NULL; H264eRkvDpbCtx *dpb_ctx = NULL;
h264e_hal_rkv_buffers *buffers = NULL; h264e_hal_rkv_buffers *buffers = NULL;
@@ -335,14 +336,17 @@ MPP_RET hal_h264e_rkv_init(void *hal, MppHalCfg *cfg)
dpb_ctx->i_frame_cnt = 0; dpb_ctx->i_frame_cnt = 0;
dpb_ctx->i_frame_num = 0; dpb_ctx->i_frame_num = 0;
ctx->vpu_fd = -1;
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_fd <= 0) { MppDevCfg dev_cfg = {
ctx->vpu_fd = mpp_device_init(&ctx->dev_ctx, MPP_CTX_ENC, MPP_VIDEO_CodingAVC); .type = MPP_CTX_ENC, /* type */
if (ctx->vpu_fd <= 0) { .coding = MPP_VIDEO_CodingAVC, /* coding */
h264e_hal_err("get vpu_socket(%d) <=0, failed. \n", ctx->vpu_fd); .platform = 0, /* platform */
return MPP_ERR_UNKNOW; .pp_enable = 0, /* pp_enable */
} };
ret = mpp_device_init(&ctx->dev_ctx, &dev_cfg);
if (ret != MPP_OK) {
h264e_hal_err("mpp_device_init failed. ret: %d\n", ret);
return ret;
} }
#endif #endif
@@ -361,6 +365,7 @@ MPP_RET hal_h264e_rkv_init(void *hal, MppHalCfg *cfg)
MPP_RET hal_h264e_rkv_deinit(void *hal) MPP_RET hal_h264e_rkv_deinit(void *hal)
{ {
MPP_RET ret = MPP_OK;
H264eHalContext *ctx = (H264eHalContext *)hal; H264eHalContext *ctx = (H264eHalContext *)hal;
h264e_hal_enter(); h264e_hal_enter();
@@ -422,18 +427,14 @@ MPP_RET hal_h264e_rkv_deinit(void *hal)
} }
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_fd <= 0) { if (ctx->dev_ctx) {
h264e_hal_err("invalid vpu socket: %d", ctx->vpu_fd); ret = mpp_device_deinit(ctx->dev_ctx);
return MPP_NOK; if (MPP_OK != ret) {
} h264e_hal_err("mpp_device_deinit failed. ret: %d\n", ret);
}
if (mpp_device_deinit(ctx->vpu_fd)) {
h264e_hal_err("mpp_device_deinit failed");
return MPP_ERR_VPUHW;
} }
#endif #endif
h264e_hal_leave(); h264e_hal_leave();
return MPP_OK; return MPP_OK;
} }
@@ -1498,13 +1499,8 @@ MPP_RET hal_h264e_rkv_start(void *hal, HalTaskInfo *task)
(void)task; (void)task;
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_fd <= 0) {
h264e_hal_err("invalid vpu socket: %d", ctx->vpu_fd);
return MPP_NOK;
}
h264e_hal_dbg(H264E_DBG_DETAIL, "vpu client is sending %d regs", length); h264e_hal_dbg(H264E_DBG_DETAIL, "vpu client is sending %d regs", length);
if (MPP_OK != mpp_device_send_reg(ctx->vpu_fd, (RK_U32 *)ioctl_info, length)) { if (MPP_OK != mpp_device_send_reg(ctx->dev_ctx, (RK_U32 *)ioctl_info, length)) {
h264e_hal_err("mpp_device_send_reg Failed!!!"); h264e_hal_err("mpp_device_send_reg Failed!!!");
return MPP_ERR_VPUHW; return MPP_ERR_VPUHW;
} else { } else {
@@ -1610,14 +1606,14 @@ static MPP_RET h264e_rkv_resend(H264eHalContext *ctx, RK_S32 mb_rc)
ioctl_info->frame_num) >> 2; ioctl_info->frame_num) >> 2;
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (mpp_device_send_reg(ctx->vpu_fd, (RK_U32 *)ioctl_info, length)) { if (mpp_device_send_reg(ctx->dev_ctx, (RK_U32 *)ioctl_info, length)) {
h264e_hal_err("mpp_device_send_reg Failed!!!"); h264e_hal_err("mpp_device_send_reg Failed!!!");
return MPP_ERR_VPUHW; return MPP_ERR_VPUHW;
} else { } else {
h264e_hal_dbg(H264E_DBG_DETAIL, "mpp_device_send_reg successfully!"); h264e_hal_dbg(H264E_DBG_DETAIL, "mpp_device_send_reg successfully!");
} }
hw_ret = mpp_device_wait_reg(ctx->vpu_fd, (RK_U32 *)reg_out, length); hw_ret = mpp_device_wait_reg(ctx->dev_ctx, (RK_U32 *)reg_out, length);
#endif #endif
if (hw_ret != MPP_OK) { if (hw_ret != MPP_OK) {
h264e_hal_err("hardware returns error:%d", hw_ret); h264e_hal_err("hardware returns error:%d", hw_ret);
@@ -1679,15 +1675,10 @@ MPP_RET hal_h264e_rkv_wait(void *hal, HalTaskInfo *task)
} }
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_fd <= 0) {
h264e_hal_err("invalid vpu socket: %d", ctx->vpu_fd);
return MPP_NOK;
}
h264e_hal_dbg(H264E_DBG_DETAIL, "mpp_device_wait_reg expect length %d\n", h264e_hal_dbg(H264E_DBG_DETAIL, "mpp_device_wait_reg expect length %d\n",
length); length);
hw_ret = mpp_device_wait_reg(ctx->vpu_fd, (RK_U32 *)reg_out, length); hw_ret = mpp_device_wait_reg(ctx->dev_ctx, (RK_U32 *)reg_out, length);
h264e_hal_dbg(H264E_DBG_DETAIL, "mpp_device_wait_reg: ret %d\n", hw_ret); h264e_hal_dbg(H264E_DBG_DETAIL, "mpp_device_wait_reg: ret %d\n", hw_ret);

View File

@@ -30,7 +30,7 @@ MPP_RET h264e_rkv_set_osd_plt(H264eHalContext *ctx, void *param)
if (plt->buf) { if (plt->buf) {
ctx->osd_plt_type = H264E_OSD_PLT_TYPE_USERDEF; ctx->osd_plt_type = H264E_OSD_PLT_TYPE_USERDEF;
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (MPP_OK != mpp_device_send_reg_with_id(ctx->vpu_fd, if (MPP_OK != mpp_device_send_reg_with_id(ctx->dev_ctx,
H264E_IOC_SET_OSD_PLT, param, H264E_IOC_SET_OSD_PLT, param,
sizeof(MppEncOSDPlt))) { sizeof(MppEncOSDPlt))) {
h264e_hal_err("set osd plt error"); h264e_hal_err("set osd plt error");

View File

@@ -39,7 +39,6 @@ typedef struct h263d_reg_context {
MppDevCtx dev_ctx; MppDevCtx dev_ctx;
// save fd for curr/ref0/ref1 for reg_gen // save fd for curr/ref0/ref1 for reg_gen
RK_S32 vpu_fd;
RK_S32 fd_curr; RK_S32 fd_curr;
RK_S32 fd_ref0; RK_S32 fd_ref0;
@@ -150,7 +149,6 @@ MPP_RET hal_vpu_h263d_init(void *hal, MppHalCfg *cfg)
MPP_RET ret = MPP_OK; MPP_RET ret = MPP_OK;
VpuH263dRegSet_t *regs = NULL; VpuH263dRegSet_t *regs = NULL;
hal_h263_ctx *ctx = (hal_h263_ctx *)hal; hal_h263_ctx *ctx = (hal_h263_ctx *)hal;
RK_S32 vpu_fd = -1;
mpp_assert(hal); mpp_assert(hal);
@@ -162,9 +160,15 @@ MPP_RET hal_vpu_h263d_init(void *hal, MppHalCfg *cfg)
} }
#ifdef RKPLATFORM #ifdef RKPLATFORM
vpu_fd = mpp_device_init(&ctx->dev_ctx, MPP_CTX_DEC, MPP_VIDEO_CodingH263); MppDevCfg dev_cfg = {
if (vpu_fd < 0) { .type = MPP_CTX_DEC, /* type */
mpp_err_f("failed to open vpu client\n"); .coding = MPP_VIDEO_CodingH263, /* coding */
.platform = 0, /* platform */
.pp_enable = 0, /* pp_enable */
};
ret = mpp_device_init(&ctx->dev_ctx, &dev_cfg);
if (ret != MPP_OK) {
mpp_err_f("mpp_device_init failed. ret: %d\n", ret);
ret = MPP_ERR_UNKNOW; ret = MPP_ERR_UNKNOW;
goto ERR_RET; goto ERR_RET;
} }
@@ -192,7 +196,6 @@ MPP_RET hal_vpu_h263d_init(void *hal, MppHalCfg *cfg)
ctx->frm_slots = cfg->frame_slots; ctx->frm_slots = cfg->frame_slots;
ctx->pkt_slots = cfg->packet_slots; ctx->pkt_slots = cfg->packet_slots;
ctx->int_cb = cfg->hal_int_cb; ctx->int_cb = cfg->hal_int_cb;
ctx->vpu_fd = vpu_fd;
ctx->regs = regs; ctx->regs = regs;
mpp_env_get_u32("h263d_hal_debug", &h263d_hal_debug, 0); mpp_env_get_u32("h263d_hal_debug", &h263d_hal_debug, 0);
@@ -220,9 +223,9 @@ MPP_RET hal_vpu_h263d_deinit(void *hal)
} }
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_fd >= 0) { ret = mpp_device_deinit(ctx->dev_ctx);
mpp_device_deinit(ctx->vpu_fd); if (MPP_OK != ret) {
ctx->vpu_fd = -1; mpp_err("mpp_device_deinit failed ret: %d\n", ret);
} }
#endif #endif
@@ -276,7 +279,7 @@ MPP_RET hal_vpu_h263d_start(void *hal, HalTaskInfo *task)
} }
} }
ret = mpp_device_send_reg(ctx->vpu_fd, regs, reg_count); ret = mpp_device_send_reg(ctx->dev_ctx, regs, reg_count);
#endif #endif
(void)hal; (void)hal;
(void)task; (void)task;
@@ -292,7 +295,7 @@ MPP_RET hal_vpu_h263d_wait(void *hal, HalTaskInfo *task)
RK_U32* regs = (RK_U32 *)&reg_out; RK_U32* regs = (RK_U32 *)&reg_out;
RK_U32 reg_count = (sizeof(reg_out) / sizeof(RK_U32)); RK_U32 reg_count = (sizeof(reg_out) / sizeof(RK_U32));
ret = mpp_device_wait_reg(ctx->vpu_fd, regs, (sizeof(reg_out) / sizeof(RK_U32))); ret = mpp_device_wait_reg(ctx->dev_ctx, regs, (sizeof(reg_out) / sizeof(RK_U32)));
if (h263d_hal_debug & H263D_HAL_DBG_REG_GET) { if (h263d_hal_debug & H263D_HAL_DBG_REG_GET) {
RK_U32 i = 0; RK_U32 i = 0;

View File

@@ -37,6 +37,7 @@ static RK_U32 hal_vpu_h264e_debug = 0;
MPP_RET hal_h264e_vepu1_init(void *hal, MppHalCfg *cfg) MPP_RET hal_h264e_vepu1_init(void *hal, MppHalCfg *cfg)
{ {
MPP_RET ret = MPP_OK;
H264eHalContext *ctx = (H264eHalContext *)hal; H264eHalContext *ctx = (H264eHalContext *)hal;
h264e_hal_enter(); h264e_hal_enter();
@@ -51,15 +52,17 @@ MPP_RET hal_h264e_vepu1_init(void *hal, MppHalCfg *cfg)
h264e_vpu_init_extra_info(ctx->extra_info); h264e_vpu_init_extra_info(ctx->extra_info);
ctx->vpu_fd = -1;
h264e_hal_dbg(H264E_DBG_DETAIL, "vpu client: %d", ctx->vpu_fd);
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_fd <= 0) { MppDevCfg dev_cfg = {
ctx->vpu_fd = mpp_device_init(&ctx->dev_ctx, MPP_CTX_ENC, MPP_VIDEO_CodingAVC); .type = MPP_CTX_ENC, /* type */
if (ctx->vpu_fd <= 0) { .coding = MPP_VIDEO_CodingAVC, /* coding */
mpp_err("get vpu_fd(%d) <=0, failed. \n", ctx->vpu_fd); .platform = 0, /* platform */
return MPP_ERR_UNKNOW; .pp_enable = 0, /* pp_enable */
} };
ret = mpp_device_init(&ctx->dev_ctx, &dev_cfg);
if (ret != MPP_OK) {
mpp_err("mpp_device_init failed. ret: %d\n", ret);
return ret;
} }
#endif #endif
ctx->hw_cfg.qp_prev = ctx->cfg->codec.h264.qp_init; ctx->hw_cfg.qp_prev = ctx->cfg->codec.h264.qp_init;
@@ -71,6 +74,7 @@ MPP_RET hal_h264e_vepu1_init(void *hal, MppHalCfg *cfg)
MPP_RET hal_h264e_vepu1_deinit(void *hal) MPP_RET hal_h264e_vepu1_deinit(void *hal)
{ {
MPP_RET ret = MPP_OK;
H264eHalContext *ctx = (H264eHalContext *)hal; H264eHalContext *ctx = (H264eHalContext *)hal;
h264e_hal_enter(); h264e_hal_enter();
@@ -107,19 +111,14 @@ MPP_RET hal_h264e_vepu1_deinit(void *hal)
} }
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_fd <= 0) { ret = mpp_device_deinit(ctx->dev_ctx);
mpp_err("invalid vpu socket: %d", ctx->vpu_fd); if (ret) {
return MPP_NOK; mpp_err("mpp_device_deinit failed ret: %d", ret);
}
if (mpp_device_deinit(ctx->vpu_fd)) {
mpp_err("mpp_device_deinit failed");
return MPP_ERR_VPUHW;
} }
#endif #endif
h264e_hal_leave(); h264e_hal_leave();
return MPP_OK; return ret;
} }
MPP_RET hal_h264e_vepu1_gen_regs(void *hal, HalTaskInfo *task) MPP_RET hal_h264e_vepu1_gen_regs(void *hal, HalTaskInfo *task)
@@ -429,11 +428,11 @@ MPP_RET hal_h264e_vepu1_start(void *hal, HalTaskInfo *task)
(void)task; (void)task;
h264e_hal_enter(); h264e_hal_enter();
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_fd > 0) { if (ctx->dev_ctx) {
RK_U32 *p_regs = (RK_U32 *)ctx->regs; RK_U32 *p_regs = (RK_U32 *)ctx->regs;
h264e_hal_dbg(H264E_DBG_DETAIL, "vpu client is sending %d regs", h264e_hal_dbg(H264E_DBG_DETAIL, "vpu client is sending %d regs",
VEPU_H264E_VEPU1_NUM_REGS); VEPU_H264E_VEPU1_NUM_REGS);
if (MPP_OK != mpp_device_send_reg(ctx->vpu_fd, p_regs, if (MPP_OK != mpp_device_send_reg(ctx->dev_ctx, p_regs,
VEPU_H264E_VEPU1_NUM_REGS)) { VEPU_H264E_VEPU1_NUM_REGS)) {
mpp_err("mpp_device_send_reg Failed!!!"); mpp_err("mpp_device_send_reg Failed!!!");
return MPP_ERR_VPUHW; return MPP_ERR_VPUHW;
@@ -441,7 +440,7 @@ MPP_RET hal_h264e_vepu1_start(void *hal, HalTaskInfo *task)
h264e_hal_dbg(H264E_DBG_DETAIL, "mpp_device_send_reg successfully!"); h264e_hal_dbg(H264E_DBG_DETAIL, "mpp_device_send_reg successfully!");
} }
} else { } else {
mpp_err("invalid vpu socket: %d", ctx->vpu_fd); mpp_err("invalid device ctx: %p", ctx->dev_ctx);
return MPP_NOK; return MPP_NOK;
} }
#endif #endif
@@ -485,8 +484,8 @@ MPP_RET hal_h264e_vepu1_wait(void *hal, HalTaskInfo *task)
h264e_hal_enter(); h264e_hal_enter();
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_fd > 0) { if (ctx->dev_ctx) {
RK_S32 hw_ret = mpp_device_wait_reg(ctx->vpu_fd, (RK_U32 *)reg_out, RK_S32 hw_ret = mpp_device_wait_reg(ctx->dev_ctx, (RK_U32 *)reg_out,
VEPU_H264E_VEPU1_NUM_REGS); VEPU_H264E_VEPU1_NUM_REGS);
h264e_hal_dbg(H264E_DBG_DETAIL, "mpp_device_wait_reg: ret %d\n", hw_ret); h264e_hal_dbg(H264E_DBG_DETAIL, "mpp_device_wait_reg: ret %d\n", hw_ret);
@@ -496,7 +495,7 @@ MPP_RET hal_h264e_vepu1_wait(void *hal, HalTaskInfo *task)
return MPP_ERR_VPUHW; return MPP_ERR_VPUHW;
} }
} else { } else {
mpp_err("invalid vpu socket: %d", ctx->vpu_fd); mpp_err("invalid device ctx: %p", ctx->dev_ctx);
return MPP_NOK; return MPP_NOK;
} }
#endif #endif

View File

@@ -257,13 +257,17 @@ MPP_RET hal_h264e_vepu2_init(void *hal, MppHalCfg *cfg)
h264e_vpu_open_dump_files(ctx->dump_files); h264e_vpu_open_dump_files(ctx->dump_files);
#endif #endif
ctx->vpu_fd = -1;
#ifdef RKPLATFORM #ifdef RKPLATFORM
ctx->vpu_fd = mpp_device_init(&ctx->dev_ctx, MPP_CTX_ENC, MPP_VIDEO_CodingAVC); MppDevCfg dev_cfg = {
if (ctx->vpu_fd <= 0) { .type = MPP_CTX_ENC, /* type */
mpp_err("get vpu_socket(%d) <=0, failed. \n", ctx->vpu_fd); .coding = MPP_VIDEO_CodingAVC, /* coding */
ret = MPP_ERR_UNKNOW; .platform = 0, /* platform */
.pp_enable = 0, /* pp_enable */
};
ret = mpp_device_init(&ctx->dev_ctx, &dev_cfg);
if (ret) {
mpp_err("mpp_device_init failed. ret: %d\n", ret);
return ret;
} }
#endif #endif
ctx->hw_cfg.qp_prev = ctx->cfg->codec.h264.qp_init; ctx->hw_cfg.qp_prev = ctx->cfg->codec.h264.qp_init;
@@ -275,6 +279,7 @@ MPP_RET hal_h264e_vepu2_init(void *hal, MppHalCfg *cfg)
MPP_RET hal_h264e_vepu2_deinit(void *hal) MPP_RET hal_h264e_vepu2_deinit(void *hal)
{ {
MPP_RET ret = MPP_OK;
H264eHalContext *ctx = (H264eHalContext *)hal; H264eHalContext *ctx = (H264eHalContext *)hal;
h264e_hal_enter(); h264e_hal_enter();
@@ -314,19 +319,14 @@ MPP_RET hal_h264e_vepu2_deinit(void *hal)
#endif #endif
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_fd <= 0) { ret = mpp_device_deinit(ctx->dev_ctx);
mpp_err("invalid vpu socket: %d", ctx->vpu_fd); if (ret) {
return MPP_NOK; mpp_err("mpp_device_deinit failed, ret: %d", ret);
}
if (mpp_device_deinit(ctx->vpu_fd)) {
mpp_err("mpp_device_deinit failed");
return MPP_ERR_VPUHW;
} }
#endif #endif
h264e_hal_leave(); h264e_hal_leave();
return MPP_OK; return ret;
} }
MPP_RET hal_h264e_vepu2_gen_regs(void *hal, HalTaskInfo *task) MPP_RET hal_h264e_vepu2_gen_regs(void *hal, HalTaskInfo *task)
@@ -662,21 +662,23 @@ MPP_RET hal_h264e_vepu2_gen_regs(void *hal, HalTaskInfo *task)
MPP_RET hal_h264e_vepu2_start(void *hal, HalTaskInfo *task) MPP_RET hal_h264e_vepu2_start(void *hal, HalTaskInfo *task)
{ {
MPP_RET ret;
H264eHalContext *ctx = (H264eHalContext *)hal; H264eHalContext *ctx = (H264eHalContext *)hal;
(void)task; (void)task;
h264e_hal_enter(); h264e_hal_enter();
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_fd > 0) { if (ctx->dev_ctx) {
RK_U32 *p_regs = (RK_U32 *)ctx->regs; RK_U32 *p_regs = (RK_U32 *)ctx->regs;
h264e_hal_dbg(H264E_DBG_DETAIL, "vpu client is sending %d regs", VEPU2_H264E_NUM_REGS); h264e_hal_dbg(H264E_DBG_DETAIL, "vpu client is sending %d regs", VEPU2_H264E_NUM_REGS);
if (MPP_OK != mpp_device_send_reg(ctx->vpu_fd, p_regs, VEPU2_H264E_NUM_REGS)) { ret = mpp_device_send_reg(ctx->dev_ctx, p_regs, VEPU2_H264E_NUM_REGS);
if (ret) {
mpp_err("mpp_device_send_reg Failed!!!"); mpp_err("mpp_device_send_reg Failed!!!");
return MPP_ERR_VPUHW; return ret;
} else { } else {
h264e_hal_dbg(H264E_DBG_DETAIL, "mpp_device_send_reg successfully!"); h264e_hal_dbg(H264E_DBG_DETAIL, "mpp_device_send_reg successfully!");
} }
} else { } else {
mpp_err("invalid vpu socket: %d", ctx->vpu_fd); mpp_err("invalid device ctx: %p", ctx->dev_ctx);
return MPP_NOK; return MPP_NOK;
} }
#endif #endif
@@ -720,8 +722,8 @@ MPP_RET hal_h264e_vepu2_wait(void *hal, HalTaskInfo *task)
h264e_hal_enter(); h264e_hal_enter();
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_fd > 0) { if (ctx->dev_ctx) {
RK_S32 hw_ret = mpp_device_wait_reg(ctx->vpu_fd, (RK_U32 *)reg_out, RK_S32 hw_ret = mpp_device_wait_reg(ctx->dev_ctx, (RK_U32 *)reg_out,
VEPU2_H264E_NUM_REGS); VEPU2_H264E_NUM_REGS);
h264e_hal_dbg(H264E_DBG_DETAIL, "mpp_device_wait_reg: ret %d\n", hw_ret); h264e_hal_dbg(H264E_DBG_DETAIL, "mpp_device_wait_reg: ret %d\n", hw_ret);
@@ -731,7 +733,7 @@ MPP_RET hal_h264e_vepu2_wait(void *hal, HalTaskInfo *task)
return MPP_ERR_VPUHW; return MPP_ERR_VPUHW;
} }
} else { } else {
mpp_err("invalid vpu socket: %d", ctx->vpu_fd); mpp_err("invalid device ctx: %p", ctx->dev_ctx);
return MPP_NOK; return MPP_NOK;
} }
#endif #endif

View File

@@ -52,7 +52,6 @@ typedef struct JpegdHalCtx {
MppBufSlots packet_slots; MppBufSlots packet_slots;
MppBufSlots frame_slots; MppBufSlots frame_slots;
MppDevCtx dev_ctx; MppDevCtx dev_ctx;
RK_S32 vpu_socket;
void *regs; void *regs;
MppBufferGroup group; MppBufferGroup group;
MppBuffer frame_buf; MppBuffer frame_buf;

View File

@@ -770,17 +770,16 @@ MPP_RET hal_jpegd_vdpu1_init(void *hal, MppHalCfg *cfg)
//get vpu socket //get vpu socket
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (JpegHalCtx->vpu_socket <= 0) { MppDevCfg dev_cfg = {
JpegHalCtx->vpu_socket = mpp_device_init(&JpegHalCtx->dev_ctx, MPP_CTX_DEC, .type = MPP_CTX_DEC, /* type */
MPP_VIDEO_CodingMJPEG); .coding = MPP_VIDEO_CodingMJPEG, /* coding */
if (JpegHalCtx->vpu_socket <= 0) { .platform = 0, /* platform */
mpp_err_f("get vpu_socket(%d) <= 0, failed.\n", .pp_enable = 0, /* pp_enable */
JpegHalCtx->vpu_socket); };
return MPP_ERR_UNKNOW; ret = mpp_device_init(&JpegHalCtx->dev_ctx, &dev_cfg);
} else { if (ret) {
jpegd_dbg_hal("get vpu_socket(%d), success.\n", mpp_err("mpp_device_init failed. ret: %d\n", ret);
JpegHalCtx->vpu_socket); return ret;
}
} }
#endif #endif
@@ -856,8 +855,11 @@ MPP_RET hal_jpegd_vdpu1_deinit(void *hal)
JpegdHalCtx *JpegHalCtx = (JpegdHalCtx *)hal; JpegdHalCtx *JpegHalCtx = (JpegdHalCtx *)hal;
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (JpegHalCtx->vpu_socket >= 0) { if (JpegHalCtx->dev_ctx) {
mpp_device_deinit(JpegHalCtx->vpu_socket); ret = mpp_device_deinit(JpegHalCtx->dev_ctx);
if (MPP_OK != ret) {
mpp_err("mpp_device_deinit failed ret: %d\n", ret);
}
} }
#endif #endif
@@ -922,19 +924,20 @@ MPP_RET hal_jpegd_vdpu1_gen_regs(void *hal, HalTaskInfo *syn)
jpegd_setup_output_fmt(JpegHalCtx, syntax); jpegd_setup_output_fmt(JpegHalCtx, syntax);
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (JpegHalCtx->set_output_fmt_flag && (JpegHalCtx->vpu_socket > 0)) { if (JpegHalCtx->set_output_fmt_flag && (NULL != JpegHalCtx->dev_ctx)) {
mpp_device_deinit(JpegHalCtx->vpu_socket); mpp_device_deinit(JpegHalCtx->dev_ctx);
JpegHalCtx->vpu_socket = 0; MppDevCfg dev_cfg = {
mpp_device_control(&JpegHalCtx->dev_ctx, MPP_DEV_ENABLE_POSTPROCCESS, NULL); .type = MPP_CTX_DEC, /* type */
JpegHalCtx->vpu_socket = mpp_device_init(&JpegHalCtx->dev_ctx, MPP_CTX_DEC, .coding = MPP_VIDEO_CodingMJPEG, /* coding */
MPP_VIDEO_CodingMJPEG); .platform = 0, /* platform */
if (JpegHalCtx->vpu_socket <= 0) { .pp_enable = 1, /* pp_enable */
mpp_err_f("get vpu_socket(%d) <= 0, failed.\n", };
JpegHalCtx->vpu_socket); ret = mpp_device_init(&JpegHalCtx->dev_ctx, &dev_cfg);
return MPP_ERR_UNKNOW; if (ret) {
mpp_err("mpp_device_init failed. ret: %d\n", ret);
return ret;
} else { } else {
jpegd_dbg_hal("get vpu_socket(%d), success.\n", jpegd_dbg_hal("mpp_device_init success.\n");
JpegHalCtx->vpu_socket);
} }
} }
@@ -972,7 +975,7 @@ MPP_RET hal_jpegd_vdpu1_start(void *hal, HalTaskInfo *task)
#ifdef RKPLATFORM #ifdef RKPLATFORM
RK_U32 *p_regs = (RK_U32 *)JpegHalCtx->regs; RK_U32 *p_regs = (RK_U32 *)JpegHalCtx->regs;
ret = mpp_device_send_reg(JpegHalCtx->vpu_socket, p_regs, ret = mpp_device_send_reg(JpegHalCtx->dev_ctx, p_regs,
sizeof(JpegdIocRegInfo) / sizeof(RK_U32)); sizeof(JpegdIocRegInfo) / sizeof(RK_U32));
if (ret != 0) { if (ret != 0) {
mpp_err_f("mpp_device_send_reg Failed!!!\n"); mpp_err_f("mpp_device_send_reg Failed!!!\n");
@@ -999,7 +1002,7 @@ MPP_RET hal_jpegd_vdpu1_wait(void *hal, HalTaskInfo *task)
MppFrame tmp = NULL; MppFrame tmp = NULL;
RK_U32 reg[164]; /* kernel will return 164 registers */ RK_U32 reg[164]; /* kernel will return 164 registers */
ret = mpp_device_wait_reg(JpegHalCtx->vpu_socket, reg, ret = mpp_device_wait_reg(JpegHalCtx->dev_ctx, reg,
sizeof(reg) / sizeof(RK_U32)); sizeof(reg) / sizeof(RK_U32));
reg_out = (JpegRegSet *)reg; reg_out = (JpegRegSet *)reg;
if (reg_out->reg1_interrupt.sw_dec_bus_int) { if (reg_out->reg1_interrupt.sw_dec_bus_int) {

View File

@@ -753,17 +753,18 @@ MPP_RET hal_jpegd_vdpu2_init(void *hal, MppHalCfg *cfg)
//get vpu socket //get vpu socket
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (JpegHalCtx->vpu_socket <= 0) { MppDevCfg dev_cfg = {
JpegHalCtx->vpu_socket = mpp_device_init(&JpegHalCtx->dev_ctx, MPP_CTX_DEC, .type = MPP_CTX_DEC, /* type */
MPP_VIDEO_CodingMJPEG); .coding = MPP_VIDEO_CodingMJPEG, /* coding */
if (JpegHalCtx->vpu_socket <= 0) { .platform = 0, /* platform */
mpp_err_f("get vpu_socket(%d) <= 0, failed. \n", .pp_enable = 0, /* pp_enable */
JpegHalCtx->vpu_socket); };
return MPP_ERR_UNKNOW; ret = mpp_device_init(&JpegHalCtx->dev_ctx, &dev_cfg);
} else { if (ret) {
jpegd_dbg_hal("get vpu_socket(%d), success. \n", mpp_err("mpp_device_init failed. ret: %d\n", ret);
JpegHalCtx->vpu_socket); return ret;
} } else {
jpegd_dbg_hal("mpp_device_init success. \n");
} }
#endif #endif
@@ -837,8 +838,11 @@ MPP_RET hal_jpegd_vdpu2_deinit(void *hal)
JpegdHalCtx *JpegHalCtx = (JpegdHalCtx *)hal; JpegdHalCtx *JpegHalCtx = (JpegdHalCtx *)hal;
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (JpegHalCtx->vpu_socket >= 0) { if (JpegHalCtx->dev_ctx) {
mpp_device_deinit(JpegHalCtx->vpu_socket); ret = mpp_device_deinit(JpegHalCtx->dev_ctx);
if (MPP_OK != ret) {
mpp_err("mpp_device_deinit failed. ret: %d\n", ret);
}
} }
#endif #endif
@@ -901,19 +905,20 @@ MPP_RET hal_jpegd_vdpu2_gen_regs(void *hal, HalTaskInfo *syn)
jpegd_setup_output_fmt(JpegHalCtx, syntax); jpegd_setup_output_fmt(JpegHalCtx, syntax);
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (JpegHalCtx->set_output_fmt_flag && (JpegHalCtx->vpu_socket > 0)) { if (JpegHalCtx->set_output_fmt_flag && (NULL != JpegHalCtx->dev_ctx)) {
mpp_device_deinit(JpegHalCtx->vpu_socket); mpp_device_deinit(JpegHalCtx->dev_ctx);
JpegHalCtx->vpu_socket = 0; MppDevCfg dev_cfg = {
mpp_device_control(&JpegHalCtx->dev_ctx, MPP_DEV_ENABLE_POSTPROCCESS, NULL); .type = MPP_CTX_DEC, /* type */
JpegHalCtx->vpu_socket = mpp_device_init(&JpegHalCtx->dev_ctx, MPP_CTX_DEC, .coding = MPP_VIDEO_CodingMJPEG, /* coding */
MPP_VIDEO_CodingMJPEG); .platform = 0, /* platform */
if (JpegHalCtx->vpu_socket <= 0) { .pp_enable = 1, /* pp_enable */
mpp_err_f("get vpu_socket(%d) <= 0, failed. \n", };
JpegHalCtx->vpu_socket); ret = mpp_device_init(&JpegHalCtx->dev_ctx, &dev_cfg);
return MPP_ERR_UNKNOW; if (ret != MPP_OK) {
mpp_err("mpp_device_init failed. ret: %d\n", ret);
return ret;
} else { } else {
jpegd_dbg_hal("get vpu_socket(%d), success. \n", jpegd_dbg_hal("mpp_device_init success. \n");
JpegHalCtx->vpu_socket);
} }
} }
@@ -951,7 +956,7 @@ MPP_RET hal_jpegd_vdpu2_start(void *hal, HalTaskInfo *task)
#ifdef RKPLATFORM #ifdef RKPLATFORM
RK_U32 *p_regs = (RK_U32 *)JpegHalCtx->regs; RK_U32 *p_regs = (RK_U32 *)JpegHalCtx->regs;
ret = mpp_device_send_reg(JpegHalCtx->vpu_socket, p_regs, ret = mpp_device_send_reg(JpegHalCtx->dev_ctx, p_regs,
sizeof(JpegdIocRegInfo) / sizeof(RK_U32)); sizeof(JpegdIocRegInfo) / sizeof(RK_U32));
if (ret != 0) { if (ret != 0) {
mpp_err_f("mpp_device_send_reg Failed!!!\n"); mpp_err_f("mpp_device_send_reg Failed!!!\n");
@@ -978,7 +983,7 @@ MPP_RET hal_jpegd_vdpu2_wait(void *hal, HalTaskInfo *task)
MppFrame tmp = NULL; MppFrame tmp = NULL;
RK_U32 reg[184]; RK_U32 reg[184];
ret = mpp_device_wait_reg(JpegHalCtx->vpu_socket, reg, ret = mpp_device_wait_reg(JpegHalCtx->dev_ctx, reg,
sizeof(reg) / sizeof(RK_U32)); sizeof(reg) / sizeof(RK_U32));
reg_out = (JpegRegSet *)reg; reg_out = (JpegRegSet *)reg;

View File

@@ -34,8 +34,6 @@ typedef struct JpegeIocRegInfo_t {
} JpegeIocRegInfo; } JpegeIocRegInfo;
typedef struct hal_jpege_ctx_s { typedef struct hal_jpege_ctx_s {
RK_S32 vpu_fd;
IOInterruptCB int_cb; IOInterruptCB int_cb;
MppDevCtx dev_ctx; MppDevCtx dev_ctx;
JpegeBits bits; JpegeBits bits;

View File

@@ -51,6 +51,7 @@ static const RK_U32 qp_reorder_table[64] = {
MPP_RET hal_jpege_vepu1_init(void *hal, MppHalCfg *cfg) MPP_RET hal_jpege_vepu1_init(void *hal, MppHalCfg *cfg)
{ {
MPP_RET ret = MPP_OK;
HalJpegeCtx *ctx = (HalJpegeCtx *)hal; HalJpegeCtx *ctx = (HalJpegeCtx *)hal;
mpp_env_get_u32("hal_jpege_debug", &hal_jpege_debug, 0); mpp_env_get_u32("hal_jpege_debug", &hal_jpege_debug, 0);
@@ -59,10 +60,16 @@ MPP_RET hal_jpege_vepu1_init(void *hal, MppHalCfg *cfg)
ctx->int_cb = cfg->hal_int_cb; ctx->int_cb = cfg->hal_int_cb;
#ifdef RKPLATFORM #ifdef RKPLATFORM
ctx->vpu_fd = mpp_device_init(&ctx->dev_ctx, MPP_CTX_ENC, MPP_VIDEO_CodingMJPEG); MppDevCfg dev_cfg = {
if (ctx->vpu_fd < 0) { .type = MPP_CTX_ENC, /* type */
mpp_err_f("failed to open vpu client\n"); .coding = MPP_VIDEO_CodingMJPEG, /* coding */
return MPP_NOK; .platform = 0, /* platform */
.pp_enable = 0, /* pp_enable */
};
ret = mpp_device_init(&ctx->dev_ctx, &dev_cfg);
if (ret) {
mpp_err("mpp_device_init failed. ret: %d\n", ret);
return ret;
} }
#endif #endif
jpege_bits_init(&ctx->bits); jpege_bits_init(&ctx->bits);
@@ -84,6 +91,7 @@ MPP_RET hal_jpege_vepu1_init(void *hal, MppHalCfg *cfg)
MPP_RET hal_jpege_vepu1_deinit(void *hal) MPP_RET hal_jpege_vepu1_deinit(void *hal)
{ {
MPP_RET ret = MPP_OK;
HalJpegeCtx *ctx = (HalJpegeCtx *)hal; HalJpegeCtx *ctx = (HalJpegeCtx *)hal;
hal_jpege_dbg_func("enter hal %p\n", hal); hal_jpege_dbg_func("enter hal %p\n", hal);
@@ -94,15 +102,17 @@ MPP_RET hal_jpege_vepu1_deinit(void *hal)
} }
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_fd >= 0) { if (ctx->dev_ctx) {
mpp_device_deinit(ctx->vpu_fd); ret = mpp_device_deinit(ctx->dev_ctx);
ctx->vpu_fd = -1; if (ret) {
mpp_err("mpp_device_deinit failed. ret: %d\n", ret);
}
} }
#endif #endif
mpp_free(ctx->ioctl_info.regs); mpp_free(ctx->ioctl_info.regs);
hal_jpege_dbg_func("leave hal %p\n", hal); hal_jpege_dbg_func("leave hal %p\n", hal);
return MPP_OK; return ret;
} }
static MPP_RET hal_jpege_vepu1_set_extra_info(JpegeIocExtInfo *info, JpegeSyntax *syntax) static MPP_RET hal_jpege_vepu1_set_extra_info(JpegeIocExtInfo *info, JpegeSyntax *syntax)
@@ -434,8 +444,8 @@ MPP_RET hal_jpege_vepu1_start(void *hal, HalTaskInfo *task)
memcpy(cache, ctx->ioctl_info.regs, reg_size); memcpy(cache, ctx->ioctl_info.regs, reg_size);
memcpy(cache + reg_num, &(ctx->ioctl_info.extra_info), extra_size); memcpy(cache + reg_num, &(ctx->ioctl_info.extra_info), extra_size);
if (ctx->vpu_fd >= 0) { if (ctx->dev_ctx) {
ret = mpp_device_send_reg(ctx->vpu_fd, cache, reg_num + extra_num); ret = mpp_device_send_reg(ctx->dev_ctx, cache, reg_num + extra_num);
} }
mpp_free(cache); mpp_free(cache);
@@ -460,8 +470,8 @@ MPP_RET hal_jpege_vepu1_wait(void *hal, HalTaskInfo *task)
hal_jpege_dbg_func("enter hal %p\n", hal); hal_jpege_dbg_func("enter hal %p\n", hal);
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_fd >= 0) { if (ctx->dev_ctx) {
ret = mpp_device_wait_reg(ctx->vpu_fd, regs, sizeof(jpege_vepu1_reg_set) / sizeof(RK_U32)); ret = mpp_device_wait_reg(ctx->dev_ctx, regs, sizeof(jpege_vepu1_reg_set) / sizeof(RK_U32));
} }
#endif #endif
val = regs[1]; val = regs[1];

View File

@@ -50,6 +50,7 @@ static const RK_U32 qp_reorder_table[64] = {
MPP_RET hal_jpege_vepu2_init(void *hal, MppHalCfg *cfg) MPP_RET hal_jpege_vepu2_init(void *hal, MppHalCfg *cfg)
{ {
MPP_RET ret = MPP_OK;
HalJpegeCtx *ctx = (HalJpegeCtx *)hal; HalJpegeCtx *ctx = (HalJpegeCtx *)hal;
mpp_env_get_u32("hal_jpege_debug", &hal_jpege_debug, 0); mpp_env_get_u32("hal_jpege_debug", &hal_jpege_debug, 0);
@@ -58,10 +59,16 @@ MPP_RET hal_jpege_vepu2_init(void *hal, MppHalCfg *cfg)
ctx->int_cb = cfg->hal_int_cb; ctx->int_cb = cfg->hal_int_cb;
#ifdef RKPLATFORM #ifdef RKPLATFORM
ctx->vpu_fd = mpp_device_init(&ctx->dev_ctx, MPP_CTX_ENC, MPP_VIDEO_CodingMJPEG); MppDevCfg dev_cfg = {
if (ctx->vpu_fd < 0) { .type = MPP_CTX_ENC, /* type */
.coding = MPP_VIDEO_CodingMJPEG, /* coding */
.platform = 0, /* platform */
.pp_enable = 0, /* pp_enable */
};
ret = mpp_device_init(&ctx->dev_ctx, &dev_cfg);
if (ret != MPP_OK) {
mpp_err_f("failed to open vpu client\n"); mpp_err_f("failed to open vpu client\n");
return MPP_NOK; return ret;
} }
#endif #endif
jpege_bits_init(&ctx->bits); jpege_bits_init(&ctx->bits);
@@ -93,9 +100,9 @@ MPP_RET hal_jpege_vepu2_deinit(void *hal)
} }
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_fd >= 0) { if (ctx->dev_ctx) {
mpp_device_deinit(ctx->vpu_fd); mpp_device_deinit(ctx->dev_ctx);
ctx->vpu_fd = -1; ctx->dev_ctx = NULL;
} }
#endif #endif
mpp_free(ctx->ioctl_info.regs); mpp_free(ctx->ioctl_info.regs);
@@ -419,8 +426,8 @@ MPP_RET hal_jpege_vepu2_start(void *hal, HalTaskInfo *task)
memcpy(cache, ctx->ioctl_info.regs, reg_size); memcpy(cache, ctx->ioctl_info.regs, reg_size);
memcpy(cache + reg_num, &(ctx->ioctl_info.extra_info), extra_size); memcpy(cache + reg_num, &(ctx->ioctl_info.extra_info), extra_size);
if (ctx->vpu_fd >= 0) { if (ctx->dev_ctx) {
ret = mpp_device_send_reg(ctx->vpu_fd, cache, reg_num + extra_num); ret = mpp_device_send_reg(ctx->dev_ctx, cache, reg_num + extra_num);
} }
mpp_free(cache); mpp_free(cache);
@@ -446,8 +453,8 @@ MPP_RET hal_jpege_vepu2_wait(void *hal, HalTaskInfo *task)
hal_jpege_dbg_func("enter hal %p\n", hal); hal_jpege_dbg_func("enter hal %p\n", hal);
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_fd >= 0) { if (ctx->dev_ctx) {
ret = mpp_device_wait_reg(ctx->vpu_fd, regs, sizeof(jpege_vepu2_reg_set) / sizeof(RK_U32)); ret = mpp_device_wait_reg(ctx->dev_ctx, regs, sizeof(jpege_vepu2_reg_set) / sizeof(RK_U32));
} }
#endif #endif
val = regs[109]; val = regs[109];

View File

@@ -66,12 +66,16 @@ MPP_RET hal_m2vd_init(void *hal, MppHalCfg *cfg)
mpp_env_get_u32("m2vh_debug", &m2vh_debug, 0); mpp_env_get_u32("m2vh_debug", &m2vh_debug, 0);
//get vpu socket //get vpu socket
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (p->vpu_socket <= 0) { MppDevCfg dev_cfg = {
p->vpu_socket = mpp_device_init(&p->dev_ctx, MPP_CTX_DEC, MPP_VIDEO_CodingMPEG2); .type = MPP_CTX_DEC, /* type */
if (p->vpu_socket <= 0) { .coding = MPP_VIDEO_CodingMPEG2, /* coding */
mpp_err("get vpu_socket(%d) <=0, failed. \n", p->vpu_socket); .platform = 0, /* platform */
return MPP_ERR_UNKNOW; .pp_enable = 0, /* pp_enable */
} };
ret = mpp_device_init(&p->dev_ctx, &dev_cfg);
if (ret) {
mpp_err("mpp_device_init failed. ret: %d\n", ret);
return ret;
} }
#endif #endif
if (p->group == NULL) { if (p->group == NULL) {
@@ -148,8 +152,12 @@ MPP_RET hal_m2vd_deinit(void *hal)
M2VDHalContext *p = (M2VDHalContext *)hal; M2VDHalContext *p = (M2VDHalContext *)hal;
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (p->vpu_socket >= 0) if (p->dev_ctx) {
mpp_device_deinit(p->vpu_socket); ret = mpp_device_deinit(p->dev_ctx);
if (MPP_OK != ret) {
mpp_err("mpp_device_deinit failed ret: %d\n", ret);
}
}
#endif #endif
if (p->qp_table) { if (p->qp_table) {
ret = mpp_buffer_put(p->qp_table); ret = mpp_buffer_put(p->qp_table);
@@ -318,7 +326,7 @@ MPP_RET hal_m2vd_start(void *hal, HalTaskInfo *task)
M2VDHalContext *ctx = (M2VDHalContext *)hal; M2VDHalContext *ctx = (M2VDHalContext *)hal;
RK_U32 *p_regs = (RK_U32 *)&ctx->regs; RK_U32 *p_regs = (RK_U32 *)&ctx->regs;
FUN_T("FUN_I"); FUN_T("FUN_I");
ret = mpp_device_send_reg(ctx->vpu_socket, p_regs, M2VD_REG_NUM); ret = mpp_device_send_reg(ctx->dev_ctx, p_regs, M2VD_REG_NUM);
if (ret != 0) { if (ret != 0) {
mpp_err("mpp_device_send_reg Failed!!!\n"); mpp_err("mpp_device_send_reg Failed!!!\n");
return MPP_ERR_VPUHW; return MPP_ERR_VPUHW;
@@ -339,7 +347,7 @@ MPP_RET hal_m2vd_wait(void *hal, HalTaskInfo *task)
FUN_T("FUN_I"); FUN_T("FUN_I");
memset(&reg_out, 0, sizeof(M2VDRegSet)); memset(&reg_out, 0, sizeof(M2VDRegSet));
ret = mpp_device_wait_reg(ctx->vpu_socket, (RK_U32 *)&reg_out, M2VD_REG_NUM); ret = mpp_device_wait_reg(ctx->dev_ctx, (RK_U32 *)&reg_out, M2VD_REG_NUM);
if (ctx->fp_reg_out) { if (ctx->fp_reg_out) {
int k = 0; int k = 0;
RK_U32 *p_reg = (RK_U32*)&reg_out; RK_U32 *p_reg = (RK_U32*)&reg_out;

View File

@@ -304,7 +304,6 @@ typedef struct M2VDRegSet_t {
typedef struct M2VDHalContext_t { typedef struct M2VDHalContext_t {
MppBufSlots packet_slots; MppBufSlots packet_slots;
MppBufSlots frame_slots; MppBufSlots frame_slots;
RK_S32 vpu_socket;
M2VDRegSet regs; M2VDRegSet regs;
MppBufferGroup group; MppBufferGroup group;
MppBuffer qp_table; MppBuffer qp_table;

View File

@@ -34,7 +34,6 @@ typedef struct mpeg4d_reg_context {
IOInterruptCB int_cb; IOInterruptCB int_cb;
MppDevCtx dev_ctx; MppDevCtx dev_ctx;
// save fd for curr/ref0/ref1 for reg_gen // save fd for curr/ref0/ref1 for reg_gen
RK_S32 vpu_fd;
RK_S32 fd_curr; RK_S32 fd_curr;
RK_S32 fd_ref0; RK_S32 fd_ref0;
RK_S32 fd_ref1; RK_S32 fd_ref1;

View File

@@ -231,7 +231,6 @@ MPP_RET vdpu1_mpg4d_init(void *hal, MppHalCfg *cfg)
MppBuffer mv_buf = NULL; MppBuffer mv_buf = NULL;
MppBuffer qp_table = NULL; MppBuffer qp_table = NULL;
hal_mpg4_ctx *ctx = (hal_mpg4_ctx *)hal; hal_mpg4_ctx *ctx = (hal_mpg4_ctx *)hal;
RK_S32 vpu_fd = -1;
mpp_assert(hal); mpp_assert(hal);
@@ -261,10 +260,15 @@ MPP_RET vdpu1_mpg4d_init(void *hal, MppHalCfg *cfg)
} }
#ifdef RKPLATFORM #ifdef RKPLATFORM
vpu_fd = mpp_device_init(&ctx->dev_ctx, MPP_CTX_DEC, MPP_VIDEO_CodingMPEG4); MppDevCfg dev_cfg = {
if (vpu_fd < 0) { .type = MPP_CTX_DEC, /* type */
mpp_err_f("failed to open vpu client\n"); .coding = MPP_VIDEO_CodingMPEG4, /* coding */
ret = MPP_ERR_UNKNOW; .platform = 0, /* platform */
.pp_enable = 0, /* pp_enable */
};
ret = mpp_device_init(&ctx->dev_ctx, &dev_cfg);
if (ret) {
mpp_err_f("mpp_device_init failed. ret: %d\n", ret);
goto ERR_RET; goto ERR_RET;
} }
#endif #endif
@@ -292,7 +296,6 @@ MPP_RET vdpu1_mpg4d_init(void *hal, MppHalCfg *cfg)
ctx->pkt_slots = cfg->packet_slots; ctx->pkt_slots = cfg->packet_slots;
ctx->int_cb = cfg->hal_int_cb; ctx->int_cb = cfg->hal_int_cb;
ctx->group = group; ctx->group = group;
ctx->vpu_fd = vpu_fd;
ctx->mv_buf = mv_buf; ctx->mv_buf = mv_buf;
ctx->qp_table = qp_table; ctx->qp_table = qp_table;
ctx->regs = regs; ctx->regs = regs;
@@ -352,9 +355,11 @@ MPP_RET vdpu1_mpg4d_deinit(void *hal)
} }
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_fd >= 0) { if (ctx->dev_ctx) {
mpp_device_deinit(ctx->vpu_fd); ret = mpp_device_deinit(ctx->dev_ctx);
ctx->vpu_fd = -1; if (MPP_OK != ret) {
mpp_err("mpp_device_deinit failed ret: %d\n", ret);
}
} }
#endif #endif
@@ -418,7 +423,7 @@ MPP_RET vdpu1_mpg4d_start(void *hal, HalTaskInfo *task)
} }
} }
ret = mpp_device_send_reg(ctx->vpu_fd, regs, reg_count); ret = mpp_device_send_reg(ctx->dev_ctx, regs, reg_count);
#endif #endif
(void)ret; (void)ret;
(void)hal; (void)hal;
@@ -435,7 +440,7 @@ MPP_RET vdpu1_mpg4d_wait(void *hal, HalTaskInfo *task)
RK_U32* regs = (RK_U32 *)&reg_out; RK_U32* regs = (RK_U32 *)&reg_out;
RK_U32 reg_count = (sizeof(reg_out) / sizeof(RK_U32)); RK_U32 reg_count = (sizeof(reg_out) / sizeof(RK_U32));
ret = mpp_device_wait_reg(ctx->vpu_fd, regs, (sizeof(reg_out) / sizeof(RK_U32))); ret = mpp_device_wait_reg(ctx->dev_ctx, regs, (sizeof(reg_out) / sizeof(RK_U32)));
if (mpg4d_hal_debug & MPG4D_HAL_DBG_REG_GET) { if (mpg4d_hal_debug & MPG4D_HAL_DBG_REG_GET) {
RK_U32 i = 0; RK_U32 i = 0;

View File

@@ -229,7 +229,6 @@ MPP_RET vdpu2_mpg4d_init(void *hal, MppHalCfg *cfg)
MppBuffer mv_buf = NULL; MppBuffer mv_buf = NULL;
MppBuffer qp_table = NULL; MppBuffer qp_table = NULL;
hal_mpg4_ctx *ctx = (hal_mpg4_ctx *)hal; hal_mpg4_ctx *ctx = (hal_mpg4_ctx *)hal;
RK_S32 vpu_fd = -1;
mpp_assert(hal); mpp_assert(hal);
@@ -259,10 +258,15 @@ MPP_RET vdpu2_mpg4d_init(void *hal, MppHalCfg *cfg)
} }
#ifdef RKPLATFORM #ifdef RKPLATFORM
vpu_fd = mpp_device_init(&ctx->dev_ctx, MPP_CTX_DEC, MPP_VIDEO_CodingMPEG4); MppDevCfg dev_cfg = {
if (vpu_fd < 0) { .type = MPP_CTX_DEC, /* type */
mpp_err_f("failed to open vpu client\n"); .coding = MPP_VIDEO_CodingMPEG4, /* coding */
ret = MPP_ERR_UNKNOW; .platform = 0, /* platform */
.pp_enable = 0, /* pp_enable */
};
ret = mpp_device_init(&ctx->dev_ctx, &dev_cfg);
if (ret) {
mpp_err_f("mpp_device_init failed. ret: %d\n", ret);
goto ERR_RET; goto ERR_RET;
} }
#endif #endif
@@ -290,7 +294,6 @@ MPP_RET vdpu2_mpg4d_init(void *hal, MppHalCfg *cfg)
ctx->pkt_slots = cfg->packet_slots; ctx->pkt_slots = cfg->packet_slots;
ctx->int_cb = cfg->hal_int_cb; ctx->int_cb = cfg->hal_int_cb;
ctx->group = group; ctx->group = group;
ctx->vpu_fd = vpu_fd;
ctx->mv_buf = mv_buf; ctx->mv_buf = mv_buf;
ctx->qp_table = qp_table; ctx->qp_table = qp_table;
ctx->regs = regs; ctx->regs = regs;
@@ -350,9 +353,11 @@ MPP_RET vdpu2_mpg4d_deinit(void *hal)
} }
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_fd >= 0) { if (ctx->dev_ctx) {
mpp_device_deinit(ctx->vpu_fd); ret = mpp_device_deinit(ctx->dev_ctx);
ctx->vpu_fd = -1; if (MPP_OK != ret) {
mpp_err("mpp_device_deinit failed. ret: %d\n", ret);
}
} }
#endif #endif
@@ -416,7 +421,7 @@ MPP_RET vdpu2_mpg4d_start(void *hal, HalTaskInfo *task)
} }
} }
ret = mpp_device_send_reg(ctx->vpu_fd, regs, reg_count); ret = mpp_device_send_reg(ctx->dev_ctx, regs, reg_count);
#endif #endif
(void)ret; (void)ret;
(void)hal; (void)hal;
@@ -433,7 +438,7 @@ MPP_RET vdpu2_mpg4d_wait(void *hal, HalTaskInfo *task)
RK_U32* regs = (RK_U32 *)&reg_out; RK_U32* regs = (RK_U32 *)&reg_out;
RK_U32 reg_count = (sizeof(reg_out) / sizeof(RK_U32)); RK_U32 reg_count = (sizeof(reg_out) / sizeof(RK_U32));
ret = mpp_device_wait_reg(ctx->vpu_fd, regs, (sizeof(reg_out) / sizeof(RK_U32))); ret = mpp_device_wait_reg(ctx->dev_ctx, regs, (sizeof(reg_out) / sizeof(RK_U32)));
if (mpg4d_hal_debug & MPG4D_HAL_DBG_REG_GET) { if (mpg4d_hal_debug & MPG4D_HAL_DBG_REG_GET) {
RK_U32 i = 0; RK_U32 i = 0;

View File

@@ -43,7 +43,6 @@
typedef struct VP8DHalContext { typedef struct VP8DHalContext {
MppBufSlots packet_slots; MppBufSlots packet_slots;
MppBufSlots frame_slots; MppBufSlots frame_slots;
RK_S32 vpu_socket;
MppDevCtx dev_ctx; MppDevCtx dev_ctx;
void *regs; void *regs;
RK_U8 reg_size; RK_U8 reg_size;

View File

@@ -53,14 +53,17 @@ MPP_RET hal_vp8d_vdpu1_init(void *hal, MppHalCfg *cfg)
mpp_env_get_u32("vp8h_debug", &vp8h_debug, 0); mpp_env_get_u32("vp8h_debug", &vp8h_debug, 0);
//get vpu socket //get vpu socket
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_socket <= 0) { MppDevCfg dev_cfg = {
ctx->vpu_socket = mpp_device_init(&ctx->dev_ctx, MPP_CTX_DEC, MPP_VIDEO_CodingVP8); .type = MPP_CTX_DEC, /* type */
if (ctx->vpu_socket <= 0) { .coding = MPP_VIDEO_CodingVP8, /* coding */
mpp_err("get vpu_socket(%d) <=0, failed. \n", ctx->vpu_socket); .platform = 0, /* platform */
.pp_enable = 0, /* pp_enable */
FUN_T("FUN_OUT"); };
return MPP_ERR_UNKNOW; ret = mpp_device_init(&ctx->dev_ctx, &dev_cfg);
} if (ret) {
mpp_err("mpp_device_init failed, ret: %d\n", ret);
FUN_T("FUN_OUT");
return ret;
} }
#endif #endif
if (NULL == ctx->regs) { if (NULL == ctx->regs) {
@@ -112,8 +115,11 @@ MPP_RET hal_vp8d_vdpu1_deinit(void *hal)
FUN_T("FUN_IN"); FUN_T("FUN_IN");
VP8DHalContext_t *ctx = (VP8DHalContext_t *)hal; VP8DHalContext_t *ctx = (VP8DHalContext_t *)hal;
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_socket >= 0) { if (ctx->dev_ctx) {
mpp_device_deinit(ctx->vpu_socket); ret = mpp_device_deinit(ctx->dev_ctx);
if (MPP_OK != ret) {
mpp_err("mpp_device_deinit failed. ret: %d\n", ret);
}
} }
#endif #endif
if (ctx->probe_table) { if (ctx->probe_table) {
@@ -614,7 +620,7 @@ MPP_RET hal_vp8d_vdpu1_start(void *hal, HalTaskInfo *task)
vp8h_dbg(VP8H_DBG_REG, "vp8d: regs[%02d]=%08X\n", i, *((RK_U32*)p)); vp8h_dbg(VP8H_DBG_REG, "vp8d: regs[%02d]=%08X\n", i, *((RK_U32*)p));
p += 4; p += 4;
} }
ret = mpp_device_send_reg(ctx->vpu_socket, (RK_U32 *)regs, VP8D_REG_NUM); ret = mpp_device_send_reg(ctx->dev_ctx, (RK_U32 *)regs, VP8D_REG_NUM);
if (ret != 0) { if (ret != 0) {
mpp_err("mpp_device_send_reg Failed!!!\n"); mpp_err("mpp_device_send_reg Failed!!!\n");
return MPP_ERR_VPUHW; return MPP_ERR_VPUHW;
@@ -637,7 +643,7 @@ MPP_RET hal_vp8d_vdpu1_wait(void *hal, HalTaskInfo *task)
FUN_T("FUN_IN"); FUN_T("FUN_IN");
memset(&reg_out, 0, sizeof(VP8DRegSet_t)); memset(&reg_out, 0, sizeof(VP8DRegSet_t));
ret = mpp_device_wait_reg(ctx->vpu_socket, (RK_U32 *)&reg_out, VP8D_REG_NUM); ret = mpp_device_wait_reg(ctx->dev_ctx, (RK_U32 *)&reg_out, VP8D_REG_NUM);
FUN_T("FUN_OUT"); FUN_T("FUN_OUT");
#endif #endif
(void)hal; (void)hal;

View File

@@ -53,15 +53,19 @@ MPP_RET hal_vp8d_vdpu2_init(void *hal, MppHalCfg *cfg)
mpp_env_get_u32("vp8h_debug", &vp8h_debug, 0); mpp_env_get_u32("vp8h_debug", &vp8h_debug, 0);
//get vpu socket //get vpu socket
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_socket <= 0) { MppDevCfg dev_cfg = {
ctx->vpu_socket = mpp_device_init(&ctx->dev_ctx, MPP_CTX_DEC, MPP_VIDEO_CodingVP8); .type = MPP_CTX_DEC, /* type */
if (ctx->vpu_socket <= 0) { .coding = MPP_VIDEO_CodingVP8, /* coding */
mpp_err("get vpu_socket(%d) <=0, failed. \n", ctx->vpu_socket); .platform = 0, /* platform */
.pp_enable = 0, /* pp_enable */
FUN_T("FUN_OUT"); };
return MPP_ERR_UNKNOW; ret = mpp_device_init(&ctx->dev_ctx, &dev_cfg);
} if (ret) {
mpp_err("mpp_device_init failed. ret: %d\n", ret);
FUN_T("FUN_OUT");
return ret;
} }
#endif #endif
if (NULL == ctx->regs) { if (NULL == ctx->regs) {
ctx->regs = mpp_calloc_size(void, sizeof(VP8DRegSet_t)); ctx->regs = mpp_calloc_size(void, sizeof(VP8DRegSet_t));
@@ -113,8 +117,11 @@ MPP_RET hal_vp8d_vdpu2_deinit(void *hal)
VP8DHalContext_t *ctx = (VP8DHalContext_t *)hal; VP8DHalContext_t *ctx = (VP8DHalContext_t *)hal;
#ifdef RKPLATFORM #ifdef RKPLATFORM
if (ctx->vpu_socket >= 0) { if (ctx->dev_ctx) {
mpp_device_deinit(ctx->vpu_socket); ret = mpp_device_deinit(ctx->dev_ctx);
if (MPP_OK != ret) {
mpp_err("mpp_device_deinit failed. ret: %d\n", ret);
}
} }
#endif #endif
if (ctx->probe_table) { if (ctx->probe_table) {
@@ -594,7 +601,7 @@ MPP_RET hal_vp8d_vdpu2_start(void *hal, HalTaskInfo *task)
vp8h_dbg(VP8H_DBG_REG, "vp8d: regs[%02d]=%08X\n", i, *((RK_U32*)p)); vp8h_dbg(VP8H_DBG_REG, "vp8d: regs[%02d]=%08X\n", i, *((RK_U32*)p));
p += 4; p += 4;
} }
ret = mpp_device_send_reg(ctx->vpu_socket, (RK_U32 *)regs, VP8D_REG_NUM); ret = mpp_device_send_reg(ctx->dev_ctx, (RK_U32 *)regs, VP8D_REG_NUM);
if (ret != 0) { if (ret != 0) {
mpp_err("mpp_device_send_reg Failed!!!\n"); mpp_err("mpp_device_send_reg Failed!!!\n");
return MPP_ERR_VPUHW; return MPP_ERR_VPUHW;
@@ -616,7 +623,7 @@ MPP_RET hal_vp8d_vdpu2_wait(void *hal, HalTaskInfo *task)
FUN_T("FUN_IN"); FUN_T("FUN_IN");
memset(&reg_out, 0, sizeof(VP8DRegSet_t)); memset(&reg_out, 0, sizeof(VP8DRegSet_t));
ret = mpp_device_wait_reg(ctx->vpu_socket, (RK_U32 *)&reg_out, VP8D_REG_NUM); ret = mpp_device_wait_reg(ctx->dev_ctx, (RK_U32 *)&reg_out, VP8D_REG_NUM);
FUN_T("FUN_OUT"); FUN_T("FUN_OUT");
#endif #endif
(void)hal; (void)hal;

View File

@@ -40,33 +40,35 @@ typedef enum MppDevCmd_e {
MPP_DEV_PROP_BUTT, MPP_DEV_PROP_BUTT,
} MppDevCmd; } MppDevCmd;
typedef struct MppDevCtx_t { typedef struct MppDevCfg_t {
MppCtxType coding; // input
MppCodingType type; MppCtxType type;
RK_S32 client_type; MppCodingType coding;
RK_U32 platform; // platfrom for vcodec to init RK_U32 platform;
RK_U32 mmu_status; // 0 disable, 1 enable RK_U32 pp_enable;
RK_U32 pp_enable; // postprocess, 0 disable, 1 enable } MppDevCfg;
typedef void* MppDevCtx;
} MppDevCtx;
/* /*
* hardware device open function * hardware device open function
* coding and type for device name detection * coding and type for device name detection
*/ */
RK_S32 mpp_device_init(MppDevCtx *ctx, MppCtxType coding, MppCodingType type); MPP_RET mpp_device_init(MppDevCtx *ctx, MppDevCfg *cfg);
MPP_RET mpp_device_deinit(RK_S32 dev); MPP_RET mpp_device_deinit(MppDevCtx ctx);
/* /*
* control function for set or get device property * control function for set or get device property
*/ */
RK_S32 mpp_device_control(MppDevCtx *ctx, MppDevCmd cmd, void *param); RK_S32 mpp_device_control(MppDevCtx ctx, MppDevCmd cmd, void *param);
/* /*
* register access interface * register access interface
*/ */
MPP_RET mpp_device_send_reg(RK_S32 dev, RK_U32 *regs, RK_U32 nregs); MPP_RET mpp_device_send_reg(MppDevCtx ctx, RK_U32 *regs, RK_U32 nregs);
MPP_RET mpp_device_wait_reg(RK_S32 dev, RK_U32 *regs, RK_U32 nregs); MPP_RET mpp_device_wait_reg(MppDevCtx ctx, RK_U32 *regs, RK_U32 nregs);
MPP_RET mpp_device_send_reg_with_id(RK_S32 dev, RK_S32 id, void *param, RK_S32 size); MPP_RET mpp_device_send_reg_with_id(MppDevCtx ctx, RK_S32 id, void *param, RK_S32 size);
/* /*
* New interface * New interface

View File

@@ -27,6 +27,7 @@
#include "mpp_device.h" #include "mpp_device.h"
#include "mpp_platform.h" #include "mpp_platform.h"
#include "mpp_mem.h"
#include "vpu.h" #include "vpu.h"
@@ -45,6 +46,17 @@ typedef struct MppReq_t {
RK_U32 size; RK_U32 size;
} MppReq; } MppReq;
typedef struct MppDevCtxImpl_t {
MppCtxType type;
MppCodingType coding;
RK_S32 client_type;
RK_U32 platform; // platfrom for vcodec to init
RK_U32 mmu_status; // 0 disable, 1 enable
RK_U32 pp_enable; // postprocess, 0 disable, 1 enable
RK_S32 vpu_fd;
} MppDevCtxImpl;
static RK_U32 mpp_device_debug = 0; static RK_U32 mpp_device_debug = 0;
static RK_S32 mpp_device_set_client_type(int dev, RK_S32 client_type) static RK_S32 mpp_device_set_client_type(int dev, RK_S32 client_type)
@@ -80,15 +92,25 @@ static RK_S32 mpp_device_set_client_type(int dev, RK_S32 client_type)
return ret; return ret;
} }
static RK_S32 mpp_device_get_client_type(MppDevCtx *ctx, MppCtxType coding, MppCodingType type) static RK_S32 mpp_device_get_client_type(MppDevCtx ctx, MppCtxType type, MppCodingType coding)
{ {
RK_S32 client_type = -1; RK_S32 client_type = -1;
MppDevCtxImpl *p;
if (coding == MPP_CTX_ENC) if (NULL == ctx ||
(type >= MPP_CTX_BUTT || type < 0) ||
(coding >= MPP_VIDEO_CodingMax || coding <= MPP_VIDEO_CodingUnused)) {
mpp_err_f("found NULL input ctx %p coding %d type %d\n", ctx, coding, type);
return MPP_ERR_NULL_PTR;
}
p = (MppDevCtxImpl *)ctx;
if (type == MPP_CTX_ENC)
client_type = VPU_ENC; client_type = VPU_ENC;
else { /* MPP_CTX_DEC */ else { /* MPP_CTX_DEC */
client_type = VPU_DEC; client_type = VPU_DEC;
if (ctx->pp_enable) if (p->pp_enable)
client_type = VPU_DEC_PP; client_type = VPU_DEC_PP;
} }
@@ -97,51 +119,91 @@ static RK_S32 mpp_device_get_client_type(MppDevCtx *ctx, MppCtxType coding, MppC
return client_type; return client_type;
} }
RK_S32 mpp_device_init(MppDevCtx *ctx, MppCtxType coding, MppCodingType type) MPP_RET mpp_device_init(MppDevCtx *ctx, MppDevCfg *cfg)
{ {
RK_S32 dev = -1; RK_S32 dev = -1;
const char *name = NULL; const char *name = NULL;
MppDevCtxImpl *p;
if (NULL == ctx || NULL == cfg) {
mpp_err_f("found NULL input ctx %p cfg %p\n", ctx, cfg);
return MPP_ERR_NULL_PTR;
}
*ctx = NULL;
mpp_env_get_u32("mpp_device_debug", &mpp_device_debug, 0); mpp_env_get_u32("mpp_device_debug", &mpp_device_debug, 0);
ctx->coding = coding; p = mpp_calloc(MppDevCtxImpl, 1);
ctx->type = type; if (NULL == p) {
if (ctx->platform) mpp_err_f("malloc failed\n");
name = mpp_get_platform_dev_name(coding, type, ctx->platform); return MPP_ERR_MALLOC;
}
p->coding = cfg->coding;
p->type = cfg->type;
p->platform = cfg->platform;
p->pp_enable = cfg->pp_enable;
if (p->platform)
name = mpp_get_platform_dev_name(p->type, p->coding, p->platform);
else else
name = mpp_get_vcodec_dev_name(coding, type); name = mpp_get_vcodec_dev_name(p->type, p->coding);
if (name) { if (name) {
dev = open(name, O_RDWR); dev = open(name, O_RDWR);
if (dev > 0) { if (dev > 0) {
RK_S32 client_type = mpp_device_get_client_type(ctx, coding, type); RK_S32 client_type = mpp_device_get_client_type(p, p->type, p->coding);
RK_S32 ret = mpp_device_set_client_type(dev, client_type); RK_S32 ret = mpp_device_set_client_type(dev, client_type);
if (ret) { if (ret) {
close(dev); close(dev);
dev = -2; dev = -2;
} }
ctx->client_type = client_type; p->client_type = client_type;
} else } else
mpp_err_f("failed to open device %s, errno %d, error msg: %s\n", mpp_err_f("failed to open device %s, errno %d, error msg: %s\n",
name, errno, strerror(errno)); name, errno, strerror(errno));
} else } else
mpp_err_f("failed to find device for coding %d type %d\n", coding, type); mpp_err_f("failed to find device for coding %d type %d\n", p->coding, p->type);
return dev; *ctx = p;
} p->vpu_fd = dev;
MPP_RET mpp_device_deinit(RK_S32 dev)
{
if (dev > 0)
close(dev);
return MPP_OK; return MPP_OK;
} }
MPP_RET mpp_device_send_reg(RK_S32 dev, RK_U32 *regs, RK_U32 nregs) MPP_RET mpp_device_deinit(MppDevCtx ctx)
{
MppDevCtxImpl *p;
if (NULL == ctx) {
mpp_err_f("found NULL input ctx %p\n", ctx);
return MPP_ERR_NULL_PTR;
}
p = (MppDevCtxImpl *)ctx;
if (p->vpu_fd > 0) {
close(p->vpu_fd);
} else {
mpp_err_f("invalid negtive file handle,\n");
}
mpp_free(p);
return MPP_OK;
}
MPP_RET mpp_device_send_reg(MppDevCtx ctx, RK_U32 *regs, RK_U32 nregs)
{ {
MPP_RET ret; MPP_RET ret;
MppReq req; MppReq req;
MppDevCtxImpl *p;
if (NULL == ctx || NULL == regs) {
mpp_err_f("found NULL input ctx %p regs %p\n", ctx, regs);
return MPP_ERR_NULL_PTR;
}
p = (MppDevCtxImpl *)ctx;
if (mpp_device_debug) { if (mpp_device_debug) {
RK_U32 i; RK_U32 i;
@@ -154,7 +216,7 @@ MPP_RET mpp_device_send_reg(RK_S32 dev, RK_U32 *regs, RK_U32 nregs)
nregs *= sizeof(RK_U32); nregs *= sizeof(RK_U32);
req.req = regs; req.req = regs;
req.size = nregs; req.size = nregs;
ret = (RK_S32)ioctl(dev, VPU_IOC_SET_REG, &req); ret = (RK_S32)ioctl(p->vpu_fd, VPU_IOC_SET_REG, &req);
if (ret) { if (ret) {
mpp_err_f("ioctl VPU_IOC_SET_REG failed ret %d errno %d %s\n", mpp_err_f("ioctl VPU_IOC_SET_REG failed ret %d errno %d %s\n",
ret, errno, strerror(errno)); ret, errno, strerror(errno));
@@ -164,16 +226,23 @@ MPP_RET mpp_device_send_reg(RK_S32 dev, RK_U32 *regs, RK_U32 nregs)
return ret; return ret;
} }
MPP_RET mpp_device_wait_reg(RK_S32 dev, RK_U32 *regs, RK_U32 nregs) MPP_RET mpp_device_wait_reg(MppDevCtx ctx, RK_U32 *regs, RK_U32 nregs)
{ {
MPP_RET ret; MPP_RET ret;
MppReq req; MppReq req;
MppDevCtxImpl *p;
if (NULL == ctx || NULL == regs) {
mpp_err_f("found NULL input ctx %p regs %p\n", ctx, regs);
return MPP_ERR_NULL_PTR;
}
p = (MppDevCtxImpl *)ctx;
nregs *= sizeof(RK_U32); nregs *= sizeof(RK_U32);
req.req = regs; req.req = regs;
req.size = nregs; req.size = nregs;
ret = (RK_S32)ioctl(p->vpu_fd, VPU_IOC_GET_REG, &req);
ret = (RK_S32)ioctl(dev, VPU_IOC_GET_REG, &req);
if (ret) { if (ret) {
mpp_err_f("ioctl VPU_IOC_GET_REG failed ret %d errno %d %s\n", mpp_err_f("ioctl VPU_IOC_GET_REG failed ret %d errno %d %s\n",
ret, errno, strerror(errno)); ret, errno, strerror(errno));
@@ -192,17 +261,20 @@ MPP_RET mpp_device_wait_reg(RK_S32 dev, RK_U32 *regs, RK_U32 nregs)
return ret; return ret;
} }
MPP_RET mpp_device_send_reg_with_id(RK_S32 dev, RK_S32 id, void *param, MPP_RET mpp_device_send_reg_with_id(MppDevCtx ctx, RK_S32 id, void *param,
RK_S32 size) RK_S32 size)
{ {
MPP_RET ret = MPP_NOK; MPP_RET ret = MPP_NOK;
MppDevCtxImpl *p;
if (param == NULL) { if (NULL == ctx || NULL == param) {
mpp_err_f("input param is NULL"); mpp_err_f("found NULL input ctx %p param %p\n", ctx, param);
return ret; return MPP_ERR_NULL_PTR;
} }
ret = (RK_S32)ioctl(dev, VPU_IOC_WRITE(id, size), param); p = (MppDevCtxImpl *)ctx;
ret = (RK_S32)ioctl(p->vpu_fd, VPU_IOC_WRITE(id, size), param);
if (ret) { if (ret) {
mpp_err_f("ioctl VPU_IOC_WRITE failed ret %d errno %d %s\n", mpp_err_f("ioctl VPU_IOC_WRITE failed ret %d errno %d %s\n",
ret, errno, strerror(errno)); ret, errno, strerror(errno));
@@ -212,18 +284,27 @@ MPP_RET mpp_device_send_reg_with_id(RK_S32 dev, RK_S32 id, void *param,
return ret; return ret;
} }
RK_S32 mpp_device_control(MppDevCtx *ctx, MppDevCmd cmd, void* param) RK_S32 mpp_device_control(MppDevCtx ctx, MppDevCmd cmd, void* param)
{ {
MppDevCtxImpl *p;
if (NULL == ctx || NULL == param) {
mpp_err_f("found NULL input ctx %p param %p\n", ctx, param);
return MPP_ERR_NULL_PTR;
}
p = (MppDevCtxImpl *)ctx;
switch (cmd) { switch (cmd) {
case MPP_DEV_GET_MMU_STATUS : { case MPP_DEV_GET_MMU_STATUS : {
ctx->mmu_status = 1; p->mmu_status = 1;
*((RK_U32 *)param) = ctx->mmu_status; *((RK_U32 *)param) = p->mmu_status;
} break; } break;
case MPP_DEV_ENABLE_POSTPROCCESS : { case MPP_DEV_ENABLE_POSTPROCCESS : {
ctx->pp_enable = 1; p->pp_enable = 1;
} break; } break;
case MPP_DEV_SET_HARD_PLATFORM : { case MPP_DEV_SET_HARD_PLATFORM : {
ctx->platform = *((RK_U32 *)param); p->platform = *((RK_U32 *)param);
} break; } break;
default : { default : {
} break; } break;

View File

@@ -427,9 +427,9 @@ const char *mpp_get_vcodec_dev_name(MppCtxType type, MppCodingType coding)
} else if (type == MPP_CTX_DEC) { } else if (type == MPP_CTX_DEC) {
if (coding == MPP_VIDEO_CodingAVC || if (coding == MPP_VIDEO_CodingAVC ||
coding == MPP_VIDEO_CodingHEVC || coding == MPP_VIDEO_CodingHEVC ||
coding == MPP_VIDEO_CodingVP9) coding == MPP_VIDEO_CodingVP9) {
dev = mpp_find_device(mpp_rkvdec_dev); dev = mpp_find_device(mpp_rkvdec_dev);
else } else
dev = mpp_find_device(mpp_vpu_dev); dev = mpp_find_device(mpp_vpu_dev);
} }
} break; } break;

0
osal/mpp_queue.cpp Executable file → Normal file
View File