4 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 * @file display-state-transition.c
21 * @brief This file has functions related to display state transition
24 #include "device-interface.h"
25 #include "display-state-transition.h"
26 #include "display-plugin.h"
28 static int trans_table[S_END][EVENT_END] = {
30 { S_START, S_START }, /* S_START */
31 { S_LCDDIM, S_NORMAL }, /* S_NORMAL */
32 { S_LCDOFF, S_NORMAL }, /* S_LCDDIM */
33 { S_SLEEP, S_NORMAL }, /* S_LCDOFF */
34 { S_SLEEP, S_STANDBY }, /* S_STANDBY */
35 { S_LCDOFF, S_NORMAL }, /* S_SLEEP */
36 { S_POWEROFF, S_POWEROFF }, /* S_POWEROFF */
39 static bool is_display_state_valid(enum state_t display_state)
41 return (display_state >= S_START && display_state < S_END);
44 static bool is_device_event_type_valid(int event_type)
46 return (event_type >= EVENT_TIMEOUT && event_type < EVENT_END);
49 int display_state_transition_get_next_transition_display_state(enum state_t from_state, enum state_t *to_state, int evt_type)
51 if (!to_state || !is_display_state_valid(from_state) || !is_device_event_type_valid(evt_type))
54 *to_state = trans_table[from_state][evt_type];
58 int display_state_transition_set_transition_table_display_state(enum state_t display_state, enum state_t set_state, int evt_type)
60 if (!is_display_state_valid(display_state) || !is_device_event_type_valid(evt_type) || !is_display_state_valid(set_state))
63 trans_table[display_state][evt_type] = set_state;