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 <quic_grajagop@quicinc.com>
这个提交包含在:
Govindaraj Rajagopal
2023-02-16 15:02:50 +05:30
父节点 373880e521
当前提交 3ba2cb9ed1
修改 4 个文件,包含 15 行新增38 行删除

查看文件

@@ -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);

查看文件

@@ -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;

查看文件

@@ -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;

查看文件

@@ -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;