tklock.h 13.6 KB
Newer Older
1 2 3 4 5
/**
 * @file tklock.h
 * Headers for the touchscreen/keypad lock component
 * of the Mode Control Entity
 * <p>
Santtu Lakkala's avatar
Santtu Lakkala committed
6
 * Copyright © 2004-2011 Nokia Corporation and/or its subsidiary(-ies).
7
 * Copyright (C) 2013-2019 Jolla Ltd.
8 9
 * <p>
 * @author David Weinehall <david.weinehall@nokia.com>
10 11 12 13 14 15
 * @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 Mika Laitio <lamikr@pilppa.org>
 * @author Markus Lehtonen <markus.lehtonen@iki.fi>
 * @author Simo Piiroinen <simo.piiroinen@jollamobile.com>
16 17 18 19 20 21 22 23 24 25 26 27 28
 *
 * 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/>.
 */
29 30
#ifndef TKLOCK_H_
# define TKLOCK_H_
31

32
# include "mce.h"
33

34 35 36
/* ========================================================================= *
 * Settings
 * ========================================================================= */
37

38
/** Prefix for tklock setting keys */
39
# define MCE_SETTING_TK_PATH                     "/system/osso/dsm/locks"
40

41
/** Whether lockscreen should be activated when display turns off */
42 43
# define MCE_SETTING_TK_AUTOLOCK_ENABLED         MCE_SETTING_TK_PATH "/touchscreen_keypad_autolock_enabled"
# define MCE_DEFAULT_TK_AUTOLOCK_ENABLED         true
44

45
/** Whether automatic blanking from lockscreen is disabled */
46 47
# define MCE_SETTING_TK_AUTO_BLANK_DISABLE       MCE_SETTING_TK_PATH "/tklock_blank_disable"
# define MCE_DEFAULT_TK_AUTO_BLANK_DISABLE       0
48

49 50 51 52 53
/** Automatic lpm triggering modes */
enum
{
    /** Automatic triggering disabled */
    LPMUI_TRIGGERING_NONE        = 0,
54

55 56
    /** Proximity sensor based out-of-pocket triggering */
    LPMUI_TRIGGERING_FROM_POCKET = 1<<0,
57

58 59 60
    /** Proximity sensor based hover-over triggering */
    LPMUI_TRIGGERING_HOVER_OVER  = 1<<1,
};
61

62
/** What conditions can trigger lpm mode display */
63 64
# define MCE_SETTING_TK_LPMUI_TRIGGERING         MCE_SETTING_TK_PATH "/lpm_triggering"
# define MCE_DEFAULT_TK_LPMUI_TRIGGERING         1 // = LPMUI_TRIGGERING_FROM_POCKET
65

66 67 68 69 70 71 72 73 74
/** Whether touch input should remain blocked until ps is not covered
 *
 * To avoid accidental touch interaction related to lipstick
 * crashes/restarts occurring while the device is in a pocket,
 * it would be highly desirable to block touch input while
 * proximity sensor is covered. However, this causes massive
 * problems during bootup for devices with unreliably working
 * proximity sensor, so this must remain disabled by default.
 */
75 76
# define MCE_SETTING_TK_PROXIMITY_BLOCKS_TOUCH   MCE_SETTING_TK_PATH "/proximity_blocks_touch"
# define MCE_DEFAULT_TK_PROXIMITY_BLOCKS_TOUCH   false
77

78 79 80 81 82
/** Whether device unlocking happens in lockscreen
 *
 * Deactivating lockscreen must not be allowed if device unlock code
 * is entered in lockscreen context.
 */
83 84
# define MCE_SETTING_TK_DEVICELOCK_IN_LOCKSCREEN MCE_SETTING_TK_PATH "/devicelock_in_lockscreen"
# define MCE_DEFAULT_TK_DEVICELOCK_IN_LOCKSCREEN false
85

86 87 88 89 90 91 92
/** Whether MCE is allowed to use lid sensor
 *
 * Note: Unlike other sensors that are powered on/off via sensorfw,
 *       it is assumed that lid sensor is powered on if present and
 *       this settings just controls whether mce uses or ignores the
 *       lid events that it receives.
 */
93 94
# define MCE_SETTING_TK_LID_SENSOR_ENABLED       MCE_SETTING_TK_PATH "/lid_sensor_enabled"
# define MCE_DEFAULT_TK_LID_SENSOR_ENABLED       true
95

96 97 98 99 100 101 102
/** Whether lid sensor state should be verified with light sensor
 *
 * If enabled, lid sensor state changes are ignored unless they
 * occur in close proximity to ambient light level changes. This
 * is mainly useful for filtering out false state changes reported
 * by hall effect sensors confused by unexpected magnetic fields.
 */
