Bladeren bron

Merge "video: driver: Modify decode order and some misc changes"

qctecmdr 4 jaren geleden
bovenliggende
commit
07b361166a

+ 46 - 37
driver/platform/waipio/src/msm_vidc_waipio.c

@@ -312,7 +312,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		1, MAX_BITRATE, 1, DEFAULT_BITRATE,
 		V4L2_CID_MPEG_VIDEO_BITRATE,
 		HFI_PROP_TOTAL_BITRATE,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{ENH_LAYER_COUNT, BITRATE_MODE}, {PEAK_BITRATE},
 		msm_vidc_adjust_bitrate, msm_vidc_set_bitrate},
 
@@ -374,7 +375,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		1, MAX_CONSTANT_QUALITY, 1, 90,
 		V4L2_CID_MPEG_VIDEO_CONSTANT_QUALITY,
 		HFI_PROP_CONSTANT_QUALITY,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{BITRATE_MODE}, {0},
 		NULL, msm_vidc_set_constant_quality},
 
@@ -382,7 +384,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		0, INT_MAX, 1, 2 * DEFAULT_FPS - 1,
 		V4L2_CID_MPEG_VIDEO_GOP_SIZE,
 		HFI_PROP_MAX_GOP_FRAMES,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{ENH_LAYER_COUNT},
 		{0},
 		msm_vidc_adjust_gop_size, msm_vidc_set_gop_size},
@@ -539,7 +542,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 			(DEFAULT_BITRATE / PERCENT_PEAK_BITRATE_INCREASED)),
 		V4L2_CID_MPEG_VIDEO_BITRATE_PEAK,
 		HFI_PROP_TOTAL_PEAK_BITRATE,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{BITRATE_MODE, BIT_RATE},
 		{0},
 		msm_vidc_adjust_peak_bitrate,
@@ -625,18 +629,12 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		MIN_QP_10BIT, MAX_QP, 1, MAX_QP,
 		V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MAX_QP},
 
-	{HEVC_HIER_QP, ENC, HEVC|HEIC,
-		V4L2_MPEG_MSM_VIDC_DISABLE, V4L2_MPEG_MSM_VIDC_ENABLE,
-		1, V4L2_MPEG_MSM_VIDC_DISABLE,
-		V4L2_CID_MPEG_VIDEO_HEVC_HIER_QP,
-		HFI_PROP_QP_PACKED,
-		CAP_FLAG_ROOT | CAP_FLAG_OUTPUT_PORT},
-
 	{I_FRAME_QP, ENC, HEVC|HEIC,
 		MIN_QP_10BIT, MAX_QP, 1, DEFAULT_QP,
 		V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_QP,
 		HFI_PROP_QP_PACKED,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{PIX_FMTS, BITRATE_MODE}, {0},
 		msm_vidc_adjust_hevc_frame_qp, msm_vidc_set_frame_qp},
 
@@ -644,7 +642,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		MIN_QP_8BIT, MAX_QP, 1, DEFAULT_QP,
 		V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP,
 		HFI_PROP_QP_PACKED,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{BITRATE_MODE}, {0},
 		NULL, msm_vidc_set_frame_qp},
 
@@ -664,12 +663,6 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		MIN_QP_8BIT, MAX_QP, 1, DEFAULT_QP,
 		V4L2_CID_MPEG_VIDEO_H264_B_FRAME_QP},
 
-	{HIER_LAYER_QP, ENC, H264,
-		0, 0x0060033, 1, 20,
-		V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER_QP,
-		HFI_PROP_QP_PACKED,
-		CAP_FLAG_ROOT | CAP_FLAG_OUTPUT_PORT},
-
 	{LAYER_TYPE, ENC, HEVC,
 		V4L2_MPEG_VIDEO_HEVC_HIERARCHICAL_CODING_B,
 		V4L2_MPEG_VIDEO_HEVC_HIERARCHICAL_CODING_P,
@@ -701,7 +694,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		0, 5, 1, 0,
 		V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_LAYER,
 		HFI_PROP_LAYER_COUNT,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{BITRATE_MODE},
 		{GOP_SIZE, B_FRAME, BIT_RATE},
 		msm_vidc_adjust_layer_count, msm_vidc_set_layer_count_and_type},
@@ -710,7 +704,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		0, 5, 1, 0,
 		V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER,
 		HFI_PROP_LAYER_COUNT,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{BITRATE_MODE},
 		{GOP_SIZE, B_FRAME, BIT_RATE},
 		msm_vidc_adjust_layer_count, msm_vidc_set_layer_count_and_type},
@@ -723,7 +718,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		1, MAX_BITRATE, 1, DEFAULT_BITRATE,
 		V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L0_BR,
 		HFI_PROP_BITRATE_LAYER1,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{0}, {0},
 		msm_vidc_adjust_bitrate, msm_vidc_set_bitrate},
 
@@ -731,7 +727,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		1, MAX_BITRATE, 1, DEFAULT_BITRATE,
 		V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L1_BR,
 		HFI_PROP_BITRATE_LAYER2,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{0}, {0},
 		msm_vidc_adjust_bitrate, msm_vidc_set_bitrate},
 
@@ -739,7 +736,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		1, MAX_BITRATE, 1, DEFAULT_BITRATE,
 		V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L2_BR,
 		HFI_PROP_BITRATE_LAYER3,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{0}, {0},
 		msm_vidc_adjust_bitrate, msm_vidc_set_bitrate},
 
@@ -747,7 +745,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		1, MAX_BITRATE, 1, DEFAULT_BITRATE,
 		V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L3_BR,
 		HFI_PROP_BITRATE_LAYER4,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{0}, {0},
 		msm_vidc_adjust_bitrate, msm_vidc_set_bitrate},
 
@@ -755,7 +754,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		1, MAX_BITRATE, 1, DEFAULT_BITRATE,
 		V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L4_BR,
 		HFI_PROP_BITRATE_LAYER5,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{0}, {0},
 		msm_vidc_adjust_bitrate, msm_vidc_set_bitrate},
 
@@ -763,7 +763,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		1, MAX_BITRATE, 1, DEFAULT_BITRATE,
 		V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L5_BR,
 		HFI_PROP_BITRATE_LAYER6,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{0}, {0},
 		msm_vidc_adjust_bitrate, msm_vidc_set_bitrate},
 
@@ -771,7 +772,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		1, MAX_BITRATE, 1, DEFAULT_BITRATE,
 		V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L0_BR,
 		HFI_PROP_BITRATE_LAYER1,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{0}, {0},
 		msm_vidc_adjust_bitrate, msm_vidc_set_bitrate},
 
@@ -779,7 +781,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		1, MAX_BITRATE, 1, DEFAULT_BITRATE,
 		V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L1_BR,
 		HFI_PROP_BITRATE_LAYER2,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{0}, {0},
 		msm_vidc_adjust_bitrate, msm_vidc_set_bitrate},
 
@@ -787,7 +790,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		1, MAX_BITRATE, 1, DEFAULT_BITRATE,
 		V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L2_BR,
 		HFI_PROP_BITRATE_LAYER3,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{0}, {0},
 		msm_vidc_adjust_bitrate, msm_vidc_set_bitrate},
 
@@ -795,7 +799,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		1, MAX_BITRATE, 1, DEFAULT_BITRATE,
 		V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L3_BR,
 		HFI_PROP_BITRATE_LAYER4,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{0}, {0},
 		msm_vidc_adjust_bitrate, msm_vidc_set_bitrate},
 
@@ -803,7 +808,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		1, MAX_BITRATE, 1, DEFAULT_BITRATE,
 		V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L4_BR,
 		HFI_PROP_BITRATE_LAYER5,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{0}, {0},
 		msm_vidc_adjust_bitrate, msm_vidc_set_bitrate},
 
@@ -811,7 +817,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		1, MAX_BITRATE, 1, DEFAULT_BITRATE,
 		V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L5_BR,
 		HFI_PROP_BITRATE_LAYER6,
-		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{0}, {0},
 		msm_vidc_adjust_bitrate, msm_vidc_set_bitrate},
 
@@ -1063,13 +1070,13 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		1, V4L2_MPEG_MSM_VIDC_DISABLE,
 		V4L2_CID_MPEG_MFC51_VIDEO_DECODER_H264_DISPLAY_DELAY_ENABLE,
 		HFI_PROP_DECODE_ORDER_OUTPUT,
