Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[datapipe] Elevate logging of display state requests. JB#36274
Analyzing reasons for pocket calls and other issues related to unwanted
display unblanking is next to impossible if reason for the display wakeup
is not known.

Use a wrapper macro that logs points in mce code base from which display
state request leading to actually powered up states are made.
  • Loading branch information
spiiroin committed Oct 11, 2016
1 parent 9671594 commit c4f0ba6
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 83 deletions.
31 changes: 31 additions & 0 deletions datapipe.h
Expand Up @@ -255,4 +255,35 @@ void datapipe_bindings_quit(datapipe_bindings_t *self);
void mce_datapipe_init(void);
void mce_datapipe_quit(void);

/* Helper for making display state requests
*
* This needs to be macro so that logging context stays
* at the point of call.
*/
#define mce_datapipe_req_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_);\
if( cur_target != req_target ) {\
int level = LL_DEBUG; \
switch( req_target ) {\
case MCE_DISPLAY_ON:\
case MCE_DISPLAY_LPM_ON:\
level = LL_CRUCIAL;\
break;\
default:\
break;\
}\
mce_log(level, "display state req: %s",\
display_state_repr(req_target));\
execute_datapipe(&display_state_req_pipe,\
GINT_TO_POINTER(req_target),\
USE_INDATA, CACHE_INDATA);\
}\
else {\
/* TODO: double check request handling and remove this logging */\
mce_log(LL_WARN, "ignoring display state req: %s",\
display_state_repr(req_target));\
}\
} while(0)

#endif /* _DATAPIPE_H_ */
4 changes: 1 addition & 3 deletions modetransition.c
Expand Up @@ -179,9 +179,7 @@ static void system_state_trigger(gconstpointer data)
switch( old_system_state ) {
case MCE_STATE_USER:
case MCE_STATE_ACTDEAD:
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(MCE_DISPLAY_ON);
break;

default:
Expand Down
48 changes: 13 additions & 35 deletions modules/display.c
Expand Up @@ -1686,9 +1686,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");
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(MCE_DISPLAY_ON);
break;

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

execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(display),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(display);

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

execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(next_state),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(next_state);

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

mdy_blanking_lpm_off_cb_id = 0;

execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_LPM_OFF),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(MCE_DISPLAY_LPM_OFF);

return FALSE;
}
Expand Down Expand Up @@ -4330,19 +4322,15 @@ static void mdy_blanking_rethink_proximity(void)
switch( display_state ) {
case MCE_DISPLAY_LPM_ON:
if( proximity_state == COVER_CLOSED )
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_LPM_OFF),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(MCE_DISPLAY_LPM_OFF);
else
mdy_blanking_schedule_lpm_off();
break;

case MCE_DISPLAY_LPM_OFF:
if( proximity_state == COVER_OPEN &&
lid_cover_policy_state != COVER_CLOSED )
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_LPM_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(MCE_DISPLAY_LPM_ON);
else
mdy_blanking_schedule_off();
break;
Expand Down Expand Up @@ -7721,9 +7709,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();

execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(state),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(state);
}

/**
Expand Down Expand Up @@ -8522,9 +8508,7 @@ static void mdy_flagfiles_update_mode_cb(const char *path,

if( mdy_update_mode ) {
/* Issue display on request when update mode starts */
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(MCE_DISPLAY_ON);
}

/* suspend policy is affected by update mode */
Expand Down Expand Up @@ -8821,17 +8805,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))) {
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_OFF),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(MCE_DISPLAY_OFF);
}
else if ((display_state == MCE_DISPLAY_OFF) &&
(mdy_use_low_power_mode == TRUE) &&
(mdy_blanking_can_blank_from_low_power_mode() == FALSE) &&
(mdy_low_power_mode_supported == TRUE)) {
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_LPM_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(MCE_DISPLAY_LPM_ON);
}
}
else if (id == mdy_adaptive_dimming_enabled_setting_id) {
Expand Down Expand Up @@ -9588,11 +9568,9 @@ 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");
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(display_is_on ?
MCE_DISPLAY_ON :
MCE_DISPLAY_OFF),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(display_is_on ?
MCE_DISPLAY_ON :
MCE_DISPLAY_OFF);

/* Start the framebuffer sleep/wakeup thread */
#ifdef ENABLE_WAKELOCKS
Expand Down
8 changes: 2 additions & 6 deletions powerkey.c
Expand Up @@ -815,9 +815,7 @@ pwrkey_action_blank(void)

mce_log(LL_DEBUG, "Requesting display=%s",
display_state_repr(request));
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(request),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(request);
}

