Remove 00-fix-reinit.patch
Initialization and deinitialization functions were rewritten as part of switch to libusb 1.0 path. There is no point in keeping a separate patch that changes them slightly.
This commit is contained in:
1 parent
3e35fe1061
commit
02ea3752d0
5 files changed
+70
-160
No files matched your search
Vendored
-94
@@ -1,94 +0,0 @@
|
||||
From: Alexander Ponyatykh <lazyranma@gmail.com>
|
||||
Date: Fri, 15 Nov 2019 02:19:01 +0300
|
||||
Subject: fix re_initLibG15() to properly reset internal state.
|
||||
|
||||
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/libusb/+bug/1357556
|
||||
Forwarded: no
|
||||
Last-Update: 2015-05-17
|
||||
|
||||
===================================================================
|
||||
---
|
||||
libg15.c | 55 ++++++++++++++++++++++++++++---------------------------
|
||||
1 file changed, 28 insertions(+), 27 deletions(-)
|
||||
|
||||
diff --git a/libg15.c b/libg15.c
|
||||
index 31b2bd6..369ed40 100644
|
||||
--- a/libg15.c
|
||||
+++ b/libg15.c
|
||||
@@ -283,19 +283,36 @@ static usb_dev_handle * findAndOpenG15() {
|
||||
return keyboard_device;
|
||||
}
|
||||
|
||||
-
|
||||
-int re_initLibG15()
|
||||
+/* reset the keyboard, returning it to a known state */
|
||||
+static int closeKeyboardDevice()
|
||||
{
|
||||
+ int retval = G15_NO_ERROR;
|
||||
|
||||
- usb_init();
|
||||
+ enospc_slowdown = shared_device = g15_keys_endpoint = g15_lcd_endpoint = 0;
|
||||
+ found_devicetype = -1;
|
||||
|
||||
- /**
|
||||
- * 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 (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;
|
||||
+int re_initLibG15()
|
||||
+{
|
||||
+ closeKeyboardDevice();
|
||||
+
|
||||
+ usb_find_busses();
|
||||
+ usb_find_devices();
|
||||
|
||||
keyboard_device = findAndOpenG15();
|
||||
if (!keyboard_device)
|
||||
@@ -327,28 +344,12 @@ int initLibG15()
|
||||
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
+2
-2
@@ -7,7 +7,7 @@ Subject: fix spelling error
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/libg15.c b/libg15.c
|
||||
index 369ed40..ba1c94b 100644
|
||||
index 31b2bd6..56df958 100644
|
||||
--- a/libg15.c
|
||||
+++ b/libg15.c
|
||||
@@ -152,7 +152,7 @@ static usb_dev_handle * findAndOpenDevice(libg15_devices_t handled_device, int d
|
||||
@@ -19,7 +19,7 @@ index 369ed40..ba1c94b 100644
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -434,7 +434,7 @@ int handle_usb_errors(const char *prefix, int ret) {
|
||||
@@ -433,7 +433,7 @@ int handle_usb_errors(const char *prefix, int ret) {
|
||||
case -ETIMEDOUT:
|
||||
return G15_ERROR_READING_USB_DEVICE; /* backward-compatibility */
|
||||
break;
|
||||
|
||||
+64
-60
@@ -4,8 +4,8 @@ Subject: Migrate from legacy libusb-0.1 to libusb-1.0
|
||||
|
||||
---
|
||||
configure.in | 5 +-
|
||||
libg15.c | 615 +++++++++++++++++++++++++++++++----------------------------
|
||||
2 files changed, 327 insertions(+), 293 deletions(-)
|
||||
libg15.c | 624 +++++++++++++++++++++++++++++++----------------------------
|
||||
2 files changed, 332 insertions(+), 297 deletions(-)
|
||||
|
||||
diff --git a/configure.in b/configure.in
|
||||
index 074d98e..b533d2c 100644
|
||||
@@ -31,7 +31,7 @@ index 074d98e..b533d2c 100644
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
diff --git a/libg15.c b/libg15.c
|
||||
index ba1c94b..4c0afc4 100644
|
||||
index 56df958..4c0afc4 100644
|
||||
--- a/libg15.c
|
||||
+++ b/libg15.c
|
||||
@@ -24,20 +24,22 @@
|
||||
@@ -71,7 +71,7 @@ index ba1c94b..4c0afc4 100644
|
||||
}
|
||||
|
||||
/* debugging wrapper */
|
||||
@@ -86,234 +90,281 @@ static int g15_log (FILE *fd, unsigned int level, const char *fmt, ...) {
|
||||
@@ -86,216 +90,280 @@ static int g15_log (FILE *fd, unsigned int level, const char *fmt, ...) {
|
||||
|
||||
/* return number of connected and supported devices */
|
||||
int g15NumberOfConnectedDevices() {
|
||||
@@ -87,14 +87,14 @@ index ba1c94b..4c0afc4 100644
|
||||
+ ssize_t cnt = libusb_get_device_list(libg15_libusb_context, &list);
|
||||
+
|
||||
+ if (cnt < 0)
|
||||
+ {
|
||||
{
|
||||
- for (dev = bus->devices; dev; dev = dev->next)
|
||||
+ g15_log(stderr, G15_LOG_INFO, "Unable to list USB devices: %s\n", libusb_strerror(cnt));
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ for (ssize_t i = 0; i < cnt; i++)
|
||||
{
|
||||
- for (dev = bus->devices; dev; dev = dev->next)
|
||||
+ {
|
||||
+ libusb_get_device_descriptor(list[i], &desc);
|
||||
+
|
||||
+ for (int j = 0; g15_devices[i].name != NULL; j++)
|
||||
@@ -115,13 +115,13 @@ index ba1c94b..4c0afc4 100644
|
||||
static int initLibUsb()
|
||||
{
|
||||
- usb_init();
|
||||
+ int errcode = libusb_init(&libg15_libusb_context);
|
||||
|
||||
-
|
||||
- /**
|
||||
- * 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 */
|
||||
-
|
||||
+ int errcode = libusb_init(&libg15_libusb_context);
|
||||
|
||||
- if (!usb_find_busses())
|
||||
+ if (errcode != 0)
|
||||
+ {
|
||||
@@ -414,8 +414,7 @@ index ba1c94b..4c0afc4 100644
|
||||
+ {
|
||||
+ g15_keys_endpoint = ep->bEndpointAddress;
|
||||
+ }
|
||||
else
|
||||
- g15_log(stderr,G15_LOG_INFO,"%s not found\n",g15_devices[i].name);
|
||||
+ else
|
||||
+ {
|
||||
+ g15_lcd_endpoint = ep->bEndpointAddress;
|
||||
+ }
|
||||
@@ -430,7 +429,8 @@ index ba1c94b..4c0afc4 100644
|
||||
+ {
|
||||
+ g15_log(stderr,G15_LOG_INFO,"Success, detached the driver\n");
|
||||
+ }
|
||||
+ else
|
||||
else
|
||||
- g15_log(stderr,G15_LOG_INFO,"%s not found\n",g15_devices[i].name);
|
||||
+ {
|
||||
+ g15_log(stderr,G15_LOG_INFO,"Could not detach the driver, giving up: %s\n", libusb_strerror(ret));
|
||||
+ goto error;
|
||||
@@ -486,29 +486,14 @@ index ba1c94b..4c0afc4 100644
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
+
|
||||
/* reset the keyboard, returning it to a known state */
|
||||
static int closeKeyboardDevice()
|
||||
|
||||
-int re_initLibG15()
|
||||
+/* 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;
|
||||
+ int retval = G15_ERROR_OPENING_USB_DEVICE;
|
||||
+
|
||||
|
||||
- usb_init();
|
||||
+ pthread_mutex_lock(&libusb_mutex);
|
||||
+ if (keyboard_device) {
|
||||
+ retval = libusb_release_interface(keyboard_device, 0);
|
||||
@@ -516,27 +501,28 @@ index ba1c94b..4c0afc4 100644
|
||||
+ libusb_close(keyboard_device);
|
||||
+ keyboard_device = NULL;
|
||||
+ retval = G15_NO_ERROR;
|
||||
}
|
||||
- return -1;
|
||||
+
|
||||
+ }
|
||||
|
||||
- /**
|
||||
- * 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 */
|
||||
+ shared_device = g15_keys_endpoint = g15_lcd_endpoint = 0;
|
||||
+ g15_interface_id = found_devicetype = -1;
|
||||
+ pthread_mutex_unlock(&libusb_mutex);
|
||||
+
|
||||
|
||||
- if (!usb_find_devices())
|
||||
- return G15_ERROR_OPENING_USB_DEVICE;
|
||||
+ return retval;
|
||||
}
|
||||
+}
|
||||
+
|
||||
+int re_initLibG15()
|
||||
+{
|
||||
+ closeKeyboardDevice();
|
||||
|
||||
int re_initLibG15()
|
||||
{
|
||||
closeKeyboardDevice();
|
||||
|
||||
- usb_find_busses();
|
||||
- usb_find_devices();
|
||||
-
|
||||
keyboard_device = findAndOpenG15();
|
||||
if (!keyboard_device)
|
||||
return G15_ERROR_OPENING_USB_DEVICE;
|
||||
@@ -323,31 +374,33 @@ int re_initLibG15()
|
||||
@@ -306,48 +374,34 @@ int re_initLibG15()
|
||||
|
||||
int initLibG15()
|
||||
{
|
||||
@@ -571,19 +557,37 @@ index ba1c94b..4c0afc4 100644
|
||||
+ return G15_NO_ERROR;
|
||||
}
|
||||
|
||||
-/* 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;
|
||||
-}
|
||||
+ closeKeyboardDevice();
|
||||
+ if (libg15_libusb_context) libusb_exit(libg15_libusb_context);
|
||||
+ libg15_libusb_context = NULL;
|
||||
+
|
||||
pthread_mutex_destroy(&libusb_mutex);
|
||||
- return closeKeyboardDevice();
|
||||
|
||||
+ pthread_mutex_destroy(&libusb_mutex);
|
||||
+ return G15_NO_ERROR;
|
||||
}
|
||||
+}
|
||||
|
||||
static void dumpPixmapIntoLCDFormat(unsigned char *lcd_buffer, unsigned char const *data)
|
||||
@@ -428,36 +481,6 @@ static void dumpPixmapIntoLCDFormat(unsigned char *lcd_buffer, unsigned char con
|
||||
{
|
||||
@@ -427,36 +481,6 @@ static void dumpPixmapIntoLCDFormat(unsigned char *lcd_buffer, unsigned char con
|
||||
}
|
||||
}
|
||||
|
||||
@@ -620,7 +624,7 @@ index ba1c94b..4c0afc4 100644
|
||||
int writePixmapToLCD(unsigned char const *data)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -474,43 +497,27 @@ int writePixmapToLCD(unsigned char const *data)
|
||||
@@ -473,43 +497,27 @@ int writePixmapToLCD(unsigned char const *data)
|
||||
|
||||
/* the keyboard needs this magic byte */
|
||||
lcd_buffer[0] = 0x03;
|
||||
@@ -682,7 +686,7 @@ index ba1c94b..4c0afc4 100644
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -535,7 +542,9 @@ int setLCDContrast(unsigned int level)
|
||||
@@ -534,7 +542,9 @@ int setLCDContrast(unsigned int level)
|
||||
usb_data[3] = 18;
|
||||
}
|
||||
pthread_mutex_lock(&libusb_mutex);
|
||||
@@ -693,7 +697,7 @@ index ba1c94b..4c0afc4 100644
|
||||
pthread_mutex_unlock(&libusb_mutex);
|
||||
return retval;
|
||||
}
|
||||
@@ -553,7 +562,9 @@ int setLEDs(unsigned int leds)
|
||||
@@ -552,7 +562,9 @@ int setLEDs(unsigned int leds)
|
||||
return G15_ERROR_UNSUPPORTED;
|
||||
|
||||
pthread_mutex_lock(&libusb_mutex);
|
||||
@@ -704,7 +708,7 @@ index ba1c94b..4c0afc4 100644
|
||||
pthread_mutex_unlock(&libusb_mutex);
|
||||
return retval;
|
||||
}
|
||||
@@ -578,7 +589,9 @@ int setLCDBrightness(unsigned int level)
|
||||
@@ -577,7 +589,9 @@ int setLCDBrightness(unsigned int level)
|
||||
usb_data[2] = 0x00;
|
||||
}
|
||||
pthread_mutex_lock(&libusb_mutex);
|
||||
@@ -715,7 +719,7 @@ index ba1c94b..4c0afc4 100644
|
||||
pthread_mutex_unlock(&libusb_mutex);
|
||||
return retval;
|
||||
}
|
||||
@@ -604,7 +617,9 @@ int setKBBrightness(unsigned int level)
|
||||
@@ -603,7 +617,9 @@ int setKBBrightness(unsigned int level)
|
||||
usb_data[2] = 0x0;
|
||||
}
|
||||
pthread_mutex_lock(&libusb_mutex);
|
||||
@@ -726,7 +730,7 @@ index ba1c94b..4c0afc4 100644
|
||||
pthread_mutex_unlock(&libusb_mutex);
|
||||
return retval;
|
||||
}
|
||||
@@ -619,7 +634,9 @@ int setG510LEDColor(unsigned char r, unsigned char g, unsigned char b)
|
||||
@@ -618,7 +634,9 @@ int setG510LEDColor(unsigned char r, unsigned char g, unsigned char b)
|
||||
usb_data[3] = b;
|
||||
|
||||
pthread_mutex_lock(&libusb_mutex);
|
||||
@@ -737,7 +741,7 @@ index ba1c94b..4c0afc4 100644
|
||||
pthread_mutex_unlock(&libusb_mutex);
|
||||
return retval;
|
||||
}
|
||||
@@ -1033,38 +1050,54 @@ static void processKeyEvent4Byte(unsigned int *pressed_keys, unsigned char *buff
|
||||
@@ -1032,38 +1050,54 @@ static void processKeyEvent4Byte(unsigned int *pressed_keys, unsigned char *buff
|
||||
int getPressedKeys(unsigned int *pressed_keys, unsigned int timeout)
|
||||
{
|
||||
unsigned char buffer[G15_KEY_READ_LENGTH];
|
||||
Vendored
-1
@@ -1,3 +1,2 @@
|
||||
00-fix-reinit.patch
|
||||
01-fix-spelling.path
|
||||
02-Migrate-from-legacy-libusb-0.1-to-libusb-1.0.patch
|
||||
Reference in new issue
Block a user