Commit f2fb3f02 authored by Dikshita Agarwal's avatar Dikshita Agarwal Committed by Mauro Carvalho Chehab

media: venus: venc: Add support for Long Term Reference (LTR) controls

Add support for below LTR controls in encoder:
- V4L2_CID_MPEG_VIDEO_LTR_COUNT
- V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX
- V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES
Signed-off-by: default avatarDikshita Agarwal <dikshita@codeaurora.org>
Signed-off-by: default avatarStanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent f15c54cf
......@@ -241,6 +241,7 @@ struct venc_controls {
} level;
u32 base_priority_id;
u32 ltr_count;
};
struct venus_buffer {
......
......@@ -546,6 +546,7 @@ static int venc_set_properties(struct venus_inst *inst)
struct hfi_quantization quant;
struct hfi_quantization_range quant_range;
struct hfi_enable en;
struct hfi_ltr_mode ltr_mode;
u32 ptype, rate_control, bitrate;
u32 profile, level;
int ret;
......@@ -722,6 +723,14 @@ static int venc_set_properties(struct venus_inst *inst)
if (ret)
return ret;
ptype = HFI_PROPERTY_PARAM_VENC_LTRMODE;
ltr_mode.ltr_count = ctr->ltr_count;
ltr_mode.ltr_mode = HFI_LTR_MODE_MANUAL;
ltr_mode.trust_mode = 1;
ret = hfi_session_set_property(inst, ptype, &ltr_mode);
if (ret)
return ret;
switch (inst->hfi_codec) {
case HFI_VIDEO_CODEC_H264:
profile = ctr->profile.h264;
......
......@@ -20,6 +20,7 @@
#define INTRA_REFRESH_MBS_MAX 300
#define AT_SLICE_BOUNDARY \
V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY
#define MAX_LTR_FRAME_COUNT 4
static int venc_calc_bpframes(u32 gop_size, u32 conseq_b, u32 *bf, u32 *pf)
{
......@@ -72,6 +73,8 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
struct venc_controls *ctr = &inst->controls.enc;
struct hfi_enable en = { .enable = 1 };
struct hfi_bitrate brate;
struct hfi_ltr_use ltr_use;
struct hfi_ltr_mark ltr_mark;
u32 bframes;
u32 ptype;
int ret;
......@@ -279,6 +282,37 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
case V4L2_CID_MPEG_VIDEO_AU_DELIMITER:
ctr->aud_enable = ctrl->val;
break;
case V4L2_CID_MPEG_VIDEO_LTR_COUNT:
ctr->ltr_count = ctrl->val;
break;
case V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX:
mutex_lock(&inst->lock);
if (inst->streamon_out && inst->streamon_cap) {
ptype = HFI_PROPERTY_CONFIG_VENC_MARKLTRFRAME;
ltr_mark.mark_frame = ctrl->val;
ret = hfi_session_set_property(inst, ptype, &ltr_mark);
if (ret) {
mutex_unlock(&inst->lock);
return ret;
}
}
mutex_unlock(&inst->lock);
break;
case V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES:
mutex_lock(&inst->lock);
if (inst->streamon_out && inst->streamon_cap) {
ptype = HFI_PROPERTY_CONFIG_VENC_USELTRFRAME;
ltr_use.ref_ltr = ctrl->val;
ltr_use.use_constrnt = true;
ltr_use.frames = 0;
ret = hfi_session_set_property(inst, ptype, &ltr_use);
if (ret) {
mutex_unlock(&inst->lock);
return ret;
}
}
mutex_unlock(&inst->lock);
break;
default:
return -EINVAL;
}
......@@ -294,7 +328,7 @@ int venc_ctrl_init(struct venus_inst *inst)
{
int ret;
ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 52);
ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 55);
if (ret)
return ret;
......@@ -504,6 +538,18 @@ int venc_ctrl_init(struct venus_inst *inst)
v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
V4L2_CID_MPEG_VIDEO_AU_DELIMITER, 0, 1, 1, 0);
v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES, 0,
((1 << MAX_LTR_FRAME_COUNT) - 1), 0, 0);
v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
V4L2_CID_MPEG_VIDEO_LTR_COUNT, 0,
MAX_LTR_FRAME_COUNT, 1, 0);
v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX, 0,
(MAX_LTR_FRAME_COUNT - 1), 1, 0);
ret = inst->ctrl_handler.error;
if (ret)
goto err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment