video: driver: adjust/set mark/use ltr dynamically only

Avoid adjusting, sanitizing, and setting mark and use ltr
controls to fw for input port static case.

Change-Id: I8ac7fd9537ff0c5ddce0ff0f4d0337cb19dd83d2
Signed-off-by: Akshata Sahukar <asahukar@codeaurora.org>
This commit is contained in:
Akshata Sahukar
2021-04-07 14:16:40 -07:00
parent 7c612dd033
commit 1b42ed0a67
3 changed files with 49 additions and 29 deletions

View File

@@ -447,23 +447,27 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
V4L2_CID_MPEG_VIDEO_LTR_COUNT, V4L2_CID_MPEG_VIDEO_LTR_COUNT,
HFI_PROP_LTR_COUNT, HFI_PROP_LTR_COUNT,
CAP_FLAG_OUTPUT_PORT, CAP_FLAG_OUTPUT_PORT,
{BITRATE_MODE}, {USE_LTR, MARK_LTR}, {BITRATE_MODE}, {0},
msm_vidc_adjust_ltr_count, msm_vidc_set_u32}, msm_vidc_adjust_ltr_count, msm_vidc_set_u32},
{USE_LTR, ENC, H264|HEVC, {USE_LTR, ENC, H264|HEVC,
0, ((1 << MAX_LTR_FRAME_COUNT) - 1), 1, 0, INVALID_DEFAULT_MARK_OR_USE_LTR,
((1 << MAX_LTR_FRAME_COUNT) - 1),
1, INVALID_DEFAULT_MARK_OR_USE_LTR,
V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES, V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES,
HFI_PROP_LTR_USE, HFI_PROP_LTR_USE,
CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED, CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
{LTR_COUNT}, {0}, {0}, {0},
msm_vidc_adjust_use_ltr, msm_vidc_set_use_and_mark_ltr}, msm_vidc_adjust_use_ltr, msm_vidc_set_use_and_mark_ltr},
{MARK_LTR, ENC, H264|HEVC, {MARK_LTR, ENC, H264|HEVC,
0, (MAX_LTR_FRAME_COUNT - 1), 1, 0, INVALID_DEFAULT_MARK_OR_USE_LTR,
(MAX_LTR_FRAME_COUNT - 1),
1, INVALID_DEFAULT_MARK_OR_USE_LTR,
V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX, V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX,
HFI_PROP_LTR_MARK, HFI_PROP_LTR_MARK,
CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED, CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
{LTR_COUNT}, {0}, {0}, {0},
msm_vidc_adjust_mark_ltr, msm_vidc_set_use_and_mark_ltr}, msm_vidc_adjust_mark_ltr, msm_vidc_set_use_and_mark_ltr},
{BASELAYER_PRIORITY, ENC, H264, {BASELAYER_PRIORITY, ENC, H264,

View File

@@ -56,6 +56,7 @@
#define MAX_AVC_ENH_LAYER_SLIDING_WINDOW 3 #define MAX_AVC_ENH_LAYER_SLIDING_WINDOW 3
#define MAX_AVC_ENH_LAYER_HYBRID_HP 5 #define MAX_AVC_ENH_LAYER_HYBRID_HP 5
#define PERCENT_PEAK_BITRATE_INCREASED 10 #define PERCENT_PEAK_BITRATE_INCREASED 10
#define INVALID_DEFAULT_MARK_OR_USE_LTR -1
#define DCVS_WINDOW 16 #define DCVS_WINDOW 16
/* Superframe can have maximum of 32 frames */ /* Superframe can have maximum of 32 frames */

View File

@@ -899,9 +899,8 @@ int msm_vidc_adjust_ltr_count(void *instance, struct v4l2_ctrl *ctrl)
int msm_vidc_adjust_use_ltr(void *instance, struct v4l2_ctrl *ctrl) int msm_vidc_adjust_use_ltr(void *instance, struct v4l2_ctrl *ctrl)
{ {
struct msm_vidc_inst_capability *capability; struct msm_vidc_inst_capability *capability;
s32 adjusted_value; s32 adjusted_value, ltr_count;
struct msm_vidc_inst *inst = (struct msm_vidc_inst *) instance; struct msm_vidc_inst *inst = (struct msm_vidc_inst *) instance;
s32 ltr_count = -1;
if (!inst || !inst->capabilities) { if (!inst || !inst->capabilities) {
d_vpr_e("%s: invalid params\n", __func__); d_vpr_e("%s: invalid params\n", __func__);
@@ -911,18 +910,25 @@ int msm_vidc_adjust_use_ltr(void *instance, struct v4l2_ctrl *ctrl)
adjusted_value = ctrl ? ctrl->val : capability->cap[USE_LTR].value; adjusted_value = ctrl ? ctrl->val : capability->cap[USE_LTR].value;
if (msm_vidc_get_parent_value(inst, USE_LTR, LTR_COUNT, /*
&ltr_count, __func__)) * Since USE_LTR is only set dynamically, and LTR_COUNT is static
return -EINVAL; * control, no need to make LTR_COUNT as parent for USE_LTR as
* LTR_COUNT value will always be updated when dynamically USE_LTR
* is set
*/
ltr_count = capability->cap[LTR_COUNT].value;
if (!ltr_count)
return 0;
if (!ltr_count) { if (adjusted_value <= 0 ||
adjusted_value = 0; adjusted_value > ((1 << ltr_count) - 1)) {
} else if (adjusted_value <= 0 || /*
adjusted_value >= (1 << ltr_count)) { * USE_LTR is bitmask value, hence should be
/* USE_LTR value should be > 0 and < (2 ^ LTR_COUNT) */ * > 0 and <= (2 ^ LTR_COUNT) - 1
*/
i_vpr_e(inst, "%s: invalid value %d\n", i_vpr_e(inst, "%s: invalid value %d\n",
__func__, adjusted_value); __func__, adjusted_value);
return -EINVAL; return 0;
} }
/* USE_LTR value is a bitmask value */ /* USE_LTR value is a bitmask value */
@@ -935,9 +941,8 @@ int msm_vidc_adjust_use_ltr(void *instance, struct v4l2_ctrl *ctrl)
int msm_vidc_adjust_mark_ltr(void *instance, struct v4l2_ctrl *ctrl) int msm_vidc_adjust_mark_ltr(void *instance, struct v4l2_ctrl *ctrl)
{ {
struct msm_vidc_inst_capability *capability; struct msm_vidc_inst_capability *capability;
s32 adjusted_value; s32 adjusted_value, ltr_count;
struct msm_vidc_inst *inst = (struct msm_vidc_inst *) instance; struct msm_vidc_inst *inst = (struct msm_vidc_inst *) instance;
s32 ltr_count = -1;
if (!inst || !inst->capabilities) { if (!inst || !inst->capabilities) {
d_vpr_e("%s: invalid params\n", __func__); d_vpr_e("%s: invalid params\n", __func__);
@@ -947,18 +952,22 @@ int msm_vidc_adjust_mark_ltr(void *instance, struct v4l2_ctrl *ctrl)
adjusted_value = ctrl ? ctrl->val : capability->cap[MARK_LTR].value; adjusted_value = ctrl ? ctrl->val : capability->cap[MARK_LTR].value;
if (msm_vidc_get_parent_value(inst, MARK_LTR, LTR_COUNT, /*
&ltr_count, __func__)) * Since MARK_LTR is only set dynamically, and LTR_COUNT is static
return -EINVAL; * control, no need to make LTR_COUNT as parent for MARK_LTR as
* LTR_COUNT value will always be updated when dynamically MARK_LTR
* is set
*/
ltr_count = capability->cap[LTR_COUNT].value;
if (!ltr_count)
return 0;
if (!ltr_count) { if (adjusted_value < 0 ||
adjusted_value = 0;
} else if (adjusted_value < 0 ||
adjusted_value > (ltr_count - 1)) { adjusted_value > (ltr_count - 1)) {
/* MARK_LTR value should be > 0 and <= (LTR_COUNT - 1) */ /* MARK_LTR value should be >= 0 and <= (LTR_COUNT - 1) */
i_vpr_e(inst, "%s: invalid value %d\n", i_vpr_e(inst, "%s: invalid value %d\n",
__func__, adjusted_value); __func__, adjusted_value);
return -EINVAL; return 0;
} }
msm_vidc_update_cap_value(inst, MARK_LTR, msm_vidc_update_cap_value(inst, MARK_LTR,
@@ -1741,9 +1750,15 @@ int msm_vidc_set_use_and_mark_ltr(void *instance,
return -EINVAL; return -EINVAL;
} }
if (!inst->capabilities->cap[LTR_COUNT].value) { if (!inst->capabilities->cap[LTR_COUNT].value ||
i_vpr_h(inst, "%s: ltr count is 0, cap %s is not set\n", (inst->capabilities->cap[cap_id].value ==
__func__, cap_name(cap_id)); INVALID_DEFAULT_MARK_OR_USE_LTR)) {
i_vpr_h(inst,
"%s: LTR_COUNT: %d %s: %d, cap %s is not set\n",
__func__, inst->capabilities->cap[LTR_COUNT].value,
cap_name(cap_id),
inst->capabilities->cap[cap_id].value,
cap_name(cap_id));
return 0; return 0;
} }