Bladeren bron

Merge "video: driver: decouple min quality, CAC and quality boost"

qctecmdr 3 jaren geleden
bovenliggende
commit
8c00483b2c

+ 20 - 8
driver/platform/kalama/src/msm_vidc_kalama.c

@@ -13,6 +13,7 @@
 #include "msm_vidc_core.h"
 #include "msm_vidc_control.h"
 #include "hfi_property.h"
+#include "msm_vidc_iris3.h"
 
 #define DEFAULT_VIDEO_CONCEAL_COLOR_BLACK 0x8020010
 #define MAX_LTR_FRAME_COUNT     2
@@ -652,9 +653,9 @@ static struct msm_platform_inst_capability instance_data_kalama[] = {
 		V4L2_CID_MPEG_VIDC_CONTENT_ADAPTIVE_CODING,
 		HFI_PROP_CONTENT_ADAPTIVE_CODING,
 		CAP_FLAG_OUTPUT_PORT,
-		{BITRATE_MODE, MIN_QUALITY},
+		{BITRATE_MODE, LAYER_ENABLE, LAYER_TYPE},
 		{0},
-		msm_vidc_adjust_cac,
+		msm_vidc_adjust_brs,
 		msm_vidc_set_vbr_related_properties},
 
 	{BITRATE_BOOST, ENC, H264|HEVC,
@@ -662,9 +663,9 @@ static struct msm_platform_inst_capability instance_data_kalama[] = {
 		V4L2_CID_MPEG_VIDC_QUALITY_BITRATE_BOOST,
 		HFI_PROP_BITRATE_BOOST,
 		CAP_FLAG_OUTPUT_PORT,
-		{BITRATE_MODE, MIN_QUALITY},
+		{BITRATE_MODE},
 		{0},
-		msm_vidc_adjust_bitrate_boost,
+		msm_vidc_adjust_bitrate_boost_iris3,
 		msm_vidc_set_vbr_related_properties},
 
 	{MIN_QUALITY, ENC, H264,
@@ -673,7 +674,7 @@ static struct msm_platform_inst_capability instance_data_kalama[] = {
 		HFI_PROP_MAINTAIN_MIN_QUALITY,
 		CAP_FLAG_OUTPUT_PORT,
 		{BITRATE_MODE, ENH_LAYER_COUNT, META_ROI_INFO},
-		{CONTENT_ADAPTIVE_CODING, BITRATE_BOOST, BLUR_TYPES},
+		{BLUR_TYPES},
 		msm_vidc_adjust_min_quality,
 		msm_vidc_set_vbr_related_properties},
 
@@ -684,7 +685,7 @@ static struct msm_platform_inst_capability instance_data_kalama[] = {
 		CAP_FLAG_OUTPUT_PORT,
 		{BITRATE_MODE, PIX_FMTS, ENH_LAYER_COUNT,
 			META_ROI_INFO},
-		{CONTENT_ADAPTIVE_CODING, BITRATE_BOOST, BLUR_TYPES},
+		{BLUR_TYPES},
 		msm_vidc_adjust_min_quality,
 		msm_vidc_set_vbr_related_properties},
 
@@ -861,14 +862,25 @@ static struct msm_platform_inst_capability instance_data_kalama[] = {
 		V4L2_MPEG_VIDEO_H264_HIERARCHICAL_CODING_P,
 		V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_TYPE,
 		HFI_PROP_LAYER_ENCODING_TYPE,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU},
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
+		{0}, {CONTENT_ADAPTIVE_CODING}},
 
 	{LAYER_ENABLE, ENC, H264,
 		V4L2_MPEG_MSM_VIDC_DISABLE, V4L2_MPEG_MSM_VIDC_ENABLE,
 		1, V4L2_MPEG_MSM_VIDC_DISABLE,
 		V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING,
 		HFI_PROP_LAYER_ENCODING_TYPE,
-		CAP_FLAG_OUTPUT_PORT},
+		CAP_FLAG_OUTPUT_PORT,
+		{0}, {CONTENT_ADAPTIVE_CODING}},
+
+	{LAYER_ENABLE, ENC, HEVC,
+		V4L2_MPEG_MSM_VIDC_DISABLE, V4L2_MPEG_MSM_VIDC_ENABLE,
+		1, V4L2_MPEG_MSM_VIDC_DISABLE,
+		0,
+		0,
+		CAP_FLAG_OUTPUT_PORT,
+		{0},
+		{CONTENT_ADAPTIVE_CODING}},
 
 	{ENH_LAYER_COUNT, ENC, HEVC,
 		0, 5, 1, 0,

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

@@ -601,9 +601,9 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		V4L2_CID_MPEG_VIDC_CONTENT_ADAPTIVE_CODING,
 		HFI_PROP_CONTENT_ADAPTIVE_CODING,
 		CAP_FLAG_OUTPUT_PORT,
-		{BITRATE_MODE, MIN_QUALITY},
+		{BITRATE_MODE, LAYER_ENABLE, LAYER_TYPE},
 		{BLUR_TYPES},
-		msm_vidc_adjust_cac,
+		msm_vidc_adjust_brs,
 		msm_vidc_set_vbr_related_properties},
 
 	{BITRATE_BOOST, ENC, H264|HEVC,
@@ -800,7 +800,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		V4L2_MPEG_VIDEO_HEVC_HIERARCHICAL_CODING_P,
 		V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_TYPE,
 		HFI_PROP_LAYER_ENCODING_TYPE,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU},
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
+		{0}, {CONTENT_ADAPTIVE_CODING}},
 
 	{LAYER_TYPE, ENC, H264,
 		V4L2_MPEG_VIDEO_H264_HIERARCHICAL_CODING_B,
@@ -810,14 +811,25 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		V4L2_MPEG_VIDEO_H264_HIERARCHICAL_CODING_P,
 		V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_TYPE,
 		HFI_PROP_LAYER_ENCODING_TYPE,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU},
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
+		{0}, {CONTENT_ADAPTIVE_CODING}},
 
 	{LAYER_ENABLE, ENC, H264,
 		V4L2_MPEG_MSM_VIDC_DISABLE, V4L2_MPEG_MSM_VIDC_ENABLE,
 		1, V4L2_MPEG_MSM_VIDC_DISABLE,
 		V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING,
 		HFI_PROP_LAYER_ENCODING_TYPE,
-		CAP_FLAG_OUTPUT_PORT},
+		CAP_FLAG_OUTPUT_PORT,
+		{0}, {CONTENT_ADAPTIVE_CODING}},
+
+	{LAYER_ENABLE, ENC, HEVC,
+		V4L2_MPEG_MSM_VIDC_DISABLE, V4L2_MPEG_MSM_VIDC_ENABLE,
+		1, V4L2_MPEG_MSM_VIDC_DISABLE,
+		0,
+		0,
+		CAP_FLAG_OUTPUT_PORT,
+		{0},
+		{CONTENT_ADAPTIVE_CODING}},
 
 	{ENH_LAYER_COUNT, ENC, HEVC,
 		0, 5, 1, 0,

+ 5 - 0
driver/variant/iris3/inc/msm_vidc_iris3.h

@@ -12,6 +12,7 @@
 #if defined(CONFIG_MSM_VIDC_IRIS3)
 int msm_vidc_init_iris3(struct msm_vidc_core *core);
 int msm_vidc_deinit_iris3(struct msm_vidc_core *core);
+int msm_vidc_adjust_bitrate_boost_iris3(void *instance, struct v4l2_ctrl *ctrl);
 #else
 static inline int msm_vidc_init_iris3(struct msm_vidc_core *core)
 {
@@ -21,6 +22,10 @@ static inline int msm_vidc_deinit_iris3(struct msm_vidc_core *core)
 {
 	return -EINVAL;
 }
+static inline int msm_vidc_adjust_bitrate_boost_iris3(void *instance, struct v4l2_ctrl *ctrl)
+{
+	return -EINVAL;
+}
 #endif
 
 #endif // _MSM_VIDC_IRIS3_H_

+ 63 - 0
driver/variant/iris3/src/msm_vidc_iris3.c

@@ -1137,6 +1137,69 @@ exit:
 	return 0;
 }
 
+int msm_vidc_adjust_bitrate_boost_iris3(void* instance, struct v4l2_ctrl *ctrl)
+{
+	struct msm_vidc_inst_capability* capability = NULL;
+	s32 adjusted_value;
+	struct msm_vidc_inst *inst = (struct msm_vidc_inst *) instance;
+	s32 rc_type = -1;
+	u32 width, height, frame_rate;
+	struct v4l2_format *f;
+
+	if (!inst || !inst->capabilities) {
+		d_vpr_e("%s: invalid params\n", __func__);
+		return -EINVAL;
+	}
+
+	capability = inst->capabilities;
+
+	adjusted_value = ctrl ? ctrl->val :
+		capability->cap[BITRATE_BOOST].value;
+
+	if (inst->bufq[OUTPUT_PORT].vb2q->streaming)
+		return 0;
+
+	if (msm_vidc_get_parent_value(inst, BITRATE_BOOST,
+		BITRATE_MODE, &rc_type, __func__))
+		return -EINVAL;
+
+	/*
+	 * Bitrate Boost are supported only for VBR rc type.
+	 * Hence, do not adjust or set to firmware for non VBR rc's
+	 */
+	if (rc_type != HFI_RC_VBR_CFR) {
+		adjusted_value = 0;
+		goto adjust;
+	}
+
+	frame_rate = inst->capabilities->cap[FRAME_RATE].value >> 16;
+	f= &inst->fmts[OUTPUT_PORT];
+	width = f->fmt.pix_mp.width;
+	height = f->fmt.pix_mp.height;
+
+	/*
+	 * honor client set bitrate boost
+	 * if client did not set, keep max bitrate boost upto 4k@60fps
+	 * and remove bitrate boost after 4k@60fps
+	*/
+	if (capability->cap[BITRATE_BOOST].flags & CAP_FLAG_CLIENT_SET) {
+		/* accept client set bitrate boost value as is */
+	} else {
+		if (res_is_less_than_or_equal_to(width, height, 3840, 2160) &&
+			frame_rate <= 60)
+			adjusted_value = MAX_BITRATE_BOOST;
+		else
+			adjusted_value = 0;
+	}
+
+adjust:
+	msm_vidc_update_cap_value(inst, BITRATE_BOOST, adjusted_value, __func__);
+
+	return 0;
+}
+
+
+
 static struct msm_vidc_venus_ops iris3_ops = {
 	.boot_firmware = __boot_firmware_iris3,
 	.interrupt_init = __interrupt_init_iris3,

+ 1 - 1
driver/vidc/inc/msm_vidc_control.h

@@ -43,7 +43,7 @@ int msm_vidc_adjust_hevc_p_frame_qp(void *instance, struct v4l2_ctrl *ctrl);
 int msm_vidc_adjust_hevc_b_frame_qp(void *instance, struct v4l2_ctrl *ctrl);
 int msm_vidc_adjust_blur_type(void *instance, struct v4l2_ctrl *ctrl);
 int msm_vidc_adjust_blur_resolution(void *instance, struct v4l2_ctrl *ctrl);
-int msm_vidc_adjust_cac(void *instance, struct v4l2_ctrl *ctrl);
+int msm_vidc_adjust_brs(void *instance, struct v4l2_ctrl *ctrl);
 int msm_vidc_adjust_bitrate_boost(void *instance, struct v4l2_ctrl *ctrl);
 int msm_vidc_adjust_min_quality(void *instance, struct v4l2_ctrl *ctrl);
 int msm_vidc_adjust_lowlatency_mode(void *instance, struct v4l2_ctrl *ctrl);

+ 33 - 8
driver/vidc/src/msm_vidc_control.c

@@ -1056,7 +1056,17 @@ static int msm_vidc_update_static_property(struct msm_vidc_inst *inst,
 
 		msm_vidc_allow_dcvs(inst);
 	}
+	if (ctrl->id == V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_LAYER) {
+		u32 enable;
 
+		/* enable LAYER_ENABLE cap if HEVC_HIER enh layers > 0 */
+		if (ctrl->val > 0)
+			enable = 1;
+		else
+			enable = 0;
+
+		msm_vidc_update_cap_value(inst, LAYER_ENABLE, enable, __func__);
+	}
 	if (is_meta_cap(cap_id)) {
 		/* validate metadata control value against allowed settings */
 		if ((ctrl->val & inst->capabilities->cap[cap_id].max) != ctrl->val) {
@@ -2413,12 +2423,13 @@ int msm_vidc_adjust_blur_resolution(void *instance, struct v4l2_ctrl *ctrl)
 	return 0;
 }
 
-int msm_vidc_adjust_cac(void *instance, struct v4l2_ctrl *ctrl)
+int msm_vidc_adjust_brs(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 min_quality = -1, rc_type = -1;
+	s32 rc_type = -1, layer_enabled = -1, layer_type = -1;
+	bool hp_requested = false;
 
 	if (!inst || !inst->capabilities) {
 		d_vpr_e("%s: invalid params\n", __func__);
@@ -2433,22 +2444,36 @@ int msm_vidc_adjust_cac(void *instance, struct v4l2_ctrl *ctrl)
 		return 0;
 
 	if (msm_vidc_get_parent_value(inst, CONTENT_ADAPTIVE_CODING,
-		MIN_QUALITY, &min_quality, __func__) ||
+		BITRATE_MODE, &rc_type, __func__) ||
 		msm_vidc_get_parent_value(inst, CONTENT_ADAPTIVE_CODING,
-		BITRATE_MODE, &rc_type, __func__))
+		LAYER_ENABLE, &layer_enabled, __func__) ||
+		msm_vidc_get_parent_value(inst, CONTENT_ADAPTIVE_CODING,
+		LAYER_TYPE, &layer_type, __func__))
 		return -EINVAL;
 
 	/*
-	 * CAC is supported only for VBR rc type.
-	 * Hence, do not adjust or set to firmware for non VBR rc's
+	 * -BRS is supported only for VBR rc type.
+	 *  Hence, do not adjust or set to firmware for non VBR rc's
+	 * -If HP is enabled then BRS is not allowed.
 	 */
 	if (rc_type != HFI_RC_VBR_CFR) {
 		adjusted_value = 0;
 		goto adjust;
 	}
 
-	if (min_quality) {
-		adjusted_value = 1;
+	if (inst->codec == MSM_VIDC_H264) {
+		layer_type = V4L2_MPEG_VIDEO_H264_HIERARCHICAL_CODING_P;
+	} else if (inst->codec == MSM_VIDC_HEVC) {
+		layer_type = V4L2_MPEG_VIDEO_HEVC_HIERARCHICAL_CODING_P;
+	}
+	hp_requested = (inst->capabilities->cap[LAYER_TYPE].value == layer_type);
+
+	/*
+	 * Disable BRS in case of HP encoding
+	 * Hence set adjust value to 0.
+	 */
+	if (layer_enabled == 1 && hp_requested) {
+		adjusted_value = 0;
 		goto adjust;
 	}