Enabling hotkey features on UbuntuDecember 8th 2011
Ike Panhc
Hardware Enablement Team
2 Canonical Confidential Ubuntu Hardware Summit. December 8th 2011
Event
● Where the events come from?
● Polling, Interrupt
● Monitor interrupts - `watch -n 1 cat /proc/interrupts`
Every 1.0s: cat /proc/interrupts
CPU0 CPU1 0: 498408 774770 IO-APIC-edge timer 1: 4 6 IO-APIC-edge i8042 8: 0 1 IO-APIC-edge rtc0 9: 770 748 IO-APIC-fasteoi acpi 12: 58 48 IO-APIC-edge i8042 16: 115 110 IO-APIC-fasteoi uhci_hcd:usb3 18: 2317 19 IO-APIC-fasteoi uhci_hcd:usb8, eth2
3 Canonical Confidential Ubuntu Hardware Summit. December 8th 2011
If it is ACPI based event
● Read DSDT
$ sudo cp /sys/firmware/acpi/tables/DSDT ./DSDT.dat
$ sudo iasl -d ./DSDT.dat
● ACPI device with non-generic HID. e.g. Name (_HID, "VPC2004")
● WMI Interface, HID PNP0C14 with method _WDG
4 Canonical Confidential Ubuntu Hardware Summit. December 8th 2011
ACPI device - asus-laptop
● HID: ATK0101 or ATK0100
● Run method INIT to initial
● Get notify on key event
● Each key event has different notify number
/* Lenovo SL Specific keycodes */ {KE_KEY, 0x02, { KEY_SCREENLOCK } }, {KE_KEY, 0x05, { KEY_WLAN } }, {KE_KEY, 0x08, { KEY_F13 } }, {KE_KEY, 0x17, { KEY_ZOOM } }, {KE_KEY, 0x1f, { KEY_BATTERY } }, /* End of Lenovo SL Specific keycodes */ {KE_KEY, 0x30, { KEY_VOLUMEUP } }, {KE_KEY, 0x31, { KEY_VOLUMEDOWN } }, {KE_KEY, 0x32, { KEY_MUTE } }, {KE_KEY, 0x33, { KEY_SWITCHVIDEOMODE } }, {KE_KEY, 0x34, { KEY_SWITCHVIDEOMODE } }, {KE_KEY, 0x4c, { KEY_MEDIA } }, ......... {KE_END, 0},
5 Canonical Confidential Ubuntu Hardware Summit. December 8th 2011
ACPI device - eeepc-laptop
● HID: ASUS010
● Run method INIT to initial
● Get notify on key event
● Each key event has different notify number
{ KE_KEY, 0x10, { KEY_WLAN } }, { KE_KEY, 0x11, { KEY_WLAN } }, { KE_KEY, 0x12, { KEY_PROG1 } }, { KE_KEY, 0x13, { KEY_MUTE } }, { KE_KEY, 0x14, { KEY_VOLUMEDOWN } }, { KE_KEY, 0x15, { KEY_VOLUMEUP } }, { KE_KEY, 0x16, { KEY_DISPLAY_OFF } }, { KE_KEY, 0x1a, { KEY_COFFEE } }, ......... { KE_KEY, 0x30, { KEY_SWITCHVIDEOMODE } }, { KE_KEY, 0x31, { KEY_SWITCHVIDEOMODE } }, { KE_KEY, 0x32, { KEY_SWITCHVIDEOMODE } }, { KE_KEY, 0x37, { KEY_F13 } }, /* Disable Touchpad */ { KE_KEY, 0x38, { KEY_F14 } }, { KE_END, 0 },
6 Canonical Confidential Ubuntu Hardware Summit. December 8th 2011
ACPI device - ideapad-laptop
● HID: VPC2004
● Run method _CFG to get machine capability
● On any key event, get notify with event number 0x80
● Use method VPCR to tell which key is pressed
{ KE_KEY, 6, { KEY_SWITCHVIDEOMODE } }, { KE_KEY, 13, { KEY_WLAN } }, { KE_KEY, 16, { KEY_PROG1 } }, { KE_KEY, 17, { KEY_PROG2 } }, { KE_END, 0 },
7 Canonical Confidential Ubuntu Hardware Summit. December 8th 2011
ACPI device - panasonic-laptop
● HID: MAT0012, MAT0013, MAT0018 and MAT0019
● On any key event, get notify with event number 0x80
● Use method HINF to tell which key is pressed
{ KE_KEY, 0, { KEY_RESERVED } }, { KE_KEY, 1, { KEY_BRIGHTNESSDOWN } }, { KE_KEY, 2, { KEY_BRIGHTNESSUP } }, { KE_KEY, 3, { KEY_DISPLAYTOGGLE } }, { KE_KEY, 4, { KEY_MUTE } }, { KE_KEY, 5, { KEY_VOLUMEDOWN } }, { KE_KEY, 6, { KEY_VOLUMEUP } }, { KE_KEY, 7, { KEY_SLEEP } }, { KE_KEY, 8, { KEY_PROG1 } }, /* Change CPU boost */ { KE_KEY, 9, { KEY_BATTERY } }, { KE_KEY, 10, { KEY_SUSPEND } }, { KE_END, 0 }
8 Canonical Confidential Ubuntu Hardware Summit. December 8th 2011
ACPI device - toshiba-acpi
● HID: TOS6200, TOS6208 and TOS1900
● On any key event, get notify with event number 0x80
● Use method GHCI or SPFC to tell which key is pressed
{ KE_KEY, 0x101, { KEY_MUTE } }, { KE_KEY, 0x102, { KEY_ZOOMOUT } }, { KE_KEY, 0x103, { KEY_ZOOMIN } }, { KE_KEY, 0x13b, { KEY_COFFEE } }, { KE_KEY, 0x13c, { KEY_BATTERY } }, { KE_KEY, 0x13d, { KEY_SLEEP } }, { KE_KEY, 0x13e, { KEY_SUSPEND } }, { KE_KEY, 0x13f, { KEY_SWITCHVIDEOMODE } }, { KE_KEY, 0x140, { KEY_BRIGHTNESSDOWN } }, { KE_KEY, 0x141, { KEY_BRIGHTNESSUP } }, { KE_KEY, 0x142, { KEY_WLAN } }, ......... { KE_KEY, 0xb31, { KEY_PREVIOUSSONG } }, { KE_KEY, 0xb32, { KEY_NEXTSONG } }, { KE_KEY, 0xb33, { KEY_PLAYPAUSE } }, { KE_KEY, 0xb5a, { KEY_MEDIA } }, { KE_END, 0 },
9 Canonical Confidential Ubuntu Hardware Summit. December 8th 2011
ACPI device - topstar-laptop
● HID: TPSACPI01
● Get notify on key event
● Each key event has different notify number
{ KE_KEY, 0x80, { KEY_BRIGHTNESSUP } }, { KE_KEY, 0x81, { KEY_BRIGHTNESSDOWN } }, { KE_KEY, 0x83, { KEY_VOLUMEUP } }, { KE_KEY, 0x84, { KEY_VOLUMEDOWN } }, { KE_KEY, 0x85, { KEY_MUTE } }, { KE_KEY, 0x86, { KEY_SWITCHVIDEOMODE } }, { KE_KEY, 0x87, { KEY_F13 } }, /* touchpad enable/disable key */ { KE_KEY, 0x88, { KEY_WLAN } }, { KE_KEY, 0x8a, { KEY_WWW } }, { KE_KEY, 0x8b, { KEY_MAIL } }, { KE_KEY, 0x8c, { KEY_MEDIA } }, ......... { KE_END, 0 }
10 Canonical Confidential Ubuntu Hardware Summit. December 8th 2011
WMI
● Windows Management Instrumentation
● Register by a unique GUID for each driver
● Find _WDG within PNP0C14 device
Name (_WDG, Buffer (0x64){ /* 0000 */ 0x81, 0x17, 0xF4, 0xD9, 0x33, 0xF6, 0x00, 0x44, /* 0008 */ 0x93, 0x55, 0x60, 0x17, 0x70, 0xBE, 0xC5, 0x10, /* 0010 */ 0x41, 0x41, 0x01, 0x00, 0x1D, 0x37, 0xC3, 0x67, /* 0018 */ 0xA3, 0x95, 0x37, 0x4C, 0xBB, 0x61, 0xDD, 0x47, /* 0020 */ 0xB4, 0x91, 0xDA, 0xAB, 0x41, 0x42, 0x01, 0x02, /* 0028 */ 0xED, 0x16, 0x1F, 0x43, 0x2B, 0x0C, 0x4C, 0x44, /* 0030 */ 0xB2, 0x67, 0x27, 0xDE, 0xB1, 0x40, 0xCF, 0x9C, /* 0038 */ 0x41, 0x43, 0x01, 0x02, 0x71, 0xBF, 0xD1, 0x40, /* 0040 */ 0x2D, 0xA8, 0x59, 0x4E, 0xA1, 0x68, 0x39, 0x85, /* 0048 */ 0xE0, 0x3B, 0x2E, 0x87, 0xB0, 0x00, 0x01, 0x08, /* 0050 */ 0x21, 0x12, 0x90, 0x05, 0x66, 0xD5, 0xD1, 0x11, /* 0058 */ 0xB2, 0xF0, 0x00, 0xA0, 0xC9, 0x06, 0x29, 0x10, /* 0060 */ 0x44, 0x44, 0x01, 0x00})
11 Canonical Confidential Ubuntu Hardware Summit. December 8th 2011
WMI
● Use wmidump to decode: http://xf.iksaif.net/dev/wmidump.html
● Register notify function on event GUID and you will have the event and its source
$ wmidump < ./wmi.txt 67C3371D-95A3-4C37-BB61-DD47B491DAAB:
object_id: ABnotify_id: 41reserved: 42instance_count: 1flags: 0x2 ACPI_WMI_METHOD
40D1BF71-A82D-4E59-A168-3985E03B2E87:object_id: �notify_id: B0reserved: 00instance_count: 1flags: 0x8 ACPI_WMI_EVENT
12 Canonical Confidential Ubuntu Hardware Summit. December 8th 2011
WMI - GUIDs
● F6E4FE6E-909D-47cb-8BAB-C9F6F2F8D396 dell_led● 0B3CBB35-E3C2-45ED-91C2-4C5A6D195D1C asus_nb_wmi● ABBC0F72-8EA1-11D1-00A0-C90629100000 eeepc_wmi● 9DBB5994-A997-11DA-B012-B622A1EF5492 dell_wmi● 02314822-307C-4F66-BF0E-48AEAEB26CC8 dell_wmi_aio● 284A0E6B-380E-472A-921F-E52786257FB4 dell_wmi_aio● 676AA15E-6A47-4D9F-A2CC-1E6D18D14026 acer_wmi● 6AF4F258-B401-42FD-BE91-3D4AC2D7C0D3 acer_wmi● 67C3371D-95A3-4C37-BB61-DD47B491DAAB acer_wmi● 5FB7F034-2C63-45e9-BE91-3D44E2C707E4 hp_wmi● 95F24279-4D7B-4334-9387-ACCDC67EF61C hp_wmi● B6F3EEF2-3D2F-49DC-9DE3-85BCE18C62F2 msi_wmi● 551A1F84-FBDD-4125-91DB-3EA8F44F1D45 msi_wmi● F6CB5C3C-9CAE-4EBD-B577-931EA32A2CC0 mxm_wmi
13 Canonical Confidential Ubuntu Hardware Summit. December 8th 2011
Something important about key enablement
● In Linux, we are using a driver for an ACPI device/GUID on all machine
● Driver will map each ACPI device:event or GUID:event to a single keycode
● Please NOT to use same device:event on different machine for different propose
14 Canonical Confidential Ubuntu Hardware Summit. December 8th 2011
rfkill
● We want our airplane landing safely
● We would like to save more power when wireless is not necessary
● Rfkill provides a generic interface to disabling any radio transmitter in the system
● User can monitor rfkill status by `rfkill list`
$ rfkill list0: brcmwl-0: Wireless LAN
Soft blocked: noHard blocked: no
1: ideapad_wlan: Wireless LANSoft blocked: noHard blocked: no
2: hci0: BluetoothSoft blocked: noHard blocked: no
3: ideapad_bluetooth: BluetoothSoft blocked: noHard blocked: no
15 Canonical Confidential Ubuntu Hardware Summit. December 8th 2011
rfkill
ApplicationApplication
Rfkill subsystem coreRfkill subsystem core
Platform driverPlatform driver
HardwareHardware
Soft block or unblock
Hard/Soft status
Soft block or unblock
Event/status of physical switch
Update soft status
Status of hard/soft
Thank you
Questions ?
Top Related