Selaa lähdekoodia

video: driver: ignore input/output port streamoff if already streamed off

Ignore input port or output port streamoff if corresponding port is already
streamed off.

Change-Id: I708126b24758ee0f76bc2646527d1baee59e5178
Signed-off-by: Akshata Sahukar <[email protected]>
Akshata Sahukar 4 vuotta sitten
vanhempi
sitoutus
7616a6bdad

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

@@ -275,6 +275,7 @@ u32 v4l2_matrix_coeff_from_driver(struct msm_vidc_inst *inst,
 	u32 vidc_matrix_coeff, const char *func);
 int v4l2_type_to_driver_port(struct msm_vidc_inst *inst, u32 type,
 	const char *func);
+const char *allow_name(enum msm_vidc_allow allow);
 const char *state_name(enum msm_vidc_inst_state state);
 int msm_vidc_change_inst_state(struct msm_vidc_inst *inst,
 	enum msm_vidc_inst_state request_state, const char *func);
@@ -375,7 +376,7 @@ bool msm_vidc_allow_reqbufs(struct msm_vidc_inst *inst, u32 type);
 enum msm_vidc_allow msm_vidc_allow_stop(struct msm_vidc_inst *inst);
 bool msm_vidc_allow_start(struct msm_vidc_inst *inst);
 bool msm_vidc_allow_streamon(struct msm_vidc_inst *inst, u32 type);
-bool msm_vidc_allow_streamoff(struct msm_vidc_inst *inst, u32 type);
+enum msm_vidc_allow msm_vidc_allow_streamoff(struct msm_vidc_inst *inst, u32 type);
 enum msm_vidc_allow msm_vidc_allow_qbuf(struct msm_vidc_inst *inst, u32 type);
 enum msm_vidc_allow msm_vidc_allow_input_psc(struct msm_vidc_inst *inst);
 bool msm_vidc_allow_last_flag(struct msm_vidc_inst *inst);

+ 8 - 1
driver/vidc/src/msm_vidc.c

@@ -543,15 +543,22 @@ int msm_vidc_streamoff(void *instance, enum v4l2_buf_type type)
 	int rc = 0;
 	struct msm_vidc_inst *inst = instance;
 	int port;
+	enum msm_vidc_allow allow;
 
 	if (!inst) {
 		d_vpr_e("%s: invalid params\n", __func__);
 		return -EINVAL;
 	}
 
-	if (!msm_vidc_allow_streamoff(inst, type)) {
+	allow = msm_vidc_allow_streamoff(inst, type);
+	if (allow == MSM_VIDC_DISALLOW) {
 		rc = -EBUSY;
 		goto exit;
+	} else if (allow == MSM_VIDC_IGNORE) {
+		goto exit;
+	} else if (allow != MSM_VIDC_ALLOW) {
+		rc = -EINVAL;
+		goto exit;
 	}
 	rc = msm_vidc_state_change_streamoff(inst, type);
 	if (rc)

+ 49 - 17
driver/vidc/src/msm_vidc_driver.c

@@ -238,6 +238,35 @@ exit:
 	return name;
 }
 
+struct msm_vidc_allow_name {
+	enum msm_vidc_allow allow;
+	char *name;
+};
+
+static const struct msm_vidc_allow_name inst_allow_name_arr[] = {
+	{MSM_VIDC_DISALLOW,                  "MSM_VIDC_DISALLOW"   },
+	{MSM_VIDC_ALLOW,                     "MSM_VIDC_ALLOW"      },
+	{MSM_VIDC_DEFER,                     "MSM_VIDC_DEFER"      },
+	{MSM_VIDC_DISCARD,                   "MSM_VIDC_DISCARD"    },
+	{MSM_VIDC_IGNORE,                    "MSM_VIDC_IGNORE"     },
+};
+
+const char *allow_name(enum msm_vidc_allow allow)
+{
+	const char *name = "UNKNOWN";
+
+	if (allow > ARRAY_SIZE(inst_allow_name_arr))
+		goto exit;
+
+	if (inst_allow_name_arr[allow].allow != allow)
+		goto exit;
+
+	name = inst_allow_name_arr[allow].name;
+
+exit:
+	return name;
+}
+
 struct msm_vidc_inst_state_name {
 	enum msm_vidc_inst_state state;
 	char *name;
@@ -1444,32 +1473,35 @@ bool msm_vidc_allow_streamon(struct msm_vidc_inst *inst, u32 type)
 	return false;
 }
 
-bool msm_vidc_allow_streamoff(struct msm_vidc_inst *inst, u32 type)
+enum msm_vidc_allow msm_vidc_allow_streamoff(struct msm_vidc_inst *inst, u32 type)
 {
-	bool allow = true;
+	enum msm_vidc_allow allow = MSM_VIDC_ALLOW;
 
 	if (!inst) {
 		d_vpr_e("%s: invalid params\n", __func__);
-		return false;
+		return MSM_VIDC_DISALLOW;
 	}
 	if (type == INPUT_MPLANE) {
-		if (inst->state == MSM_VIDC_OPEN ||
-			inst->state == MSM_VIDC_START_OUTPUT)
-			allow = false;
+		if (!inst->vb2q[INPUT_PORT].streaming)
+			allow = MSM_VIDC_IGNORE;
 	} else if (type == INPUT_META_PLANE) {
-		if (inst->state == MSM_VIDC_START_INPUT)
-			allow = false;
+		if (inst->vb2q[INPUT_PORT].streaming)
+			allow = MSM_VIDC_DISALLOW;
+		else if (!inst->vb2q[INPUT_META_PORT].streaming)
+			allow = MSM_VIDC_IGNORE;
 	} else if (type == OUTPUT_MPLANE) {
-		if (inst->state == MSM_VIDC_OPEN ||
-			inst->state == MSM_VIDC_START_INPUT)
-			allow = false;
+		if (!inst->vb2q[OUTPUT_PORT].streaming)
+			allow = MSM_VIDC_IGNORE;
 	} else if (type == OUTPUT_META_PLANE) {
-		if (inst->state == MSM_VIDC_START_OUTPUT)
-			allow = false;
-	}
-	if (!allow)
-		i_vpr_e(inst, "%s: type %d not allowed in state %s\n",
-				__func__, type, state_name(inst->state));
+		if (inst->vb2q[OUTPUT_PORT].streaming)
+			allow = MSM_VIDC_DISALLOW;
+		else if (!inst->vb2q[OUTPUT_META_PORT].streaming)
+			allow = MSM_VIDC_IGNORE;
+	}
+	if (allow != MSM_VIDC_ALLOW)
+		i_vpr_e(inst, "%s: type %d is %s in state %s\n",
+				__func__, type, allow_name(allow),
+				state_name(inst->state));
 
 	return allow;
 }