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:
@@ -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,
|
||||
u32 session_id);
|
||||
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,
|
||||
u32 cap_id, u32 port);
|
||||
bool msm_vidc_allow_metadata_subscription(struct msm_vidc_inst *inst,
|
||||
|
@@ -19,6 +19,7 @@ struct msm_vidc_core;
|
||||
}
|
||||
|
||||
#define FOREACH_EVENT(EVENT) { \
|
||||
EVENT(TRY_FMT) \
|
||||
EVENT(S_FMT) \
|
||||
EVENT(REQBUFS) \
|
||||
EVENT(S_CTRL) \
|
||||
|
@@ -228,9 +228,6 @@ int msm_vidc_try_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_try_fmt(inst, f);
|
||||
if (inst->domain == MSM_VIDC_ENCODER)
|
||||
|
@@ -958,38 +958,6 @@ int signal_session_msg_receipt(struct msm_vidc_inst *inst,
|
||||
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,
|
||||
u32 port)
|
||||
{
|
||||
|
@@ -656,6 +656,16 @@ static int msm_vidc_open_state(struct msm_vidc_inst *inst,
|
||||
}
|
||||
|
||||
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:
|
||||
{
|
||||
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;
|
||||
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:
|
||||
{
|
||||
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;
|
||||
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:
|
||||
{
|
||||
struct v4l2_format *f = (struct v4l2_format *)data;
|
||||
|
@@ -135,7 +135,7 @@ int msm_v4l2_try_fmt(struct file *filp, void *fh, struct v4l2_format *f)
|
||||
rc = -EBUSY;
|
||||
goto unlock;
|
||||
}
|
||||
rc = msm_vidc_try_fmt((void *)inst, f);
|
||||
rc = inst->event_handle(inst, MSM_VIDC_TRY_FMT, f);
|
||||
if (rc)
|
||||
goto unlock;
|
||||
|
||||
|
Reference in New Issue
Block a user