浏览代码

video: driver: Add checks for fw configured session params

Query final values of session params like stage,
pipe and quality mode from FW and check if they
are the same intended values as configured by
the driver.

Change-Id: I1a504401a599860ab971e34e1e184e67631d6120
Signed-off-by: Chandrakant I Viraktamath <[email protected]>
Chandrakant I Viraktamath 4 年之前
父节点
当前提交
a626d5c731

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

@@ -432,5 +432,6 @@ bool res_is_less_than(u32 width, u32 height,
 	u32 ref_width, u32 ref_height);
 bool res_is_less_than_or_equal_to(u32 width, u32 height,
 	u32 ref_width, u32 ref_height);
+int msm_vidc_get_properties(struct msm_vidc_inst *inst);
 #endif // _MSM_VIDC_DRIVER_H_
 

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

@@ -217,6 +217,7 @@ enum msm_vidc_port_type {
 	OUTPUT_PORT,
 	INPUT_META_PORT,
 	OUTPUT_META_PORT,
+	PORT_NONE,
 	MAX_PORT,
 };
 

+ 46 - 0
driver/vidc/src/msm_vidc_driver.c

@@ -5504,3 +5504,49 @@ int msm_vidc_check_scaling_supported(struct msm_vidc_inst *inst)
 	return 0;
 }
 
+struct msm_vidc_fw_query_params {
+	u32 hfi_prop_name;
+	u32 port;
+};
+
+int msm_vidc_get_properties(struct msm_vidc_inst *inst)
+{
+	int rc = 0;
+	int i;
+
+	static const struct msm_vidc_fw_query_params fw_query_params[] = {
+		{HFI_PROP_STAGE, HFI_PORT_NONE},
+		{HFI_PROP_PIPE, HFI_PORT_NONE},
+		{HFI_PROP_QUALITY_MODE, HFI_PORT_BITSTREAM}
+	};
+
+	if (!inst || !inst->capabilities) {
+		d_vpr_e("%s: invalid params\n", __func__);
+		return -EINVAL;
+	}
+
+	for (i = 0; i < ARRAY_SIZE(fw_query_params); i++) {
+
+		if (is_decode_session(inst)) {
+			if (fw_query_params[i].hfi_prop_name == HFI_PROP_QUALITY_MODE)
+				continue;
+		}
+
+		i_vpr_l(inst, "%s: querying fw for property %#x\n", __func__,
+				fw_query_params[i].hfi_prop_name);
+
+		rc = venus_hfi_session_property(inst,
+				fw_query_params[i].hfi_prop_name,
+				(HFI_HOST_FLAGS_RESPONSE_REQUIRED |
+				HFI_HOST_FLAGS_INTR_REQUIRED |
+				HFI_HOST_FLAGS_GET_PROPERTY),
+				fw_query_params[i].port,
+				HFI_PAYLOAD_NONE,
+				NULL,
+				0);
+		if (rc)
+			return rc;
+	}
+
+	return 0;
+}

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

@@ -249,6 +249,13 @@ int msm_vidc_start_streaming(struct vb2_queue *q, unsigned int count)
 	if (rc)
 		goto error;
 
+	if ((q->type == INPUT_MPLANE && inst->vb2q[OUTPUT_PORT].streaming) ||
+		(q->type == OUTPUT_MPLANE && inst->vb2q[INPUT_PORT].streaming)) {
+		rc = msm_vidc_get_properties(inst);
+		if (rc)
+			goto error;
+	}
+
 	i_vpr_h(inst, "Streamon: %s successful\n", v4l2_type_name(q->type));
 
 	return rc;

+ 25 - 0
driver/vidc/src/venus_hfi_response.c

@@ -93,6 +93,9 @@ u32 vidc_port_from_hfi(struct msm_vidc_inst *inst,
 		case HFI_PORT_RAW:
 			port = OUTPUT_PORT;
 			break;
+		case HFI_PORT_NONE:
+			port = PORT_NONE;
+			break;
 		default:
 			i_vpr_e(inst, "%s: invalid hfi port type %d\n",
 				__func__, hfi_port);
@@ -106,6 +109,9 @@ u32 vidc_port_from_hfi(struct msm_vidc_inst *inst,
 		case HFI_PORT_BITSTREAM:
 			port = OUTPUT_PORT;
 			break;
+		case HFI_PORT_NONE:
+			port = PORT_NONE;
+			break;
 		default:
 			i_vpr_e(inst, "%s: invalid hfi port type %d\n",
 				__func__, hfi_port);
@@ -1404,6 +1410,25 @@ static int handle_session_property(struct msm_vidc_inst *inst,
 				port, inst->capabilities->cap[DPB_LIST].value);
 		}
 		break;
+	case HFI_PROP_QUALITY_MODE:
+		if (inst->capabilities->cap[QUALITY_MODE].value !=  payload_ptr[0])
+			i_vpr_e(inst,
+				"%s: fw quality mode(%d) not matching the capability value(%d)\n",
+				__func__,  payload_ptr[0],
+				inst->capabilities->cap[QUALITY_MODE].value);
+		break;
+	case HFI_PROP_STAGE:
+		if (inst->capabilities->cap[STAGE].value !=  payload_ptr[0])
+			i_vpr_e(inst,
+				"%s: fw stage mode(%d) not matching the capability value(%d)\n",
+				__func__,  payload_ptr[0], inst->capabilities->cap[STAGE].value);
+		break;
+	case HFI_PROP_PIPE:
+		if (inst->capabilities->cap[PIPE].value !=  payload_ptr[0])
+			i_vpr_e(inst,
+				"%s: fw pipe mode(%d) not matching the capability value(%d)\n",
+				__func__,  payload_ptr[0], inst->capabilities->cap[PIPE].value);
+		break;
 	default:
 		i_vpr_e(inst, "%s: invalid property %#x\n",
 			__func__, pkt->type);