-		CAP_FLAG_ROOT | CAP_FLAG_OUTPUT_PORT},
+		CAP_FLAG_ROOT | CAP_FLAG_INPUT_PORT},
 
 	{DISPLAY_DELAY, DEC, H264|HEVC|VP9,
 		0, 1, 1, 0,
 		V4L2_CID_MPEG_MFC51_VIDEO_DECODER_H264_DISPLAY_DELAY,
 		HFI_PROP_DECODE_ORDER_OUTPUT,
-		CAP_FLAG_ROOT | CAP_FLAG_OUTPUT_PORT},
+		CAP_FLAG_ROOT | CAP_FLAG_INPUT_PORT},
 
 	/* conceal color */
 	{CONCEAL_COLOR_8BIT, DEC, CODECS_ALL, 0x0, 0xff3fcff, 1,
@@ -1304,7 +1311,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		1, MAX_CONSTANT_QUALITY, 1, 100,
 		V4L2_CID_MPEG_VIDEO_CONSTANT_QUALITY,
 		HFI_PROP_CONSTANT_QUALITY,
-		CAP_FLAG_ROOT | CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_OUTPUT_PORT | CAP_FLAG_INPUT_PORT |
+			CAP_FLAG_DYNAMIC_ALLOWED,
 		{BITRATE_MODE}, {0},
 		NULL, msm_vidc_set_constant_quality},
 	{GRID, ENC, HEIC,
@@ -1319,7 +1327,8 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
 		0, INT_MAX, 1, 0 /* all intra */,
 		V4L2_CID_MPEG_VIDEO_GOP_SIZE,
 		HFI_PROP_MAX_GOP_FRAMES,
-		CAP_FLAG_ROOT | CAP_FLAG_OUTPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
+		CAP_FLAG_ROOT | CAP_FLAG_OUTPUT_PORT |
+			CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
 		{0}, {0},
 		NULL, msm_vidc_set_u32},
 	{B_FRAME, ENC, HEIC,

+ 10 - 5
driver/variant/iris2/src/msm_vidc_buffer_iris2.c

@@ -473,8 +473,8 @@ struct msm_vidc_buf_type_handle {
 int msm_buffer_size_iris2(struct msm_vidc_inst *inst,
 		enum msm_vidc_buffer_type buffer_type)
 {
-	int i, size = 0;
-	u32 buf_type_handle_size = 0;
+	int i;
+	u32 size = 0, buf_type_handle_size = 0;
 	const struct msm_vidc_buf_type_handle *buf_type_handle_arr = NULL;
 	static const struct msm_vidc_buf_type_handle dec_buf_type_handle[] = {
 		{MSM_VIDC_BUF_INPUT,           msm_vidc_decoder_input_size              },
@@ -525,9 +525,14 @@ int msm_buffer_size_iris2(struct msm_vidc_inst *inst,
 	}
 
 	/* handle unknown buffer type */
-	if (i == buf_type_handle_size)
+	if (i == buf_type_handle_size) {
 		i_vpr_e(inst, "%s: unknown buffer type %#x\n", __func__, buffer_type);
+		goto exit;
+	}
+
+	i_vpr_l(inst, "buffer_size: type: %11s,  size: %9u\n", buf_name(buffer_type), size);
 
+exit:
 	return size;
 }
 
@@ -589,7 +594,7 @@ int msm_buffer_min_count_iris2(struct msm_vidc_inst *inst,
 		break;
 	}
 
-	i_vpr_l(inst, "%s: type %u, count %u\n", __func__, buffer_type, count);
+	i_vpr_l(inst, "  min_count: type: %11s, count: %9u\n", buf_name(buffer_type), count);
 	return count;
 }
 
@@ -616,6 +621,6 @@ int msm_buffer_extra_count_iris2(struct msm_vidc_inst *inst,
 		break;
 	}
 
-	i_vpr_l(inst, "%s: type %u, count %u\n", __func__, buffer_type, count);
+	i_vpr_l(inst, "extra_count: type: %11s, count: %9u\n", buf_name(buffer_type), count);
 	return count;
 }

+ 0 - 2
driver/vidc/inc/msm_vidc_control.h

@@ -79,8 +79,6 @@ int msm_vidc_set_session_priority(void *instance,
 	enum msm_vidc_inst_capability_type cap_id);
 int msm_vidc_set_s32(void *instance,
 	enum msm_vidc_inst_capability_type cap_id);
-int msm_vidc_set_array(void *instance,
-	enum msm_vidc_inst_capability_type cap_id);
 int msm_vidc_set_q16(void *instance,
 	enum msm_vidc_inst_capability_type cap_id);
 int msm_vidc_set_v4l2_properties(struct msm_vidc_inst *inst);

+ 2 - 0
driver/vidc/inc/msm_vidc_driver.h

@@ -272,6 +272,7 @@ int msm_vidc_change_core_state(struct msm_vidc_core *core,
 int msm_vidc_core_init(struct msm_vidc_core *core);
 int msm_vidc_core_deinit(struct msm_vidc_core *core, bool force);
 int msm_vidc_core_timeout(struct msm_vidc_core *core);
+int msm_vidc_print_buffer_info(struct msm_vidc_inst *inst);
 int msm_vidc_print_inst_info(struct msm_vidc_inst *inst);
 void msm_vidc_print_core_info(struct msm_vidc_core *core);
 int msm_vidc_smmu_fault_handler(struct iommu_domain *domain,
@@ -360,5 +361,6 @@ bool msm_vidc_allow_decode_batch(struct msm_vidc_inst *inst);
 int msm_vidc_check_session_supported(struct msm_vidc_inst *inst);
 int msm_vidc_check_mbps_supported(struct msm_vidc_inst *inst);
 int msm_vidc_check_scaling_supported(struct msm_vidc_inst *inst);
+const char *buf_name(enum msm_vidc_buffer_type type);
 #endif // _MSM_VIDC_DRIVER_H_
 

+ 14 - 17
driver/vidc/inc/msm_vidc_internal.h

@@ -136,21 +136,20 @@ enum msm_vidc_colorformat_type {
 };
 
 enum msm_vidc_buffer_type {
-	MSM_VIDC_BUF_NONE = 0,
-	MSM_VIDC_BUF_INPUT         = 1,
-	MSM_VIDC_BUF_OUTPUT        = 2,
-	MSM_VIDC_BUF_INPUT_META    = 3,
-	MSM_VIDC_BUF_OUTPUT_META   = 4,
-	MSM_VIDC_BUF_READ_ONLY     = 5,
-	MSM_VIDC_BUF_QUEUE         = 10,
-	MSM_VIDC_BUF_BIN           = 20,
-	MSM_VIDC_BUF_ARP           = 21,
-	MSM_VIDC_BUF_COMV          = 22,
-	MSM_VIDC_BUF_NON_COMV      = 23,
-	MSM_VIDC_BUF_LINE          = 24,
-	MSM_VIDC_BUF_DPB           = 25,
-	MSM_VIDC_BUF_PERSIST       = 26,
-	MSM_VIDC_BUF_VPSS          = 27,
+	MSM_VIDC_BUF_INPUT                 = 1,
+	MSM_VIDC_BUF_OUTPUT                = 2,
+	MSM_VIDC_BUF_INPUT_META            = 3,
+	MSM_VIDC_BUF_OUTPUT_META           = 4,
+	MSM_VIDC_BUF_READ_ONLY             = 5,
+	MSM_VIDC_BUF_QUEUE                 = 6,
+	MSM_VIDC_BUF_BIN                   = 7,
+	MSM_VIDC_BUF_ARP                   = 8,
+	MSM_VIDC_BUF_COMV                  = 9,
+	MSM_VIDC_BUF_NON_COMV              = 10,
+	MSM_VIDC_BUF_LINE                  = 11,
+	MSM_VIDC_BUF_DPB                   = 12,
+	MSM_VIDC_BUF_PERSIST               = 13,
+	MSM_VIDC_BUF_VPSS                  = 14,
 };
 
 /* always match with v4l2 flags V4L2_BUF_FLAG_* */
@@ -373,11 +372,9 @@ enum msm_vidc_inst_capability_type {
 	I_FRAME_MAX_QP,
 	P_FRAME_MAX_QP,
 	B_FRAME_MAX_QP,
-	HEVC_HIER_QP,
 	I_FRAME_QP,
 	P_FRAME_QP,
 	B_FRAME_QP,
-	HIER_LAYER_QP,
 	LAYER_TYPE,
 	LAYER_ENABLE,
 	ENH_LAYER_COUNT,

+ 12 - 29
driver/vidc/src/msm_vdec.c

@@ -588,14 +588,17 @@ static int msm_vdec_set_output_order(struct msm_vidc_inst *inst,
 	enum msm_vidc_port_type port)
 {
 	int rc = 0;
-	u32 output_order;
+	u32 output_order = 0;
 
 	if (port != INPUT_PORT) {
 		i_vpr_e(inst, "%s: invalid port %d\n", __func__, port);
 		return -EINVAL;
 	}
 
-	output_order = inst->capabilities->cap[DISPLAY_DELAY_ENABLE].value;
+	if (inst->capabilities->cap[DISPLAY_DELAY_ENABLE].value &&
+		!inst->capabilities->cap[DISPLAY_DELAY].value)
+		output_order = 1;
+
 	i_vpr_h(inst, "%s: output order: %d", __func__, output_order);
 	rc = venus_hfi_session_property(inst,
 			HFI_PROP_DECODE_ORDER_OUTPUT,
@@ -816,24 +819,6 @@ static int msm_vdec_get_input_internal_buffers(struct msm_vidc_inst *inst)
 			return rc;
 	}
 
-	i_vpr_h(inst, "input internal buffer: min     size     reuse\n");
-	i_vpr_h(inst, "bin  buffer: %d      %d      %d\n",
-		inst->buffers.bin.min_count,
-		inst->buffers.bin.size,
-		inst->buffers.bin.reuse);
-	i_vpr_h(inst, "comv  buffer: %d      %d      %d\n",
-		inst->buffers.comv.min_count,
-		inst->buffers.comv.size,
-		inst->buffers.comv.reuse);
-	i_vpr_h(inst, "non_comv  buffer: %d      %d      %d\n",
-		inst->buffers.non_comv.min_count,
-		inst->buffers.non_comv.size,
-		inst->buffers.non_comv.reuse);
-	i_vpr_h(inst, "line buffer: %d      %d      %d\n",
-		inst->buffers.line.min_count,
-		inst->buffers.line.size,
-		inst->buffers.line.reuse);
-
 	return rc;
 }
 
@@ -850,12 +835,6 @@ static int msm_vdec_get_output_internal_buffers(struct msm_vidc_inst *inst)
 	if (rc)
 		return rc;
 
-	i_vpr_h(inst, "output internal buffer: min     size     reuse\n");
-	i_vpr_h(inst, "dpb  buffer: %d      %d      %d\n",
-		inst->buffers.dpb.min_count,
-		inst->buffers.dpb.size,
-		inst->buffers.dpb.reuse);
-
 	return rc;
 }
 
@@ -1832,14 +1811,18 @@ int msm_vdec_process_cmd(struct msm_vidc_inst *inst, u32 cmd)
 		vb2_clear_last_buffer_dequeued(&inst->vb2q[OUTPUT_META_PORT]);
 		vb2_clear_last_buffer_dequeued(&inst->vb2q[OUTPUT_PORT]);
 
+		rc = msm_vidc_state_change_start(inst);
+		if (rc)
+			return rc;
+
 		/* tune power features */
 		inst->decode_batch.enable = msm_vidc_allow_decode_batch(inst);
 		msm_vidc_allow_dcvs(inst);
 		msm_vidc_power_data_reset(inst);
 
-		rc = msm_vidc_state_change_start(inst);
-		if (rc)
-			return rc;
+		/* print final buffer counts & size details */
+		msm_vidc_print_buffer_info(inst);
+
 		rc = venus_hfi_session_command(inst,
 				HFI_CMD_RESUME,
 				port,

+ 7 - 20
driver/vidc/src/msm_venc.c

@@ -653,23 +653,6 @@ static int msm_venc_get_output_internal_buffers(struct msm_vidc_inst *inst)
 			return rc;
 	}
 
-	i_vpr_h(inst, "internal buffer: min     size\n");
-	i_vpr_h(inst, "bin  buffer: %d      %d\n",
-		inst->buffers.bin.min_count,
-		inst->buffers.bin.size);
-	i_vpr_h(inst, "comv  buffer: %d      %d\n",
-		inst->buffers.comv.min_count,
-		inst->buffers.comv.size);
-	i_vpr_h(inst, "non_comv  buffer: %d      %d\n",
-		inst->buffers.non_comv.min_count,
-		inst->buffers.non_comv.size);
-	i_vpr_h(inst, "line buffer: %d      %d\n",
-		inst->buffers.line.min_count,
-		inst->buffers.line.size);
-	i_vpr_h(inst, "dpb buffer: %d      %d\n",
-		inst->buffers.dpb.min_count,
-		inst->buffers.dpb.size);
-
 	return rc;
 }
 
@@ -973,13 +956,17 @@ int msm_venc_process_cmd(struct msm_vidc_inst *inst, u32 cmd)
 		vb2_clear_last_buffer_dequeued(&inst->vb2q[OUTPUT_META_PORT]);
 		vb2_clear_last_buffer_dequeued(&inst->vb2q[OUTPUT_PORT]);
 
+		rc = msm_vidc_state_change_start(inst);
+		if (rc)
+			return rc;
+
 		/* tune power features */
 		msm_vidc_allow_dcvs(inst);
 		msm_vidc_power_data_reset(inst);
 
-		rc = msm_vidc_state_change_start(inst);
-		if (rc)
-			return rc;
+		/* print final buffer counts & size details */
+		msm_vidc_print_buffer_info(inst);
+
 		rc = venus_hfi_session_command(inst,
 				HFI_CMD_RESUME,
 				INPUT_PORT,

+ 2 - 14
driver/vidc/src/msm_vidc_buffer.c

@@ -34,15 +34,6 @@ u32 msm_vidc_input_min_count(struct msm_vidc_inst* inst)
 	if (is_thumbnail_session(inst) || is_image_session(inst))
 		input_min_count = 1;
 
-	//if (is_grid_session(inst))
-	//	input_min_count = 2;
-
-	//if (is_hier_b_session(inst)) {
-		//max_layer = get_ctrl(inst,
-		//	V4L2_CID_MPEG_VIDC_VIDEO_HEVC_MAX_HIER_CODING_LAYER);
-		//input_min_count = (1 << (max_layer->val - 1)) + 2;
-	//}
-
 	return input_min_count;
 }
 
@@ -193,8 +184,8 @@ u32 msm_vidc_internal_buffer_count(struct msm_vidc_inst *inst,
 			else
 				count = 0;
 		} else {
-			i_vpr_e(inst, "%s: unsupported buffer type %#x\n",
-				__func__, buffer_type);
+			i_vpr_e(inst, "%s: unsupported buffer type %s\n",
+				__func__, buf_name(buffer_type));
 			count = 0;
 		}
 	}
@@ -317,9 +308,6 @@ u32 msm_vidc_encoder_output_size(struct msm_vidc_inst *inst)
 	 * Initially frame_size = YUVsize * 2;
 	 */
 
-	/* if (is_grid_session(inst)) {
-		f->fmt.pix_mp.width = f->fmt.pix_mp.height = HEIC_GRID_DIMENSION;
-	} */
 	width = ALIGN(f->fmt.pix_mp.width, BUFFER_ALIGNMENT_SIZE(32));
 	height = ALIGN(f->fmt.pix_mp.height, BUFFER_ALIGNMENT_SIZE(32));
 	mbs_per_frame = NUM_MBS_PER_FRAME(width, height);

+ 86 - 118
driver/vidc/src/msm_vidc_control.c

@@ -111,11 +111,12 @@ static u32 msm_vidc_get_port_info(struct msm_vidc_inst *inst,
 
 	if (capability->cap[cap_id].flags & CAP_FLAG_INPUT_PORT &&
 		capability->cap[cap_id].flags & CAP_FLAG_OUTPUT_PORT) {
-		i_vpr_e(inst,
-			"%s: both ports enabled. Default port set: BITSTREAM\n",
-			__func__);
-		return HFI_PORT_BITSTREAM;
+		if (inst->vb2q[OUTPUT_PORT].streaming)
+			return get_hfi_port(inst, INPUT_PORT);
+		else
+			return get_hfi_port(inst, OUTPUT_PORT);
 	}
+
 	if (capability->cap[cap_id].flags & CAP_FLAG_INPUT_PORT)
 		return get_hfi_port(inst, INPUT_PORT);
 	else if (capability->cap[cap_id].flags & CAP_FLAG_OUTPUT_PORT)
@@ -149,9 +150,9 @@ static int msm_vidc_packetize_control(struct msm_vidc_inst *inst,
 {
 	int rc = 0;
 
-	i_vpr_l(inst,
-		"%s: hfi_id: %#x, value: %#x\n", func,
-		inst->capabilities->cap[cap_id].hfi_id,
+	i_vpr_h(inst,
+		"set cap: name: %24s, cap value: %#10x, hfi: %#10x\n",
+		cap_name(cap_id), inst->capabilities->cap[cap_id].value,
 		*(s64 *)hfi_val);
 
 	rc = venus_hfi_session_property(inst,
@@ -163,8 +164,8 @@ static int msm_vidc_packetize_control(struct msm_vidc_inst *inst,
 		sizeof(payload_size));
 	if (rc)
 		i_vpr_e(inst,
-			"%s: failed to set cap_id: %d to fw\n",
-			__func__, cap_id);
+			"%s: failed to set cap[%d] %s to fw\n",
+			__func__, cap_id, cap_name(cap_id));
 
 	return rc;
 }
@@ -199,8 +200,8 @@ static int msm_vidc_add_capid_to_list(struct msm_vidc_inst *inst,
 		list_for_each_entry(curr_node, &inst->firmware.list, list) {
 			if (curr_node->cap_id == cap_id) {
 				i_vpr_l(inst,
-					"%s: cap %d already present in FW_LIST\n",
-					__func__, cap_id);
+					"%s: cap[%d] %s already present in FW_LIST\n",
+					__func__, cap_id, cap_name(cap_id));
 				return 0;
 			}
 		}
@@ -266,7 +267,7 @@ int msm_vidc_update_cap_value(struct msm_vidc_inst *inst, u32 cap,
 
 	if (inst->capabilities->cap[cap].value != adjusted_val)
 		i_vpr_h(inst,
-			"%s: updated database: name %s, value %#x -> %#x\n",
+			"%s: updated database: name: %s, value: %#x -> %#x\n",
 			func, cap_name(cap),
 			inst->capabilities->cap[cap].value, adjusted_val);
 
@@ -294,8 +295,8 @@ static int msm_vidc_get_parent_value(struct msm_vidc_inst* inst,
 		}
 	} else {
 		i_vpr_e(inst,
-			"%s: missing parent %d for cap %d, please correct database\n",
-			func, parent, cap);
+			"%s: missing parent %d for cap[%d] %s, fix database\n",
+			func, parent, cap, cap_name(cap));
 		rc = -EINVAL;
 	}
 
@@ -312,8 +313,8 @@ static int msm_vidc_adjust_hevc_qp(struct msm_vidc_inst *inst,
 
 	if (!(inst->codec == MSM_VIDC_HEVC || inst->codec == MSM_VIDC_HEIC)) {
 		i_vpr_e(inst,
-			"%s: incorrect entry in database for cap %d. fix the database\n",
-			__func__, cap_id);
+			"%s: incorrect cap[%d] %s entry in database, fix database\n",
+			__func__, cap_id, cap_name(cap_id));
 		return -EINVAL;
 	}
 
@@ -394,8 +395,8 @@ static int msm_vidc_adjust_dynamic_property(struct msm_vidc_inst *inst,
 	 */
 	if (!(capability->cap[cap_id].flags & CAP_FLAG_DYNAMIC_ALLOWED)) {
 		i_vpr_e(inst,
-			"%s: dynamic setting of cap_id %d is not allowed\n",
-			__func__, cap_id);
+			"%s: dynamic setting of cap[%d] %s is not allowed\n",
+			__func__, cap_id, cap_name(cap_id));
 		msm_vidc_change_inst_state(inst, MSM_VIDC_ERROR, __func__);
 		return -EINVAL;
 	}
@@ -406,8 +407,9 @@ static int msm_vidc_adjust_dynamic_property(struct msm_vidc_inst *inst,
 	 */
 	if (!ctrl && !capability->cap[cap_id].adjust) {
 		i_vpr_e(inst,
-			"%s: child cap %d must have ajdust function\n",
-			__func__, capability->cap[cap_id].cap);
+			"%s: child cap[%d] %s must have ajdust function\n",
+			__func__, capability->cap[cap_id].cap,
+			cap_name(capability->cap[cap_id].cap));
 		return -EINVAL;
 	}
 	prev_value = capability->cap[cap_id].value;
@@ -512,8 +514,8 @@ int msm_vidc_ctrl_init(struct msm_vidc_inst *inst)
 			goto error;
 		}
 		i_vpr_h(inst,
-			"%s: cap idx %d, value %d min %d max %d step_or_mask %#x flags %#x v4l2_id %#x hfi_id %#x\n",
-			__func__, idx,
+			"%s: cap[%d] %24s, value %d min %d max %d step_or_mask %#x flags %#x v4l2_id %#x hfi_id %#x\n",
+			__func__, idx, cap_name(idx),
 			capability->cap[idx].value,
 			capability->cap[idx].min,
 			capability->cap[idx].max,
@@ -687,8 +689,8 @@ int msm_v4l2_op_s_ctrl(struct v4l2_ctrl *ctrl)
 	if (inst->vb2q[OUTPUT_PORT].streaming &&
 		!(capability->cap[cap_id].flags & CAP_FLAG_DYNAMIC_ALLOWED)) {
 		i_vpr_e(inst,
-			"%s: dynamic setting of cap_id %d is not allowed\n",
-			__func__, cap_id);
+			"%s: dynamic setting of cap[%d] %s is not allowed\n",
+			__func__, cap_id, cap_name(cap_id));
 		return -EBUSY;
 	}
 
@@ -1584,11 +1586,10 @@ int msm_vidc_set_header_mode(void *instance,
 	if (hdr_metadata)
 		hfi_value |= HFI_SEQ_HEADER_METADATA;
 
-	i_vpr_h(inst, "set cap: name: %24s, value: %#10x, hfi: %#10x\n", cap_name(cap_id),
-		inst->capabilities->cap[cap_id].value, hfi_value);
-
 	rc = msm_vidc_packetize_control(inst, cap_id, HFI_PAYLOAD_U32_ENUM,
 		&hfi_value, sizeof(u32), __func__);
+	if (rc)
+		return rc;
 
 	return rc;
 }
@@ -1616,11 +1617,10 @@ int msm_vidc_set_deblock_mode(void *instance,
 	alpha = inst->capabilities->cap[LF_ALPHA].value + lf_offset;
 	hfi_value = (alpha << 16) | (beta << 8) | lf_mode;
 
-	i_vpr_h(inst, "set cap: name: %24s, value: %#10x, hfi: %#10x\n", cap_name(cap_id),
-		inst->capabilities->cap[cap_id].value, hfi_value);
-
 	rc = msm_vidc_packetize_control(inst, cap_id, HFI_PAYLOAD_32_PACKED,
 		&hfi_value, sizeof(u32), __func__);
+	if (rc)
+		return rc;
 
 	return rc;
 }
@@ -1647,11 +1647,10 @@ int msm_vidc_set_constant_quality(void *instance,
 
 	hfi_value = inst->capabilities->cap[cap_id].value;
 
-	i_vpr_h(inst, "set cap: name: %24s, value: %#10x, hfi: %#10x\n", cap_name(cap_id),
-		inst->capabilities->cap[cap_id].value, hfi_value);
-
 	rc = msm_vidc_packetize_control(inst, cap_id, HFI_PAYLOAD_U32,
 		&hfi_value, sizeof(u32), __func__);
+	if (rc)
+		return rc;
 
 	return rc;
 }
@@ -1680,6 +1679,8 @@ int msm_vidc_set_vbr_related_properties(void *instance,
 
 	rc = msm_vidc_packetize_control(inst, cap_id, HFI_PAYLOAD_U32,
 		&hfi_value, sizeof(u32), __func__);
+	if (rc)
+		return rc;
 
 	return rc;
 }
@@ -1709,6 +1710,8 @@ int msm_vidc_set_cbr_related_properties(void *instance,
 
 	rc = msm_vidc_packetize_control(inst, cap_id, HFI_PAYLOAD_U32,
 		&hfi_value, sizeof(u32), __func__);
+	if (rc)
+		return rc;
 
 	return rc;
 }
@@ -1725,16 +1728,18 @@ int msm_vidc_set_use_and_mark_ltr(void *instance,
 		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",
+			__func__, cap_name(cap_id));
 		return 0;
+	}
 
 	hfi_value = inst->capabilities->cap[cap_id].value;
 
-	i_vpr_h(inst, "set cap: name: %24s, value: %#10x, hfi: %#10x\n", cap_name(cap_id),
-		inst->capabilities->cap[cap_id].value, hfi_value);
-
 	rc = msm_vidc_packetize_control(inst, cap_id, HFI_PAYLOAD_U32,
 		&hfi_value, sizeof(u32), __func__);
+	if (rc)
+		return rc;
 
 	return rc;
 }
