From 73056c6eb134130aa7f7f8280ee56c75cf9a9efc Mon Sep 17 00:00:00 2001 From: Herman Chen Date: Wed, 9 May 2018 10:46:11 +0800 Subject: [PATCH] [jpege]: Add no extra info path for compatibility Some old kernel do not support register file with extra info. So when it is no necessary to add extra info slots just disable it. The reason for extra info is to handle buffer offset larger than 4M. Due to low 10bit of 32bit address register is used for file handle and only high 22bit can be used to as offset from buffer head. Then the offset is limited to 4M. When we need a offset larger than 22bit we need to add extra info slot behind register file to let kernel handle it as a register value patch. BTW, this is not a good design but it fix the issue so far. Change-Id: Id5cb694f72b15958164175e402dcc03b08e898b5 Signed-off-by: Herman Chen --- mpp/hal/vpu/jpege/hal_jpege_vepu1.c | 54 +++++++++++++++---------- mpp/hal/vpu/jpege/hal_jpege_vepu2.c | 62 ++++++++++++++++------------- 2 files changed, 68 insertions(+), 48 deletions(-) diff --git a/mpp/hal/vpu/jpege/hal_jpege_vepu1.c b/mpp/hal/vpu/jpege/hal_jpege_vepu1.c index d83e5c4f..a86f0654 100644 --- a/mpp/hal/vpu/jpege/hal_jpege_vepu1.c +++ b/mpp/hal/vpu/jpege/hal_jpege_vepu1.c @@ -115,7 +115,9 @@ MPP_RET hal_jpege_vepu1_deinit(void *hal) return ret; } -static MPP_RET hal_jpege_vepu1_set_extra_info(JpegeIocExtInfo *info, JpegeSyntax *syntax) +static MPP_RET hal_jpege_vepu1_set_extra_info(RK_U32 *regs, + JpegeIocExtInfo *info, + JpegeSyntax *syntax) { if (info == NULL || syntax == NULL) { mpp_err_f("invalid input parameter!"); @@ -125,29 +127,40 @@ static MPP_RET hal_jpege_vepu1_set_extra_info(JpegeIocExtInfo *info, JpegeSyntax MppFrameFormat fmt = syntax->format; RK_U32 hor_stride = syntax->hor_stride; RK_U32 ver_stride = syntax->ver_stride; - JpegeIocExtInfoSlot *slot = NULL; - info->magic = EXTRA_INFO_MAGIC; - info->cnt = 2; + if (hor_stride * ver_stride * 5 / 4 >= SZ_4M) { + JpegeIocExtInfoSlot *slot = NULL; - if (fmt == MPP_FMT_YUV420P) { - slot = &(info->slots[0]); - slot->reg_idx = 12; - slot->offset = hor_stride * ver_stride; + info->magic = EXTRA_INFO_MAGIC; + info->cnt = 2; - slot = &(info->slots[1]); - slot->reg_idx = 13; - slot->offset = hor_stride * ver_stride * 5 / 4; - } else if (fmt == MPP_FMT_YUV420SP) { - slot = &(info->slots[0]); - slot->reg_idx = 12; - slot->offset = hor_stride * ver_stride; + if (fmt == MPP_FMT_YUV420P) { + slot = &(info->slots[0]); + slot->reg_idx = 12; + slot->offset = hor_stride * ver_stride; - slot = &(info->slots[1]); - slot->reg_idx = 13; - slot->offset = hor_stride * ver_stride; + slot = &(info->slots[1]); + slot->reg_idx = 13; + slot->offset = hor_stride * ver_stride * 5 / 4; + } else if (fmt == MPP_FMT_YUV420SP) { + slot = &(info->slots[0]); + slot->reg_idx = 12; + slot->offset = hor_stride * ver_stride; + + slot = &(info->slots[1]); + slot->reg_idx = 13; + slot->offset = hor_stride * ver_stride; + } else { + mpp_log_f("other format(%d)\n", fmt); + } } else { - mpp_log_f("other format(%d)\n", fmt); + if (fmt == MPP_FMT_YUV420P) { + regs[12] += (hor_stride * ver_stride) << 10; + regs[13] += (hor_stride * ver_stride * 5 / 4) << 10; + } else if (fmt == MPP_FMT_YUV420SP) { + regs[12] += (hor_stride * ver_stride) << 10; + regs[13] += (hor_stride * ver_stride) << 10; + } } return MPP_OK; @@ -199,8 +212,7 @@ MPP_RET hal_jpege_vepu1_gen_regs(void *hal, HalTaskInfo *task) regs[11] = mpp_buffer_get_fd(input); regs[12] = mpp_buffer_get_fd(input); regs[13] = regs[12]; - - hal_jpege_vepu1_set_extra_info(extra_info, syntax); + hal_jpege_vepu1_set_extra_info(regs, extra_info, syntax); bitpos = jpege_bits_get_bitpos(bits); bytepos = (bitpos + 7) >> 3; diff --git a/mpp/hal/vpu/jpege/hal_jpege_vepu2.c b/mpp/hal/vpu/jpege/hal_jpege_vepu2.c index 368e00b7..818f7d23 100644 --- a/mpp/hal/vpu/jpege/hal_jpege_vepu2.c +++ b/mpp/hal/vpu/jpege/hal_jpege_vepu2.c @@ -111,41 +111,48 @@ MPP_RET hal_jpege_vepu2_deinit(void *hal) return MPP_OK; } -static MPP_RET hal_jpege_vepu2_set_extra_info(JpegeIocExtInfo *info, JpegeSyntax *syntax) +static MPP_RET hal_jpege_vepu2_set_extra_info(RK_U32 *regs, + JpegeIocExtInfo *info, + JpegeSyntax *syntax) { - if (info == NULL || syntax == NULL) { - mpp_err_f("invalid input parameter!"); - return MPP_NOK; - } - MppFrameFormat fmt = syntax->format; RK_U32 hor_stride = syntax->hor_stride; RK_U32 ver_stride = syntax->ver_stride; - JpegeIocExtInfoSlot *slot = NULL; - info->magic = EXTRA_INFO_MAGIC; - info->cnt = 2; + if (hor_stride * ver_stride * 5 / 4 >= SZ_4M) { + JpegeIocExtInfoSlot *slot = NULL; - if (fmt == MPP_FMT_YUV420P) { - slot = &(info->slots[0]); - slot->reg_idx = 49; - slot->offset = hor_stride * ver_stride; + info->magic = EXTRA_INFO_MAGIC; + info->cnt = 2; - slot = &(info->slots[1]); - slot->reg_idx = 50; - slot->offset = hor_stride * ver_stride * 5 / 4; - } else if (fmt == MPP_FMT_YUV420SP) { - slot = &(info->slots[0]); - slot->reg_idx = 49; - slot->offset = hor_stride * ver_stride; + if (fmt == MPP_FMT_YUV420P) { + slot = &(info->slots[0]); + slot->reg_idx = 49; + slot->offset = hor_stride * ver_stride; - slot = &(info->slots[1]); - slot->reg_idx = 50; - slot->offset = hor_stride * ver_stride; + slot = &(info->slots[1]); + slot->reg_idx = 50; + slot->offset = hor_stride * ver_stride * 5 / 4; + } else if (fmt == MPP_FMT_YUV420SP) { + slot = &(info->slots[0]); + slot->reg_idx = 49; + slot->offset = hor_stride * ver_stride; + + slot = &(info->slots[1]); + slot->reg_idx = 50; + slot->offset = hor_stride * ver_stride; + } else { + mpp_log_f("other format(%d)\n", fmt); + } } else { - mpp_log_f("other format(%d)\n", fmt); + if (fmt == MPP_FMT_YUV420P) { + regs[49] += (hor_stride * ver_stride) << 10; + regs[50] += (hor_stride * ver_stride * 5 / 4) << 10; + } else if (fmt == MPP_FMT_YUV420SP) { + regs[49] += (hor_stride * ver_stride) << 10; + regs[50] += (hor_stride * ver_stride) << 10; + } } - return MPP_OK; } @@ -195,7 +202,7 @@ MPP_RET hal_jpege_vepu2_gen_regs(void *hal, HalTaskInfo *task) regs[48] = mpp_buffer_get_fd(input); regs[49] = mpp_buffer_get_fd(input); regs[50] = regs[49]; - hal_jpege_vepu2_set_extra_info(extra_info, syntax); + hal_jpege_vepu2_set_extra_info(regs, extra_info, syntax); // output address setup bitpos = jpege_bits_get_bitpos(bits); @@ -410,7 +417,8 @@ MPP_RET hal_jpege_vepu2_start(void *hal, HalTaskInfo *task) HalJpegeCtx *ctx = (HalJpegeCtx *)hal; RK_U32 *cache = NULL; RK_U32 reg_size = sizeof(jpege_vepu2_reg_set); - RK_U32 extra_size = sizeof(JpegeIocExtInfo); + RK_U32 extra_size = (ctx->ioctl_info.extra_info.cnt) ? + (sizeof(JpegeIocExtInfo)) : (0); RK_U32 reg_num = reg_size / sizeof(RK_U32); RK_U32 extra_num = extra_size / sizeof(RK_U32);