This repository has been archived by the owner on Feb 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
usb-event-revert.patch
82 lines (75 loc) · 2.56 KB
/
usb-event-revert.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# --- T2-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# T2 SDE: target/coreos/package/.../usb-event-revert.patch
# Copyright (C) 2012 The T2 SDE Project
#
# More information can be found in the files COPYING and README.
#
# This patch file is dual-licensed. It is available under the license the
# patched project is licensed under, as long as it is an OpenSource license
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
# of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# --- T2-COPYRIGHT-NOTE-END ---
diff --git a/hw/usb-hid.c b/hw/usb-hid.c
index b730692..870cc66 100644
--- qemu-kvm-1.0.1/hw/hid.h.vanilla 2012-06-28 09:02:21.238285847 +0000
+++ qemu-kvm-1.0.1/hw/hid.h 2012-06-28 09:02:33.246270536 +0000
@@ -42,13 +42,13 @@
int32_t protocol;
uint8_t idle;
int64_t next_idle_clock;
+ int changed;
HIDEventFunc event;
};
void hid_init(HIDState *hs, int kind, HIDEventFunc event);
void hid_reset(HIDState *hs);
void hid_free(HIDState *hs);
-
bool hid_has_events(HIDState *hs);
void hid_set_next_idle(HIDState *hs, int64_t curtime);
void hid_pointer_activate(HIDState *hs);
--- qemu-kvm-1.0.1/hw/usb-hid.c.orig 2012-06-28 08:56:29.854287667 +0000
+++ qemu-kvm-1.0.1/hw/usb-hid.c 2012-06-28 09:08:34.998287611 +0000
@@ -360,6 +360,8 @@
{
USBHIDState *us = container_of(hs, USBHIDState, hid);
+ us->hid.changed = 1;
+
usb_wakeup(&us->dev);
}
@@ -419,6 +421,7 @@
} else if (hs->kind == HID_KEYBOARD) {
ret = hid_keyboard_poll(hs, data, length);
}
+ us->hid.changed = hs->n > 0;
break;
case SET_REPORT:
if (hs->kind == HID_KEYBOARD) {
@@ -472,7 +475,7 @@
case USB_TOKEN_IN:
if (p->devep == 1) {
int64_t curtime = qemu_get_clock_ns(vm_clock);
- if (!hid_has_events(hs) &&
+ if (!us->hid.changed &&
(!hs->idle || hs->next_idle_clock - curtime > 0)) {
return USB_RET_NAK;
}
@@ -483,6 +486,7 @@
ret = hid_keyboard_poll(hs, buf, p->iov.size);
}
usb_packet_copy(p, buf, ret);
+ us->hid.changed = hs->n > 0;
} else {
goto fail;
}
@@ -509,6 +513,9 @@
usb_desc_init(dev);
hid_init(&us->hid, kind, usb_hid_changed);
+
+ /* Force poll routine to be run and grab input the first time. */
+ us->hid.changed = 1;
return 0;
}