103
# define MCE_SETTING_TK_FILTER_LID_WITH_ALS      MCE_SETTING_TK_PATH"/filter_lid_with_als"
104
# define MCE_DEFAULT_TK_FILTER_LID_WITH_ALS      false
105

106
/** Maximum amount of light ALS is expected to report when LID is closed */
107 108
# define MCE_SETTING_TK_FILTER_LID_ALS_LIMIT     MCE_SETTING_TK_PATH"/filter_lid_als_limit"
# define MCE_DEFAULT_TK_FILTER_LID_ALS_LIMIT     0
109

110 111 112 113 114 115 116 117 118 119 120 121 122 123
/** Lid sensor open actions */
typedef enum
{
    /** Actions disabled */
    LID_OPEN_ACTION_DISABLED = 0,

    /** Just show lockscreen */
    LID_OPEN_ACTION_UNBLANK  = 1,

    /* Deactivate lockscreen */
    LID_OPEN_ACTION_TKUNLOCK = 2,

} lid_open_action_t;

124
/** Actions to be taken when lid is opened */
125 126
# define MCE_SETTING_TK_LID_OPEN_ACTIONS         MCE_SETTING_TK_PATH "/lid_open_actions"
# define MCE_DEFAULT_TK_LID_OPEN_ACTIONS         1 // = LID_OPEN_ACTION_UNBLANK
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141

/** Lid sensor close actions */
typedef enum
{
    /** Actions disabled */
    LID_CLOSE_ACTION_DISABLED = 0,

    /** Just blank screen */
    LID_CLOSE_ACTION_BLANK    = 1,

    /* Activate lockscreen */
    LID_CLOSE_ACTION_TKLOCK   = 2,

} lid_close_action_t;

142
/** Actions to be taken when lid is closed */
143 144
# define MCE_SETTING_TK_LID_CLOSE_ACTIONS        MCE_SETTING_TK_PATH "/lid_close_actions"
# define MCE_DEFAULT_TK_LID_CLOSE_ACTIONS        2 // = LID_CLOSE_ACTION_TKLOCK
145

146 147
/** When to react to kbd slide closed events */
typedef enum {
148 149 150
    KBD_OPEN_TRIGGER_NEVER        = 0,
    KBD_OPEN_TRIGGER_ALWAYS       = 1,
    KBD_OPEN_TRIGGER_NO_PROXIMITY = 2,
151 152
} kbd_open_trigger_t;

153
/** When MCE should react to kbd slide open */
154 155
# define MCE_SETTING_TK_KBD_OPEN_TRIGGER         MCE_SETTING_TK_PATH "/keyboard_open_trigger"
# define MCE_DEFAULT_TK_KBD_OPEN_TRIGGER         2 // = KBD_OPEN_TRIGGER_NO_PROXIMITY
156

157
/** Actions to be taken when kbd slide is opened */
158 159 160 161 162 163 164 165 166
# define MCE_SETTING_TK_KBD_OPEN_ACTIONS         MCE_SETTING_TK_PATH "/keyboard_open_actions"
# define MCE_DEFAULT_TK_KBD_OPEN_ACTIONS         1 // = LID_OPEN_ACTION_UNBLANK

/* When to react to kbd slide opened events */
typedef enum {
    KBD_CLOSE_TRIGGER_NEVER      = 0,
    KBD_CLOSE_TRIGGER_ALWAYS     = 1,
    KBD_CLOSE_TRIGGER_AFTER_OPEN = 2,
} kbd_close_trigger_t;
167

168
/** When MCE should react to kbd slide close */
169 170
# define MCE_SETTING_TK_KBD_CLOSE_TRIGGER        MCE_SETTING_TK_PATH "/keyboard_close_trigger"
# define MCE_DEFAULT_TK_KBD_CLOSE_TRIGGER        2 // = KBD_CLOSE_TRIGGER_AFTER_OPEN
171

172
/** Actions to be taken when kbd slide is closed */
173 174
# define MCE_SETTING_TK_KBD_CLOSE_ACTIONS        MCE_SETTING_TK_PATH "/keyboard_close_actions"
# define MCE_DEFAULT_TK_KBD_CLOSE_ACTIONS        2 // = LID_CLOSE_ACTION_TKLOCK
175

176 177 178 179 180 181
/** Autolock delay after display off [ms]
 *
 * When display gets dimmed and then blanked, there is
 * a "grace period" before the application that was
 * active gets backgrounded and lockscreen activated.
 */
182 183 184 185
# define MCE_SETTING_TK_AUTOLOCK_DELAY           MCE_SETTING_TK_PATH "/autolock_delay"
# define MCE_DEFAULT_TK_AUTOLOCK_DELAY           30000
# define MINIMUM_AUTOLOCK_DELAY                  0
# define MAXIMUM_AUTOLOCK_DELAY                  600000
186

