Skip to content

Commit

Permalink
media: venus: support frame rate control
Browse files Browse the repository at this point in the history
Add encoder control for enabling/disabling frame rate control via
V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE. It is enabled by default.

Signed-off-by: Jeffrey Kardatzke <[email protected]>
Signed-off-by: Stanimir Varbanov <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
Narflex authored and mchehab committed Mar 12, 2020
1 parent 808431d commit 6f704b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions drivers/media/platform/qcom/venus/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ struct venc_controls {
u32 bitrate_mode;
u32 bitrate;
u32 bitrate_peak;
u32 rc_enable;

u32 h264_i_period;
u32 h264_entropy_mode;
Expand Down
4 changes: 3 additions & 1 deletion drivers/media/platform/qcom/venus/venc.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,9 @@ static int venc_set_properties(struct venus_inst *inst)
if (ret)
return ret;

if (ctr->bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR)
if (!ctr->rc_enable)
rate_control = HFI_RATE_CONTROL_OFF;
else if (ctr->bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR)
rate_control = HFI_RATE_CONTROL_VBR_CFR;
else
rate_control = HFI_RATE_CONTROL_CBR_CFR;
Expand Down
8 changes: 7 additions & 1 deletion drivers/media/platform/qcom/venus/venc_ctrls.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
}
mutex_unlock(&inst->lock);
break;
case V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE:
ctr->rc_enable = ctrl->val;
break;
default:
return -EINVAL;
}
Expand All @@ -214,7 +217,7 @@ int venc_ctrl_init(struct venus_inst *inst)
{
int ret;

ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 30);
ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 31);
if (ret)
return ret;

Expand Down Expand Up @@ -351,6 +354,9 @@ int venc_ctrl_init(struct venus_inst *inst)
v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME, 0, 0, 0, 0);

v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE, 0, 1, 1, 1);

ret = inst->ctrl_handler.error;
if (ret)
goto err;
Expand Down

0 comments on commit 6f704b2

Please sign in to comment.