2015-05-17 21:35:48 +03:00
|
|
|
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
|
2019-11-14 00:08:14 +03:00
|
|
|
@@ -283,19 +283,36 @@
|
2015-05-17 21:35:48 +03:00
|
|
|
return keyboard_device;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-14 00:08:14 +03:00
|
|
|
-
|
|
|
|
|
-int re_initLibG15()
|
2015-05-17 21:35:48 +03:00
|
|
|
+/* reset the keyboard, returning it to a known state */
|
|
|
|
|
+static int closeKeyboardDevice()
|
2019-11-14 00:08:14 +03:00
|
|
|
{
|
2015-05-17 21:35:48 +03:00
|
|
|
+ int retval = G15_NO_ERROR;
|
2019-11-14 00:08:14 +03:00
|
|
|
|
|
|
|
|
- usb_init();
|
2015-05-17 21:35:48 +03:00
|
|
|
+ enospc_slowdown = shared_device = g15_keys_endpoint = g15_lcd_endpoint = 0;
|
|
|
|
|
+ found_devicetype = -1;
|
2019-11-14 00:08:14 +03:00
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 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 */
|
2015-05-17 21:35:48 +03:00
|
|
|
+ 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;
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
- if (!usb_find_devices())
|
|
|
|
|
- return G15_ERROR_OPENING_USB_DEVICE;
|
2019-11-14 00:08:14 +03:00
|
|
|
+int re_initLibG15()
|
|
|
|
|
+{
|
|
|
|
|
+ closeKeyboardDevice();
|
|
|
|
|
+
|
2015-05-17 21:35:48 +03:00
|
|
|
+ usb_find_busses();
|
|
|
|
|
+ usb_find_devices();
|
2019-11-14 00:08:14 +03:00
|
|
|
|
2015-05-17 21:35:48 +03:00
|
|
|
keyboard_device = findAndOpenG15();
|
|
|
|
|
if (!keyboard_device)
|
2019-11-14 00:08:14 +03:00
|
|
|
@@ -327,28 +344,12 @@
|
2015-05-17 21:35:48 +03:00
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
/*
|