Skip to content

Commit

Permalink
[display] Optionally disable suspend while charging. Fixes MER#1723
Browse files Browse the repository at this point in the history
If device does not firmware based doubletap detection, suspend must
be blocked to enable sw based doubletap detection. While this can be
handy during development, it consumes too much power for regular use.

As a compromise add option for disabling suspend, but only when charger
is connected.


Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Dec 21, 2016
1 parent dd3d352 commit 5e0a3bc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
13 changes: 13 additions & 0 deletions modules/display.c
Expand Up @@ -1494,8 +1494,16 @@ static void mdy_datapipe_charger_state_cb(gconstpointer data)
if( charger_state == prev )
goto EXIT;

mce_log(LL_DEBUG, "charger_state: %s -> %s",
charger_state_repr(prev),
charger_state_repr(charger_state));

// keep display on/dim while charging etc
mdy_blanking_rethink_timers(false);

// charging can block suspend
mdy_stm_schedule_rethink();

EXIT:
return;
}
Expand Down Expand Up @@ -5764,6 +5772,11 @@ static int mdy_autosuspend_get_allowed_level(void)
block_late = true;
break;

case SUSPEND_POLICY_DISABLE_ON_CHARGER:
if( charger_state == CHARGER_STATE_ON )
block_early = true;
break;

default:
case SUSPEND_POLICY_ENABLED:
break;
Expand Down
3 changes: 3 additions & 0 deletions modules/display.h
Expand Up @@ -509,6 +509,9 @@ enum

/** Allow on and early suspend, but never enter late suspend */
SUSPEND_POLICY_EARLY_ONLY = 2,

/** Disable suspend when charger is connected */
SUSPEND_POLICY_DISABLE_ON_CHARGER = 3,
};

/** Whether the device is allowed to automatically suspend [mode]
Expand Down
17 changes: 12 additions & 5 deletions tools/mcetool.c
Expand Up @@ -1445,9 +1445,10 @@ static const char *rlookup(const symbol_t *stab, int val)
* @note These must match the hardcoded values in mce itself.
*/
static const symbol_t suspendpol_values[] = {
{ "disabled", 0 },
{ "enabled", 1 },
{ "early", 2 },
{ "disabled", SUSPEND_POLICY_DISABLED },
{ "enabled", SUSPEND_POLICY_ENABLED },
{ "early", SUSPEND_POLICY_EARLY_ONLY },
{ "disable_on_charger", SUSPEND_POLICY_DISABLE_ON_CHARGER },
{ NULL, -1 }
};

Expand Down Expand Up @@ -6125,10 +6126,16 @@ static const mce_opt_t options[] =
.name = "set-suspend-policy",
.flag = 's',
.with_arg = xmce_set_suspend_policy,
.values = "enabled|disabled|early",
.values = "enabled|disabled|early|disable_on_charger",
.usage =
"set the autosuspend mode; valid modes are:\n"
"'enabled', 'disabled' and 'early'\n"
" enabled Allow early and late suspend. This is the default mode.\n"
" disabled Deny suspending altogether. Also display and touch panel should\n"
" stay powered on and allow sw double tap detection.\n"
" early Allow early suspend / display power off, but not late suspend\n"
" so that (at least one) cpu stays online.\n"
" disable_on_charger Switch between enabled and disabled based on charger\n"
" availability.\n"
},
{
.name = "get-suspend-stats",
Expand Down

0 comments on commit 5e0a3bc

Please sign in to comment.