[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 <herman.chen@rock-chips.com>
This commit is contained in:
Herman Chen
2018-05-09 10:46:11 +08:00
parent c72247fb96
commit 73056c6eb1
2 changed files with 68 additions and 48 deletions

View File

@@ -115,7 +115,9 @@ MPP_RET hal_jpege_vepu1_deinit(void *hal)
return ret; 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) { if (info == NULL || syntax == NULL) {
mpp_err_f("invalid input parameter!"); 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; MppFrameFormat fmt = syntax->format;
RK_U32 hor_stride = syntax->hor_stride; RK_U32 hor_stride = syntax->hor_stride;
RK_U32 ver_stride = syntax->ver_stride; RK_U32 ver_stride = syntax->ver_stride;
JpegeIocExtInfoSlot *slot = NULL;
info->magic = EXTRA_INFO_MAGIC; if (hor_stride * ver_stride * 5 / 4 >= SZ_4M) {
info->cnt = 2; JpegeIocExtInfoSlot *slot = NULL;
if (fmt == MPP_FMT_YUV420P) { info->magic = EXTRA_INFO_MAGIC;
slot = &(info->slots[0]); info->cnt = 2;
slot->reg_idx = 12;
slot->offset = hor_stride * ver_stride;
slot = &(info->slots[1]); if (fmt == MPP_FMT_YUV420P) {
slot->reg_idx = 13; slot = &(info->slots[0]);
slot->offset = hor_stride * ver_stride * 5 / 4; slot->reg_idx = 12;
} else if (fmt == MPP_FMT_YUV420SP) { slot->offset = hor_stride * ver_stride;
slot = &(info->slots[0]);
slot->reg_idx = 12;
slot->offset = hor_stride * ver_stride;
slot = &(info->slots[1]); slot = &(info->slots[1]);
slot->reg_idx = 13; slot->reg_idx = 13;
slot->offset = hor_stride * ver_stride; 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 { } 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; 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[11] = mpp_buffer_get_fd(input);
regs[12] = mpp_buffer_get_fd(input); regs[12] = mpp_buffer_get_fd(input);
regs[13] = regs[12]; regs[13] = regs[12];
hal_jpege_vepu1_set_extra_info(regs, extra_info, syntax);
hal_jpege_vepu1_set_extra_info(extra_info, syntax);
bitpos = jpege_bits_get_bitpos(bits); bitpos = jpege_bits_get_bitpos(bits);
bytepos = (bitpos + 7) >> 3; bytepos = (bitpos + 7) >> 3;

View File

@@ -111,41 +111,48 @@ MPP_RET hal_jpege_vepu2_deinit(void *hal)
return MPP_OK; 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; MppFrameFormat fmt = syntax->format;
RK_U32 hor_stride = syntax->hor_stride; RK_U32 hor_stride = syntax->hor_stride;
RK_U32 ver_stride = syntax->ver_stride; RK_U32 ver_stride = syntax->ver_stride;
JpegeIocExtInfoSlot *slot = NULL;
info->magic = EXTRA_INFO_MAGIC; if (hor_stride * ver_stride * 5 / 4 >= SZ_4M) {
info->cnt = 2; JpegeIocExtInfoSlot *slot = NULL;
if (fmt == MPP_FMT_YUV420P) { info->magic = EXTRA_INFO_MAGIC;
slot = &(info->slots[0]); info->cnt = 2;
slot->reg_idx = 49;
slot->offset = hor_stride * ver_stride;
slot = &(info->slots[1]); if (fmt == MPP_FMT_YUV420P) {
slot->reg_idx = 50; slot = &(info->slots[0]);
slot->offset = hor_stride * ver_stride * 5 / 4; slot->reg_idx = 49;
} else if (fmt == MPP_FMT_YUV420SP) { slot->offset = hor_stride * ver_stride;
slot = &(info->slots[0]);
slot->reg_idx = 49;
slot->offset = hor_stride * ver_stride;
slot = &(info->slots[1]); slot = &(info->slots[1]);
slot->reg_idx = 50; slot->reg_idx = 50;
slot->offset = hor_stride * ver_stride; 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 { } 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; 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[48] = mpp_buffer_get_fd(input);
regs[49] = mpp_buffer_get_fd(input); regs[49] = mpp_buffer_get_fd(input);
regs[50] = regs[49]; 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 // output address setup
bitpos = jpege_bits_get_bitpos(bits); bitpos = jpege_bits_get_bitpos(bits);
@@ -410,7 +417,8 @@ MPP_RET hal_jpege_vepu2_start(void *hal, HalTaskInfo *task)
HalJpegeCtx *ctx = (HalJpegeCtx *)hal; HalJpegeCtx *ctx = (HalJpegeCtx *)hal;
RK_U32 *cache = NULL; RK_U32 *cache = NULL;
RK_U32 reg_size = sizeof(jpege_vepu2_reg_set); 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 reg_num = reg_size / sizeof(RK_U32);
RK_U32 extra_num = extra_size / sizeof(RK_U32); RK_U32 extra_num = extra_size / sizeof(RK_U32);