Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Synchronize double tap recalibrations with DSME
DSME sends PING messages periodically, causing wakeups. Synchronize
recalibrations with these to reduce total amount of wakeups.
  • Loading branch information
Santtu Lakkala committed Nov 22, 2011
1 parent 0ee52bb commit 0ffe99b
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -3,7 +3,7 @@
# Written by David Weinehall
# Modified by Tuomo Tanskanen

VERSION := 1.11.17
VERSION := 1.11.18

INSTALL := install -o root -g root --mode=755
INSTALL_DIR := install -d
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
@@ -1,3 +1,9 @@
mce (1.11.18) unstable; urgency=low

* Synchronize double tap recalibrations with DSME PINGs

-- Santtu Lakkala <ext-santtu.1.lakkala@nokia.com> Tue, 22 Nov 2011 13:24:16 +0200

mce (1.11.17) unstable; urgency=low

* Recalibrate double tap with growing intervals (Fixes: NB#273570)
Expand Down
3 changes: 3 additions & 0 deletions mce-dsme.c
Expand Up @@ -159,6 +159,9 @@ static void dsme_send_pong(void)
mce_dsme_send(&msg);
mce_log(LL_DEBUG,
"DSM_MSGTYPE_PROCESSWD_PONG sent to DSME");

execute_datapipe(&heartbeat_pipe, GINT_TO_POINTER(0),
USE_INDATA, DONT_CACHE_INDATA);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions mce.c
Expand Up @@ -623,6 +623,8 @@ int main(int argc, char **argv)
0, GINT_TO_POINTER(0));
setup_datapipe(&thermal_state_pipe, READ_ONLY, DONT_FREE_CACHE,
0, GINT_TO_POINTER(THERMAL_STATE_UNDEF));
setup_datapipe(&heartbeat_pipe, READ_ONLY, DONT_FREE_CACHE,
0, GINT_TO_POINTER(0));

/* Initialise mode management
* pre-requisite: mce_gconf_init()
Expand Down Expand Up @@ -732,6 +734,7 @@ int main(int argc, char **argv)
free_datapipe(&call_state_pipe);
free_datapipe(&master_radio_pipe);
free_datapipe(&system_state_pipe);
free_datapipe(&heartbeat_pipe);

/* Call the exit function for all subsystems */
mce_gconf_exit();
Expand Down
2 changes: 2 additions & 0 deletions mce.h
Expand Up @@ -327,6 +327,8 @@ datapipe_struct jack_sense_pipe;
datapipe_struct power_saving_mode_pipe;
/** Thermal state; read only */
datapipe_struct thermal_state_pipe;
/** Heartbeat; read only */
datapipe_struct heartbeat_pipe;

/* XXX: use HAL */
/** Does the device have a flicker key? */
Expand Down
46 changes: 39 additions & 7 deletions tklock.c
Expand Up @@ -181,6 +181,9 @@ static guint doubletap_recal_index = 0;
/** Double tap recalibration toumeout identifier */
static guint doubletap_recal_timeout_id = 0;

/** Do double tap recalibration on heartbeat */
static gboolean doubletap_recal_on_heartbeat = FALSE;

/** TKLock saved state type */
typedef enum {
/** TKLock was not enabled */
Expand Down Expand Up @@ -361,6 +364,22 @@ static gboolean is_pocket_mode_enabled(void)
return ((mce_get_submode_int32() & MCE_POCKET_SUBMODE) != 0);
}

/**
* Heartbeat trigger
*
* @param data Not used
*/
static void heartbeat_trigger(gconstpointer data)
{
(void)data;

if (doubletap_recal_on_heartbeat == TRUE) {
mce_log(LL_DEBUG, "Recalibrating double tap");
(void)mce_write_string_to_file(mce_touchscreen_calibration_control_path,
"1");
}
}

/**
* Callback for doubletap recalibration
*
Expand All @@ -371,17 +390,24 @@ static gboolean doubletap_recal_timeout_cb(gpointer data)
{
(void)data;

/* Hop to next delay, if available */
if (doubletap_recal_index < G_N_ELEMENTS(doubletap_recal_delays) - 1)
doubletap_recal_index++;
doubletap_recal_timeout_id =
g_timeout_add_seconds(doubletap_recal_delays[doubletap_recal_index],
doubletap_recal_timeout_cb, NULL);

mce_log(LL_DEBUG, "Recalibrating double tap");
(void)mce_write_string_to_file(mce_touchscreen_calibration_control_path,
"1");

/* If at last delay, start recalibrating on DSME heartbeat */
if (doubletap_recal_index == G_N_ELEMENTS(doubletap_recal_delays) - 1) {
doubletap_recal_timeout_id = 0;
doubletap_recal_on_heartbeat = TRUE;

return FALSE;
}

/* Otherwise use next delay */
doubletap_recal_index++;
doubletap_recal_timeout_id =
g_timeout_add_seconds(doubletap_recal_delays[doubletap_recal_index],
doubletap_recal_timeout_cb, NULL);

return FALSE;
}

Expand All @@ -393,6 +419,7 @@ static void cancel_doubletap_recal_timeout(void)
if (doubletap_recal_timeout_id != 0)
g_source_remove(doubletap_recal_timeout_id);
doubletap_recal_timeout_id = 0;
doubletap_recal_on_heartbeat = FALSE;
}

/**
Expand All @@ -405,6 +432,7 @@ static void setup_doubletap_recal_timeout(void)

cancel_doubletap_recal_timeout();
doubletap_recal_index = 0;
doubletap_recal_on_heartbeat = FALSE;

doubletap_recal_timeout_id =
g_timeout_add_seconds(doubletap_recal_delays[doubletap_recal_index],
Expand Down Expand Up @@ -3134,6 +3162,8 @@ gboolean mce_tklock_init(void)
jack_sense_trigger);
append_output_trigger_to_datapipe(&usb_cable_pipe,
usb_cable_trigger);
append_output_trigger_to_datapipe(&heartbeat_pipe,
heartbeat_trigger);

/* Touchscreen/keypad autolock */
/* Since we've set a default, error handling is unnecessary */
Expand Down Expand Up @@ -3273,6 +3303,8 @@ gboolean mce_tklock_init(void)
void mce_tklock_exit(void)
{
/* Remove triggers/filters from datapipes */
remove_output_trigger_from_datapipe(&heartbeat_pipe,
heartbeat_trigger);
remove_output_trigger_from_datapipe(&usb_cable_pipe,
usb_cable_trigger);
remove_output_trigger_from_datapipe(&jack_sense_pipe,
Expand Down

0 comments on commit 0ffe99b

Please sign in to comment.