video: driver: ignore input/output port streamoff if already streamed off

Ignore input port or output port streamoff if corresponding port is already
streamed off.

Change-Id: I708126b24758ee0f76bc2646527d1baee59e5178
Signed-off-by: Akshata Sahukar <asahukar@codeaurora.org>
This commit is contained in:
Akshata Sahukar
2021-07-07 10:49:21 -07:00
parent d90bcf45f5
commit 7616a6bdad
3 changed files with 58 additions and 18 deletions

View File

@@ -275,6 +275,7 @@ u32 v4l2_matrix_coeff_from_driver(struct msm_vidc_inst *inst,
u32 vidc_matrix_coeff, const char *func); u32 vidc_matrix_coeff, const char *func);
int v4l2_type_to_driver_port(struct msm_vidc_inst *inst, u32 type, int v4l2_type_to_driver_port(struct msm_vidc_inst *inst, u32 type,
const char *func); const char *func);
const char *allow_name(enum msm_vidc_allow allow);
const char *state_name(enum msm_vidc_inst_state state); const char *state_name(enum msm_vidc_inst_state state);
int msm_vidc_change_inst_state(struct msm_vidc_inst *inst, int msm_vidc_change_inst_state(struct msm_vidc_inst *inst,
enum msm_vidc_inst_state request_state, const char *func); enum msm_vidc_inst_state request_state, const char *func);
@@ -375,7 +376,7 @@ 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); 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_start(struct msm_vidc_inst *inst);
bool msm_vidc_allow_streamon(struct msm_vidc_inst *inst, u32 type); bool msm_vidc_allow_streamon(struct msm_vidc_inst *inst, u32 type);
bool msm_vidc_allow_streamoff(struct msm_vidc_inst *inst, u32 type); enum msm_vidc_allow msm_vidc_allow_streamoff(struct msm_vidc_inst *inst, u32 type);
enum msm_vidc_allow msm_vidc_allow_qbuf(struct msm_vidc_inst *inst, u32 type); enum msm_vidc_allow msm_vidc_allow_qbuf(struct msm_vidc_inst *inst, u32 type);
enum msm_vidc_allow msm_vidc_allow_input_psc(struct msm_vidc_inst *inst); enum msm_vidc_allow msm_vidc_allow_input_psc(struct msm_vidc_inst *inst);
bool msm_vidc_allow_last_flag(struct msm_vidc_inst *inst); bool msm_vidc_allow_last_flag(struct msm_vidc_inst *inst);

View File

@@ -543,15 +543,22 @@ int msm_vidc_streamoff(void *instance, enum v4l2_buf_type type)
int rc = 0; int rc = 0;
struct msm_vidc_inst *inst = instance; struct msm_vidc_inst *inst = instance;
int port; int port;
enum msm_vidc_allow allow;
if (!inst) { if (!inst) {
d_vpr_e("%s: invalid params\n", __func__); d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL; return -EINVAL;
} }
if (!msm_vidc_allow_streamoff(inst, type)) { allow = msm_vidc_allow_streamoff(inst, type);
if (allow == MSM_VIDC_DISALLOW) {
rc = -EBUSY; rc = -EBUSY;
goto exit; goto exit;
} else if (allow == MSM_VIDC_IGNORE) {
goto exit;
} else if (allow != MSM_VIDC_ALLOW) {
rc = -EINVAL;
goto exit;
} }
rc = msm_vidc_state_change_streamoff(inst, type); rc = msm_vidc_state_change_streamoff(inst, type);
if (rc) if (rc)

View File

@@ -238,6 +238,35 @@ exit:
return name; return name;
} }
struct msm_vidc_allow_name {
enum msm_vidc_allow allow;
char *name;
};
static const struct msm_vidc_allow_name inst_allow_name_arr[] = {
{MSM_VIDC_DISALLOW, "MSM_VIDC_DISALLOW" },
{MSM_VIDC_ALLOW, "MSM_VIDC_ALLOW" },
{MSM_VIDC_DEFER, "MSM_VIDC_DEFER" },
{MSM_VIDC_DISCARD, "MSM_VIDC_DISCARD" },
{MSM_VIDC_IGNORE, "MSM_VIDC_IGNORE" },
};
const char *allow_name(enum msm_vidc_allow allow)
{
const char *name = "UNKNOWN";
if (allow > ARRAY_SIZE(inst_allow_name_arr))
goto exit;
if (inst_allow_name_arr[allow].allow != allow)
goto exit;
name = inst_allow_name_arr[allow].name;
exit:
return name;
}
struct msm_vidc_inst_state_name { struct msm_vidc_inst_state_name {
enum msm_vidc_inst_state state; enum msm_vidc_inst_state state;
char *name; char *name;
@@ -1444,32 +1473,35 @@ bool msm_vidc_allow_streamon(struct msm_vidc_inst *inst, u32 type)
return false; return false;
} }
bool msm_vidc_allow_streamoff(struct msm_vidc_inst *inst, u32 type) enum msm_vidc_allow msm_vidc_allow_streamoff(struct msm_vidc_inst *inst, u32 type)
{ {
bool allow = true; enum msm_vidc_allow allow = MSM_VIDC_ALLOW;
if (!inst) { if (!inst) {
d_vpr_e("%s: invalid params\n", __func__); d_vpr_e("%s: invalid params\n", __func__);
return false; return MSM_VIDC_DISALLOW;
} }
if (type == INPUT_MPLANE) { if (type == INPUT_MPLANE) {
if (inst->state == MSM_VIDC_OPEN || if (!inst->vb2q[INPUT_PORT].streaming)
inst->state == MSM_VIDC_START_OUTPUT) allow = MSM_VIDC_IGNORE;
allow = false;
} else if (type == INPUT_META_PLANE) { } else if (type == INPUT_META_PLANE) {
if (inst->state == MSM_VIDC_START_INPUT) if (inst->vb2q[INPUT_PORT].streaming)
allow = false; allow = MSM_VIDC_DISALLOW;
else if (!inst->vb2q[INPUT_META_PORT].streaming)
allow = MSM_VIDC_IGNORE;
} else if (type == OUTPUT_MPLANE) { } else if (type == OUTPUT_MPLANE) {
if (inst->state == MSM_VIDC_OPEN || if (!inst->vb2q[OUTPUT_PORT].streaming)
inst->state == MSM_VIDC_START_INPUT) allow = MSM_VIDC_IGNORE;
allow = false;
} else if (type == OUTPUT_META_PLANE) { } else if (type == OUTPUT_META_PLANE) {
if (inst->state == MSM_VIDC_START_OUTPUT) if (inst->vb2q[OUTPUT_PORT].streaming)
allow = false; allow = MSM_VIDC_DISALLOW;
else if (!inst->vb2q[OUTPUT_META_PORT].streaming)
allow = MSM_VIDC_IGNORE;
} }
if (!allow) if (allow != MSM_VIDC_ALLOW)
i_vpr_e(inst, "%s: type %d not allowed in state %s\n", i_vpr_e(inst, "%s: type %d is %s in state %s\n",
__func__, type, state_name(inst->state)); __func__, type, allow_name(allow),
state_name(inst->state));
return allow; return allow;
} }