Procházet zdrojové kódy

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 <[email protected]>
Akshata Sahukar před 4 roky
rodič
revize
1b42ed0a67

+ 9 - 5
driver/platform/waipio/src/msm_vidc_waipio.c

@@ -447,23 +447,27 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		V4L2_CID_MPEG_VIDEO_LTR_COUNT,
 		HFI_PROP_LTR_COUNT,
 		CAP_FLAG_OUTPUT_PORT,
-		{BITRATE_MODE}, {USE_LTR, MARK_LTR},
+		{BITRATE_MODE}, {0},
 		msm_vidc_adjust_ltr_count, msm_vidc_set_u32},
 
 	{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,
 		HFI_PROP_LTR_USE,
 		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},
 
 	{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,
 		HFI_PROP_LTR_MARK,
 		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},
 
 	{BASELAYER_PRIORITY, ENC, H264,

+ 1 - 0
driver/vidc/inc/msm_vidc_internal.h

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

+ 39 - 24
driver/vidc/src/msm_vidc_control.c

@@ -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)
 {
 	struct msm_vidc_inst_capability *capability;
-	s32 adjusted_value;
+	s32 adjusted_value, ltr_count;
 	struct msm_vidc_inst *inst = (struct msm_vidc_inst *) instance;
-	s32 ltr_count = -1;
 
 	if (!inst || !inst->capabilities) {
 		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;
 
-	if (msm_vidc_get_parent_value(inst, USE_LTR, LTR_COUNT,
-		&ltr_count, __func__))
-		return -EINVAL;
+	/*
+	 * Since USE_LTR is only set dynamically, and LTR_COUNT is static
+	 * 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) {
-		adjusted_value = 0;
-	} else if (adjusted_value <= 0 ||
-		adjusted_value >= (1 << ltr_count)) {
-		/* USE_LTR value should be > 0 and < (2 ^ LTR_COUNT) */
+	if (adjusted_value <= 0 ||
+		adjusted_value > ((1 << ltr_count) - 1)) {
+		/*
+		 * USE_LTR is bitmask value, hence should be
+		 * > 0 and <= (2 ^ LTR_COUNT) - 1
+		 */
 		i_vpr_e(inst, "%s: invalid value %d\n",
 			__func__, adjusted_value);
-		return -EINVAL;
+		return 0;
 	}
 
 	/* 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)
 {
 	struct msm_vidc_inst_capability *capability;
-	s32 adjusted_value;
+	s32 adjusted_value, ltr_count;
 	struct msm_vidc_inst *inst = (struct msm_vidc_inst *) instance;
-	s32 ltr_count = -1;
 
 	if (!inst || !inst->capabilities) {
 		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;
 
-	if (msm_vidc_get_parent_value(inst, MARK_LTR, LTR_COUNT,
-		&ltr_count, __func__))
-		return -EINVAL;
+	/*
+	 * Since MARK_LTR is only set dynamically, and LTR_COUNT is static
+	 * 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) {
-		adjusted_value = 0;
-	} else if (adjusted_value < 0 ||
+	if (adjusted_value < 0 ||
 		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",
 			__func__, adjusted_value);
-		return -EINVAL;
+		return 0;
 	}
 
 	msm_vidc_update_cap_value(inst, MARK_LTR,
@@ -1741,9 +1750,15 @@ int msm_vidc_set_use_and_mark_ltr(void *instance,
 		return -EINVAL;
 	}
 
-	if (!inst->capabilities->cap[LTR_COUNT].value) {
-		i_vpr_h(inst, "%s: ltr count is 0, cap %s is not set\n",
-			__func__, cap_name(cap_id));
+	if (!inst->capabilities->cap[LTR_COUNT].value ||
+		(inst->capabilities->cap[cap_id].value ==
+			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;
 	}