
This fixes an bug where the system is prevented from suspending by a stuck "Waiting for cronjob" mutex. The wakeup_active count doesn't provide information about system wakeups, so track the amount of time spent in suspend instead. Also make sxmo_hook_mnc.sh responsible for deciding if the system has time to suspend before the next cron job. This makes the suspend code a bit cleaner. There are two bugs that can cause the mutex to get stuck: Bug one: The kernel allows multiple applications to request multiple wakeup times, if anything else does we will get stuck. Bug two: /sys/class/wakeup/wakeupN/active_count does not count the number of times the device woke the system from suspend. It counts the number of times the device prevented the system from suspending. Periodically the kernel syncs the system clock to the rtc. When doing this the rtc subsystem takes a wakelock to prevent the system from suspending until the time has been updated, which increments active_count. If this happens while resuming we get stuck. This is a kernel stack trace I captured of this happening while resuming: wakeup_source_activate+0 pm_stay_awake+68 rtc_set_time+212 sync_hw_clock+436 process_one_work+520 worker_thread+120 kthread+276 ret_from_fork+16 Signed-off-by: Stacy Harper <contact@stacyharper.net>
Device profile
A device profile is a shell script that is loaded early in sxmo startup, and is intended to be used for defining device-specific attributes that sxmo will use at run time.
While it is technically possible to put any valid shell commands/logic in the device profile, it is recommended to only use environment variables to keep the script's execution time at a minimum and to keep things simple.
File name
To define a device profile, you need to first obtain the device name. This can
be found in /proc/device-tree/compatible
.
The compatible file is a null terminated array, sxmo uses the first item as the
name of the device. For example, the poco f1 is a 3 button touch device and
tr '\0' '\n' < /proc/device-tree/compatible
returns:
xiaomi,beryllium
qcom,sdm845
As such, sxmo-utils/configs/default_hooks/xiaomi,beryllium
is a symlink to sxmo-utils/configs/default_hooks/three_button_touchscreen
.
Finally, the device profile variables (explained in the following secion) is defined in:
sxmo-utils/scripts/deviceprofiles/sxmo_deviceprofile_xiaomi,beryllium.sh
Further reading:
- Accessing the devicetree from userspace
- An overview of how the devicetree works on linux
- The devicetree spec
Device profile variables used by sxmo
Supported variables used by sxmo are:
Modem related
export SXMO_MODEM_GPIO_KEY_RI | If the modem driver handle a gpio, sxmo have to know it to disable the events from this input source.
Screen-related
SXMO_ROTATION_POLL_TIME | Polling time for rotate in seconds (decimals allowed e.g. .1) [default: 1]
SXMO_ROTATION_GRAVITY | Override gravity for calculating rotation [default: 500]
SXMO_ROTATION_THRESHOLD | Threshold for detecting rotation [default: 60]
SXMO_MIN_BRIGHTNESS | Minimum brightness level [default: 5]
SXMO_DISABLE_LEDS | Disable leds (1 or 0) [default: 0]
SXMO_LED_WHITE_TYPE | LED device type, i.e., the part after the colon in the path: /sys/class/leds/<color>:<type>
[default: status]
SXMO_LED_BLUE_TYPE | LED device type, i.e., the part after the colon in the path: /sys/class/leds/<color>:<type>
[default: status]
SXMO_LED_RED_TYPE | LED device type, i.e., the part after the colon in the path: /sys/class/leds/<color>:<type>
[default: status]
SXMO_LED_GREEN_TYPE | LED device type, i.e., the part after the colon in the path: /sys/class/leds/<color>:<type>
[default: status]
SXMO_SWAY_SCALE | Screen scale for hidpi screens. Can be fractional [SWAY-ONLY].
Music-related
SXMO_SPEAKER | Audio device name for the main speaker [default: Speaker]
SXMO_EARPIECE | Audio device name for the earpiece speaker [default: Earpiece]
SXMO_HEADPHONE | Audio device name for the headphones [default: Headphone]
SXMO_ALSA_CONTROL_NAME | Alsa audio control name [default: 0]
Input-related
SXMO_TOUCHSCREEN_ID | ID (from xinput) for the touchscreen device [DWM-ONLY] [default: 10]
SXMO_STYLUS_ID | ID (from xinput) for the stylus device [DWM-ONLY] [default: 10]
SXMO_LISGD_THRESHOLD | Threshold for detecting touches [default: 125]
SXMO_LISGD_THRESHOLD_PRESSED | Threshold for detecting long presses [default: 60]
SXMO_LISGD_INPUT_DEVICE | Input device [default: /dev/input/touchscreen]
SXMO_VOLUME_BUTTON | Volume button "Identifier" from swaymsg -t get_inputs
command. If the volume up identifier ($VOL_UP_ID
) is different from the volume down identifier ($VOL_DOWN_ID
), set $SXMO_VOLUME_BUTTON="$VOL_UP_ID $VOL_DOWN_ID"
. See the sxmo-utils/scripts/deviceprofiles/sxmo_deviceprofile_xiaomi,beryllium.sh
file.
SXMO_POWER_BUTTON | Power button "Identifier" from swaymsg -t get_inputs
command.
SXMO_MONITOR | Touch screen "Identifier" from swaymsg -t get_inputs
command.
General / Misc.
SXMO_WIFI_MODULE | The wifi kernel module used when switching scan intervals
SXMO_SYS_FILES | String of files for sxmo_setpermissions.sh to make +rw (see sxmo_setpermissions.sh)
SXMO_MODEMRTC | Modem wakeup number in /sys/class/wakeup/wakeup/ (see sxmo_suspend.sh) [default: 10]
SXMO_POWERRTC | Power wakeup number in /sys/class/wakeup/wakeup/ (see sxmo_suspend.sh) [default: 5]
SXMO_COVERRTC | Open cover wakeup number in /sys/class/wakeup/wakeup/ (see sxmo_suspend.sh) [default: 9999]
SXMO_VIBRATE_DEV | Path to vibration device (see sxmo_vibrate.c and clickclack.c) [default: /dev/input/by-path/platform-vibrator-event]