]> xenbits.xensource.com Git - qemu-xen-3.4-testing.git/commitdiff
fix usb-hid emulation SET_IDLE
authorIan Jackson <ian.jackson@eu.citrix.com>
Wed, 7 Jan 2009 15:16:04 +0000 (15:16 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 7 Jan 2009 15:16:04 +0000 (15:16 +0000)
there is a bug in the current usb-hid emulation code that affects the
way the idle flag is handled: the spec clearly states that when SET_IDLE
is called with a value == 0 means "do not send any event unless there is
an actual change". However we are currently assuming the opposite
meaning of the flag.
This patch fixes it and it also fixes a possible initialization issue
that is uncovered by using the default idle flag set to 0.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
[supplied patch also trivially changed by Ian Jackson]

hw/usb-hid.c

index e4e58f2ea829e90e6fed05874079ae33f61fd869..4e4e1e143bea06a42d5a827bc33171f4aabcafd8 100644 (file)
@@ -541,8 +541,7 @@ static inline int int_clamp(int val, int vmin, int vmax)
 
 static int usb_suppress_report(USBHIDState *hs, int unchanged) {
     /* TODO: Implement finite idle delays.  */
-    if (!hs->idle) return 0; /* SET_IDLE 0 means always report */
-    return unchanged;
+    return !hs->idle && unchanged; /* SET_IDLE 0 means do not report */
 }
 
 static int usb_pointer_poll(USBHIDState *hs, uint8_t *buf, int len)
@@ -551,15 +550,15 @@ static int usb_pointer_poll(USBHIDState *hs, uint8_t *buf, int len)
     USBPointerState *s = &hs->ptr;
     USBPointerEvent *e;
 
-    if (usb_suppress_report(hs, s->head == s->tail))
-       return USB_RET_NAK;
-
     if (!s->mouse_grabbed) {
        s->eh_entry = qemu_add_mouse_event_handler(usb_pointer_event, hs,
                                           !s->xyrel, "QEMU USB Pointer");
        s->mouse_grabbed = 1;
     }
 
+    if (usb_suppress_report(hs, s->head == s->tail))
+       return USB_RET_NAK;
+
     if (s->head == s->tail)
         /* use the last report */
         s->head = (s->head - 1) & QUEUEINDEXMASK;