[RX51] Add support for physical events w/ acpid
This adds a way to handle physical events like keypad slide switch, screen lock, camera lid, and others. This uses acpid from busybox (I was wrong about the real acpid package), and anl acpi.map file to map events to 'scripts'. The scripts are symlinked to /etc/acpi/handler.sh, automatically by the new post-install script, where they are handled based on which script was called. This allows for easily adding whatever is necessary for #178. If this PR is merged, I will create a new wiki page detailing how others can use this framework on other devices. There's an issue with Busybox's acpid, where it is unable to detect new devices added after the daemon loads. This is the case on the N900, where openrc starts acpid well before the kernel is done modprobing drivers (e.g. gpio_keys), so it's necessary to restart the acpid daemon after some time to 'load' the new devices.
This commit is contained in:
parent
66501ac5fd
commit
fefb606912
4 changed files with 137 additions and 4 deletions
|
@ -1,15 +1,15 @@
|
|||
pkgname=device-nokia-rx51
|
||||
pkgver=1
|
||||
pkgrel=6
|
||||
pkgrel=7
|
||||
pkgdesc="Nokia N900"
|
||||
url="https://github.com/postmarketOS"
|
||||
arch="noarch"
|
||||
license="MIT"
|
||||
depends="linux-nokia-rx51 uboot-tools linux-firmware"
|
||||
makedepends="uboot-tools"
|
||||
install=""
|
||||
install="$pkgname.post-install"
|
||||
subpackages=""
|
||||
source="deviceinfo uboot-script.cmd backlight-enable.sh 90-touchscreen-dev.rules"
|
||||
source="deviceinfo uboot-script.cmd backlight-enable.sh 90-touchscreen-dev.rules acpi_handler.sh acpi.map $install"
|
||||
options="!check"
|
||||
|
||||
build() {
|
||||
|
@ -26,9 +26,17 @@ package() {
|
|||
"$pkgdir"/etc/postmarketos-mkinitfs/hooks/00-${pkgname}-backlight.sh
|
||||
install -D -m644 "$srcdir"/90-touchscreen-dev.rules \
|
||||
"$pkgdir"/etc/udev/rules.d/90-touchscreen-dev.rules
|
||||
mkdir "$pkgdir"/etc/acpi
|
||||
install -D -m755 "$srcdir"/acpi_handler.sh\
|
||||
"$pkgdir"/etc/acpi/handler.sh
|
||||
install -D -m644 "$srcdir"/acpi.map\
|
||||
"$pkgdir"/etc/acpi.map
|
||||
}
|
||||
|
||||
sha512sums="7eb602ae1f6002a928f2a5cf12edf21ffe76e6e378907f73da6b6df98016bf5f3e256f93a4187a354069631f283a2f0769b5acf05445e42d8f630966b36dfa6b deviceinfo
|
||||
36fdcdc32e75ad82402d7f8dc6ec5879002513b3552ae4cf755df52f2c3df7b12c3ab0aae8ea8207a7fa22240b88f8098fd283298d08f923f9b07b7964289b83 uboot-script.cmd
|
||||
3d55e34b95791636e44a5f41754f3d0de039dbba41f7a556d43a95c9e64afcfa930046b4b96b40020b6f196096ffba93514682927e32fa4488686fdd19c6da5a backlight-enable.sh
|
||||
98c554a709d6e8da5835bd792d833355d830fca1cfea12ec7fe4f41d1d1126389c51a8a392a7f94093473c19263cc6846cc40d7e179c2facf12db2d68ff923f9 90-touchscreen-dev.rules"
|
||||
98c554a709d6e8da5835bd792d833355d830fca1cfea12ec7fe4f41d1d1126389c51a8a392a7f94093473c19263cc6846cc40d7e179c2facf12db2d68ff923f9 90-touchscreen-dev.rules
|
||||
df5dcae9a32d04ba2fed8b4dbb8722f8d56d063a288dfbaeca37806bdbb8ba4de639b392859b9f24040a1032456d5dcd754f51314e3ab66515b91ae1e03c93a7 acpi_handler.sh
|
||||
7761aec6e6e219245b006e7bdc1d19812e9c5915cf3e64bb3dd46bb4b5570c1715650b53a1fc1007cb814076b5d81be0a66ba7ebf06d9a1fa4e364725c3ee633 acpi.map
|
||||
fd148b38a187710c9ed8729b6a5be5fcdb066c08c187cd11a783798fcb5b662e5fbff57c09031964b54c22bab5c0d407732bc9440d23865a77d0081ab5cdffd9 device-nokia-rx51.post-install"
|
||||
|
|
30
device-nokia-rx51/acpi.map
Normal file
30
device-nokia-rx51/acpi.map
Normal file
|
@ -0,0 +1,30 @@
|
|||
# FORMAT: "<EV_XXX>" <type> "<input.h name>" <keycode> <value> <script under /etc/acpi>
|
||||
# hint: "evtest /dev/input/eventX" is very helpful!
|
||||
|
||||
"EV_SW" 0x05 "SW_CAMERA_LENS_COVER" 9 1 CAM_LID_OPEN
|
||||
"EV_SW" 0x05 "SW_CAMERA_LENS_COVER" 9 0 CAM_LID_CLOSE
|
||||
|
||||
"EV_SW" 0x05 "SW_KEYPAD_SLIDE" 10 1 KP_SLIDE_OPEN
|
||||
"EV_SW" 0x05 "SW_KEYPAD_SLIDE" 10 0 KP_SLIDE_CLOSE
|
||||
|
||||
"EV_SW" 0x05 "SW_FRONT_PROXIMITY" 11 1 FRNT_PRXY_ON
|
||||
"EV_SW" 0x05 "SW_FRONT_PROXIMITY" 11 0 FRNT_PRXY_OFF
|
||||
|
||||
"EV_KEY" 0x01 "KEY_SCREENLOCK" 152 0 SCRNLCK_UP
|
||||
"EV_KEY" 0x01 "KEY_SCREENLOCK" 152 1 SCRNLCK_DWN
|
||||
|
||||
"EV_KEY" 0x01 "KEY_CAMERA" 212 0 CAM_BTN_UP
|
||||
"EV_KEY" 0x01 "KEY_CAMERA" 212 1 CAM_BTN_DWN
|
||||
|
||||
"EV_KEY" 0x01 "KEY_CAMERA_FOCUS" 528 0 CAM_FOCUS_UP
|
||||
"EV_KEY" 0x01 "KEY_CAMERA_FOCUS" 528 1 CAM_FOCUS_DWN
|
||||
|
||||
"EV_KEY" 0x01 "KEY_POWER" 116 0 PWR_BTN_UP
|
||||
"EV_KEY" 0x01 "KEY_POWER" 116 1 PWR_BTN_DWN
|
||||
|
||||
"EV_SW" 0x05 "SW_HEADPHONE_INSERT" 2 1 HEADPHONE_INSERT
|
||||
"EV_SW" 0x05 "SW_MICROPHONE_INSERT" 2 1 MICROPHONE_INSERT
|
||||
"EV_SW" 0x05 "SW_VIDEOOUT_INSERT" 2 1 VIDEOOUT_INSERT
|
||||
|
||||
"EV_KEY" 0x01 "KEY_VOLUMEUP" 66 1 VOL_UP
|
||||
"EV_KEY" 0x01 "KEY_VOLUMEDOWN" 65 1 VOL_DWN
|
84
device-nokia-rx51/acpi_handler.sh
Executable file
84
device-nokia-rx51/acpi_handler.sh
Executable file
|
@ -0,0 +1,84 @@
|
|||
#!/bin/ash
|
||||
|
||||
cmd=$( echo $0 | awk '{i=split($0,a,"/"); print a[i]}' )
|
||||
|
||||
function adjust_keypad_bl {
|
||||
for i in $(seq 1 6); do
|
||||
echo $1 > /sys/class/leds/lp5523\:kb$i/brightness
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
case $cmd in
|
||||
KP_SLIDE_OPEN)
|
||||
adjust_keypad_bl 255
|
||||
;;
|
||||
KP_SLIDE_CLOSE)
|
||||
adjust_keypad_bl 0
|
||||
;;
|
||||
CAM_BTN_DWN)
|
||||
echo "Not implemented yet"
|
||||
;;
|
||||
CAM_BTN_UP)
|
||||
echo "Not implemented yet"
|
||||
;;
|
||||
CAM_FOCUS_DWN)
|
||||
echo "Not implemented yet"
|
||||
;;
|
||||
CAM_FOCUS_UP)
|
||||
echo "Not implemented yet"
|
||||
;;
|
||||
CAM_LID_CLOSE)
|
||||
echo "Not implemented yet"
|
||||
;;
|
||||
CAM_LID_OPEN)
|
||||
echo "Not implemented yet"
|
||||
;;
|
||||
FRNT_PRXY_OFF)
|
||||
echo "Not implemented yet"
|
||||
;;
|
||||
FRNT_PRXY_ON)
|
||||
echo "Not implemented yet"
|
||||
;;
|
||||
KP_SLIDE_CLOSE)
|
||||
echo "Not implemented yet"
|
||||
;;
|
||||
KP_SLIDE_OPEN)
|
||||
echo "Not implemented yet"
|
||||
;;
|
||||
SCRNLCK_DWN)
|
||||
echo "Not implemented yet"
|
||||
;;
|
||||
SCRNLCK_UP)
|
||||
echo "Not implemented yet"
|
||||
;;
|
||||
HEADPHONE_INSERT)
|
||||
echo "Not implemented yet"
|
||||
;;
|
||||
MICROPHONE_INSERT)
|
||||
echo "Not implemented yet"
|
||||
;;
|
||||
PWR_BTN_DWN)
|
||||
echo "Not implemented yet"
|
||||
;;
|
||||
PWR_BTN_UP)
|
||||
echo "Not implemented yet"
|
||||
;;
|
||||
VIDEOOUT_INSERT)
|
||||
echo "Not implemented yet"
|
||||
;;
|
||||
VOL_DWN)
|
||||
echo "Not implemented yet"
|
||||
;;
|
||||
VOL_UP)
|
||||
echo "Not implemented yet"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown event"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
|
11
device-nokia-rx51/device-nokia-rx51.post-install
Normal file
11
device-nokia-rx51/device-nokia-rx51.post-install
Normal file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Generate symlinks for acpid events, based on definitions in /etc/acpi.map
|
||||
for i in $(awk '{if($NF && ($1 !~ /^#/)) print $NF}' /etc/acpi.map); do
|
||||
ln -s /etc/acpi/handler.sh /etc/acpi/$i
|
||||
done
|
||||
|
||||
# Enable acpid
|
||||
rc-update add acpid default
|
||||
|
||||
exit 0
|
Loading…
Reference in a new issue