187 188 189 190 191 192 193 194 195
/** Volume key input policy modes */
typedef enum {
    /** Default rules apply */
    VOLKEY_POLICY_DEFAULT    = 0,

    /** Volume keys are enabled only when there is music playback. */
    VOLKEY_POLICY_MEDIA_ONLY = 1,
} volkey_policy_t;

196
/** When MCE should block/allow volume key events */
197 198
# define MCE_SETTING_TK_VOLKEY_POLICY            MCE_SETTING_TK_PATH "/volume_key_input_policy"
# define MCE_DEFAULT_TK_VOLKEY_POLICY            0 // = VOLKEY_POLICY_DEFAULT
199

200
/** How long to keep display on after incoming call ends [ms] */
201 202
# define MCE_SETTING_TK_EXCEPT_LEN_CALL_IN       MCE_SETTING_TK_PATH"/exception_length_call_in"
# define MCE_DEFAULT_TK_EXCEPT_LEN_CALL_IN       5000
203 204

/** How long to keep display on after outgoing call ends [ms] */
205 206
# define MCE_SETTING_TK_EXCEPT_LEN_CALL_OUT      MCE_SETTING_TK_PATH"/exception_length_call_out"
# define MCE_DEFAULT_TK_EXCEPT_LEN_CALL_OUT      2500
207 208

/** How long to keep display on after alarm is handled [ms] */
209 210
# define MCE_SETTING_TK_EXCEPT_LEN_ALARM         MCE_SETTING_TK_PATH"/exception_length_alarm"
# define MCE_DEFAULT_TK_EXCEPT_LEN_ALARM         1250
211 212

/** How long to keep display on when usb cable is connected [ms] */
213 214
# define MCE_SETTING_TK_EXCEPT_LEN_USB_CONNECT   MCE_SETTING_TK_PATH"/exception_length_usb_connect"
# define MCE_DEFAULT_TK_EXCEPT_LEN_USB_CONNECT   5000
215 216

/** How long to keep display on when usb mode dialog is shown [ms] */
217 218
# define MCE_SETTING_TK_EXCEPT_LEN_USB_DIALOG    MCE_SETTING_TK_PATH"/exception_length_usb_dialog"
# define MCE_DEFAULT_TK_EXCEPT_LEN_USB_DIALOG    10000
219 220

/** How long to keep display on when charging starts [ms] */
221 222
# define MCE_SETTING_TK_EXCEPT_LEN_CHARGER       MCE_SETTING_TK_PATH"/exception_length_charger"
# define MCE_DEFAULT_TK_EXCEPT_LEN_CHARGER       3000
223 224

/** How long to keep display on after battery full [ms] */
225 226
# define MCE_SETTING_TK_EXCEPT_LEN_BATTERY       MCE_SETTING_TK_PATH"/exception_length_battery"
# define MCE_DEFAULT_TK_EXCEPT_LEN_BATTERY       0
227 228

/** How long to keep display on when audio jack is inserted [ms] */
229 230
# define MCE_SETTING_TK_EXCEPT_LEN_JACK_IN       MCE_SETTING_TK_PATH"/exception_length_jack_in"
# define MCE_DEFAULT_TK_EXCEPT_LEN_JACK_IN       3000
231 232

/** How long to keep display on when audio jack is removed [ms] */
233 234
# define MCE_SETTING_TK_EXCEPT_LEN_JACK_OUT      MCE_SETTING_TK_PATH"/exception_length_jack_out"
# define MCE_DEFAULT_TK_EXCEPT_LEN_JACK_OUT      3000
235 236

/** How long to keep display on when camera button is pressed [ms] */
237 238
# define MCE_SETTING_TK_EXCEPT_LEN_CAMERA        MCE_SETTING_TK_PATH"/exception_length_camera"
# define MCE_DEFAULT_TK_EXCEPT_LEN_CAMERA        3000
239 240

/** How long to keep display on when volume button is pressed [ms] */
241 242
# define MCE_SETTING_TK_EXCEPT_LEN_VOLUME        MCE_SETTING_TK_PATH"/exception_length_volume"
# define MCE_DEFAULT_TK_EXCEPT_LEN_VOLUME        2000
243 244

/** How long to extend display on when there is user activity [ms] */
245 246
# define MCE_SETTING_TK_EXCEPT_LEN_ACTIVITY      MCE_SETTING_TK_PATH"/exception_length_activity"
# define MCE_DEFAULT_TK_EXCEPT_LEN_ACTIVITY      2000
247

