Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Reset lid-sensor-is-working status on triple powerkey press
Similarly to proximity sensor, it is now possible to configure also
the lid sensor to block power key events. This makes it difficult to
recover from situations where the sensor suddenly starts misbehaving.

Triple powerkey press can already be used to force cached proximity
sensor state to not-covered position. Use the same triggering mechanism
to reset lid-sensor-is-working status. Effectively the sensor is ignored
until the next time it switches to open position.

[mce] Reset lid-sensor-is-working status on triple powerkey press. Contributes to JB#29011
  • Loading branch information
spiiroin committed Jun 11, 2015
1 parent 4b8d964 commit 6939d83
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions powerkey.c
Expand Up @@ -532,8 +532,12 @@ pwrkey_ps_override_evaluate(void)
cover_state_t proximity_sensor_state =
datapipe_get_gint(proximity_sensor_pipe);

/* If the sensor is not covered, just reset the counter */
if( proximity_sensor_state != COVER_CLOSED ) {
cover_state_t lid_cover_policy_state =
datapipe_get_gint(lid_cover_policy_pipe);

/* If neither sensor is not covered, just reset the counter */
if( proximity_sensor_state != COVER_CLOSED &&
lid_cover_policy_state != COVER_CLOSED ) {
t_last = 0, count = 0;
goto EXIT;
}
Expand All @@ -560,16 +564,33 @@ pwrkey_ps_override_evaluate(void)
* If sensor gets unstuck and new proximity readings are
* received, this override will be automatically undone.
*/
if( ++count == pwrkey_ps_override_count ) {

if( ++count != pwrkey_ps_override_count ) {
mce_log(LL_DEBUG, "ps override count = %d", count);
goto EXIT;
}

if( proximity_sensor_state == COVER_CLOSED ) {
mce_log(LL_CRIT, "assuming stuck proximity sensor;"
" faking uncover event");

/* Force cached proximity state to "open" */
execute_datapipe(&proximity_sensor_pipe,
GINT_TO_POINTER(COVER_OPEN),
USE_INDATA, CACHE_INDATA);
t_last = 0, count = 0;
}
else
mce_log(LL_DEBUG, "ps override count = %d", count);

if( lid_cover_policy_state == COVER_CLOSED ) {
mce_log(LL_CRIT, "assuming stuck lid sensor;"
" resetting validation data");

/* Reset lid sensor validation data */
execute_datapipe(&lid_sensor_is_working_pipe,
GINT_TO_POINTER(false),
USE_INDATA, CACHE_INDATA);
}

t_last = 0, count = 0;

EXIT:

Expand Down

0 comments on commit 6939d83

Please sign in to comment.