@@ -1766,8 +1771,12 @@ int msm_vidc_set_min_qp(void *instance,
 		capability->cap[B_FRAME_MIN_QP].flags & CAP_FLAG_CLIENT_SET;
 
 	client_qp_enable = i_qp_enable | p_qp_enable << 1 | b_qp_enable << 2;
-	if (!client_qp_enable)
+	if (!client_qp_enable) {
+		i_vpr_h(inst,
+			"%s: client did not set min qp, cap %s is not set\n",
+			__func__, cap_name(cap_id));
 		return 0;
+	}
 
 	if (is_10bit_colorformat(capability->cap[PIX_FMTS].value))
 		offset = 12;
@@ -1789,11 +1798,10 @@ int msm_vidc_set_min_qp(void *instance,
 	hfi_value = i_frame_qp | p_frame_qp << 8 | b_frame_qp << 16 |
 		client_qp_enable << 24;
 
-	i_vpr_h(inst, "set cap: name: %24s, value: %#10x, hfi: %#10x\n", cap_name(cap_id),
-		inst->capabilities->cap[cap_id].value, hfi_value);
-
 	rc = msm_vidc_packetize_control(inst, cap_id, HFI_PAYLOAD_32_PACKED,
 		&hfi_value, sizeof(u32), __func__);
+	if (rc)
+		return rc;
 
 	return rc;
 }
@@ -1825,8 +1833,12 @@ int msm_vidc_set_max_qp(void *instance,
 		capability->cap[B_FRAME_MIN_QP].flags & CAP_FLAG_CLIENT_SET;
 
 	client_qp_enable = i_qp_enable | p_qp_enable << 1 | b_qp_enable << 2;
-	if (!client_qp_enable)
+	if (!client_qp_enable) {
+		i_vpr_h(inst,
+			"%s: client did not set max qp, cap %s is not set\n",
+			__func__, cap_name(cap_id));
 		return 0;
+	}
 
 	if (is_10bit_colorformat(capability->cap[PIX_FMTS].value))
 		offset = 12;
@@ -1848,11 +1860,10 @@ int msm_vidc_set_max_qp(void *instance,
 	hfi_value = i_frame_qp | p_frame_qp << 8 | b_frame_qp << 16 |
 		client_qp_enable << 24;
 
-	i_vpr_h(inst, "set cap: name: %24s, value: %#10x, hfi: %#10x\n", cap_name(cap_id),
-		inst->capabilities->cap[cap_id].value, hfi_value);
-
 	rc = msm_vidc_packetize_control(inst, cap_id, HFI_PAYLOAD_32_PACKED,
 		&hfi_value, sizeof(u32), __func__);
+	if (rc)
+		return rc;
 
 	return rc;
 }
@@ -1892,8 +1903,12 @@ int msm_vidc_set_frame_qp(void *instance,
 	}
 
 	client_qp_enable = i_qp_enable | p_qp_enable << 1 | b_qp_enable << 2;
-	if (!client_qp_enable)
+	if (!client_qp_enable) {
+		i_vpr_h(inst,
+			"%s: client did not set frame qp, cap %s is not set\n",
+			__func__, cap_name(cap_id));
 		return 0;
+	}
 
 	if (is_10bit_colorformat(capab->cap[PIX_FMTS].value))
 		offset = 12;
@@ -1905,11 +1920,10 @@ int msm_vidc_set_frame_qp(void *instance,
 	hfi_value = i_frame_qp | p_frame_qp << 8 | b_frame_qp << 16 |
 		client_qp_enable << 24;
 
-	i_vpr_h(inst, "set cap: name: %24s, value: %#10x, hfi: %#10x\n", cap_name(cap_id),
-		inst->capabilities->cap[cap_id].value, hfi_value);
-
 	rc = msm_vidc_packetize_control(inst, cap_id, HFI_PAYLOAD_32_PACKED,
 		&hfi_value, sizeof(u32), __func__);
+	if (rc)
+		return rc;
 
 	return rc;
 }
@@ -1933,11 +1947,10 @@ int msm_vidc_set_req_sync_frame(void *instance,
 	else
 		hfi_value = HFI_SYNC_FRAME_REQUEST_WITHOUT_SEQ_HDR;
 
-	i_vpr_h(inst, "set cap: name: %24s, value: %#10x, hfi: %#10x\n", cap_name(cap_id),
-		inst->capabilities->cap[cap_id].value, hfi_value);
-
 	rc = msm_vidc_packetize_control(inst, cap_id, HFI_PAYLOAD_U32_ENUM,
 		&hfi_value, sizeof(u32), __func__);
+	if (rc)
+		return rc;
 
 	return rc;
 }
@@ -1963,11 +1976,10 @@ int msm_vidc_set_chroma_qp_index_offset(void *instance,
 	chroma_qp = inst->capabilities->cap[cap_id].value + offset;
 	hfi_value = chroma_qp_offset_mode | chroma_qp << 8 | chroma_qp << 16 ;
 
-	i_vpr_h(inst, "set cap: name: %24s, value: %#10x, hfi: %#10x\n", cap_name(cap_id),
-		inst->capabilities->cap[cap_id].value, hfi_value);
-
 	rc = msm_vidc_packetize_control(inst, cap_id, HFI_PAYLOAD_32_PACKED,
 		&hfi_value, sizeof(u32), __func__);
+	if (rc)
+		return rc;
 
 	return rc;
 }
@@ -1988,7 +2000,7 @@ int msm_vidc_set_slice_count(void* instance,
 	slice_mode = inst->capabilities->cap[SLICE_MODE].value;
 
 	if (slice_mode == V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE) {
-		i_vpr_l(inst, "%s: slice mode is: %u, ignore setting to fw\n",
+		i_vpr_h(inst, "%s: slice mode is: %u, ignore setting to fw\n",
 			__func__, slice_mode);
 		return 0;
 	}
@@ -1999,11 +2011,11 @@ int msm_vidc_set_slice_count(void* instance,
 		hfi_value = inst->capabilities->cap[SLICE_MAX_BYTES].value;
 		set_cap_id = SLICE_MAX_BYTES;
 	}
-	i_vpr_h(inst, "set cap: name: %24s, value: %#10x, hfi: %#10x\n", cap_name(cap_id),
-		inst->capabilities->cap[cap_id].value, hfi_value);
 
 	rc = msm_vidc_packetize_control(inst, set_cap_id, HFI_PAYLOAD_U32,
 		&hfi_value, sizeof(u32), __func__);
+	if (rc)
+		return rc;
 
 	return rc;
 }
@@ -2027,11 +2039,11 @@ int msm_vidc_set_nal_length(void* instance,
 		if (rc)
 			return -EINVAL;
 	}
-	i_vpr_h(inst, "set cap: name: %24s, value: %#10x, hfi: %#10x\n", cap_name(cap_id),
-		inst->capabilities->cap[cap_id].value, hfi_value);
 
 	rc = msm_vidc_packetize_control(inst, cap_id, HFI_PAYLOAD_U32_ENUM,
 		&hfi_value, sizeof(u32), __func__);
+	if (rc)
+		return rc;
 
 	return rc;
 }
@@ -2105,6 +2117,8 @@ int msm_vidc_set_gop_size(void *instance,
 
 	rc = msm_vidc_packetize_control(inst, cap_id, HFI_PAYLOAD_U32,
 		&hfi_value, sizeof(u32), __func__);
+	if (rc)
+		return rc;
 
 	return rc;
 }
@@ -2172,6 +2186,8 @@ set_total_bitrate:
 	hfi_value = inst->capabilities->cap[BIT_RATE].value;
 	rc = msm_vidc_packetize_control(inst, BIT_RATE, HFI_PAYLOAD_U32,
 			&hfi_value, sizeof(u32), __func__);
+	if (rc)
+		return rc;
 exit:
 	return rc;
 }
@@ -2192,6 +2208,8 @@ int msm_vidc_set_session_priority(void *instance,
 
 	rc = msm_vidc_packetize_control(inst, cap_id, HFI_PAYLOAD_U32,
 		&hfi_value, sizeof(u32), __func__);
+	if (rc)
+		return rc;
 
 	return rc;
 }
@@ -2242,11 +2260,10 @@ int msm_vidc_set_q16(void *instance,
 
 	hfi_value = inst->capabilities->cap[cap_id].value;
 
-	i_vpr_h(inst, "set cap: name: %24s, value: %#10x, hfi: %#10x\n", cap_name(cap_id),
-		inst->capabilities->cap[cap_id].value, hfi_value);
-
 	rc = msm_vidc_packetize_control(inst, cap_id, HFI_PAYLOAD_Q16,
 		&hfi_value, sizeof(u32), __func__);
+	if (rc)
+		return rc;
 
 	return rc;
 }
@@ -2270,11 +2287,11 @@ int msm_vidc_set_u32(void *instance,
 	} else {
 		hfi_value = inst->capabilities->cap[cap_id].value;
 	}
-	i_vpr_h(inst, "set cap: name: %24s, value: %#10x, hfi: %#10x\n", cap_name(cap_id),
-		inst->capabilities->cap[cap_id].value, hfi_value);
 
 	rc = msm_vidc_packetize_control(inst, cap_id, HFI_PAYLOAD_U32,
 		&hfi_value, sizeof(u32), __func__);
+	if (rc)
+		return rc;
 
 	return rc;
 }
