Skip to content

Commit

Permalink
[datapipe] Use macro for making display state requests. JB#22475
Browse files Browse the repository at this point in the history
Most of mce code base has already been changed so that it uses
convenience macro for invoking display state changes, but there
are still some files where direct datapipe_execute_full() calls
are made.

Use more appropriate name for the macro and make sure only it
is used for making display state transitions within all of mce
source tree.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Mar 16, 2018
1 parent 4f558cd commit fe7de61
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 59 deletions.
2 changes: 1 addition & 1 deletion datapipe.h
Expand Up @@ -248,7 +248,7 @@ void mce_datapipe_quit(void);
* This needs to be macro so that logging context stays
* at the point of call.
*/
#define mce_datapipe_req_display_state(state_) do {\
#define mce_datapipe_request_display_state(state_) do {\
display_state_t cur_target = datapipe_get_gint(display_state_next_pipe);\
display_state_t req_target = (display_state_t)(state_);\
/* Use elevated logginng verbosity for requests that \
Expand Down
2 changes: 1 addition & 1 deletion modetransition.c
Expand Up @@ -129,7 +129,7 @@ static void system_state_trigger(gconstpointer data)
switch( old_system_state ) {
case MCE_SYSTEM_STATE_USER:
case MCE_SYSTEM_STATE_ACTDEAD:
mce_datapipe_req_display_state(MCE_DISPLAY_ON);
mce_datapipe_request_display_state(MCE_DISPLAY_ON);
break;

default:
Expand Down
24 changes: 12 additions & 12 deletions modules/display.c
Expand Up @@ -1876,7 +1876,7 @@ static void mdy_datapipe_device_inactive_cb(gconstpointer data)
case MCE_DISPLAY_DIM:
/* DIM->ON on device activity */
mce_log(LL_NOTICE, "display on due to activity");
mce_datapipe_req_display_state(MCE_DISPLAY_ON);
mce_datapipe_request_display_state(MCE_DISPLAY_ON);
break;

default:
Expand Down Expand Up @@ -3580,7 +3580,7 @@ static gboolean mdy_blanking_dim_cb(gpointer data)
if( submode & MCE_SUBMODE_MALF )
display = MCE_DISPLAY_OFF;

mce_datapipe_req_display_state(display);
mce_datapipe_request_display_state(display);

return FALSE;
}
Expand Down Expand Up @@ -3720,7 +3720,7 @@ static gboolean mdy_blanking_off_cb(gpointer data)
break;
}

mce_datapipe_req_display_state(next_state);
mce_datapipe_request_display_state(next_state);

/* Remove wakelock unless the timer got re-programmed */
if( !mdy_blanking_off_cb_id )
Expand Down Expand Up @@ -3838,7 +3838,7 @@ static gboolean mdy_blanking_lpm_off_cb(gpointer data)

mdy_blanking_lpm_off_cb_id = 0;

mce_datapipe_req_display_state(MCE_DISPLAY_LPM_OFF);
mce_datapipe_request_display_state(MCE_DISPLAY_LPM_OFF);

return FALSE;
}
Expand Down Expand Up @@ -4560,15 +4560,15 @@ static void mdy_blanking_rethink_proximity(void)
switch( display_state_curr ) {
case MCE_DISPLAY_LPM_ON:
if( proximity_sensor_actual == COVER_CLOSED )
mce_datapipe_req_display_state(MCE_DISPLAY_LPM_OFF);
mce_datapipe_request_display_state(MCE_DISPLAY_LPM_OFF);
else
mdy_blanking_schedule_lpm_off();
break;

case MCE_DISPLAY_LPM_OFF:
if( proximity_sensor_actual == COVER_OPEN &&
lid_sensor_filtered != COVER_CLOSED )
mce_datapipe_req_display_state(MCE_DISPLAY_LPM_ON);
mce_datapipe_request_display_state(MCE_DISPLAY_LPM_ON);
else
mdy_blanking_schedule_off();
break;
Expand Down Expand Up @@ -8649,7 +8649,7 @@ static void mdy_dbus_handle_display_state_req(display_state_t state)
* similar -> reset the last indication sent cache */
mdy_dbus_invalidate_display_status();

mce_datapipe_req_display_state(state);
mce_datapipe_request_display_state(state);
}

/**
Expand Down Expand Up @@ -9502,7 +9502,7 @@ static void mdy_flagfiles_osupdate_running_cb(const char *path,

if( mdy_osupdate_running ) {
/* Issue display on request when update mode starts */
mce_datapipe_req_display_state(MCE_DISPLAY_ON);
mce_datapipe_request_display_state(MCE_DISPLAY_ON);
}