248
/** Is mce allowed to grab input devices */
249 250
# define MCE_SETTING_TK_INPUT_POLICY_ENABLED     MCE_SETTING_TK_PATH "/touchscreen_policy_enabled"
# define MCE_DEFAULT_TK_INPUT_POLICY_ENABLED     true
251

252
/** Whether mce should allow lockscreen animations on unblank */
253 254 255
# define MCE_SETTING_TK_LOCKSCREEN_ANIM_ENABLED  MCE_SETTING_TK_PATH "/lockscreen_animation_enabled"
# define MCE_DEFAULT_TK_LOCKSCREEN_ANIM_ENABLED  true

256 257 258 259 260 261 262 263 264 265 266 267
/** Default proximity sensor uncover handling [ms]*/
# define MCE_SETTING_TK_PROXIMITY_DELAY_DEFAULT  MCE_SETTING_TK_PATH "/proximity_delay_default"
# define MCE_DEFAULT_TK_PROXIMITY_DELAY_DEFAULT  100

/** In-call proximity sensor uncover handling [ms]*/
# define MCE_SETTING_TK_PROXIMITY_DELAY_INCALL   MCE_SETTING_TK_PATH "/proximity_delay_incall"
# define MCE_DEFAULT_TK_PROXIMITY_DELAY_INCALL   500

/** Accpeted range for proximity sensor uncover delay: [0s, 1h] */
# define MCE_MINIMUM_TK_PROXIMITY_DELAY          0
# define MCE_MAXIMUM_TK_PROXIMITY_DELAY          (60 * 60 * 1000)

268 269 270
/* ========================================================================= *
 * Configuration
 * ========================================================================= */
271

272
/** Name of Touchscreen/Keypad lock configuration group */
273
# define MCE_CONF_TKLOCK_GROUP           "TKLock"
274

275
/** Name of configuration key for camera popout unlock */
276 277 278 279 280 281 282 283
# define MCE_CONF_CAMERA_POPOUT_UNLOCK   "CameraPopoutUnlock"

/* ========================================================================= *
 * HW Constants
 * ========================================================================= */

/** SysFS interface to enable/disable RX-51 keyboard IRQs */
# define MCE_RX51_KEYBOARD_SYSFS_DISABLE_PATH            "/sys/class/i2c-adapter/i2c-1/1-004a/twl4030_keypad/disable_kp"
Santtu Lakkala's avatar
Santtu Lakkala committed
284

285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
/** SysFS interface to enable/disable keypad IRQs */
# define MCE_KEYPAD_SYSFS_DISABLE_PATH                   "/sys/devices/platform/omap2_mcspi.1/spi1.0/disable_kp"

/** SysFS interface to enable/disable the RX-44/RX-48 keyboard IRQs */
# define MCE_RX44_KEYBOARD_SYSFS_DISABLE_PATH            "/sys/devices/platform/i2c_omap.2/i2c-0/0-0045/disable_kp"

/**
 * SysFS interface to enable/disable
 * RM-680/RM-690/RM-696/RM-716 double tap gesture recognition
 */
# define MCE_RM680_DOUBLETAP_SYSFS_PATH                  "/sys/class/i2c-adapter/i2c-2/2-004b/wait_for_gesture"

/**
 * SysFS interface to recalibrate
 * RM-680/RM-690/RM-696/RM-716 touchscreen
300
 */
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
# define MCE_RM680_TOUCHSCREEN_CALIBRATION_PATH          "/sys/class/i2c-adapter/i2c-2/2-004b/calibrate"

/**
 * SysFS interface to enable/disable
 * RM-680/RM-690/RM-696/RM-716 touchscreen IRQs
 */
# define MCE_RM680_TOUCHSCREEN_SYSFS_DISABLE_PATH        "/sys/class/i2c-adapter/i2c-2/2-004b/disable_ts"

/** SysFS interface to enable/disable RX-44/RX-48/RX-51 touchscreen IRQs */
# define MCE_RX44_TOUCHSCREEN_SYSFS_DISABLE_PATH             "/sys/devices/platform/omap2_mcspi.1/spi1.0/disable_ts"
# define MCE_RX44_TOUCHSCREEN_SYSFS_DISABLE_PATH_KERNEL2637  "/sys/devices/platform/omap2_mcspi.1/spi1.0/disable"

/** Touch screen enable delay for calibration **/
# define MCE_TOUCHSCREEN_CALIBRATION_DELAY               100000 /* 100 milliseconds */

/* ========================================================================= *
 * Functions
 * ========================================================================= */

320
gboolean mce_tklock_init(void);
321 322
void      mce_tklock_exit(void);
void      mce_tklock_unblank(display_state_t to_state);
323

324
#endif /* TKLOCK_H_ */