video: driver: add try_fmt allow checks inside state handler

Remove msm_vidc_allow_s_fmt function and use state specific
MSM_VIDC_TRY_FMT checks inside state_handler

Change-Id: I405b9cfb89e4daadafcc05eb99e66e2b0aad328e
Signed-off-by: Megha Byahatti <quic_mbyahatt@quicinc.com>
This commit is contained in:
Megha Byahatti
2023-03-20 11:16:11 +05:30
parent 4a2de2df11
commit c750ba048b
6 changed files with 44 additions and 37 deletions

View File

@@ -485,7 +485,6 @@ struct msm_vidc_inst *get_inst_ref(struct msm_vidc_core *core,
struct msm_vidc_inst *get_inst(struct msm_vidc_core *core, struct msm_vidc_inst *get_inst(struct msm_vidc_core *core,
u32 session_id); u32 session_id);
void put_inst(struct msm_vidc_inst *inst); void put_inst(struct msm_vidc_inst *inst);
bool msm_vidc_allow_s_fmt(struct msm_vidc_inst *inst, u32 type);
bool msm_vidc_allow_metadata_delivery(struct msm_vidc_inst *inst, bool msm_vidc_allow_metadata_delivery(struct msm_vidc_inst *inst,
u32 cap_id, u32 port); u32 cap_id, u32 port);
bool msm_vidc_allow_metadata_subscription(struct msm_vidc_inst *inst, bool msm_vidc_allow_metadata_subscription(struct msm_vidc_inst *inst,

View File

@@ -19,6 +19,7 @@ struct msm_vidc_core;
} }
#define FOREACH_EVENT(EVENT) { \ #define FOREACH_EVENT(EVENT) { \
EVENT(TRY_FMT) \
EVENT(S_FMT) \ EVENT(S_FMT) \
EVENT(REQBUFS) \ EVENT(REQBUFS) \
EVENT(S_CTRL) \ EVENT(S_CTRL) \

View File

@@ -228,9 +228,6 @@ int msm_vidc_try_fmt(void *instance, struct v4l2_format *f)
return -EINVAL; return -EINVAL;
} }
if (!msm_vidc_allow_s_fmt(inst, f->type))
return -EBUSY;
if (inst->domain == MSM_VIDC_DECODER) if (inst->domain == MSM_VIDC_DECODER)
rc = msm_vdec_try_fmt(inst, f); rc = msm_vdec_try_fmt(inst, f);
if (inst->domain == MSM_VIDC_ENCODER) if (inst->domain == MSM_VIDC_ENCODER)

View File

@@ -958,38 +958,6 @@ int signal_session_msg_receipt(struct msm_vidc_inst *inst,
return 0; return 0;
} }
bool msm_vidc_allow_s_fmt(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;
}
bool msm_vidc_allow_metadata_delivery(struct msm_vidc_inst *inst, u32 cap_id, bool msm_vidc_allow_metadata_delivery(struct msm_vidc_inst *inst, u32 cap_id,
u32 port) u32 port)
{ {

View File

@@ -656,6 +656,16 @@ static int msm_vidc_open_state(struct msm_vidc_inst *inst,
} }
switch (event) { switch (event) {
case MSM_VIDC_TRY_FMT:
{
struct v4l2_format *f = (struct v4l2_format *)data;
/* allow try_fmt request in open state */
rc = msm_vidc_try_fmt(inst, f);
if (rc)
return rc;
break;
}
case MSM_VIDC_S_FMT: case MSM_VIDC_S_FMT:
{ {
struct v4l2_format *f = (struct v4l2_format *)data; struct v4l2_format *f = (struct v4l2_format *)data;
@@ -783,6 +793,22 @@ static int msm_vidc_input_streaming_state(struct msm_vidc_inst *inst,
return rc; return rc;
break; break;
} }
case MSM_VIDC_TRY_FMT:
{
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_try_fmt(inst, f);
if (rc)
return rc;
break;
}
case MSM_VIDC_S_FMT: case MSM_VIDC_S_FMT:
{ {
struct v4l2_format *f = (struct v4l2_format *)data; struct v4l2_format *f = (struct v4l2_format *)data;
@@ -969,6 +995,22 @@ static int msm_vidc_output_streaming_state(struct msm_vidc_inst *inst,
return rc; return rc;
break; break;
} }
case MSM_VIDC_TRY_FMT:
{
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_try_fmt(inst, f);
if (rc)
return rc;
break;
}
case MSM_VIDC_S_FMT: case MSM_VIDC_S_FMT:
{ {
struct v4l2_format *f = (struct v4l2_format *)data; struct v4l2_format *f = (struct v4l2_format *)data;

View File

@@ -135,7 +135,7 @@ int msm_v4l2_try_fmt(struct file *filp, void *fh, struct v4l2_format *f)
rc = -EBUSY; rc = -EBUSY;
goto unlock; goto unlock;
} }
rc = msm_vidc_try_fmt((void *)inst, f); rc = inst->event_handle(inst, MSM_VIDC_TRY_FMT, f);
if (rc) if (rc)
goto unlock; goto unlock;