Merge lp:~hui.wang/unity-settings-daemon/unity-settings-daemon-1404-fix-touchscreen-reconnect into lp:unity-settings-daemon/14.04

Proposed by Hui Wang on 2016-05-04
Status: Rejected
Rejected by: Sebastien Bacher on 2016-05-23
Proposed branch: lp:~hui.wang/unity-settings-daemon/unity-settings-daemon-1404-fix-touchscreen-reconnect
Merge into: lp:unity-settings-daemon/14.04
Diff against target: 69 lines (+51/-1)
1 file modified
plugins/xrandr/gsd-xrandr-manager.c (+51/-1)
To merge this branch: bzr merge lp:~hui.wang/unity-settings-daemon/unity-settings-daemon-1404-fix-touchscreen-reconnect
Reviewer Review Type Date Requested Status
Sebastien Bacher Disapprove on 2016-05-23
Alberto Milone 2016-05-04 Approve on 2016-05-04
Review via email: mp+293700@code.launchpad.net

Description of the Change

We have an OEM bug, it has something to do with the u-s-d
touchscreen mapping, Please take a look. thanks.

https://bugs.launchpad.net/sutton/hwe-sutton/+bug/1530063

This is my investigation:

When we change the display resolution, the LG touchscreen will be
disconnected from usb host bus temporarily.

And at that time, the unity-settings-daemon will call on_randr_event
(GnomeRRScreen *screen, gpointer data)-->do_touchscreen_mapping
(GsdXrandrManager *manager)-->get_mappable_output_info
(GsdXrandrManager *manager, GnomeRRScreen *screen, GnomeRRConfig
*config)-->input_info_find_size_match (GsdXrandrManager *manager,
GnomeRRScreen *rr_screen)-->xdevice_get_dimensions (int deviceid,
guint *width, guint *height)-->XIQueryDevice (GDK_DISPLAY_XDISPLAY
(display), deviceid, &n_info) CRASHED IN THIS FUNCTION

It looks like the usb touchscreen is disconnected temporarily, but
the unity-settings-daemon does not know it, it finally call
XIQueryDevice() to query this input device, then it crash inside
this function.

This is the kernel log when changing display resolution:
  [ 62.941417] usb 1-10: USB disconnect, device number 7
[ 63.777166] do_trap: 154 callbacks suppressed
[ 63.777171] traps: unity-settings-[2178] trap int3
ip:7f8a69913c13 sp:7ffd1829bb50 error:0
[ 63.935059] usb 1-10: new full-speed USB device number 8 using xhci_hcd
[ 64.119528] usb 1-10: not running at top speed; connect to a high
speed hub
[ 64.120303] usb 1-10: New USB device found, idVendor=1fd2, idProduct=5003
[ 64.120305] usb 1-10: New USB device strings: Mfr=1, Product=2,
SerialNumber=0
[ 64.120307] usb 1-10: Product: LGD AIT Touch Controller
[ 64.120308] usb 1-10: Manufacturer: Melfas
[ 64.123083] input: Melfas LGD AIT Touch Controller as /devices/pci0000:00/0000:00:14.0/usb1/1-10/1-10:1.0/0003:1FD2:5003.0004/input/input19
[ 64.175930] hid-multitouch 0003:1FD2:5003.0004:
input,hiddev0,hidraw1: USB HID v1.11 Mouse [Melfas LGD AIT Touch
Controller] on usb-0000:00:14.0-10/input0
[ 64.176589] hid-generic 0003:1FD2:5003.0005: hiddev0,hidraw2: USB
HID v1.11 Device [Melfas LGD AIT Touch Controller] on
usb-0000:00:14.0-10/input1

To post a comment you must log in.
Alberto Milone (albertomilone) wrote :

The code looks good to me. It seems like a reasonable workaround. Thanks.

review: Approve
Sebastien Bacher (seb128) wrote :

thanks for the work, settings as rejected as discussed on https://code.launchpad.net/~hui.wang/unity-settings-daemon/unity-settings-daemon-master-touchscreen-fix/+merge/293704 we are looking at a better solution

review: Disapprove

Unmerged revisions

4049. By Hui Wang on 2016-04-21

check and wait the touchscreen before calling do map

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/xrandr/gsd-xrandr-manager.c'
2--- plugins/xrandr/gsd-xrandr-manager.c 2015-09-22 08:29:34 +0000
3+++ plugins/xrandr/gsd-xrandr-manager.c 2016-05-04 02:04:57 +0000
4@@ -1784,6 +1784,56 @@
5 log_msg ("Applied stored configuration\n");
6 }
7
8+/* At least on a Lenovo laptop with the LG LCD panel and the LG touchscreen,
9+ when we change the display resolution, the LG touchscreen will be temporarily
10+ disconnected from USB host bus for about 0.2 seconds, then will be
11+ reconnected to the USB host bus. If we let the system call
12+ do_touchscreen_mapping() before the reconnectting, the u-s-d will crash.
13+
14+ So we let system check and wait 2 seconds at most for the touchscreen to be ready
15+ again, if the touchscreen can't be ready after 2 seconds, we will think the
16+ touchscreen is disconnected.
17+*/
18+#define RETRY_TIMES 2
19+static gboolean
20+is_touchscreen_still_available (GsdXrandrManager *manager)
21+{
22+ GsdXrandrManagerPrivate *priv = manager->priv;
23+ XDeviceInfo *device_info;
24+ int n_devices;
25+ int i;
26+ gboolean ret = FALSE;
27+ int rtime = 0;
28+retry:
29+ device_info = XListInputDevices (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
30+ &n_devices);
31+ if (device_info == NULL)
32+ return ret;
33+
34+ for (i = 0; i < n_devices; i++) {
35+ if (device_info_is_touchscreen (&device_info[i])) {
36+ if (!strcmp(priv->main_touchscreen_name, g_strdup (device_info[i].name))) {
37+ ret = TRUE;
38+ break;
39+ }
40+ }
41+ }
42+
43+ XFreeDeviceList (device_info);
44+
45+ if (ret)
46+ return ret;
47+
48+ if (rtime++ < RETRY_TIMES) {
49+ sleep(1); /* sleep 1 second */
50+ goto retry;
51+ } else {
52+ priv->main_touchscreen_id = -1;
53+ priv->main_touchscreen_name = NULL;
54+ return ret;
55+ }
56+}
57+
58 static void
59 on_randr_event (GnomeRRScreen *screen, gpointer data)
60 {
61@@ -1837,7 +1887,7 @@
62 use_stored_configuration_or_auto_configure_outputs (manager, config_timestamp);
63 }
64
65- if (priv->main_touchscreen_id != -1) {
66+ if (priv->main_touchscreen_id != -1 && is_touchscreen_still_available(manager)) {
67 /* Set mapping of input devices onto displays */
68 log_msg ("\nSetting touchscreen mapping on RandR event\n");
69 do_touchscreen_mapping (manager);

Subscribers

People subscribed via source and target branches