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
This commit is contained in:
1 parent
ef8cd284b9
commit
dfaff3b01b
2 files changed
+86
No files matched your search
Vendored
+85
@@ -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)
|
||||||
|
{
|
||||||
|
/*
|
||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
00-fix-reinit.patch
|
||||||
Reference in new issue
Block a user