Skip to content

Commit

Permalink
Implement cpu-keepalive plugin for mce
Browse files Browse the repository at this point in the history
The cpu-keepalive plugin implementes dbus interface defined in
mce-headers >= 1.12.3.

Applications can query keepalive renew period via:
  MCE_CPU_KEEPALIVE_PERIOD_REQ

And then block suspend via:
  MCE_CPU_KEEPALIVE_START_REQ x N
  MCE_CPU_KEEPALIVE_STOP_REQ

The iphb plugin in dsme can signal wakeups via:
  MCE_CPU_KEEPALIVE_WAKEUP_REQ

While there are clients with active keepalive periods, mce will block
the device from entering late suspend.

If client with active keepalive perdiod drops from system bus, it will
be handled as if MCE_CPU_KEEPALIVE_STOP_REQ were made.

If mce is compiled without wakelock support, longer renew period is
reported by MCE_CPU_KEEPALIVE_PERIOD_REQ.

After receiving MCE_CPU_KEEPALIVE_WAKEUP_REQ from dsme, mce blocks
late suspend for a short while to allow clients using libiphb timers
to register keepalive periods.
  • Loading branch information
spiiroin committed Mar 1, 2013
1 parent b271b2d commit 1a4f929
Show file tree
Hide file tree
Showing 7 changed files with 1,048 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .depend
Expand Up @@ -352,6 +352,18 @@ modules/camera.pic.o:\
mce.h\
modules/camera.h\

modules/cpu-keepalive.o:\
modules/cpu-keepalive.c\
mce-dbus.h\
mce-log.h\
libwakelock.h\

modules/cpu-keepalive.pic.o:\
modules/cpu-keepalive.c\
mce-dbus.h\
mce-log.h\
libwakelock.h\

modules/display.o:\
modules/display.c\
datapipe.h\
Expand Down
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -147,6 +147,7 @@ MODULES += $(MODULE_DIR)/led.so
MODULES += $(MODULE_DIR)/callstate.so
MODULES += $(MODULE_DIR)/audiorouting.so
MODULES += $(MODULE_DIR)/powersavemode.so
MODULES += $(MODULE_DIR)/cpu-keepalive.so

# Tools to build
TOOLS += $(TOOLDIR)/mcetool
Expand Down
20 changes: 20 additions & 0 deletions mce-dbus.c
Expand Up @@ -52,6 +52,26 @@ typedef struct {
/** Pointer to the DBusConnection */
static DBusConnection *dbus_connection = NULL;



/** Return reference to dbus connection cached at mce-dbus module
*
* For use in situations where the abstraction provided by mce-dbus
* makes things too complicated.
*
* Caller must release non-null return values with dbus_connection_unref().
*
* @return DBusConnection, or NULL if mce has no dbus connection
*/
DBusConnection *dbus_connection_get(void)
{
if( !dbus_connection ) {
mce_log(LL_WARN, "no dbus connection");
return NULL;
}
return dbus_connection_ref(dbus_connection);
}

/**
* Create a new D-Bus signal, with proper error checking
* will exit the mainloop if an error occurs
Expand Down
2 changes: 2 additions & 0 deletions mce-dbus.h
Expand Up @@ -26,6 +26,8 @@

#include <mce/dbus-names.h>

DBusConnection *dbus_connection_get(void);

DBusMessage *dbus_new_signal(const gchar *const path,
const gchar *const interface,
const gchar *const name);
Expand Down
10 changes: 10 additions & 0 deletions mce.conf
Expand Up @@ -104,5 +104,15 @@
<allow send_destination="com.nokia.mce"
send_interface="com.nokia.mce.request"
send_member="req_led_disable"/>

<allow send_destination="com.nokia.mce"
send_interface="com.nokia.mce.request"
send_member="req_cpu_keepalive_period"/>
<allow send_destination="com.nokia.mce"
send_interface="com.nokia.mce.request"
send_member="req_cpu_keepalive_start"/>
<allow send_destination="com.nokia.mce"
send_interface="com.nokia.mce.request"
send_member="req_cpu_keepalive_stop"/>
</policy>
</busconfig>
2 changes: 1 addition & 1 deletion mce.ini
Expand Up @@ -16,7 +16,7 @@ ModulePath=/usr/lib/mce/modules
# to avoid unnecessary brightness fluctuations on mce startup
#
# Note: the name should not include the "lib"-prefix
Modules=radiostates;filter-brightness-als;display;keypad;led;battery;inactivity;alarm;callstate;audiorouting;proximity;powersavemode
Modules=radiostates;filter-brightness-als;display;keypad;led;battery;inactivity;alarm;callstate;audiorouting;proximity;powersavemode;cpu-keepalive


[HomeKey]
Expand Down

0 comments on commit 1a4f929

Please sign in to comment.