@@ -2295,11 +2312,10 @@ int msm_vidc_set_u32_enum(void *instance,
 	if (rc)
 		return -EINVAL;
 
-	i_vpr_h(inst, "set cap: name: %24s, value: %#10x, hfi: %#10x\n", cap_name(cap_id),
-		inst->capabilities->cap[cap_id].value, hfi_value);
-
 	rc = msm_vidc_packetize_control(inst, cap_id, HFI_PAYLOAD_U32_ENUM,
 		&hfi_value, sizeof(u32), __func__);
+	if (rc)
+		return rc;
 
 	return rc;
 }
@@ -2317,58 +2333,10 @@ int msm_vidc_set_s32(void *instance,
 	}
 	hfi_value = inst->capabilities->cap[cap_id].value;
 
-	i_vpr_h(inst, "set cap: name: %24s, value: %#10x, hfi: %#10x\n", cap_name(cap_id),
-		inst->capabilities->cap[cap_id].value, hfi_value);
-
 	rc = msm_vidc_packetize_control(inst, cap_id, HFI_PAYLOAD_S32,
 		&hfi_value, sizeof(s32), __func__);
-
-	return rc;
-}
-
-/* Please ignore this function for now. TO DO*/
-int msm_vidc_set_array(void *instance,
-	enum msm_vidc_inst_capability_type cap_id)
-{
-	int rc = 0;
-	struct msm_vidc_inst_capability *capability;
-	struct msm_vidc_core *core;
-
-	struct msm_vidc_inst *inst = (struct msm_vidc_inst *)instance;
-
-	if (!inst || !inst->core || !inst->capabilities) {
-		d_vpr_e("%s: invalid params\n", __func__);
-		return -EINVAL;
-	}
-
-	capability = inst->capabilities;
-	core = (struct msm_vidc_core *)inst->core;
-
-	switch (cap_id) {
-	/*
-	 * Needed if any control needs to be packed into a structure
-	 * and sent for packetization.
-	 * payload types may be:
-	 * STRUCTURE, BLOB, STRING, PACKED, ARRAY,
-	 *
-	case BITRATE_MODE:
-		i_vpr_h(inst, "%s: %d\n", __func__, hfi_value);
-		hfi_create_packet(inst->packet, inst->packet_size,
-			offset,
-			capability->cap[cap_id].hfi_id,
-			HFI_HOST_FLAGS_NONE, HFI_PAYLOAD_ENUM,
-			HFI_PORT_NONE, core->packet_id++,
-			&capability->cap[PROFILE].value, sizeof(u32));
-		break;
-	}
-	*/
-	default:
-		i_vpr_e(inst,
-			"%s: Unknown cap id %d, cannot set to fw\n",
-			__func__, cap_id);
-		rc = -EINVAL;
-		break;
-	}
+	if (rc)
+		return rc;
 
 	return rc;
 }

