Commit d9c917b7 authored by spiiroin's avatar spiiroin

[proximity] On-demand proximity sensor activation. Fixes JB#34789 MER#1562

MCE code has built-in assumption that proximity sensor is either not used at
all, or it is constantly powered on. The former basically means that in-call
proximity blanking is not available. And the latter can cause direct (the
sensor itself) or indirect (might block suspend) power drain, or make it
more likely for lower level sensor handling glitches to surface.

Make it possible to select on-demand proximity sensor activation.

When selected, proximity sensor is powered up:
- While the device in a state where it might be needed (calls, alarms, etc).
- When events that could lead to display wakeup are received (powerkey
  presses, doubletaps, etc).

As the sensor state is not available immediately after requesting
sensor powerup, implement on-proximity action queue which can be used
to schedule actions to be taken when the sensor has reached a stable
state.
Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
parent 4b25492b
......@@ -41,6 +41,7 @@ builtin-gconf.pic.o:\
datapipe.o:\
datapipe.c\
datapipe.h\
evdev.h\
mce-lib.h\
mce-log.h\
mce.h\
......@@ -48,6 +49,7 @@ datapipe.o:\
datapipe.pic.o:\
datapipe.c\
datapipe.h\
evdev.h\
mce-lib.h\
mce-log.h\
mce.h\
......@@ -142,6 +144,7 @@ mce-common.o:\
datapipe.h\
mce-common.h\
mce-dbus.h\
mce-lib.h\
mce-log.h\
mce.h\
......@@ -151,6 +154,7 @@ mce-common.pic.o:\
datapipe.h\
mce-common.h\
mce-dbus.h\
mce-lib.h\
mce-log.h\
mce.h\
......@@ -928,6 +932,7 @@ modules/proximity.o:\
modules/proximity.c\
builtin-gconf.h\
datapipe.h\
mce-lib.h\
mce-log.h\
mce-sensorfw.h\
mce-setting.h\
......@@ -938,6 +943,7 @@ modules/proximity.pic.o:\
modules/proximity.c\
builtin-gconf.h\
datapipe.h\
mce-lib.h\
mce-log.h\
mce-sensorfw.h\
mce-setting.h\
......
/* ------------------------------------------------------------------------- *
* Copyright (C) 2012-2014 Jolla Ltd.
* Contact: Simo Piiroinen <simo.piiroinen@jollamobile.com>
* License: LGPLv2
* ------------------------------------------------------------------------- */
/**
* @file builtin-gconf.c
* GConf compatibility module - for dynamic mce settings
* <p>
* Copyright (C) 2012-2019 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/>.
*/
/* ------------------------------------------------------------------------- *
* NOTE: This module implements just enough of the GConf API to allow us
......@@ -1592,6 +1607,11 @@ static const setting_t gconf_defaults[] =
.type = "b",
.def = G_STRINGIFY(MCE_DEFAULT_PROXIMITY_PS_ENABLED),
},
{
.key = MCE_SETTING_PROXIMITY_ON_DEMAND,
.type = "b",
.def = G_STRINGIFY(MCE_DEFAULT_PROXIMITY_ON_DEMAND),
},
{
.key = MCE_SETTING_PROXIMITY_PS_ACTS_AS_LID,
.type = "b",
......
......@@ -4,7 +4,7 @@
* this can be used to filter data and to setup data triggers
* <p>
* Copyright © 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
* Copyright (C) 2014-2017 Jolla Ltd.
* Copyright (C) 2014-2019 Jolla Ltd.
* <p>
* @author David Weinehall <david.weinehall@nokia.com>
* @author Simo Piiroinen <simo.piiroinen@jollamobile.com>
......@@ -630,6 +630,31 @@ datapipe_t lens_cover_state_pipe = DATAPIPE_INIT(lens_cover_state
/** Proximity sensor; read only */
datapipe_t proximity_sensor_actual_pipe = DATAPIPE_INIT(proximity_sensor_actual, cover_state, COVER_OPEN, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT);
/** Proximity sensor; read only */
datapipe_t proximity_sensor_effective_pipe = DATAPIPE_INIT(proximity_sensor_effective, cover_state, COVER_UNDEF, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT);
/** Proximity sensor on-demand control; write only
*
* The data fed into proximity_sensor_required_pipe needs to
* be a statically allocated const string with format like:
*
* "<PREFIX><NAME>"
*
* Where <PREFIX> is one of:
*
* - PROXIMITY_SENSOR_REQUIRED_ADD: <NAME> is added to the
* list of resons to keep on-demand proximity sensor mode
* active.
*
* - PROXIMITY_SENSOR_REQUIRED_REM: <NAME> is from the the
* list of resons to keep on-demand proximity sensor mode
* active.
*/
datapipe_t proximity_sensor_required_pipe = DATAPIPE_INIT(proximity_sensor_required, string, 0, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_NOTHING);
/** proximity blanking; read only */
datapipe_t proximity_blanked_pipe = DATAPIPE_INIT(proximity_blanked, boolean, false, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT);
/** Ambient light sensor; read only */
datapipe_t light_sensor_actual_pipe = DATAPIPE_INIT(light_sensor_actual, int, 400, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT);
......@@ -766,9 +791,6 @@ datapipe_t keypad_grab_active_pipe = DATAPIPE_INIT(keypad_grab_acti
/** music playback active; read only */
datapipe_t music_playback_ongoing_pipe = DATAPIPE_INIT(music_playback_ongoing, boolean, false, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT);
/** proximity blanking; read only */
datapipe_t proximity_blanked_pipe = DATAPIPE_INIT(proximity_blanked, boolean, false, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT);
/** fingerprint daemon availability; read only */
datapipe_t fpd_service_state_pipe = DATAPIPE_INIT(fpd_service_state, service_state, SERVICE_STATE_UNDEF, 0, DATAPIPE_FILTERING_DENIED, DATAPIPE_CACHE_DEFAULT);
......@@ -1265,6 +1287,9 @@ void mce_datapipe_quit(void)
datapipe_free(&interaction_expected_pipe);
datapipe_free(&tklock_request_pipe);
datapipe_free(&proximity_sensor_actual_pipe);
datapipe_free(&proximity_sensor_effective_pipe);
datapipe_free(&proximity_sensor_required_pipe);
datapipe_free(&proximity_blanked_pipe);
datapipe_free(&light_sensor_actual_pipe);
datapipe_free(&light_sensor_filtered_pipe);
datapipe_free(&light_sensor_poll_request_pipe);
......@@ -1320,7 +1345,6 @@ void mce_datapipe_quit(void)
datapipe_free(&keypad_grab_active_pipe);
datapipe_free(&keypad_grab_wanted_pipe);
datapipe_free(&music_playback_ongoing_pipe);
datapipe_free(&proximity_blanked_pipe);
datapipe_free(&fpd_service_state_pipe);
datapipe_free(&fpstate_pipe);
datapipe_free(&enroll_in_progress_pipe);
......
......@@ -3,8 +3,10 @@
* Headers for the simple filter framework
* <p>
* Copyright © 2007 Nokia Corporation and/or its subsidiary(-ies).
* Copyright (C) 2014-2019 Jolla Ltd.
* <p>
* @author David Weinehall <david.weinehall@nokia.com>
* @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
......@@ -193,6 +195,18 @@ void mce_datapipe_generate_inactivity (void);
GINT_TO_POINTER(tklock_request));\
}while(0)
/** Add reason -prefix for executing proximity_sensor_required_pipe request
*
* See #proximity_sensor_required_pipe for details.
*/
#define PROXIMITY_SENSOR_REQUIRED_ADD "+"
/** Remove reason -prefix for executing proximity_sensor_required_pipe request
*
* See #proximity_sensor_required_pipe for details.
*/
#define PROXIMITY_SENSOR_REQUIRED_REM "-"
/* ========================================================================= *
* Datapipes
* ========================================================================= */
......@@ -223,6 +237,9 @@ extern datapipe_t lid_sensor_actual_pipe;
extern datapipe_t lid_sensor_filtered_pipe;
extern datapipe_t lens_cover_state_pipe;
extern datapipe_t proximity_sensor_actual_pipe;
extern datapipe_t proximity_sensor_effective_pipe;
extern datapipe_t proximity_sensor_required_pipe;
extern datapipe_t proximity_blanked_pipe;
extern datapipe_t light_sensor_actual_pipe;
extern datapipe_t light_sensor_filtered_pipe;
extern datapipe_t light_sensor_poll_request_pipe;
......@@ -267,7 +284,6 @@ extern datapipe_t touch_grab_active_pipe;
extern datapipe_t keypad_grab_wanted_pipe;
extern datapipe_t keypad_grab_active_pipe;
extern datapipe_t music_playback_ongoing_pipe;
extern datapipe_t proximity_blanked_pipe;
extern datapipe_t fpd_service_state_pipe;
extern datapipe_t fpstate_pipe;
extern datapipe_t enroll_in_progress_pipe;
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
* @file mce-common.h
* Header for common state logic for Mode Control Entity
* <p>
* Copyright (C) 2017 Jolla Ltd.
* Copyright (C) 2017-2019 Jolla Ltd.
* <p>
* @author Simo Piiroinen <simo.piiroinen@jollamobile.com>
*
......@@ -23,8 +23,12 @@
# define MCE_COMMON_H_
# include <stdbool.h>
# include <glib.h>
bool mce_common_init(void);
void mce_common_quit(void);
void common_on_proximity_schedule(const char *srce, GDestroyNotify func, gpointer aptr);
void common_on_proximity_cancel (const char *srce, GDestroyNotify func, gpointer aptr);
#endif /* MCE_COMMON_H_ */
This diff is collapsed.
......@@ -3,9 +3,13 @@
* Headers for the proximity sensor module
* <p>
* Copyright © 2010-2011 Nokia Corporation and/or its subsidiary(-ies).
* Copyright (C) 2013-2019 Jolla Ltd.
* <p>
* @author David Weinehall <david.weinehall@nokia.com>
* @author Tuomo Tanskanen <ext-tuomo.1.tanskanen@nokia.com>
* @author Tapio Rantala <ext-tapio.rantala@nokia.com>
* @author Santtu Lakkala <ext-santtu.1.lakkala@nokia.com>
* @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
......@@ -29,6 +33,10 @@
# define MCE_SETTING_PROXIMITY_PS_ENABLED MCE_SETTING_PROXIMITY_PATH "/ps_enabled"
# define MCE_DEFAULT_PROXIMITY_PS_ENABLED true
/** Whether proximity sensor should be used on-demand*/
# define MCE_SETTING_PROXIMITY_ON_DEMAND MCE_SETTING_PROXIMITY_PATH "/on_demand"
# define MCE_DEFAULT_PROXIMITY_ON_DEMAND false
/** Whether proximity sensor should be treated as cover closed sensor */
# define MCE_SETTING_PROXIMITY_PS_ACTS_AS_LID MCE_SETTING_PROXIMITY_PATH "/ps_acts_as_lid"
# define MCE_DEFAULT_PROXIMITY_PS_ACTS_AS_LID false
......
......@@ -4,9 +4,19 @@
* of the Mode Control Entity
* <p>
* Copyright © 2004-2011 Nokia Corporation and/or its subsidiary(-ies).
* Copyright (C) 2012-2019 Jolla Ltd.
* <p>
* @author David Weinehall <david.weinehall@nokia.com>
* @author Tapio Rantala <ext-tapio.rantala@nokia.com>
* @author Santtu Lakkala <ext-santtu.1.lakkala@nokia.com>
* @author Jukka Turunen <ext-jukka.t.turunen@nokia.com>
* @author Irina Bezruk <ext-irina.bezruk@nokia.com>
* @author Kalle Jokiniemi <kalle.jokiniemi@jolla.com>
* @author Mika Laitio <lamikr@pilppa.org>
* @author Markus Lehtonen <markus.lehtonen@iki.fi>
* @author Simo Piiroinen <simo.piiroinen@jollamobile.com>
* @author Vesa Halttunen <vesa.halttunen@jollamobile.com>
* @author Andrew den Exter <andrew.den.exter@jolla.com>
*
* mce is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
......@@ -1083,6 +1093,9 @@ static void tklock_datapipe_proximity_update(void)
proximity_sensor_effective = proximity_sensor_actual;
datapipe_exec_full(&proximity_sensor_effective_pipe,
GINT_TO_POINTER(proximity_sensor_effective));
tklock_datapipe_proximity_eval_led();
tklock_uiexception_rethink();
tklock_proxlock_rethink();
......
......@@ -2,8 +2,15 @@
* Tool to test and remote control the Mode Control Entity
* <p>
* Copyright © 2005-2011 Nokia Corporation and/or its subsidiary(-ies).
* Copyright (C) 2012-2019 Jolla Ltd.
* <p>
* @author David Weinehall <david.weinehall@nokia.com>
* @author Santtu Lakkala <ext-santtu.1.lakkala@nokia.com>
* @author Victor Portnov <ext-victor.portnov@nokia.com>
* @author Philippe De Swert <philippe.deswert@jollamobile.com>
* @author Simo Piiroinen <simo.piiroinen@jollamobile.com>
* @author Vesa Halttunen <vesa.halttunen@jollamobile.com>
* @author Kimmo Lindholm <kimmo.lindholm@eke.fi>
*
* mce is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
......@@ -225,6 +232,8 @@ static bool xmce_set_flipover_gesture_detection (const ch
static void xmce_get_flipover_gesture_detection (void);
static bool xmce_set_ps_mode (const char *args);
static void xmce_get_ps_mode (void);
static bool xmce_set_ps_on_demand (const char *args);
static void xmce_get_ps_on_demand (void);
static bool xmce_set_ps_blocks_touch (const char *args);
static void xmce_get_ps_blocks_touch (void);
static bool xmce_set_ps_acts_as_lid (const char *args);
......@@ -4082,6 +4091,30 @@ static void xmce_get_ps_mode(void)
printf("%-"PAD1"s %s\n", "Use ps mode:", txt);
}
/* Set ps use mode
*
* @param args string suitable for interpreting as enabled/disabled
*/
static bool xmce_set_ps_on_demand(const char *args)
{
debugf("%s(%s)\n", __FUNCTION__, args);
gboolean val = xmce_parse_enabled(args);
xmce_setting_set_bool(MCE_SETTING_PROXIMITY_ON_DEMAND, val);
return true;
}
/** Get current ps mode from mce and print it out
*/
static void xmce_get_ps_on_demand(void)
{
gboolean val = 0;
char txt[32] = "unknown";
if( xmce_setting_get_bool(MCE_SETTING_PROXIMITY_ON_DEMAND, &val) )
snprintf(txt, sizeof txt, "%s", val ? "enabled" : "disabled");
printf("%-"PAD1"s %s\n", "Use ps on-demand:", txt);
}
/** Set ps can block touch input mode
*
* @param args string suitable for interpreting as enabled/disabled
......@@ -6362,6 +6395,7 @@ static bool xmce_get_status(const char *args)
xmce_get_orientation_change_is_activity();
xmce_get_flipover_gesture_detection();
xmce_get_ps_mode();
xmce_get_ps_on_demand();
xmce_get_ps_uncover_delay();
xmce_get_ps_blocks_touch();
xmce_get_ps_acts_as_lid();
......@@ -7219,7 +7253,17 @@ static const mce_opt_t options[] =
.with_arg = xmce_set_ps_mode,
.values = "enabled|disabled",
"set the ps mode; valid modes are:\n"
"'enabled' and 'disabled'\n"
"'enabled' sensor is disabled/enabled based on policy\n"
" and other settings\n"
"'disabled' sensor is never powered on by mce\n"
},
{
.name = "set-ps-on-demand",
.with_arg = xmce_set_ps_on_demand,
.values = "enabled|disabled",
"set the ps on-demand mode; valid modes are:\n"
"'enabled' sensor is powered up only when needed\n"
"'disabled' sensor is always kept powered on\n"
},
{
.name = "set-default-ps-uncover-delay",
......
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