/* suspend policy is affected by update mode */
Expand Down Expand Up @@ -9799,13 +9799,13 @@ static void mdy_setting_cb(GConfClient *const gcc, const guint id,
((mdy_low_power_mode_supported == FALSE) ||
(mdy_use_low_power_mode == FALSE) ||
(mdy_blanking_can_blank_from_low_power_mode() == TRUE))) {
mce_datapipe_req_display_state(MCE_DISPLAY_OFF);
mce_datapipe_request_display_state(MCE_DISPLAY_OFF);
}
else if ((display_state_curr == MCE_DISPLAY_OFF) &&
(mdy_use_low_power_mode == TRUE) &&
(mdy_blanking_can_blank_from_low_power_mode() == FALSE) &&
(mdy_low_power_mode_supported == TRUE)) {
mce_datapipe_req_display_state(MCE_DISPLAY_LPM_ON);
mce_datapipe_request_display_state(MCE_DISPLAY_LPM_ON);
}
}
else if (id == mdy_adaptive_dimming_enabled_setting_id) {
Expand Down Expand Up @@ -9855,7 +9855,7 @@ static void mdy_setting_cb(GConfClient *const gcc, const guint id,
if( prev != mdy_disp_never_blank ) {
mce_log(LL_NOTICE, "never_blank = %d", mdy_disp_never_blank);
if( mdy_disp_never_blank )
mce_datapipe_req_display_state(MCE_DISPLAY_ON);
mce_datapipe_request_display_state(MCE_DISPLAY_ON);
mdy_blanking_rethink_timers(true);
}
}
Expand Down Expand Up @@ -10570,7 +10570,7 @@ const gchar *g_module_check_init(GModule *module)
* gets notification from DSME */
mce_log(LL_INFO, "initial display mode = %s",
display_is_on ? "ON" : "OFF");
mce_datapipe_req_display_state(display_is_on ?
mce_datapipe_request_display_state(display_is_on ?
MCE_DISPLAY_ON :
MCE_DISPLAY_OFF);

Expand Down
4 changes: 2 additions & 2 deletions powerkey.c
Expand Up @@ -813,7 +813,7 @@ pwrkey_action_blank(void)

mce_log(LL_DEBUG, "Requesting display=%s",
display_state_repr(request));
mce_datapipe_req_display_state(request);
mce_datapipe_request_display_state(request);
}

static void
Expand Down Expand Up @@ -1942,7 +1942,7 @@ homekey_stm_set_state(homekey_stm_t state)
/* Initiate display power up */
mce_log(LL_DEBUG, "request %s",
display_state_repr(MCE_DISPLAY_ON));
mce_datapipe_req_display_state(MCE_DISPLAY_ON);
mce_datapipe_request_display_state(MCE_DISPLAY_ON);
break;

case HOMEKEY_STM_SEND_SIGNAL:
Expand Down
40 changes: 10 additions & 30 deletions tests/ut/ut_display.c
Expand Up @@ -1508,9 +1508,7 @@ START_TEST (ut_check_basic_state_change_no_lpm)
display_state_name(state_changes[i].required),
display_state_name(state_changes[i].expected));

datapipe_exec_full(&display_state_request_pipe,
GINT_TO_POINTER(state_changes[i].required),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_display_state(state_changes[i].required);
ut_assert_transition(ut_is_display_state_eq,
GINT_TO_POINTER(state_changes[i].expected));
}
Expand Down Expand Up @@ -1557,9 +1555,7 @@ START_TEST (ut_check_basic_state_change)
display_state_name(state_changes[i].required),
display_state_name(state_changes[i].expected));

datapipe_exec_full(&display_state_request_pipe,
GINT_TO_POINTER(state_changes[i].required),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_display_state(state_changes[i].required);
ut_assert_transition(ut_is_display_state_eq,
GINT_TO_POINTER(state_changes[i].expected));
}
Expand All @@ -1574,9 +1570,7 @@ START_TEST (ut_check_auto_blank_no_lpm)

ut_run_to_user_state();

