From 373880e521aafbafa9259c37151ea38591c3a8f0 Mon Sep 17 00:00:00 2001 From: Govindaraj Rajagopal Date: Thu, 16 Feb 2023 14:50:07 +0530 Subject: [PATCH 1/5] video: driver: add s_fmt allow checks inside state handler use state specific checks inside state_handler instead of relying global msm_vidc_allow_s_fmt function. Change-Id: I92af08e4cd5d49f763c5a2d381af86eb10a4c061 Signed-off-by: Govindaraj Rajagopal --- driver/vidc/src/msm_vidc.c | 3 --- driver/vidc/src/msm_vidc_state.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/driver/vidc/src/msm_vidc.c b/driver/vidc/src/msm_vidc.c index 449ffee961..6912fc6a88 100644 --- a/driver/vidc/src/msm_vidc.c +++ b/driver/vidc/src/msm_vidc.c @@ -253,9 +253,6 @@ int msm_vidc_s_fmt(void *instance, struct v4l2_format *f) return -EINVAL; } - if (!msm_vidc_allow_s_fmt(inst, f->type)) - return -EBUSY; - if (inst->domain == MSM_VIDC_DECODER) rc = msm_vdec_s_fmt(inst, f); if (inst->domain == MSM_VIDC_ENCODER) diff --git a/driver/vidc/src/msm_vidc_state.c b/driver/vidc/src/msm_vidc_state.c index 698309848c..7ff318133d 100644 --- a/driver/vidc/src/msm_vidc_state.c +++ b/driver/vidc/src/msm_vidc_state.c @@ -648,6 +648,7 @@ static int msm_vidc_open_state(struct msm_vidc_inst *inst, { struct v4l2_format *f = (struct v4l2_format *)data; + /* allow s_fmt request in open state */ rc = msm_vidc_s_fmt(inst, f); if (rc) return rc; @@ -771,6 +772,13 @@ static int msm_vidc_input_streaming_state(struct msm_vidc_inst *inst, { struct v4l2_format *f = (struct v4l2_format *)data; + /* disallow */ + if (f->type == INPUT_MPLANE || f->type == INPUT_META_PLANE) { + i_vpr_e(inst, "%s: (%s) not allowed for (%s) port\n", + __func__, event_name(event), v4l2_type_name(f->type)); + return -EBUSY; + } + rc = msm_vidc_s_fmt(inst, f); if (rc) return rc; @@ -921,6 +929,13 @@ static int msm_vidc_output_streaming_state(struct msm_vidc_inst *inst, { struct v4l2_format *f = (struct v4l2_format *)data; + /* disallow */ + if (f->type == OUTPUT_MPLANE || f->type == OUTPUT_META_PLANE) { + i_vpr_e(inst, "%s: (%s) not allowed for (%s) port\n", + __func__, event_name(event), v4l2_type_name(f->type)); + return -EBUSY; + } + rc = msm_vidc_s_fmt(inst, f); if (rc) return rc; From 3ba2cb9ed1c917669c9c4fe77ea4d57888dc1323 Mon Sep 17 00:00:00 2001 From: Govindaraj Rajagopal Date: Thu, 16 Feb 2023 15:02:50 +0530 Subject: [PATCH 2/5] video: driver: add reqbuf allow checks inside state handler use state specific checks inside state_handler instead of relying global msm_vidc_allow_reqbufs function. Change-Id: Iaf7f23e4e2ef9b714e3d4c2900c2753d74150fd1 Signed-off-by: Govindaraj Rajagopal --- driver/vidc/inc/msm_vidc_driver.h | 1 - driver/vidc/src/msm_vidc.c | 5 ----- driver/vidc/src/msm_vidc_driver.c | 32 ------------------------------- driver/vidc/src/msm_vidc_state.c | 15 +++++++++++++++ 4 files changed, 15 insertions(+), 38 deletions(-) diff --git a/driver/vidc/inc/msm_vidc_driver.h b/driver/vidc/inc/msm_vidc_driver.h index 931a2bcc2f..827cb803e7 100644 --- a/driver/vidc/inc/msm_vidc_driver.h +++ b/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); -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); diff --git a/driver/vidc/src/msm_vidc.c b/driver/vidc/src/msm_vidc.c index 6912fc6a88..4c3b21469c 100644 --- a/driver/vidc/src/msm_vidc.c +++ b/driver/vidc/src/msm_vidc.c @@ -397,11 +397,6 @@ int msm_vidc_reqbufs(void *instance, struct v4l2_requestbuffers *b) return -EINVAL; } - if (!msm_vidc_allow_reqbufs(inst, b->type)) { - rc = -EBUSY; - goto exit; - } - port = v4l2_type_to_driver_port(inst, b->type, __func__); if (port < 0) { rc = -EINVAL; diff --git a/driver/vidc/src/msm_vidc_driver.c b/driver/vidc/src/msm_vidc_driver.c index 73e461436a..5046bcdc64 100644 --- a/driver/vidc/src/msm_vidc_driver.c +++ b/driver/vidc/src/msm_vidc_driver.c @@ -1115,38 +1115,6 @@ int msm_vidc_update_property_cap(struct msm_vidc_inst *inst, u32 hfi_id, return rc; } -bool msm_vidc_allow_reqbufs(struct msm_vidc_inst *inst, u32 type) -{ - bool allow = false; - - if (!inst) { - d_vpr_e("%s: invalid params\n", __func__); - return false; - } - if (is_state(inst, MSM_VIDC_OPEN)) { - allow = true; - goto exit; - } - if (type == OUTPUT_MPLANE || type == OUTPUT_META_PLANE) { - if (is_state(inst, MSM_VIDC_INPUT_STREAMING)) { - allow = true; - goto exit; - } - } - if (type == INPUT_MPLANE || type == INPUT_META_PLANE) { - if (is_state(inst, MSM_VIDC_OUTPUT_STREAMING)) { - allow = true; - goto exit; - } - } - -exit: - if (!allow) - i_vpr_e(inst, "%s: type %d not allowed in state %s\n", - __func__, type, state_name(inst->state)); - return allow; -} - enum msm_vidc_allow msm_vidc_allow_stop(struct msm_vidc_inst *inst) { enum msm_vidc_allow allow = MSM_VIDC_DISALLOW; diff --git a/driver/vidc/src/msm_vidc_state.c b/driver/vidc/src/msm_vidc_state.c index 7ff318133d..2f084e7dd9 100644 --- a/driver/vidc/src/msm_vidc_state.c +++ b/driver/vidc/src/msm_vidc_state.c @@ -668,6 +668,7 @@ static int msm_vidc_open_state(struct msm_vidc_inst *inst, { struct v4l2_requestbuffers *b = (struct v4l2_requestbuffers *)data; + /* allow reqbufs request in open state */ rc = msm_vidc_reqbufs(inst, b); if (rc) return rc; @@ -813,6 +814,13 @@ static int msm_vidc_input_streaming_state(struct msm_vidc_inst *inst, { struct v4l2_requestbuffers *b = (struct v4l2_requestbuffers *)data; + /* disallow */ + if (b->type == INPUT_MPLANE || b->type == INPUT_META_PLANE) { + i_vpr_e(inst, "%s: (%s) not allowed for (%s) port\n", + __func__, event_name(event), v4l2_type_name(b->type)); + return -EBUSY; + } + rc = msm_vidc_reqbufs(inst, b); if (rc) return rc; @@ -970,6 +978,13 @@ static int msm_vidc_output_streaming_state(struct msm_vidc_inst *inst, { struct v4l2_requestbuffers *b = (struct v4l2_requestbuffers *)data; + /* disallow */ + if (b->type == OUTPUT_MPLANE || b->type == OUTPUT_META_PLANE) { + i_vpr_e(inst, "%s: (%s) not allowed for (%s) port\n", + __func__, event_name(event), v4l2_type_name(b->type)); + return -EBUSY; + } + rc = msm_vidc_reqbufs(inst, b); if (rc) return rc; From 4afdecc4fd536ed2fb95ff6eee1e66d7390dbf5c Mon Sep 17 00:00:00 2001 From: Govindaraj Rajagopal Date: Thu, 16 Feb 2023 15:10:25 +0530 Subject: [PATCH 3/5] video: driver: add streamon allow checks inside state handler use state specific checks inside state_handler instead of relying global msm_vidc_allow_streamon function. Change-Id: I67948831612ebb33cdd12a2e9f8561b6095e9433 Signed-off-by: Govindaraj Rajagopal --- driver/vidc/inc/msm_vidc_driver.h | 1 - driver/vidc/src/msm_vidc_driver.c | 21 --------------------- driver/vidc/src/msm_vidc_state.c | 15 +++++++++++++++ driver/vidc/src/msm_vidc_vb2.c | 3 --- 4 files changed, 15 insertions(+), 25 deletions(-) diff --git a/driver/vidc/inc/msm_vidc_driver.h b/driver/vidc/inc/msm_vidc_driver.h index 827cb803e7..991b76e6d9 100644 --- a/driver/vidc/inc/msm_vidc_driver.h +++ b/driver/vidc/inc/msm_vidc_driver.h @@ -494,7 +494,6 @@ 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); bool msm_vidc_allow_start(struct msm_vidc_inst *inst); -bool msm_vidc_allow_streamon(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_drain_last_flag(struct msm_vidc_inst *inst); bool msm_vidc_allow_psc_last_flag(struct msm_vidc_inst *inst); diff --git a/driver/vidc/src/msm_vidc_driver.c b/driver/vidc/src/msm_vidc_driver.c index 5046bcdc64..a20595713e 100644 --- a/driver/vidc/src/msm_vidc_driver.c +++ b/driver/vidc/src/msm_vidc_driver.c @@ -1167,27 +1167,6 @@ bool msm_vidc_allow_start(struct msm_vidc_inst *inst) return allow; } -bool msm_vidc_allow_streamon(struct msm_vidc_inst *inst, u32 type) -{ - if (!inst) { - d_vpr_e("%s: invalid params\n", __func__); - return false; - } - if (type == INPUT_MPLANE || type == INPUT_META_PLANE) { - if (is_state(inst, MSM_VIDC_OPEN) || - is_state(inst, MSM_VIDC_OUTPUT_STREAMING)) - return true; - } else if (type == OUTPUT_MPLANE || type == OUTPUT_META_PLANE) { - if (is_state(inst, MSM_VIDC_OPEN) || - is_state(inst, MSM_VIDC_INPUT_STREAMING)) - return true; - } - - i_vpr_e(inst, "%s: type %d not allowed in state %s\n", - __func__, type, state_name(inst->state)); - return false; -} - enum msm_vidc_allow msm_vidc_allow_input_psc(struct msm_vidc_inst *inst) { enum msm_vidc_allow allow = MSM_VIDC_ALLOW; diff --git a/driver/vidc/src/msm_vidc_state.c b/driver/vidc/src/msm_vidc_state.c index 2f084e7dd9..097f73358b 100644 --- a/driver/vidc/src/msm_vidc_state.c +++ b/driver/vidc/src/msm_vidc_state.c @@ -678,6 +678,7 @@ static int msm_vidc_open_state(struct msm_vidc_inst *inst, { struct vb2_queue *q = (struct vb2_queue *)data; + /* allow streamon request in open state */ rc = msm_vidc_start_streaming(inst, q); if (rc) return rc; @@ -830,6 +831,13 @@ static int msm_vidc_input_streaming_state(struct msm_vidc_inst *inst, { struct vb2_queue *q = (struct vb2_queue *)data; + /* disallow */ + if (q->type == INPUT_MPLANE || q->type == INPUT_META_PLANE) { + i_vpr_e(inst, "%s: (%s) not allowed for (%s) type\n", + __func__, event_name(event), v4l2_type_name(q->type)); + return -EBUSY; + } + rc = msm_vidc_start_streaming(inst, q); if (rc) return rc; @@ -994,6 +1002,13 @@ static int msm_vidc_output_streaming_state(struct msm_vidc_inst *inst, { struct vb2_queue *q = (struct vb2_queue *)data; + /* disallow */ + if (q->type == OUTPUT_MPLANE || q->type == OUTPUT_META_PLANE) { + i_vpr_e(inst, "%s: (%s) not allowed for (%s) type\n", + __func__, event_name(event), v4l2_type_name(q->type)); + return -EBUSY; + } + rc = msm_vidc_start_streaming(inst, q); if (rc) return rc; diff --git a/driver/vidc/src/msm_vidc_vb2.c b/driver/vidc/src/msm_vidc_vb2.c index 26ce6916a0..fb853ac11c 100644 --- a/driver/vidc/src/msm_vidc_vb2.c +++ b/driver/vidc/src/msm_vidc_vb2.c @@ -415,9 +415,6 @@ int msm_vidc_start_streaming(struct msm_vidc_inst *inst, struct vb2_queue *q) return -EINVAL; } - if (!msm_vidc_allow_streamon(inst, q->type)) - return -EBUSY; - if (q->type == INPUT_META_PLANE || q->type == OUTPUT_META_PLANE) { i_vpr_h(inst, "%s: nothing to start on %s\n", __func__, v4l2_type_name(q->type)); From a6e521d62991c137a3714b2d249175d081c92235 Mon Sep 17 00:00:00 2001 From: Govindaraj Rajagopal Date: Thu, 16 Feb 2023 15:34:12 +0530 Subject: [PATCH 4/5] video: driver: add start cmd allow checks inside state handler use state specific checks inside state_handler instead of relying global msm_vidc_allow_start function. Change-Id: I04182ee3b63fa9044acf4f40adc47ea97eaa7538 Signed-off-by: Govindaraj Rajagopal --- driver/vidc/inc/msm_vidc_driver.h | 1 - driver/vidc/inc/msm_vidc_state.h | 2 ++ driver/vidc/src/msm_vdec.c | 3 --- driver/vidc/src/msm_venc.c | 3 +-- driver/vidc/src/msm_vidc_driver.c | 25 ----------------- driver/vidc/src/msm_vidc_state.c | 45 ++++++++++++++++++++++++++++--- 6 files changed, 44 insertions(+), 35 deletions(-) diff --git a/driver/vidc/inc/msm_vidc_driver.h b/driver/vidc/inc/msm_vidc_driver.h index 991b76e6d9..a96f863e99 100644 --- a/driver/vidc/inc/msm_vidc_driver.h +++ b/driver/vidc/inc/msm_vidc_driver.h @@ -493,7 +493,6 @@ 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); -bool msm_vidc_allow_start(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); diff --git a/driver/vidc/inc/msm_vidc_state.h b/driver/vidc/inc/msm_vidc_state.h index d995a044da..6dec161d3a 100644 --- a/driver/vidc/inc/msm_vidc_state.h +++ b/driver/vidc/inc/msm_vidc_state.h @@ -91,6 +91,8 @@ const char *core_state_name(enum msm_vidc_core_state state); const char *core_sub_state_name(enum msm_vidc_core_sub_state sub_state); /* inst statemachine functions */ +bool is_drc_pending(struct msm_vidc_inst *inst); +bool is_drain_pending(struct msm_vidc_inst *inst); int msm_vidc_update_state(struct msm_vidc_inst *inst, enum msm_vidc_state request_state, const char *func); int msm_vidc_change_state(struct msm_vidc_inst *inst, diff --git a/driver/vidc/src/msm_vdec.c b/driver/vidc/src/msm_vdec.c index 50396430c1..5d53b79db9 100644 --- a/driver/vidc/src/msm_vdec.c +++ b/driver/vidc/src/msm_vdec.c @@ -2132,9 +2132,6 @@ int msm_vdec_start_cmd(struct msm_vidc_inst *inst) return -EINVAL; } - if (!msm_vidc_allow_start(inst)) - return -EBUSY; - /* tune power features */ inst->decode_batch.enable = msm_vidc_allow_decode_batch(inst); msm_vidc_allow_dcvs(inst); diff --git a/driver/vidc/src/msm_venc.c b/driver/vidc/src/msm_venc.c index 943004f647..f0c36956e6 100644 --- a/driver/vidc/src/msm_venc.c +++ b/driver/vidc/src/msm_venc.c @@ -935,8 +935,7 @@ int msm_venc_start_cmd(struct msm_vidc_inst *inst) int rc = 0; i_vpr_h(inst, "received cmd: resume\n"); - if (!msm_vidc_allow_start(inst)) - return -EBUSY; + vb2_clear_last_buffer_dequeued(inst->bufq[OUTPUT_META_PORT].vb2q); vb2_clear_last_buffer_dequeued(inst->bufq[OUTPUT_PORT].vb2q); diff --git a/driver/vidc/src/msm_vidc_driver.c b/driver/vidc/src/msm_vidc_driver.c index a20595713e..d82f80fcf3 100644 --- a/driver/vidc/src/msm_vidc_driver.c +++ b/driver/vidc/src/msm_vidc_driver.c @@ -1142,31 +1142,6 @@ enum msm_vidc_allow msm_vidc_allow_stop(struct msm_vidc_inst *inst) return allow; } -bool msm_vidc_allow_start(struct msm_vidc_inst *inst) -{ - bool allow = false; - - if (!inst) { - d_vpr_e("%s: invalid params\n", __func__); - return allow; - } - - /* client would call start (resume) to complete DRC/drain sequence */ - if (inst->state == MSM_VIDC_INPUT_STREAMING || - inst->state == MSM_VIDC_OUTPUT_STREAMING || - inst->state == MSM_VIDC_STREAMING) { - if ((is_sub_state(inst, MSM_VIDC_DRC) && - is_sub_state(inst, MSM_VIDC_DRC_LAST_BUFFER)) || - (is_sub_state(inst, MSM_VIDC_DRAIN) && - is_sub_state(inst, MSM_VIDC_DRAIN_LAST_BUFFER))) - allow = true; - } - if (!allow) - 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; diff --git a/driver/vidc/src/msm_vidc_state.c b/driver/vidc/src/msm_vidc_state.c index 097f73358b..1e6fb6d2a5 100644 --- a/driver/vidc/src/msm_vidc_state.c +++ b/driver/vidc/src/msm_vidc_state.c @@ -24,6 +24,18 @@ bool is_core_state(struct msm_vidc_core *core, enum msm_vidc_core_state state) return core->state == state; } +bool is_drc_pending(struct msm_vidc_inst *inst) +{ + return is_sub_state(inst, MSM_VIDC_DRC) && + is_sub_state(inst, MSM_VIDC_DRC_LAST_BUFFER); +} + +bool is_drain_pending(struct msm_vidc_inst *inst) +{ + return is_sub_state(inst, MSM_VIDC_DRAIN) && + is_sub_state(inst, MSM_VIDC_DRAIN_LAST_BUFFER); +} + static const char * const core_state_name_arr[] = FOREACH_CORE_STATE(GENERATE_STRING); @@ -695,10 +707,11 @@ static int msm_vidc_open_state(struct msm_vidc_inst *inst, } case MSM_VIDC_CMD_START: { - rc = msm_vidc_start_cmd(inst); - if (rc) - return rc; - break; + /* disallow start cmd request in open state */ + i_vpr_e(inst, "%s: (%s) not allowed, sub_state (%s)\n", + __func__, event_name(event), inst->sub_state_name); + + return -EBUSY; } case MSM_VIDC_CMD_STOP: { @@ -874,6 +887,14 @@ static int msm_vidc_input_streaming_state(struct msm_vidc_inst *inst, } case MSM_VIDC_CMD_START: { + /* disallow if START called for non DRC/drain cases */ + if (!is_drc_pending(inst) && !is_drain_pending(inst)) { + i_vpr_e(inst, "%s: (%s) not allowed, sub_state (%s)\n", + __func__, event_name(event), inst->sub_state_name); + return -EBUSY; + } + + /* client would call start(resume) to complete DRC/drain sequence */ rc = msm_vidc_start_cmd(inst); if (rc) return rc; @@ -1045,6 +1066,14 @@ static int msm_vidc_output_streaming_state(struct msm_vidc_inst *inst, } case MSM_VIDC_CMD_START: { + /* disallow if START called for non DRC/drain cases */ + if (!is_drc_pending(inst) && !is_drain_pending(inst)) { + i_vpr_e(inst, "%s: (%s) not allowed, sub_state (%s)\n", + __func__, event_name(event), inst->sub_state_name); + return -EBUSY; + } + + /* client would call start(resume) to complete DRC/drain sequence */ rc = msm_vidc_start_cmd(inst); if (rc) return rc; @@ -1151,6 +1180,14 @@ static int msm_vidc_streaming_state(struct msm_vidc_inst *inst, } case MSM_VIDC_CMD_START: { + /* disallow if START called for non DRC/drain cases */ + if (!is_drc_pending(inst) && !is_drain_pending(inst)) { + i_vpr_e(inst, "%s: (%s) not allowed, sub_state (%s)\n", + __func__, event_name(event), inst->sub_state_name); + return -EBUSY; + } + + /* client would call start(resume) to complete DRC/drain sequence */ rc = msm_vidc_start_cmd(inst); if (rc) return rc; From ab6770c11f3e66cc0c29a1dd0ad9e14251976c78 Mon Sep 17 00:00:00 2001 From: Govindaraj Rajagopal Date: Thu, 16 Feb 2023 16:00:59 +0530 Subject: [PATCH 5/5] 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 --- driver/vidc/inc/msm_vidc_driver.h | 1 - driver/vidc/src/msm_vdec.c | 8 -------- driver/vidc/src/msm_venc.c | 8 -------- driver/vidc/src/msm_vidc_driver.c | 27 --------------------------- driver/vidc/src/msm_vidc_state.c | 28 +++++++++++++++++++++------- 5 files changed, 21 insertions(+), 51 deletions(-) diff --git a/driver/vidc/inc/msm_vidc_driver.h b/driver/vidc/inc/msm_vidc_driver.h index a96f863e99..61a7575e40 100644 --- a/driver/vidc/inc/msm_vidc_driver.h +++ b/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); diff --git a/driver/vidc/src/msm_vdec.c b/driver/vidc/src/msm_vdec.c index 5d53b79db9..6e8cf27907 100644 --- a/driver/vidc/src/msm_vdec.c +++ b/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; diff --git a/driver/vidc/src/msm_venc.c b/driver/vidc/src/msm_venc.c index f0c36956e6..c9ccf2a100 100644 --- a/driver/vidc/src/msm_venc.c +++ b/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; diff --git a/driver/vidc/src/msm_vidc_driver.c b/driver/vidc/src/msm_vidc_driver.c index d82f80fcf3..a8c83d40cd 100644 --- a/driver/vidc/src/msm_vidc_driver.c +++ b/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; diff --git a/driver/vidc/src/msm_vidc_state.c b/driver/vidc/src/msm_vidc_state.c index 1e6fb6d2a5..ec9d30bcd2 100644 --- a/driver/vidc/src/msm_vidc_state.c +++ b/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;