Refactoring the acpi handling code of the N900 to work with all devices
Motivation
I've thought about switching speakers/headphones automatically with audio jack detection as part of my N900 music player project. This is possible by catching acpi events. But I want it to work on all devices, so some refactoring needs to take place first.
Current acpi-related code for the N900
The device-nokia-n900
package sets up busybox' acpid with a custom acpi.map
and acpi_handler.sh
, when certain acpi events are coming in. So far it turns the keyboard backlight LEDs on and off, when the keyboard gets slided out or back in. The acpi_handler.sh
looks like this:
...
case $cmd in
KP_SLIDE_OPEN)
adjust_keypad_bl 255
;;
KP_SLIDE_CLOSE)
adjust_keypad_bl 0
;;
CAM_BTN_DWN)
echo "Not implemented yet"
;;
...
The acpi.map
looks like that:
...
"EV_SW" 0x05 "SW_KEYPAD_SLIDE" 10 1 KP_SLIDE_OPEN
"EV_SW" 0x05 "SW_KEYPAD_SLIDE" 10 0 KP_SLIDE_CLOSE
...
Making it work for all devices
-
create a nokia-n900-keypad-blacklight
script as derivative from its currentacpi_handler.sh
. (I think all new device specific scripts should start with the device name if possible.) -
extend the N900's deviceinfo with:
deviceinfo_acpi_slide_open="nokia-n900-keypad-blacklight 255"
deviceinfo_acpi_slide_close="nokia-n900-keypad-blacklight 0"
-
install the acpi daemon as dependency of postmarketos-base
instead ofdevice-nokia-n900
-
put acpi_handler.sh
script inpostmarketos-base
instead ofdevice-nokia-n900
-
rewrite acpi_handler.sh
: source/etc/deviceinfo
and run thedeviceinfo_acpi_*
commands
When we have that, we can also do generic actions in acpi_handler.sh
, such as turning the volume up with alsactl when pressing the volume up button (so this would not require a deviceinfo_acpi_*
variable filled out).