static void
Expand Down Expand Up @@ -1921,9 +1919,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));
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(MCE_DISPLAY_ON);
break;

case HOMEKEY_STM_SEND_SIGNAL:
Expand Down
53 changes: 14 additions & 39 deletions tklock.c
Expand Up @@ -1450,9 +1450,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. */
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(MCE_DISPLAY_ON);
break;

default:
Expand Down Expand Up @@ -1507,9 +1505,7 @@ static void tklock_datapipe_lockkey_cb(gconstpointer const data)
GINT_TO_POINTER(LOCK_ON),
USE_INDATA, CACHE_INDATA);

execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_OFF),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(MCE_DISPLAY_OFF);
break;

default:
Expand All @@ -1519,9 +1515,7 @@ static void tklock_datapipe_lockkey_cb(gconstpointer const data)
case MCE_DISPLAY_LPM_ON:
case MCE_DISPLAY_POWER_DOWN:
mce_log(LL_DEBUG, "display -> on");
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(MCE_DISPLAY_ON);
break;
}

Expand Down Expand Up @@ -2775,9 +2769,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");
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_OFF),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(MCE_DISPLAY_OFF);
}

if( tklock_lid_close_actions == LID_CLOSE_ACTION_TKLOCK ) {
Expand All @@ -2792,9 +2784,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");
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(MCE_DISPLAY_ON);
}

if( tklock_lid_open_actions == LID_OPEN_ACTION_TKUNLOCK ) {
Expand Down Expand Up @@ -2857,9 +2847,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");
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(MCE_DISPLAY_ON);
}

if( tklock_kbd_open_actions == LID_OPEN_ACTION_TKUNLOCK ) {
Expand Down Expand Up @@ -2904,9 +2892,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");
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_OFF),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(MCE_DISPLAY_OFF);
}

if( tklock_kbd_close_actions == LID_CLOSE_ACTION_TKLOCK ) {
Expand Down Expand Up @@ -3477,9 +3463,7 @@ static void tklock_uiexcept_rethink(void)
else {
mce_log(LL_DEBUG, "display blank");
}
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_OFF),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(MCE_DISPLAY_OFF);
}
else {
mce_log(LL_DEBUG, "display already blanked");
Expand Down Expand Up @@ -3512,9 +3496,7 @@ static void tklock_uiexcept_rethink(void)
}
else if( display_state != MCE_DISPLAY_ON ) {
mce_log(LL_DEBUG, "display unblank");
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(MCE_DISPLAY_ON);
}
}

Expand Down Expand Up @@ -3584,9 +3566,7 @@ static void tklock_uiexcept_finish(void)
default:
/* If the display was not clearly ON when exception started,
* turn it OFF after exceptions are over. */
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_OFF),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(MCE_DISPLAY_OFF);
break;

case MCE_DISPLAY_ON:
Expand All @@ -3602,9 +3582,7 @@ static void tklock_uiexcept_finish(void)
lid_cover_policy_state == COVER_CLOSED )
break;

execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(exx.display),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(exx.display);
break;
}
EXIT:
Expand Down Expand Up @@ -3940,9 +3918,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. */
execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(MCE_DISPLAY_LPM_ON),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(MCE_DISPLAY_LPM_ON);
}

EXIT:
Expand Down Expand Up @@ -6665,9 +6641,8 @@ void mce_tklock_unblank(display_state_t to_state)
tklock_uiexcept_begin(UIEXC_NOANIM, 0);
}

execute_datapipe(&display_state_req_pipe,
GINT_TO_POINTER(to_state),
USE_INDATA, CACHE_INDATA);
mce_datapipe_req_display_state(to_state);

EXIT:
return;
}

0 comments on commit c4f0ba6

Please sign in to comment.