Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added functions allowing/blocking automatic suspend
When android kernels are used, MCE needs to control whether early suspend
should be used or not. The sysfs interface is used via the new functions:
wakelock_allow_suspend() and wakelock_block_suspend().
  • Loading branch information
spiiroin committed Dec 11, 2012
1 parent a74cd51 commit ecf2a96
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
29 changes: 29 additions & 0 deletions libwakelock.c
Expand Up @@ -104,3 +104,32 @@ void wakelock_unlock(const char *name)
lwl_write_file(lwl_unlock_path, tmp);
}
}

static const char lwl_state_path[] = "/sys/power/state";

/** Use sysfs interface to allow automatic entry to suspend
*
* After this call the device will enter suspend mode once all
* the wakelocks have been released.
*
* Android kernels will enter early suspend (i.e. display is
* turned off etc) even if there still are active wakelocks.
*/
void wakelock_allow_suspend(void)
{
if( lwl_enabled() ) {
lwl_write_file(lwl_state_path, "mem\n");
}
}

/** Use sysfs interface to block automatic entry to suspend
*
* The device will not enter suspend mode with or without
* active wakelocks.
*/
void wakelock_block_suspend(void)
{
if( lwl_enabled() ) {
lwl_write_file(lwl_state_path, "on\n");
}
}
3 changes: 3 additions & 0 deletions libwakelock.h
Expand Up @@ -16,6 +16,9 @@ extern "C" {
void wakelock_lock (const char *name, long long ns);
void wakelock_unlock(const char *name);

void wakelock_allow_suspend(void);
void wakelock_block_suspend(void);

# ifdef __cplusplus
};
# endif
Expand Down

0 comments on commit ecf2a96

Please sign in to comment.