Sfoglia il codice sorgente

video: driver: add stop cmd allow checks inside state handler

use state specific checks inside state_handler instead of
relying global msm_vidc_allow_stop function.

Change-Id: I83d81aa0f840412a4c61f15673a6246f0f84be7f
Signed-off-by: Govindaraj Rajagopal <[email protected]>
Govindaraj Rajagopal 2 anni fa
parent
commit
ab6770c11f

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

@@ -492,7 +492,6 @@ bool msm_vidc_allow_metadata_subscription(struct msm_vidc_inst *inst,
 bool msm_vidc_allow_property(struct msm_vidc_inst *inst, u32 hfi_id);
 int msm_vidc_update_property_cap(struct msm_vidc_inst *inst, u32 hfi_id,
 	bool allow);
-enum msm_vidc_allow msm_vidc_allow_stop(struct msm_vidc_inst *inst);
 enum msm_vidc_allow msm_vidc_allow_input_psc(struct msm_vidc_inst *inst);
 bool msm_vidc_allow_drain_last_flag(struct msm_vidc_inst *inst);
 bool msm_vidc_allow_psc_last_flag(struct msm_vidc_inst *inst);

+ 0 - 8
driver/vidc/src/msm_vdec.c

@@ -2091,17 +2091,9 @@ static int msm_vdec_alloc_and_queue_additional_dpb_buffers(struct msm_vidc_inst
 
 int msm_vdec_stop_cmd(struct msm_vidc_inst *inst)
 {
-	enum msm_vidc_allow allow = MSM_VIDC_DISALLOW;
 	int rc = 0;
 
 	i_vpr_h(inst, "received cmd: drain\n");
-	allow = msm_vidc_allow_stop(inst);
-	if (allow == MSM_VIDC_DISALLOW)
-		return -EBUSY;
-	else if (allow == MSM_VIDC_IGNORE)
-		return 0;
-	else if (allow != MSM_VIDC_ALLOW)
-		return -EINVAL;
 	rc = msm_vidc_process_drain(inst);
 	if (rc)
 		return rc;

+ 0 - 8
driver/vidc/src/msm_venc.c

@@ -912,17 +912,9 @@ int msm_venc_qbuf(struct msm_vidc_inst *inst, struct vb2_buffer *vb2)
 
 int msm_venc_stop_cmd(struct msm_vidc_inst *inst)
 {
-	enum msm_vidc_allow allow = MSM_VIDC_DISALLOW;
 	int rc = 0;
 
 	i_vpr_h(inst, "received cmd: drain\n");
-	allow = msm_vidc_allow_stop(inst);
-	if (allow == MSM_VIDC_DISALLOW)
-		return -EBUSY;
-	else if (allow == MSM_VIDC_IGNORE)
-		return 0;
-	else if (allow != MSM_VIDC_ALLOW)
-		return -EINVAL;
 	rc = msm_vidc_process_drain(inst);
 	if (rc)
 		return rc;

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

@@ -1115,33 +1115,6 @@ int msm_vidc_update_property_cap(struct msm_vidc_inst *inst, u32 hfi_id,
 	return rc;
 }
 
-enum msm_vidc_allow msm_vidc_allow_stop(struct msm_vidc_inst *inst)
-{
-	enum msm_vidc_allow allow = MSM_VIDC_DISALLOW;
-
-	if (!inst) {
-		d_vpr_e("%s: invalid params\n", __func__);
-		return allow;
-	}
-
-	/* allow stop (drain) if input port is streaming */
-	if (is_state(inst, MSM_VIDC_INPUT_STREAMING) ||
-		is_state(inst, MSM_VIDC_STREAMING)) {
-		/* do not allow back to back drain */
-		if (!(is_sub_state(inst, MSM_VIDC_DRAIN)))
-			allow = MSM_VIDC_ALLOW;
-	} else if (is_state(inst, MSM_VIDC_OPEN)) {
-		allow = MSM_VIDC_IGNORE;
-		i_vpr_e(inst, "%s: ignored in state %s, sub state %s\n",
-			__func__, state_name(inst->state), inst->sub_state_name);
-	} else {
-		i_vpr_e(inst, "%s: not allowed in state %s, sub state %s\n",
-			__func__, state_name(inst->state), inst->sub_state_name);
-	}
-
-	return allow;
-}
-
 enum msm_vidc_allow msm_vidc_allow_input_psc(struct msm_vidc_inst *inst)
 {
 	enum msm_vidc_allow allow = MSM_VIDC_ALLOW;

+ 21 - 7
driver/vidc/src/msm_vidc_state.c

@@ -715,9 +715,9 @@ static int msm_vidc_open_state(struct msm_vidc_inst *inst,
 	}
 	case MSM_VIDC_CMD_STOP:
 	{
-		rc = msm_vidc_stop_cmd(inst);
-		if (rc)
-			return rc;
+		/* ignore stop cmd request in open state */
+		i_vpr_h(inst, "%s: (%s) ignored, sub_state (%s)\n",
+			__func__, event_name(event), inst->sub_state_name);
 		break;
 	}
 	case MSM_VIDC_BUF_QUEUE:
@@ -902,6 +902,13 @@ static int msm_vidc_input_streaming_state(struct msm_vidc_inst *inst,
 	}
 	case MSM_VIDC_CMD_STOP:
 	{
+		/* back to back drain not allowed */
+		if (is_sub_state(inst, MSM_VIDC_DRAIN)) {
+			i_vpr_e(inst, "%s: drain (%s) not allowed, sub_state (%s)\n\n",
+				__func__, event_name(event), inst->sub_state_name);
+			return -EBUSY;
+		}
+
 		rc = msm_vidc_stop_cmd(inst);
 		if (rc)
 			return rc;
@@ -1081,10 +1088,10 @@ static int msm_vidc_output_streaming_state(struct msm_vidc_inst *inst,
 	}
 	case MSM_VIDC_CMD_STOP:
 	{
-		rc = msm_vidc_stop_cmd(inst);
-		if (rc)
-			return rc;
-		break;
+		/* drain not allowed as input is not streaming */
+		i_vpr_e(inst, "%s: drain (%s) not allowed, sub state %s\n",
+			__func__, event_name(event), inst->sub_state_name);
+		return -EBUSY;
 	}
 	default: {
 		i_vpr_e(inst, "%s: unexpected event %s\n", __func__, event_name(event));
@@ -1195,6 +1202,13 @@ static int msm_vidc_streaming_state(struct msm_vidc_inst *inst,
 	}
 	case MSM_VIDC_CMD_STOP:
 	{
+		/* back to back drain not allowed */
+		if (is_sub_state(inst, MSM_VIDC_DRAIN)) {
+			i_vpr_e(inst, "%s: drain (%s) not allowed, sub_state (%s)\n\n",
+				__func__, event_name(event), inst->sub_state_name);
+			return -EBUSY;
+		}
+
 		rc = msm_vidc_stop_cmd(inst);
 		if (rc)
 			return rc;