diff -Nru /tmp/SzphzA3lvK/hotkey-setup-0.1/debian/changelog /tmp/zskeWOmR1X/hotkey-setup-0.1/debian/changelog --- /tmp/SzphzA3lvK/hotkey-setup-0.1/debian/changelog 2006-04-29 20:09:27.000000000 +0100 +++ /tmp/zskeWOmR1X/hotkey-setup-0.1/debian/changelog 2006-05-29 11:24:33.000000000 +0100 @@ -1,3 +1,10 @@ +hotkey-setup (0.1-17ubuntu1) unstable; urgency=low + + * Reduce polling-frequency of 'thinkpad-keys' to mitigate excessive + CPU usage on the new LenovoPads with very slow NVRAM. + + -- Paul Sladen Mon, 29 May 2006 11:05:43 +0100 + hotkey-setup (0.1-17) unstable; urgency=low * Add support for Samsung hotkeys (eg. x05 and others) [Malone: #23165] diff -Nru /tmp/SzphzA3lvK/hotkey-setup-0.1/debian/init.d /tmp/zskeWOmR1X/hotkey-setup-0.1/debian/init.d --- /tmp/SzphzA3lvK/hotkey-setup-0.1/debian/init.d 2006-04-29 20:09:27.000000000 +0100 +++ /tmp/zskeWOmR1X/hotkey-setup-0.1/debian/init.d 2006-05-29 11:31:05.000000000 +0100 @@ -6,6 +6,7 @@ SAVED_STATE=/var/run/hotkey-setup THINKPAD_LOCKFILE=$SAVED_STATE.thinkpad-keys +THINKPAD_HERTZ=8 # This is here because it needs to be executed both if we have a # Lenovo that also IDs as a ThinkPad, or if we have a real IBM one. @@ -18,7 +19,7 @@ if [ ! -b /dev/nvram ]; then modprobe nvram fi - /usr/sbin/thinkpad-keys && touch $THINKPAD_LOCKFILE + /usr/sbin/thinkpad-keys --hertz $THINKPAD_HERTZ && touch $THINKPAD_LOCKFILE fi } diff -Nru /tmp/SzphzA3lvK/hotkey-setup-0.1/thinkpad-keys.c /tmp/zskeWOmR1X/hotkey-setup-0.1/thinkpad-keys.c --- /tmp/SzphzA3lvK/hotkey-setup-0.1/thinkpad-keys.c 2006-03-25 20:06:18.000000000 +0000 +++ /tmp/zskeWOmR1X/hotkey-setup-0.1/thinkpad-keys.c 2006-05-29 11:36:42.000000000 +0100 @@ -37,7 +37,7 @@ #define UINPUT_DEVICE "/dev/input/uinput" #define NVRAM_DEVICE "/dev/nvram" -#define POLL_DELAY 50 /* milliseconds */ +#define POLL_HZ 20 /* per second */ static int init_nvram(void) { @@ -238,6 +238,7 @@ { int nvram, uinput; struct record state[2]; + int hertz, us_delay; int buttons, counter = 1; #if 1 @@ -248,6 +249,16 @@ int mask = THINKPAD|ZOOM; #endif + if(!(argc == 3 + && !strcmp(argv[1], "--hertz") + && hertz = strtol(argv[2], NULL, 0) + && hertz >= 1 + && hertz <= 50) + ) + hertz = POLL_HZ; + + us_delay = 1000000 / hertz; + if(!(nvram = init_nvram())) { perror("Could not open nvram device"); @@ -279,7 +290,7 @@ compare_nvram(&buttons, state + (counter^1), state + counter); if(buttons &= mask) punt_keycodes(uinput, buttons, codes); - usleep(POLL_DELAY*1000); + usleep(us_delay); } cleanup_uinput(SIGTERM);