Commit 6112f541 authored by spiiroin's avatar spiiroin

Implement iphb based timers for use from within mce

There are some mce state transitions that should be taken some time after
display is powered off and device has potentially entered late suspend.
These timers are re-evaluated when the device resume from suspend, but
that might be too late and applications can end up making decisions based
on mce state data that was frozen in time.

There are nemo-keepalive interfaces that use libiphb for waking up from
suspend, but those can't be used from mce because they depend on mce for
keeping the device away from suspend via mce cpu-keepalive dbus-service.

Add mce code module mce-hbtimer, which makes available: Timers that use
regular glib timeouts, but are backed up by iphb wakeups in case the
device gets suspended.

About the backdated copyright blurb: The code dealing with iphb wakeups
is derived from keepalive-heartbeat.c from nemo-keepalive package that
was written by me for Jolla and uses the same license as mce - LGPL v2.1.

[mce] Implement iphb based timers for use from within mce. Contributes to JB#28706
parent d9933390
......@@ -210,6 +210,22 @@ mce-hal.pic.o:\
mce-lib.h\
mce-log.h\
mce-hbtimer.o:\
mce-hbtimer.c\
datapipe.h\
libwakelock.h\
mce-hbtimer.h\
mce-log.h\
mce.h\
mce-hbtimer.pic.o:\
mce-hbtimer.c\
datapipe.h\
libwakelock.h\
mce-hbtimer.h\
mce-log.h\
mce.h\
mce-hybris.o:\
mce-hybris.c\
datapipe.h\
......@@ -315,6 +331,7 @@ mce.o:\
mce-dsme.h\
mce-fbdev.h\
mce-gconf.h\
mce-hbtimer.h\
mce-log.h\
mce-modules.h\
mce-sensorfw.h\
......@@ -336,6 +353,7 @@ mce.pic.o:\
mce-dsme.h\
mce-fbdev.h\
mce-gconf.h\
mce-hbtimer.h\
mce-log.h\
mce-modules.h\
mce-sensorfw.h\
......
......@@ -260,6 +260,7 @@ MCE_PKG_NAMES += gmodule-2.0
MCE_PKG_NAMES += dbus-1
MCE_PKG_NAMES += dbus-glib-1
MCE_PKG_NAMES += dsme
MCE_PKG_NAMES += libiphb
MCE_PKG_NAMES += libsystemd-daemon
MCE_PKG_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(MCE_PKG_NAMES))
......@@ -278,6 +279,7 @@ MCE_CORE += mce-fbdev.c
MCE_CORE += mce-dbus.c
MCE_CORE += mce-dsme.c
MCE_CORE += mce-gconf.c
MCE_CORE += mce-hbtimer.c
MCE_CORE += event-input.c
MCE_CORE += event-switches.c
MCE_CORE += mce-hal.c
......@@ -531,6 +533,8 @@ NORMALIZE_USES_SPC =\
mce-fbdev.h\
mce-command-line.c\
mce-command-line.h\
mce-hbtimer.c\
mce-hbtimer.h\
mce-hybris.c\
mce-hybris.h\
mce-modules.h\
......
This diff is collapsed.
/**
* @file mce-hbtimer.h
*
* Mode Control Entity - Suspend proof timer functionality
*
* <p>
*
* Copyright (C) 2014-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_HBTIMER_H_
# define MCE_HBTIMER_H_
# include <stdbool.h>
# include <glib.h>
# ifdef __cplusplus
extern "C" {
# endif
typedef struct mce_hbtimer_t mce_hbtimer_t;
mce_hbtimer_t * mce_hbtimer_create (const char *name, int period, GSourceFunc notify, void *user_data);
void mce_hbtimer_delete (mce_hbtimer_t *self);
bool mce_hbtimer_is_active (const mce_hbtimer_t *self);
const char *mce_hbtimer_get_name (const mce_hbtimer_t *self);
void mce_hbtimer_set_period (mce_hbtimer_t *self, int period);
void mce_hbtimer_start (mce_hbtimer_t *self);
void mce_hbtimer_stop (mce_hbtimer_t *self);
void mce_hbtimer_dispatch (void);
void mce_hbtimer_init (void);
void mce_hbtimer_quit (void);
# ifdef __cplusplus
};
# endif
#endif /* MCE_HBTIMER_H_ */
......@@ -23,6 +23,7 @@
#include "mce-log.h"
#include "mce-conf.h"
#include "mce-fbdev.h"
#include "mce-hbtimer.h"
#include "mce-gconf.h"
#include "mce-dbus.h"
#include "mce-dsme.h"
......@@ -114,6 +115,7 @@ static void mce_cleanup_wakelocks(void)
wakelock_unlock("mce_led_breathing");
wakelock_unlock("mce_lpm_off");
wakelock_unlock("mce_tklock_notify");
wakelock_unlock("mce_hbtimer_dispatch");
}
#endif // ENABLE_WAKELOCKS
......@@ -965,6 +967,9 @@ int main(int argc, char **argv)
/* Setup all datapipes */
mce_datapipe_init();
/* Allow registering of suspend proof timers */
mce_hbtimer_init();
/* Initialise mode management
* pre-requisite: mce_gconf_init()
* pre-requisite: mce_dbus_init()
......@@ -1049,6 +1054,7 @@ EXIT:
mce_powerkey_exit();
mce_dsme_exit();
mce_mode_exit();
mce_hbtimer_quit();
/* Free all datapipes */
mce_datapipe_quit();
......
......@@ -17,6 +17,7 @@ Conflicts: lipstick-qt5 < 0.24.7
BuildRequires: pkgconfig(dbus-1) >= 1.0.2
BuildRequires: pkgconfig(dbus-glib-1)
BuildRequires: pkgconfig(dsme) >= 0.58
BuildRequires: pkgconfig(libiphb)
BuildRequires: pkgconfig(glib-2.0) >= 2.36.0
BuildRequires: pkgconfig(mce) >= 1.15.0
BuildRequires: pkgconfig(libsystemd-daemon)
......
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