Commit 1b5a256e authored by spiiroin's avatar spiiroin

[wakelock] Add module for virtual wakelocks. Contributes to JB#32462

MCE has multitude of reasons for blocking late suspend. Using real
wakelocks for each reason pollutes the kernel bookkeeping data and
using dynamically named wakelocks would make things even worse.

Add mce-wakelock module that multiplexes virtual wakelocks internal
to mce into just one real sysfs based wakelock.
parent fcf8376e
......@@ -330,6 +330,16 @@ mce-sensorfw.pic.o:\
mce-sensorfw.h\
mce.h\
mce-wakelock.o:\
mce-wakelock.c\
mce-log.h\
mce-wakelock.h\
mce-wakelock.pic.o:\
mce-wakelock.c\
mce-log.h\
mce-wakelock.h\
mce.o:\
mce.c\
builtin-gconf.h\
......@@ -347,6 +357,7 @@ mce.o:\
mce-log.h\
mce-modules.h\
mce-sensorfw.h\
mce-wakelock.h\
mce.h\
modetransition.h\
powerkey.h\
......@@ -369,6 +380,7 @@ mce.pic.o:\
mce-log.h\
mce-modules.h\
mce-sensorfw.h\
mce-wakelock.h\
mce.h\
modetransition.h\
powerkey.h\
......
......@@ -280,6 +280,7 @@ MCE_CORE += mce-dbus.c
MCE_CORE += mce-dsme.c
MCE_CORE += mce-gconf.c
MCE_CORE += mce-hbtimer.c
MCE_CORE += mce-wakelock.c
MCE_CORE += event-input.c
MCE_CORE += event-switches.c
MCE_CORE += mce-hal.c
......@@ -541,6 +542,8 @@ NORMALIZE_USES_SPC =\
mce-modules.h\
mce-sensorfw.c\
mce-sensorfw.h\
mce-wakelock.c\
mce-wakelock.h\
modetransition.h\
modules/audiorouting.c\
modules/battery-upower.c\
......
This diff is collapsed.
/** @file mce-wakelock.h
* Wakelock multiplexing code for the Mode Control Entity
* <p>
* Copyright (C) 2015 Jolla Ltd.
* <p>
* @author Simo Piiroinen <simo.piiroinen@jollamobile.com>
*
* mce is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* mce is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with mce. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MCE_WAKELOCK_H_
# define MCE_WAKELOCK_H_
# ifdef __cplusplus
extern "C" {
# elif 0
} /* fool JED indentation ... */
# endif
void mce_wakelock_obtain (const char *name, int duration_ms);
void mce_wakelock_release (const char *name);
void mce_wakelock_init (void);
void mce_wakelock_quit (void);
void mce_wakelock_abort (void);
# ifdef __cplusplus
};
# endif
#endif /* MCE_WAKELOCK_H_ */
......@@ -30,6 +30,7 @@
#include "mce-modules.h"
#include "mce-command-line.h"
#include "mce-sensorfw.h"
#include "mce-wakelock.h"
#include "tklock.h"
#include "powerkey.h"
#include "event-input.h"
......@@ -140,6 +141,7 @@ static void mce_exit_via_signal(int signr)
#ifdef ENABLE_WAKELOCKS
/* Cancel auto suspend */
mce_cleanup_wakelocks();
mce_wakelock_abort();
#endif
/* Try to exit via default handler */
signal(signr, SIG_DFL);
......@@ -916,6 +918,9 @@ int main(int argc, char **argv)
/* Since mce enables automatic suspend, we must try to
* disable it when mce process exits */
atexit(mce_cleanup_wakelocks);
/* Allow acquiring of multiplexed wakelock */
mce_wakelock_init();
#endif
/* Identify mce version & flavor on start up */
......@@ -1075,6 +1080,9 @@ EXIT:
/* Close signal pipe & remove io watch for it */
mce_quit_signal_pipe();
/* Release multiplexed wakelock */
mce_wakelock_quit();
/* Log a farewell message and close the log */
mce_log(LL_INFO, "Exiting...");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment