fix usb-hid SET_IDLE behaviour
PATCH 1/1 fix usb-hid SET_IDLE behaviour
Hi all,
the usb-hid spec states that the SET_IDLE request has a 16bit value, where the upper byte specifies the idle rate (currently unimplemented, we handle only the 0 case, meaning infinite duration) and the lower byte specifies the report id (0 means all reports).
In our code we do idle = value, while it should be idle = "upper byte", especially if the guest issues a GET_IDLE, we should return only the idle rate while we are returning only the report id.
In practice it doesn't make much difference because I have only seen SET_VALUE with both bytes set to 0 so far, but still it is wrong.
---
hw/usb-hid.c +2 -2
@@ -65,7 +65,7 @@ typedef struct USBHIDState { };int kind;int protocol; -int idle; +uint8_t idle;int changed;void *datain_opaque;void (*datain)(void *);
@@ -794,7 +794,7 @@ static int usb_hid_handle_control(USBDevice *dev, int request, int value, data[0 ] = s->idle;break ;case SET_IDLE : - s->idle = value; + s->idle = (uint8_t ) (value >>8 ); ret =0 ;break ;default :
Stefano Stabellini writes ("[Qemu-devel] [PATCH] fix usb-hid SET_IDLE behaviour"):
Quoted 11 lines
the usb-hid spec states that the
SET_IDLErequest has a 16bit value, where the upper byte specifies the idle rate (currently unimplemented, we handle only the 0 case, meaning infinite duration) and the lower byte specifies the report id (0 means all reports).
In our code we do idle = value, while it should be idle = "upper byte", especially if the guest issues aGET_IDLE, we should return only the idle rate while we are returning only the report id.
In practice it doesn't make much difference because I have only seenSET_VALUEwith both bytes set to 0 so far, but still it is wrong.Signed-off-by Stefano Stabellini <[email protected]>
Stefano's patch looks good to me.
Ian.
Quoted 12 lines · Ian Jackson
Stefano Stabellini writes ("[Qemu-devel] [PATCH] fix usb-hid
SET_IDLEbehaviour"):Quoted 10 lines
the usb-hid spec states that the
SET_IDLErequest has a 16bit value, where the upper byte specifies the idle rate (currently unimplemented, we handle only the 0 case, meaning infinite duration) and the lower byte specifies the report id (0 means all reports).
In our code we do idle = value, while it should be idle = "upper byte", especially if the guest issues aGET_IDLE, we should return only the idle rate while we are returning only the report id.
In practice it doesn't make much difference because I have only seenSET_VALUEwith both bytes set to 0 so far, but still it is wrong.
Quoted 7 lines
Quoted 2 lines
Signed-off-by Stefano Stabellini <[email protected]>Stefano's patch looks good to me.
Reviewed-by Stefano Stabellini <[email protected]>
Shouldn't that be Ian rather than Stefano? :-)
Alex
Alexander Graf writes ("Re: [Qemu-devel] [PATCH] fix usb-hid SET_IDLE behaviour"):
Quoted 4 lines
Quoted 1 line · Ian Jackson
Reviewed-by Stefano Stabellini <[email protected]>Shouldn't that be Ian rather than Stefano? :-)
Sorry, I'm an idiot :-).
Ian.
Anthony Liguori
AppliedQuoted 11 lines · Stefano Stabellini
Hi all,
the usb-hid spec states that theSET_IDLErequest has a 16bit value, where the upper byte specifies the idle rate (currently unimplemented, we handle only the 0 case, meaning infinite duration) and the lower byte specifies the report id (0 means all reports).
In our code we do idle = value, while it should be idle = "upper byte", especially if the guest issues aGET_IDLE, we should return only the idle rate while we are returning only the report id.
In practice it doesn't make much difference because I have only seenSET_VALUEwith both bytes set to 0 so far, but still it is wrong.
Quoted 2 lines
Signed-off-by Stefano Stabellini <[email protected]>
Applied. Thanks.
Regards,
Anthony Liguori