video: driver: add all intra encoding support

add ALL_INTRA database entry and its dependencies.
implement adjust functions.

Change-Id: Ib4522666b6c2ef7dcb5adf9110a2fd5d2daf4654
Signed-off-by: Darshana Patil <darshana@codeaurora.org>
This commit is contained in:
Darshana Patil
2021-09-24 12:02:55 -07:00
committed by Gerrit - the friendly Code Review server
parent 4d51b2ba26
commit fc6c35e8de
5 changed files with 99 additions and 15 deletions

View File

@@ -1025,7 +1025,7 @@ int msm_vidc_adjust_ltr_count(void *instance, struct v4l2_ctrl *ctrl)
struct msm_vidc_inst_capability *capability;
s32 adjusted_value;
struct msm_vidc_inst *inst = (struct msm_vidc_inst *) instance;
s32 rc_type = -1;
s32 rc_type = -1, all_intra = 0;
if (!inst || !inst->capabilities) {
d_vpr_e("%s: invalid params\n", __func__);
@@ -1036,13 +1036,20 @@ int msm_vidc_adjust_ltr_count(void *instance, struct v4l2_ctrl *ctrl)
adjusted_value = ctrl ? ctrl->val : capability->cap[LTR_COUNT].value;
if (msm_vidc_get_parent_value(inst, LTR_COUNT, BITRATE_MODE,
&rc_type, __func__))
&rc_type, __func__) ||
msm_vidc_get_parent_value(inst, LTR_COUNT, ALL_INTRA,
&all_intra, __func__))
return -EINVAL;
if (rc_type != HFI_RC_OFF &&
if ((rc_type != HFI_RC_OFF &&
rc_type != HFI_RC_CBR_CFR &&
rc_type != HFI_RC_CBR_VFR)
rc_type != HFI_RC_CBR_VFR) ||
all_intra) {
adjusted_value = 0;
i_vpr_h(inst,
"%s: ltr count unsupported, rc_type: %#x, all_intra %d\n",
__func__,rc_type, all_intra);
}
msm_vidc_update_cap_value(inst, LTR_COUNT,
adjusted_value, __func__);
@@ -1133,7 +1140,7 @@ int msm_vidc_adjust_mark_ltr(void *instance, struct v4l2_ctrl *ctrl)
int msm_vidc_adjust_ir_random(void *instance, struct v4l2_ctrl *ctrl)
{
struct msm_vidc_inst_capability *capability;
s32 adjusted_value;
s32 adjusted_value, all_intra = 0;
struct msm_vidc_inst *inst = (struct msm_vidc_inst *) instance;
if (!inst || !inst->capabilities) {
@@ -1144,6 +1151,17 @@ int msm_vidc_adjust_ir_random(void *instance, struct v4l2_ctrl *ctrl)
adjusted_value = ctrl ? ctrl->val : capability->cap[IR_RANDOM].value;
if (msm_vidc_get_parent_value(inst, IR_RANDOM, ALL_INTRA,
&all_intra, __func__))
return -EINVAL;
if (all_intra) {
adjusted_value = 0;
i_vpr_h(inst, "%s: IR unsupported, all intra: %d\n",
__func__, all_intra);
goto exit;
}
/*
* BITRATE_MODE dependency is NOT common across all chipsets.
* Hence, do not return error if not specified as one of the parent.
@@ -1153,6 +1171,7 @@ int msm_vidc_adjust_ir_random(void *instance, struct v4l2_ctrl *ctrl)
inst->hfi_rc_type != HFI_RC_CBR_VFR)
adjusted_value = 0;
exit:
msm_vidc_update_cap_value(inst, IR_RANDOM,
adjusted_value, __func__);
@@ -1256,7 +1275,7 @@ int msm_vidc_adjust_slice_count(void *instance, struct v4l2_ctrl *ctrl)
struct msm_vidc_inst *inst = (struct msm_vidc_inst *) instance;
struct msm_vidc_inst_capability *capability;
struct v4l2_format *output_fmt;
s32 adjusted_value, rc_type = -1, slice_mode;
s32 adjusted_value, rc_type = -1, slice_mode, all_intra = 0;
u32 slice_val, mbpf = 0, mbps = 0, max_mbpf = 0, max_mbps = 0;
u32 update_cap, max_avg_slicesize, output_width, output_height;
u32 min_width, min_height, max_width, max_height, fps;
@@ -1271,7 +1290,9 @@ int msm_vidc_adjust_slice_count(void *instance, struct v4l2_ctrl *ctrl)
capability->cap[SLICE_MODE].value;
if (msm_vidc_get_parent_value(inst, SLICE_MODE,
BITRATE_MODE, &rc_type, __func__))
BITRATE_MODE, &rc_type, __func__) ||
msm_vidc_get_parent_value(inst, SLICE_MODE,
ALL_INTRA, &all_intra, __func__))
return -EINVAL;
if (slice_mode == V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE)
@@ -1281,12 +1302,13 @@ int msm_vidc_adjust_slice_count(void *instance, struct v4l2_ctrl *ctrl)
if (fps > MAX_SLICES_FRAME_RATE ||
(rc_type != HFI_RC_OFF &&
rc_type != HFI_RC_CBR_CFR &&
rc_type != HFI_RC_CBR_VFR)) {
rc_type != HFI_RC_CBR_VFR) ||
all_intra) {
adjusted_value = V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE;
update_cap = SLICE_MODE;
i_vpr_h(inst,
"%s: slice unsupported, fps: %u, rc_type: %#x\n",
__func__, fps, rc_type);
"%s: slice unsupported, fps: %u, rc_type: %#x, all_intra %d\n",
__func__, fps, rc_type, all_intra);
goto exit;
}
@@ -1967,6 +1989,53 @@ int msm_vidc_adjust_blur_type(void *instance, struct v4l2_ctrl *ctrl)
return 0;
}
int msm_vidc_adjust_all_intra(void *instance, struct v4l2_ctrl *ctrl)
{
struct msm_vidc_inst_capability *capability;
s32 adjusted_value;
struct msm_vidc_core *core;
struct msm_vidc_inst *inst = (struct msm_vidc_inst *) instance;
s32 gop_size = -1, bframe = -1;
u32 width, height, fps, mbps, max_mbps;
if (!inst || !inst->capabilities || !inst->core) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
capability = inst->capabilities;
adjusted_value = capability->cap[ALL_INTRA].value;
if (msm_vidc_get_parent_value(inst, ALL_INTRA, GOP_SIZE,
&gop_size, __func__) ||
msm_vidc_get_parent_value(inst, ALL_INTRA, B_FRAME,
&bframe, __func__))
return -EINVAL;
width = inst->crop.width;
height = inst->crop.height;
fps = msm_vidc_get_fps(inst);
mbps = NUM_MBS_PER_SEC(height, width, fps);
core = inst->core;
max_mbps = core->capabilities[MAX_MBPS_ALL_INTRA].value;
if (mbps > max_mbps) {
adjusted_value = 0;
i_vpr_h(inst, "%s: mbps %d exceeds max supported mbps %d\n",
__func__, mbps, max_mbps);
goto exit;
}
if (!gop_size && !bframe)
adjusted_value = 1;
exit:
msm_vidc_update_cap_value(inst, ALL_INTRA,
adjusted_value, __func__);
return 0;
}
int msm_vidc_adjust_blur_resolution(void *instance, struct v4l2_ctrl *ctrl)
{
struct msm_vidc_inst_capability *capability;