datapipe_exec_full(&display_state_request_pipe,
GINT_TO_POINTER(MCE_DISPLAY_DIM),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_display_state(MCE_DISPLAY_DIM);
ut_assert_transition(ut_is_display_state_eq,
GINT_TO_POINTER(MCE_DISPLAY_DIM));

Expand All @@ -1600,9 +1594,7 @@ START_TEST (ut_check_auto_blank)

ut_run_to_user_state();

datapipe_exec_full(&display_state_request_pipe,
GINT_TO_POINTER(MCE_DISPLAY_LPM_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_display_state(MCE_DISPLAY_LPM_ON);
ut_assert_transition(ut_is_display_state_eq,
GINT_TO_POINTER(MCE_DISPLAY_LPM_ON));

Expand Down Expand Up @@ -1718,9 +1710,7 @@ START_TEST (ut_check_adaptive_dim_timeout)
- UT_COMPARE_TIME_TRESHOLD);
/* Verify adaptive_dimming_index=1 by meassuring time to re-enter DIM */
expected_dim_time = ut_nth_possible_dim_timeout(forced_dti + 1);
datapipe_exec_full(&display_state_request_pipe,
GINT_TO_POINTER(MCE_DISPLAY_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_display_state(MCE_DISPLAY_ON);
ut_assert_transition(ut_is_display_state_eq,
GINT_TO_POINTER(MCE_DISPLAY_ON));
ut_assert_transition_time_eq(ut_is_display_state_eq,
Expand All @@ -1733,9 +1723,7 @@ START_TEST (ut_check_adaptive_dim_timeout)
+ UT_COMPARE_TIME_TRESHOLD);
/* Verify adaptive_dimming_index=0 by meassuring time to re-enter DIM */
expected_dim_time = ut_nth_possible_dim_timeout(forced_dti + 0);
datapipe_exec_full(&display_state_request_pipe,
GINT_TO_POINTER(MCE_DISPLAY_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_display_state(MCE_DISPLAY_ON);
ut_assert_transition(ut_is_display_state_eq,
GINT_TO_POINTER(MCE_DISPLAY_ON));
ut_assert_transition_time_eq(ut_is_display_state_eq,
Expand Down Expand Up @@ -1773,9 +1761,7 @@ START_TEST (ut_check_auto_lpm)

ut_run_to_user_state();

datapipe_exec_full(&display_state_request_pipe,
GINT_TO_POINTER(MCE_DISPLAY_DIM),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_display_state(MCE_DISPLAY_DIM);
ut_assert_transition(ut_is_display_state_eq,
GINT_TO_POINTER(MCE_DISPLAY_DIM));

Expand Down Expand Up @@ -1859,9 +1845,7 @@ START_TEST (ut_check_blanking_pause)
stub__mce_setting_set_int(MCE_SETTING_DISPLAY_DIM_TIMEOUT_PATH,
set_disp_dim_timeout);

datapipe_exec_full(&display_state_request_pipe,
GINT_TO_POINTER(data[_i].initial_display_state),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_display_state(data[_i].initial_display_state);
ut_assert_transition(ut_is_display_state_eq,
GINT_TO_POINTER(data[_i].initial_display_state));

Expand Down Expand Up @@ -1970,9 +1954,7 @@ START_TEST (ut_check_set_use_lpm_while_off)
{
ut_run_to_user_state();

datapipe_exec_full(&display_state_request_pipe,
GINT_TO_POINTER(MCE_DISPLAY_OFF),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_display_state(MCE_DISPLAY_OFF);
ut_assert_transition(ut_is_display_state_eq,
GINT_TO_POINTER(MCE_DISPLAY_OFF));

Expand Down Expand Up @@ -2014,9 +1996,7 @@ START_TEST (ut_check_unset_use_lpm_while_lpm)
display_type_t required_lpm_state = data[_i].lpm_on
? MCE_DISPLAY_LPM_ON
: MCE_DISPLAY_LPM_OFF;
datapipe_exec_full(&display_state_request_pipe,
GINT_TO_POINTER(required_lpm_state),
USE_INDATA, CACHE_INDATA);
mce_datapipe_request_display_state(required_lpm_state);
ut_assert_transition(ut_is_display_state_eq,
GINT_TO_POINTER(required_lpm_state));

Expand Down
26 changes: 13 additions & 13 deletions tklock.c
Expand Up @@ -1512,7 +1512,7 @@ static void tklock_datapipe_submode_cb(gconstpointer data)
/* Nevertheless, removal of tklock means there is something
* happening at the ui side - and probably the best course of
* action is to cancel lpm state by turning on the display. */
mce_datapipe_req_display_state(MCE_DISPLAY_ON);
mce_datapipe_request_display_state(MCE_DISPLAY_ON);
break;

default:
Expand Down Expand Up @@ -1568,7 +1568,7 @@ static void tklock_datapipe_lockkey_state_cb(gconstpointer const data)
* etc, so we can just blindly request it.
*/
mce_datapipe_request_tklock(TKLOCK_REQUEST_ON);
mce_datapipe_req_display_state(MCE_DISPLAY_OFF);
mce_datapipe_request_display_state(MCE_DISPLAY_OFF);
break;

default:
Expand All @@ -1578,7 +1578,7 @@ static void tklock_datapipe_lockkey_state_cb(gconstpointer const data)
case MCE_DISPLAY_LPM_ON:
case MCE_DISPLAY_POWER_DOWN:
mce_log(LL_DEBUG, "display -> on");
mce_datapipe_req_display_state(MCE_DISPLAY_ON);
mce_datapipe_request_display_state(MCE_DISPLAY_ON);
break;
}

Expand Down Expand Up @@ -2838,7 +2838,7 @@ static void tklock_lidpolicy_rethink(void)
/* Blank display + lock ui */
if( tklock_lid_close_actions != LID_CLOSE_ACTION_DISABLED ) {
mce_log(LL_DEVEL, "lid closed - blank");
mce_datapipe_req_display_state(MCE_DISPLAY_OFF);
mce_datapipe_request_display_state(MCE_DISPLAY_OFF);
}

if( tklock_lid_close_actions == LID_CLOSE_ACTION_TKLOCK ) {
Expand All @@ -2851,7 +2851,7 @@ static void tklock_lidpolicy_rethink(void)
/* Unblank display + unlock ui */
if( tklock_lid_open_actions != LID_OPEN_ACTION_DISABLED ) {
mce_log(LL_DEVEL, "lid open - unblank");
mce_datapipe_req_display_state(MCE_DISPLAY_ON);
mce_datapipe_request_display_state(MCE_DISPLAY_ON);
}

if( tklock_lid_open_actions == LID_OPEN_ACTION_TKUNLOCK ) {
Expand Down Expand Up @@ -2912,7 +2912,7 @@ static void tklock_keyboard_slide_opened(void)
/* Check what actions are wanted */
if( tklock_kbd_open_actions != LID_OPEN_ACTION_DISABLED ) {
mce_log(LL_DEVEL, "kbd slide open - unblank");
mce_datapipe_req_display_state(MCE_DISPLAY_ON);
mce_datapipe_request_display_state(MCE_DISPLAY_ON);
}

if( tklock_kbd_open_actions == LID_OPEN_ACTION_TKUNLOCK ) {
Expand Down Expand Up @@ -2955,7 +2955,7 @@ static void tklock_keyboard_slide_closed(void)
/* Check what actions are wanted */
if( tklock_kbd_close_actions != LID_CLOSE_ACTION_DISABLED ) {
mce_log(LL_DEVEL, "kbd slide closed - blank");
mce_datapipe_req_display_state(MCE_DISPLAY_OFF);
mce_datapipe_request_display_state(MCE_DISPLAY_OFF);
}

if( tklock_kbd_close_actions == LID_CLOSE_ACTION_TKLOCK ) {
Expand Down Expand Up @@ -3533,7 +3533,7 @@ static void tklock_uiexception_rethink(void)
else {
mce_log(LL_DEBUG, "display blank");
}
mce_datapipe_req_display_state(MCE_DISPLAY_OFF);
mce_datapipe_request_display_state(MCE_DISPLAY_OFF);
}
else {
mce_log(LL_DEBUG, "display already blanked");
Expand Down Expand Up @@ -3566,7 +3566,7 @@ static void tklock_uiexception_rethink(void)
}
else if( display_state_curr != MCE_DISPLAY_ON ) {
mce_log(LL_DEBUG, "display unblank");
mce_datapipe_req_display_state(MCE_DISPLAY_ON);
mce_datapipe_request_display_state(MCE_DISPLAY_ON);
}
}

Expand Down Expand Up @@ -3635,7 +3635,7 @@ static void tklock_uiexception_finish(void)
default:
/* If the display was not clearly ON when exception started,
* turn it OFF after exceptions are over. */
mce_datapipe_req_display_state(MCE_DISPLAY_OFF);
mce_datapipe_request_display_state(MCE_DISPLAY_OFF);
break;

case MCE_DISPLAY_ON:
Expand All @@ -3651,7 +3651,7 @@ static void tklock_uiexception_finish(void)
lid_sensor_filtered == COVER_CLOSED )
break;

mce_datapipe_req_display_state(exx.display);
mce_datapipe_request_display_state(exx.display);
break;
}
EXIT:
Expand Down Expand Up @@ -4007,7 +4007,7 @@ static void tklock_lpmui_rethink(void)
/* Note: Display plugin handles MCE_DISPLAY_LPM_ON request as
* MCE_DISPLAY_OFF unless lpm mode is both supported
* and enabled. */
mce_datapipe_req_display_state(MCE_DISPLAY_LPM_ON);
mce_datapipe_request_display_state(MCE_DISPLAY_LPM_ON);
}

EXIT:
Expand Down Expand Up @@ -6847,7 +6847,7 @@ void mce_tklock_unblank(display_state_t to_state)
tklock_uiexception_begin(UIEXCEPTION_TYPE_NOANIM, 0);
}

mce_datapipe_req_display_state(to_state);
mce_datapipe_request_display_state(to_state);

EXIT:
return;
Expand Down

0 comments on commit fe7de61

Please sign in to comment.