diff options
author | Alexander Ponyatykh <lazyranma@gmail.com> | 2015-05-17 21:35:48 +0300 |
---|---|---|
committer | Andrej Shadura <andrewsh@debian.org> | 2019-05-10 11:34:58 +0200 |
commit | dfaff3b01b4fb519ad9a42e5cc8d41ea2bb98629 (patch) | |
tree | cf24b67b5e85d42a42e8c2d02600f22ab4dbb63b | |
parent | ef8cd284b9dd15a5d66bfbbfa4dd74b7acf69b76 (diff) |
Add a patch to fix re_initLibG15() to properly reset the internal state
This allows g15daemon to continue working after keyboard was
replugged and after suspend or hibernate.
LP: #1357556
-rw-r--r-- | debian/patches/00-fix-reinit.patch | 85 | ||||
-rw-r--r-- | debian/patches/series | 1 |
2 files changed, 86 insertions, 0 deletions
diff --git a/debian/patches/00-fix-reinit.patch b/debian/patches/00-fix-reinit.patch new file mode 100644 index 0000000..ea6c91e --- /dev/null +++ b/debian/patches/00-fix-reinit.patch @@ -0,0 +1,85 @@ +Description: fix re_initLibG15() to properly reset internal state. +Author: Alexander Ponyatykh <lazyranma@gmail.com> +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/libusb/+bug/1357556 +Forwarded: no +Last-Update: 2015-05-17 +=================================================================== +--- a/libg15.c ++++ b/libg15.c +@@ -275,19 +275,36 @@ + return keyboard_device; + } + ++/* reset the keyboard, returning it to a known state */ ++static int closeKeyboardDevice() ++{ ++ int retval = G15_NO_ERROR; ++ ++ enospc_slowdown = shared_device = g15_keys_endpoint = g15_lcd_endpoint = 0; ++ found_devicetype = -1; ++ ++ if (keyboard_device){ ++#ifndef SUN_LIBUSB ++ retval = usb_release_interface (keyboard_device, 0); ++ usleep(50*1000); ++#endif ++#if 0 ++ retval = usb_reset(keyboard_device); ++ usleep(50*1000); ++#endif ++ usb_close(keyboard_device); ++ keyboard_device=0; ++ return retval; ++ } ++ return -1; ++} + + int re_initLibG15() + { ++ closeKeyboardDevice(); + +- usb_init(); +- +- /** +- * usb_find_busses and usb_find_devices both report the number of devices +- * / busses added / removed since the last call. since this is the first +- * call we have to return values != 0 or else we didnt find anything */ +- +- if (!usb_find_devices()) +- return G15_ERROR_OPENING_USB_DEVICE; ++ usb_find_busses(); ++ usb_find_devices(); + + keyboard_device = findAndOpenG15(); + if (!keyboard_device) +@@ -319,28 +336,12 @@ + return retval; + } + +-/* reset the keyboard, returning it to a known state */ + int exitLibG15() + { +- int retval = G15_NO_ERROR; +- if (keyboard_device){ +-#ifndef SUN_LIBUSB +- retval = usb_release_interface (keyboard_device, 0); +- usleep(50*1000); +-#endif +-#if 0 +- retval = usb_reset(keyboard_device); +- usleep(50*1000); +-#endif +- usb_close(keyboard_device); +- keyboard_device=0; +- pthread_mutex_destroy(&libusb_mutex); +- return retval; +- } +- return -1; ++ pthread_mutex_destroy(&libusb_mutex); ++ return closeKeyboardDevice(); + } + +- + static void dumpPixmapIntoLCDFormat(unsigned char *lcd_buffer, unsigned char const *data) + { + /* diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..d3d0c3a --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +00-fix-reinit.patch |