+ 106 - 72
driver/vidc/src/msm_vidc_driver.c

@@ -37,11 +37,6 @@ extern struct msm_vidc_core *g_core;
 #define SSR_ADDR_ID 0xFFFFFFFF00000000
 #define SSR_ADDR_SHIFT 32
 
-struct msm_vidc_buf_type_name {
-	enum msm_vidc_buffer_type type;
-	char *name;
-};
-
 struct msm_vidc_cap_name {
 	enum msm_vidc_inst_capability_type cap;
 	char *name;
@@ -121,11 +116,9 @@ static const struct msm_vidc_cap_name cap_name_arr[] = {
 	{I_FRAME_MAX_QP,                 "I_FRAME_MAX_QP"             },
 	{P_FRAME_MAX_QP,                 "P_FRAME_MAX_QP"             },
 	{B_FRAME_MAX_QP,                 "B_FRAME_MAX_QP"             },
-	{HEVC_HIER_QP,                   "HEVC_HIER_QP"               },
 	{I_FRAME_QP,                     "I_FRAME_QP"                 },
 	{P_FRAME_QP,                     "P_FRAME_QP"                 },
 	{B_FRAME_QP,                     "B_FRAME_QP"                 },
-	{HIER_LAYER_QP,                  "HIER_LAYER_QP"              },
 	{LAYER_TYPE,                     "LAYER_TYPE"                 },
 	{LAYER_ENABLE,                   "LAYER_ENABLE"               },
 	{ENH_LAYER_COUNT,                "ENH_LAYER_COUNT"            },
@@ -202,6 +195,44 @@ exit:
 	return name;
 }
 
+struct msm_vidc_buf_type_name {
+	enum msm_vidc_buffer_type type;
+	char *name;
+};
+
+static const struct msm_vidc_buf_type_name buf_type_name_arr[] = {
+	{MSM_VIDC_BUF_INPUT,             "INPUT"                      },
+	{MSM_VIDC_BUF_OUTPUT,            "OUTPUT"                     },
+	{MSM_VIDC_BUF_INPUT_META,        "INPUT_META"                 },
+	{MSM_VIDC_BUF_OUTPUT_META,       "OUTPUT_META"                },
+	{MSM_VIDC_BUF_READ_ONLY,         "READ_ONLY"                  },
+	{MSM_VIDC_BUF_QUEUE,             "QUEUE"                      },
+	{MSM_VIDC_BUF_BIN,               "BIN"                        },
+	{MSM_VIDC_BUF_ARP,               "ARP"                        },
+	{MSM_VIDC_BUF_COMV,              "COMV"                       },
+	{MSM_VIDC_BUF_NON_COMV,          "NON_COMV"                   },
+	{MSM_VIDC_BUF_LINE,              "LINE"                       },
+	{MSM_VIDC_BUF_DPB,               "DPB"                        },
+	{MSM_VIDC_BUF_PERSIST,           "PERSIST"                    },
+	{MSM_VIDC_BUF_VPSS,              "VPSS"                       },
+};
+
+const char *buf_name(enum msm_vidc_buffer_type type)
+{
+	const char *name = "UNKNOWN BUF";
+
+	if (!type || type > ARRAY_SIZE(buf_type_name_arr))
+		goto exit;
+
+	if (buf_type_name_arr[type - 1].type != type)
+		goto exit;
+
+	name = buf_type_name_arr[type - 1].name;
+
+exit:
+	return name;
+}
+
 struct msm_vidc_inst_state_name {
 	enum msm_vidc_inst_state state;
 	char *name;
@@ -270,22 +301,12 @@ void print_vidc_buffer(u32 tag, const char *tag_str, const char *str, struct msm
 	if (!(tag & msm_vidc_debug) || !inst || !vbuf || !tag_str || !str)
 		return;
 
-	if (vbuf->type == MSM_VIDC_BUF_INPUT || vbuf->type == MSM_VIDC_BUF_OUTPUT) {
-		dprintk_inst(tag, tag_str, inst,
-			"%s: %s: idx %2d fd %3d off %d daddr %#llx size %d filled %d flags %#x ts %lld attr %#x\n",
-			str, vbuf->type == MSM_VIDC_BUF_INPUT ? "INPUT" : "OUTPUT",
-			vbuf->index, vbuf->fd, vbuf->data_offset,
-			vbuf->device_addr, vbuf->buffer_size, vbuf->data_size,
-			vbuf->flags, vbuf->timestamp, vbuf->attr);
-	} else if (vbuf->type == MSM_VIDC_BUF_INPUT_META ||
-			   vbuf->type == MSM_VIDC_BUF_OUTPUT_META) {
-		dprintk_inst(tag, tag_str, inst,
-			"%s: %s: idx %2d fd %3d off %d daddr %#llx size %d filled %d flags %#x ts %lld attr %#x\n",
-			str, vbuf->type == MSM_VIDC_BUF_INPUT_META ? "INPUT_META" : "OUTPUT_META",
-			vbuf->index, vbuf->fd, vbuf->data_offset,
-			vbuf->device_addr, vbuf->buffer_size, vbuf->data_size,
-			vbuf->flags, vbuf->timestamp, vbuf->attr);
-	}
+	dprintk_inst(tag, tag_str, inst,
+		"%s: %s: idx %2d fd %3d off %d daddr %#llx size %d filled %d flags %#x ts %lld attr %#x\n",
+		str, buf_name(vbuf->type),
+		vbuf->index, vbuf->fd, vbuf->data_offset,
+		vbuf->device_addr, vbuf->buffer_size, vbuf->data_size,
+		vbuf->flags, vbuf->timestamp, vbuf->attr);
 }
 
 void print_vb2_buffer(const char *str, struct msm_vidc_inst *inst,
@@ -899,6 +920,8 @@ struct msm_vidc_buffers *msm_vidc_get_buffers(
 		return &inst->buffers.persist;
 	case MSM_VIDC_BUF_VPSS:
 		return &inst->buffers.vpss;
+	case MSM_VIDC_BUF_QUEUE:
+		return NULL;
 	default:
 		i_vpr_e(inst, "%s: invalid driver buffer type %d\n",
 			func, buffer_type);
@@ -2098,6 +2121,12 @@ void msm_vidc_allow_dcvs(struct msm_vidc_inst *inst)
 		goto exit;
 	}
 
+	allow = is_realtime_session(inst);
+	if (!allow) {
+		i_vpr_h(inst, "%s: non-realtime session\n", __func__);
+		goto exit;
+	}
+
 	allow = !is_image_session(inst);
 	if (!allow) {
 		i_vpr_h(inst, "%s: image session\n", __func__);
@@ -2322,7 +2351,7 @@ int msm_vidc_queue_buffer_single(struct msm_vidc_inst *inst, struct vb2_buffer *
 		if (is_encode_session(inst)) {
 			cr = inst->capabilities->cap[ENC_IP_CR].value;
 			msm_vidc_update_input_cr(inst, vb2->index, cr);
-			inst->capabilities->cap[ENC_IP_CR].value = 0;
+			msm_vidc_update_cap_value(inst, ENC_IP_CR, 0, __func__);
 		}
 		inst->power.buffer_counter++;
 	}
@@ -2352,15 +2381,13 @@ int msm_vidc_destroy_internal_buffer(struct msm_vidc_inst *inst,
 	}
 
 	if (!is_internal_buffer(buffer->type)) {
-		i_vpr_e(inst, "%s: buffer type %#x is not internal\n",
-			__func__, buffer->type);
+		i_vpr_e(inst, "%s: type: %s is not internal\n",
+			__func__, buf_name(buffer->type));
 		return 0;
 	}
 
-	i_vpr_h(inst,
-		"%s: destroy buffer_type %#x, size %d device_addr %#x\n",
-		__func__, buffer->type, buffer->buffer_size,
-		buffer->device_addr);
+	i_vpr_h(inst, "%s: destroy: type: %8s, size: %9u, device_addr %#x\n", __func__,
+		buf_name(buffer->type), buffer->buffer_size, buffer->device_addr);
 
 	buffers = msm_vidc_get_buffers(inst, buffer->type, __func__);
 	if (!buffers)
@@ -2455,8 +2482,8 @@ int msm_vidc_create_internal_buffer(struct msm_vidc_inst *inst,
 		return -EINVAL;
 	}
 	if (!is_internal_buffer(buffer_type)) {
-		i_vpr_e(inst, "%s: buffer type %#x is not internal\n",
-			__func__, buffer_type);
+		i_vpr_e(inst, "%s: type %s is not internal\n",
+			__func__, buf_name(buffer_type));
 		return 0;
 	}
 
@@ -2517,10 +2544,8 @@ int msm_vidc_create_internal_buffer(struct msm_vidc_inst *inst,
 
 	buffer->dmabuf = alloc->dmabuf;
 	buffer->device_addr = map->device_addr;
-	i_vpr_h(inst,
-		"%s: created buffer_type %#x, size %d device_addr %#x\n",
-		__func__, buffer_type, buffers->size,
-		buffer->device_addr);
+	i_vpr_h(inst, "%s: create: type: %8s, size: %9u, device_addr %#x\n", __func__,
+		buf_name(buffer_type), buffers->size, buffer->device_addr);
 
 	return 0;
 }
@@ -2542,8 +2567,7 @@ int msm_vidc_create_internal_buffers(struct msm_vidc_inst *inst,
 		return -EINVAL;
 
 	if (buffers->reuse) {
-		i_vpr_l(inst, "%s: reuse enabled for buffer type %#x\n",
-			__func__, buffer_type);
+		i_vpr_l(inst, "%s: reuse enabled for %s\n", __func__, buf_name(buffer_type));
 		return 0;
 	}
 
@@ -2568,8 +2592,7 @@ int msm_vidc_queue_internal_buffers(struct msm_vidc_inst *inst,
 		return -EINVAL;
 	}
 	if (!is_internal_buffer(buffer_type)) {
-		i_vpr_e(inst, "%s: buffer type %#x is not internal\n",
-			__func__, buffer_type);
+		i_vpr_e(inst, "%s: %s is not internal\n", __func__, buf_name(buffer_type));
 		return 0;
 	}
 
@@ -2578,8 +2601,8 @@ int msm_vidc_queue_internal_buffers(struct msm_vidc_inst *inst,
 		return -EINVAL;
 
 	if (buffers->reuse) {
-		i_vpr_l(inst, "%s: reuse enabled for buffer type %#x\n",
-			__func__, buffer_type);
+		i_vpr_l(inst, "%s: reuse enabled for %s buf\n",
+			__func__, buf_name(buffer_type));
 		return 0;
 	}
 
@@ -2596,8 +2619,8 @@ int msm_vidc_queue_internal_buffers(struct msm_vidc_inst *inst,
 		/* mark queued */
 		buffer->attr |= MSM_VIDC_ATTR_QUEUED;
 
-		i_vpr_h(inst, "%s: queued buffer_type %#x, size %d\n",
-			__func__, buffer_type, buffers->size);
+		i_vpr_h(inst, "%s: queue: type: %8s, size: %9u, device_addr %#x\n", __func__,
+			buf_name(buffer->type), buffer->buffer_size, buffer->device_addr);
 	}
 
 	return 0;
@@ -2615,8 +2638,8 @@ int msm_vidc_alloc_and_queue_session_internal_buffers(struct msm_vidc_inst *inst
 
 	if (buffer_type != MSM_VIDC_BUF_ARP &&
 		buffer_type != MSM_VIDC_BUF_PERSIST) {
-		i_vpr_e(inst, "%s: invalid buffer type: %d\n",
-			__func__, buffer_type);
+		i_vpr_e(inst, "%s: invalid buffer type: %s\n",
+			__func__, buf_name(buffer_type));
 		rc = -EINVAL;
 		goto exit;
 	}
@@ -2649,8 +2672,8 @@ int msm_vidc_release_internal_buffers(struct msm_vidc_inst *inst,
 		return -EINVAL;
 	}
 	if (!is_internal_buffer(buffer_type)) {
-		i_vpr_e(inst, "%s: buffer type %#x is not internal\n",
-			__func__, buffer_type);
+		i_vpr_e(inst, "%s: %s is not internal\n",
+			__func__, buf_name(buffer_type));
 		return 0;
 	}
 
@@ -2659,8 +2682,8 @@ int msm_vidc_release_internal_buffers(struct msm_vidc_inst *inst,
 		return -EINVAL;
 
 	if (buffers->reuse) {
-		i_vpr_l(inst, "%s: reuse enabled for buffer type %#x\n",
-			__func__, buffer_type);
+		i_vpr_l(inst, "%s: reuse enabled for %s buf\n",
+			__func__, buf_name(buffer_type));
 		return 0;
 	}
 
@@ -2677,8 +2700,8 @@ int msm_vidc_release_internal_buffers(struct msm_vidc_inst *inst,
 		/* mark pending release */
 		buffer->attr |= MSM_VIDC_ATTR_PENDING_RELEASE;
 
-		i_vpr_h(inst, "%s: released buffer_type %#x, size %d\n",
-			__func__, buffer_type, buffers->size);
+		i_vpr_h(inst, "%s: release: type: %8s, size: %9u, device_addr %#x\n", __func__,
+			buf_name(buffer->type), buffer->buffer_size, buffer->device_addr);
 	}
 
 	return 0;
@@ -3456,6 +3479,31 @@ int msm_vidc_core_timeout(struct msm_vidc_core *core)
 	return msm_vidc_core_deinit(core, true);
 }
 
+int msm_vidc_print_buffer_info(struct msm_vidc_inst *inst)
+{
+	struct msm_vidc_buffers *buffers;
+	int i;
+
+	if (!inst) {
+		i_vpr_e(inst, "%s: invalid params\n", __func__);
+		return -EINVAL;
+	}
+
+	/* Print buffer details */
+	for (i = 0; i < ARRAY_SIZE(buf_type_name_arr); i++) {
+		buffers = msm_vidc_get_buffers(inst, buf_type_name_arr[i].type, __func__);
+		if (!buffers)
+			continue;
+
+		i_vpr_h(inst, "buf: type: %11s, count %2d, extra %2d, actual %2d, size %9u\n",
+			buf_type_name_arr[i].name, buffers->min_count,
+			buffers->extra_count, buffers->actual_count,
+			buffers->size);
+	}
+
+	return 0;
+}
+
 int msm_vidc_print_inst_info(struct msm_vidc_inst *inst)
 {
 	struct msm_vidc_buffers *buffers;
@@ -3466,20 +3514,6 @@ int msm_vidc_print_inst_info(struct msm_vidc_inst *inst)
 	struct dma_buf *dbuf;
 	int i = 0;
 
-	static const struct msm_vidc_buf_type_name buf_type_name[] = {
-		{MSM_VIDC_BUF_INPUT,             "INPUT"      },
-		{MSM_VIDC_BUF_OUTPUT,            "OUTPUT"     },
-		{MSM_VIDC_BUF_INPUT_META,        "IN_META"    },
-		{MSM_VIDC_BUF_OUTPUT_META,       "OUT_META"   },
-		{MSM_VIDC_BUF_BIN,               "BIN"        },
-		{MSM_VIDC_BUF_ARP,               "ARP"        },
-		{MSM_VIDC_BUF_COMV,              "COMV"       },
-		{MSM_VIDC_BUF_NON_COMV,          "NON_COMV"   },
-		{MSM_VIDC_BUF_LINE,              "LINE"       },
-		{MSM_VIDC_BUF_PERSIST,           "PERSIST"    },
-		{MSM_VIDC_BUF_VPSS,              "VPSS"       },
-	};
-
 	if (!inst || !inst->capabilities) {
 		i_vpr_e(inst, "%s: invalid params\n", __func__);
 		return -EINVAL;
@@ -3501,13 +3535,13 @@ int msm_vidc_print_inst_info(struct msm_vidc_inst *inst)
 		frame_rate, bit_rate, bit_depth);
 
 	/* Print buffer details */
-	for (i = 0; i < ARRAY_SIZE(buf_type_name); i++) {
-		buffers = msm_vidc_get_buffers(inst, buf_type_name[i].type, __func__);
+	for (i = 0; i < ARRAY_SIZE(buf_type_name_arr); i++) {
+		buffers = msm_vidc_get_buffers(inst, buf_type_name_arr[i].type, __func__);
 		if (!buffers)
 			continue;
 
-		i_vpr_e(inst, "count: type: %8s, min: %2d, extra: %2d, actual: %2d\n",
-			buf_type_name[i].name, buffers->min_count,
+		i_vpr_e(inst, "count: type: %11s, min: %2d, extra: %2d, actual: %2d\n",
+			buf_type_name_arr[i].name, buffers->min_count,
 			buffers->extra_count, buffers->actual_count);
 
 		list_for_each_entry(buf, &buffers->list, list) {
@@ -3515,8 +3549,8 @@ int msm_vidc_print_inst_info(struct msm_vidc_inst *inst)
 				continue;
 			dbuf = (struct dma_buf *)buf->dmabuf;
 			i_vpr_e(inst,
-				"buf: type: %8s, index: %2d, fd: %4d, size: %9u, off: %8u, filled: %9u, iova: %8x, inode: %9ld, flags: %8x, ts: %16lld, attr: %8x\n",
-				buf_type_name[i].name, buf->index, buf->fd, buf->buffer_size,
+				"buf: type: %11s, index: %2d, fd: %4d, size: %9u, off: %8u, filled: %9u, iova: %8x, inode: %9ld, flags: %8x, ts: %16lld, attr: %8x\n",
+				buf_type_name_arr[i].name, buf->index, buf->fd, buf->buffer_size,
 				buf->data_offset, buf->data_size, buf->device_addr,
 				file_inode(dbuf->file)->i_ino,
 				buf->flags, buf->timestamp, buf->attr);

+ 10 - 8
driver/vidc/src/msm_vidc_memory.c

@@ -13,6 +13,7 @@
 #include "msm_vidc_memory.h"
 #include "msm_vidc_debug.h"
 #include "msm_vidc_internal.h"
+#include "msm_vidc_driver.h"
 #include "msm_vidc_dt.h"
 #include "msm_vidc_core.h"
 
@@ -153,8 +154,8 @@ int msm_vidc_memory_map(struct msm_vidc_core *core, struct msm_vidc_map *map)
 	map->refcount++;
 
 	d_vpr_l(
-		"%s: type %d device_addr %#x refcount %d region %d\n",
-		__func__, map->type, map->device_addr, map->refcount, map->region);
+		"%s: type %11s, device_addr %#x, refcount %d, region %d\n",
+		__func__, buf_name(map->type), map->device_addr, map->refcount, map->region);
 
 	return 0;
 
@@ -188,8 +189,8 @@ int msm_vidc_memory_unmap(struct msm_vidc_core *core,
 		goto exit;
 
 	d_vpr_l(
-		"%s: type %d device_addr %#x refcount %d region %d\n",
-		__func__, map->type, map->device_addr, map->refcount, map->region);
+		"%s: type %11s, device_addr %#x, refcount %d, region %d\n",
+		__func__, buf_name(map->type), map->device_addr, map->refcount, map->region);
 
 	dma_buf_unmap_attachment(map->attach, map->table, DMA_BIDIRECTIONAL);
 	dma_buf_detach(map->dmabuf, map->attach);
@@ -281,8 +282,8 @@ int msm_vidc_memory_alloc(struct msm_vidc_core *core, struct msm_vidc_alloc *mem
 	}
 
 	d_vpr_h(
-		"%s: dmabuf = %pK, size = %d, kvaddr = %pK, buffer_type = %#x secure %d region %d\n",
-		__func__, mem->dmabuf, mem->size, mem->kvaddr, mem->type,
+		"%s: dmabuf %pK, size %d, kvaddr %pK, buffer_type %s, secure %d, region %d\n",
+		__func__, mem->dmabuf, mem->size, mem->kvaddr, buf_name(mem->type),
 		mem->secure, mem->region);
 	return 0;
 
@@ -301,8 +302,9 @@ int msm_vidc_memory_free(struct msm_vidc_core *core, struct msm_vidc_alloc *mem)
 	}
 
 	d_vpr_h(
-		"%s: dmabuf = %pK, size = %d, kvaddr = %pK, buffer_type = %#x\n",
-		__func__, mem->dmabuf, mem->size, mem->kvaddr, mem->type);
+		"%s: dmabuf %pK, size %d, kvaddr %pK, buffer_type %s, secure %d, region %d\n",
+		__func__, mem->dmabuf, mem->size, mem->kvaddr, buf_name(mem->type),
+		mem->secure, mem->region);
 
 	if (mem->kvaddr) {
 		dma_buf_vunmap(mem->dmabuf, mem->kvaddr);

+ 13 - 27
driver/vidc/src/msm_vidc_power.c

@@ -162,10 +162,6 @@ static int msm_vidc_set_buses(struct msm_vidc_inst* inst)
 	mutex_lock(&core->lock);
 	curr_time_ns = ktime_get_ns();
 	list_for_each_entry(temp, &core->instances, list) {
-		/* skip no input data sessions */
-		if (!temp->max_input_data_size)
-			continue;
-
 		/* skip inactive session bus bandwidth */
 		if (!is_active_session(temp->last_qbuf_time_ns, curr_time_ns)) {
 			temp->active = false;
@@ -201,8 +197,6 @@ int msm_vidc_scale_buses(struct msm_vidc_inst *inst)
 	struct vidc_bus_vote_data *vote_data;
 	struct v4l2_format *out_f;
 	struct v4l2_format *inp_f;
-	struct msm_vidc_buffer *vbuf;
-	u32 data_size = 0;
 	int codec = 0, frame_rate;
 
 	if (!inst || !inst->core || !inst->capabilities) {
@@ -216,12 +210,6 @@ int msm_vidc_scale_buses(struct msm_vidc_inst *inst)
 	}
 	vote_data = &inst->bus_data;
 
-	list_for_each_entry(vbuf, &inst->buffers.input.list, list)
-		data_size = max(data_size, vbuf->data_size);
-	inst->max_input_data_size = data_size;
-	if (!data_size)
-		return 0;
-
 	vote_data->power_mode = VIDC_POWER_NORMAL;
 	if (inst->power.buffer_counter < DCVS_WINDOW || is_image_session(inst))
 		vote_data->power_mode = VIDC_POWER_TURBO;
@@ -275,7 +263,7 @@ int msm_vidc_scale_buses(struct msm_vidc_inst *inst)
 		u32 color_format;
 
 		vote_data->domain = MSM_VIDC_DECODER;
-		vote_data->bitrate = data_size * vote_data->fps * 8;
+		vote_data->bitrate = inst->max_input_data_size * vote_data->fps * 8;
 		color_format = v4l2_colorformat_to_driver(
 			inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat, __func__);
 		if (is_linear_colorformat(color_format)) {
@@ -342,10 +330,6 @@ int msm_vidc_set_clocks(struct msm_vidc_inst* inst)
 	freq = 0;
 	curr_time_ns = ktime_get_ns();
 	list_for_each_entry(temp, &core->instances, list) {
-		/* skip no input data sessions */
-		if (!temp->max_input_data_size)
-			continue;
-
 		/* skip inactive session clock rate */
 		if (!is_active_session(temp->last_qbuf_time_ns, curr_time_ns)) {
 			temp->active = false;
@@ -398,7 +382,7 @@ int msm_vidc_set_clocks(struct msm_vidc_inst* inst)
 	 * TODO: Remove this scaling if using source clock instead of branch clock.
 	 */
 	rate = rate * MSM_VIDC_CLOCK_SOURCE_SCALING_RATIO;
-	i_vpr_h(inst, "%s: scaled clock rate %lu\n", __func__, rate);
+	i_vpr_l(inst, "%s: scaled clock rate %lu\n", __func__, rate);
 
 	rc = venus_hfi_scale_clocks(inst, rate);
 	if (rc)
@@ -487,8 +471,6 @@ exit:
 int msm_vidc_scale_clocks(struct msm_vidc_inst *inst)
 {
 	struct msm_vidc_core* core;
-	struct msm_vidc_buffer *vbuf;
-	u32 data_size = 0;
 
 	if (!inst || !inst->core) {
 		d_vpr_e("%s: invalid params\n", __func__);
@@ -496,12 +478,6 @@ int msm_vidc_scale_clocks(struct msm_vidc_inst *inst)
 	}
 	core = inst->core;
 
-	list_for_each_entry(vbuf, &inst->buffers.input.list, list)
-		data_size = max(data_size, vbuf->data_size);
-	inst->max_input_data_size = data_size;
-	if (!data_size)
-		return 0;
-
 	if (inst->power.buffer_counter < DCVS_WINDOW || is_image_session(inst)) {
 		inst->power.min_freq = msm_vidc_max_freq(inst);
 		inst->power.dcvs_flags = 0;
@@ -510,7 +486,7 @@ int msm_vidc_scale_clocks(struct msm_vidc_inst *inst)
 		inst->power.dcvs_flags = 0;
 	} else {
 		inst->power.min_freq =
-			call_session_op(core, calc_freq, inst, data_size);
+			call_session_op(core, calc_freq, inst, inst->max_input_data_size);
 		msm_vidc_apply_dcvs(inst);
 	}
 	inst->power.curr_freq = inst->power.min_freq;
@@ -522,6 +498,8 @@ int msm_vidc_scale_clocks(struct msm_vidc_inst *inst)
 int msm_vidc_scale_power(struct msm_vidc_inst *inst, bool scale_buses)
 {
 	struct msm_vidc_core *core;
+	struct msm_vidc_buffer *vbuf;
+	u32 data_size = 0;
 
 	if (!inst || !inst->core) {
 		d_vpr_e("%s: invalid params %pK\n", __func__, inst);
@@ -535,6 +513,14 @@ int msm_vidc_scale_power(struct msm_vidc_inst *inst, bool scale_buses)
 		inst->active = true;
 	}
 
+	list_for_each_entry(vbuf, &inst->buffers.input.list, list)
+		data_size = max(data_size, vbuf->data_size);
+	inst->max_input_data_size = data_size;
+
+	/* no pending inputs - skip scale power */
+	if (!inst->max_input_data_size)
+		return 0;
+
 	if (msm_vidc_scale_clocks(inst))
 		i_vpr_e(inst, "failed to scale clock\n");
 

+ 7 - 11
driver/vidc/src/msm_vidc_vb2.c

@@ -184,10 +184,6 @@ int msm_vidc_start_streaming(struct vb2_queue *q, unsigned int count)
 				MSM_VIDC_BUF_ARP);
 			if (rc)
 				goto error;
-			i_vpr_h(inst, "session internal buffer: min     size\n");
-			i_vpr_h(inst, "arp  buffer: %d      %d\n",
-				inst->buffers.arp.min_count,
-				inst->buffers.arp.size);
 		} else if(is_decode_session(inst)) {
 			rc = msm_vidc_session_set_default_header(inst);
 			if (rc)
@@ -197,11 +193,6 @@ int msm_vidc_start_streaming(struct vb2_queue *q, unsigned int count)
 				MSM_VIDC_BUF_PERSIST);
 			if (rc)
 				goto error;
-			i_vpr_h(inst, "session internal buffer: min     size     reuse\n");
-			i_vpr_h(inst, "persist  buffer: %d      %d      %d\n",
-				inst->buffers.persist.min_count,
-				inst->buffers.persist.size,
-				inst->buffers.persist.reuse);
 		}
 	}
 
@@ -229,8 +220,13 @@ int msm_vidc_start_streaming(struct vb2_queue *q, unsigned int count)
 		i_vpr_e(inst, "%s: invalid type %d\n", q->type);
 		goto error;
 	}
-	if (!rc)
-		i_vpr_h(inst, "Streamon: %d successful\n", q->type);
+	if (rc)
+		goto error;
+
+	/* print final buffer counts & size details */
+	msm_vidc_print_buffer_info(inst);
+
+	i_vpr_h(inst, "Streamon: %d successful\n", q->type);
 
 	return rc;
 

+ 2 - 2
driver/vidc/src/venus_hfi.c

@@ -3438,8 +3438,8 @@ int venus_hfi_release_buffer(struct msm_vidc_inst *inst,
 	}
 
 	if (!is_internal_buffer(buffer->type)) {
-		i_vpr_e(inst, "release not allowed for buffer type %d\n",
-			buffer->type);
+		i_vpr_e(inst, "release not allowed for buffer_type %s\n",
+			buf_name(buffer->type));
 		goto unlock;
 	}
 	core = inst->core;

+ 2 - 1
driver/vidc/src/venus_hfi_response.c

@@ -584,6 +584,7 @@ static int handle_input_buffer(struct msm_vidc_inst *inst,
 			return 0;
 		}
 	}
+
 	buf->data_offset = buffer->data_offset;
 	buf->data_size = buffer->data_size;
 	buf->attr &= ~MSM_VIDC_ATTR_QUEUED;
@@ -1274,7 +1275,7 @@ static int handle_session_property(struct msm_vidc_inst *inst,
 	u32 port;
 	u32 *payload_ptr;
 
-	i_vpr_h(inst, "%s: property type %#x\n", __func__, pkt->type);
+	i_vpr_l(inst, "%s: property type %#x\n", __func__, pkt->type);
 
 	port = vidc_port_from_hfi(inst, pkt->port);
 	if (port >= MAX_PORT) {