Merge lp:~lazyranma/ubuntu/wily/libg15/libg15 into lp:ubuntu/wily/libg15

Proposed by Alexander Ponyatykh
Status: Merged
Merge reported by: Łukasz Zemczak
Merged at revision: not available
Proposed branch: lp:~lazyranma/ubuntu/wily/libg15/libg15
Merge into: lp:ubuntu/wily/libg15
Diff against target: 132 lines (+96/-1)
5 files modified
debian/changelog (+8/-0)
debian/control (+1/-1)
debian/patches/00-fix-reinit.patch (+85/-0)
debian/patches/series (+1/-0)
debian/source/format (+1/-0)
To merge this branch: bzr merge lp:~lazyranma/ubuntu/wily/libg15/libg15
Reviewer Review Type Date Requested Status
Ubuntu branches Pending
Review via email: mp+259742@code.launchpad.net

Description of the change

Original re_initLibG15() doesn't properly reset internal state of the library, and therefore device cannot be reopened after replugging or suspend/resume. This patch adds code from exitLibG15() to re_initLibG15() allowing it to correctly reopen device. (LP: #1357556)

To post a comment you must log in.
Revision history for this message
Martin Pitt (pitti) wrote :

Please forward the patches to upstream (http://sourceforge.net/projects/g15tools). Thanks!

Revision history for this message
Alexander Ponyatykh (lazyranma) wrote :

Upstream seems to be dead - last release was in 2007, and last commit was in 2011, but I've posted it anyway.
https://sourceforge.net/p/g15tools/patches/5/

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

First of all, thank you for your contribution to this project! Indeed the upstream seems to be inactive, but at least now we know that your patch will not be forgotten and if the developers ever decide to resume work they'll have your changes for review.

The changes generally seem sane to me, although I could only check the code as I don't own a keyboard that would be compatible. All in all, I'll upload the package to wily shortly.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2014-01-01 22:26:54 +0000
3+++ debian/changelog 2015-05-21 10:18:23 +0000
4@@ -1,3 +1,11 @@
5+libg15 (1.2.7-2ubuntu1ppa1) wily; urgency=medium
6+
7+ * debian/patches/00-fix-reinit.patch: fixed re_initLibG15() to properly reset
8+ internal state, allowing g15daemon to continue working after keyboard was
9+ replugged and after suspend or hibernate. (LP: #1357556)
10+
11+ -- Alexander Ponyatykh <lazyranma@gmail.com> Sun, 17 May 2015 21:35:48 +0300
12+
13 libg15 (1.2.7-2ubuntu1) trusty; urgency=medium
14
15 * Use dh-autoreconf instead of autotools-dev to also fix FTBFS on ppc64el by
16
17=== modified file 'debian/control'
18--- debian/control 2014-01-01 22:26:54 +0000
19+++ debian/control 2015-05-21 10:18:23 +0000
20@@ -4,7 +4,7 @@
21 Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
22 XSBC-Original-Maintainer: Giacomo Catenazzi <cate@debian.org>
23 Build-Depends: cdbs, debhelper (>= 5), dh-autoreconf, libusb-dev
24-Standards-Version: 3.8.3
25+Standards-Version: 3.9.6
26 Homepage: http://www.g15tools.com/
27
28 Package: libg15-1
29
30=== added directory 'debian/patches'
31=== added file 'debian/patches/00-fix-reinit.patch'
32--- debian/patches/00-fix-reinit.patch 1970-01-01 00:00:00 +0000
33+++ debian/patches/00-fix-reinit.patch 2015-05-21 10:18:23 +0000
34@@ -0,0 +1,85 @@
35+Description: fix re_initLibG15() to properly reset internal state.
36+Author: Alexander Ponyatykh <lazyranma@gmail.com>
37+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/libusb/+bug/1357556
38+Forwarded: no
39+Last-Update: 2015-05-17
40+===================================================================
41+--- a/libg15.c
42++++ b/libg15.c
43+@@ -275,19 +275,36 @@
44+ return keyboard_device;
45+ }
46+
47++/* reset the keyboard, returning it to a known state */
48++static int closeKeyboardDevice()
49++{
50++ int retval = G15_NO_ERROR;
51++
52++ enospc_slowdown = shared_device = g15_keys_endpoint = g15_lcd_endpoint = 0;
53++ found_devicetype = -1;
54++
55++ if (keyboard_device){
56++#ifndef SUN_LIBUSB
57++ retval = usb_release_interface (keyboard_device, 0);
58++ usleep(50*1000);
59++#endif
60++#if 0
61++ retval = usb_reset(keyboard_device);
62++ usleep(50*1000);
63++#endif
64++ usb_close(keyboard_device);
65++ keyboard_device=0;
66++ return retval;
67++ }
68++ return -1;
69++}
70+
71+ int re_initLibG15()
72+ {
73++ closeKeyboardDevice();
74+
75+- usb_init();
76+-
77+- /**
78+- * usb_find_busses and usb_find_devices both report the number of devices
79+- * / busses added / removed since the last call. since this is the first
80+- * call we have to return values != 0 or else we didnt find anything */
81+-
82+- if (!usb_find_devices())
83+- return G15_ERROR_OPENING_USB_DEVICE;
84++ usb_find_busses();
85++ usb_find_devices();
86+
87+ keyboard_device = findAndOpenG15();
88+ if (!keyboard_device)
89+@@ -319,28 +336,12 @@
90+ return retval;
91+ }
92+
93+-/* reset the keyboard, returning it to a known state */
94+ int exitLibG15()
95+ {
96+- int retval = G15_NO_ERROR;
97+- if (keyboard_device){
98+-#ifndef SUN_LIBUSB
99+- retval = usb_release_interface (keyboard_device, 0);
100+- usleep(50*1000);
101+-#endif
102+-#if 0
103+- retval = usb_reset(keyboard_device);
104+- usleep(50*1000);
105+-#endif
106+- usb_close(keyboard_device);
107+- keyboard_device=0;
108+- pthread_mutex_destroy(&libusb_mutex);
109+- return retval;
110+- }
111+- return -1;
112++ pthread_mutex_destroy(&libusb_mutex);
113++ return closeKeyboardDevice();
114+ }
115+
116+-
117+ static void dumpPixmapIntoLCDFormat(unsigned char *lcd_buffer, unsigned char const *data)
118+ {
119+ /*
120
121=== added file 'debian/patches/series'
122--- debian/patches/series 1970-01-01 00:00:00 +0000
123+++ debian/patches/series 2015-05-21 10:18:23 +0000
124@@ -0,0 +1,1 @@
125+00-fix-reinit.patch
126
127=== added directory 'debian/source'
128=== added file 'debian/source/format'
129--- debian/source/format 1970-01-01 00:00:00 +0000
130+++ debian/source/format 2015-05-21 10:18:23 +0000
131@@ -0,0 +1,1 @@
132+3.0 (quilt)

Subscribers

People subscribed via source and target branches