video: driver: state handling code movement
state handling changes were spread across multiple files. So re-arrange all state related handling changes into msm_vidc_state.h/.c file. Change-Id: I3826daa678d1e2b5ce7e74380d465e70b1b824c6 Signed-off-by: Govindaraj Rajagopal <quic_grajagop@quicinc.com>
This commit is contained in:
@@ -99,59 +99,6 @@ exit:
|
||||
return name;
|
||||
}
|
||||
|
||||
/* do not modify the state names as it is used in test scripts */
|
||||
static const char * const state_name_arr[] =
|
||||
FOREACH_STATE(GENERATE_STRING);
|
||||
|
||||
const char *state_name(enum msm_vidc_state state)
|
||||
{
|
||||
const char *name = "UNKNOWN STATE";
|
||||
|
||||
if (state >= ARRAY_SIZE(state_name_arr))
|
||||
goto exit;
|
||||
|
||||
name = state_name_arr[state];
|
||||
|
||||
exit:
|
||||
return name;
|
||||
}
|
||||
|
||||
const char *sub_state_name(enum msm_vidc_sub_state sub_state)
|
||||
{
|
||||
switch (sub_state) {
|
||||
case MSM_VIDC_DRAIN: return "DRAIN ";
|
||||
case MSM_VIDC_DRC: return "DRC ";
|
||||
case MSM_VIDC_DRAIN_LAST_BUFFER: return "DRAIN_LAST_BUFFER ";
|
||||
case MSM_VIDC_DRC_LAST_BUFFER: return "DRC_LAST_BUFFER ";
|
||||
case MSM_VIDC_INPUT_PAUSE: return "INPUT_PAUSE ";
|
||||
case MSM_VIDC_OUTPUT_PAUSE: return "OUTPUT_PAUSE ";
|
||||
}
|
||||
|
||||
return "SUB_STATE_NONE";
|
||||
}
|
||||
|
||||
int prepare_sub_state_name(enum msm_vidc_sub_state sub_state,
|
||||
char *buf, u32 size)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if (!buf || !size)
|
||||
return -EINVAL;
|
||||
|
||||
strscpy(buf, "\0", size);
|
||||
if (sub_state == MSM_VIDC_SUB_STATE_NONE) {
|
||||
strscpy(buf, "SUB_STATE_NONE", size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < MSM_VIDC_MAX_SUB_STATES; i++) {
|
||||
if (sub_state & BIT(i))
|
||||
strlcat(buf, sub_state_name(BIT(i)), size);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *v4l2_type_name(u32 port)
|
||||
{
|
||||
switch (port) {
|
||||
@@ -1013,90 +960,6 @@ int signal_session_msg_receipt(struct msm_vidc_inst *inst,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int msm_vidc_change_state(struct msm_vidc_inst *inst,
|
||||
enum msm_vidc_state request_state, const char *func)
|
||||
{
|
||||
enum msm_vidc_allow allow;
|
||||
int rc;
|
||||
|
||||
if (!inst) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (is_session_error(inst)) {
|
||||
i_vpr_h(inst,
|
||||
"%s: inst is in bad state, can not change state to %s\n",
|
||||
func, state_name(request_state));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* current and requested state is same */
|
||||
if (inst->state == request_state)
|
||||
return 0;
|
||||
|
||||
/* check if requested state movement is allowed */
|
||||
allow = msm_vidc_allow_state_change(inst, request_state);
|
||||
if (allow != MSM_VIDC_ALLOW) {
|
||||
i_vpr_e(inst, "%s: %s state change %s -> %s\n", func,
|
||||
allow_name(allow), state_name(inst->state),
|
||||
state_name(request_state));
|
||||
return (allow == MSM_VIDC_DISALLOW ? -EINVAL : 0);
|
||||
}
|
||||
|
||||
/* go ahead and update inst state */
|
||||
rc = msm_vidc_update_state(inst, request_state, func);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int msm_vidc_change_sub_state(struct msm_vidc_inst *inst,
|
||||
enum msm_vidc_sub_state clear_sub_state,
|
||||
enum msm_vidc_sub_state set_sub_state, const char *func)
|
||||
{
|
||||
enum msm_vidc_sub_state prev_sub_state;
|
||||
int rc = 0;
|
||||
|
||||
if (!inst) {
|
||||
d_vpr_e("%s: invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (is_session_error(inst)) {
|
||||
i_vpr_h(inst,
|
||||
"%s: inst is in bad state, can not change sub state\n", func);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!clear_sub_state && !set_sub_state)
|
||||
return 0;
|
||||
|
||||
if ((clear_sub_state & set_sub_state) ||
|
||||
(set_sub_state > MSM_VIDC_MAX_SUB_STATE_VALUE) ||
|
||||
(clear_sub_state > MSM_VIDC_MAX_SUB_STATE_VALUE)) {
|
||||
i_vpr_e(inst, "%s: invalid sub states to clear %#x or set %#x\n",
|
||||
func, clear_sub_state, set_sub_state);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
prev_sub_state = inst->sub_state;
|
||||
inst->sub_state |= set_sub_state;
|
||||
inst->sub_state &= ~clear_sub_state;
|
||||
|
||||
/* print substates only when there is a change */
|
||||
if (inst->sub_state != prev_sub_state) {
|
||||
rc = prepare_sub_state_name(inst->sub_state, inst->sub_state_name,
|
||||
sizeof(inst->sub_state_name));
|
||||
if (!rc)
|
||||
i_vpr_h(inst, "%s: state %s and sub state changed to %s\n",
|
||||
func, state_name(inst->state), inst->sub_state_name);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool msm_vidc_allow_s_fmt(struct msm_vidc_inst *inst, u32 type)
|
||||
{
|
||||
bool allow = false;
|
||||
|
Reference in New Issue
Block a user