From fdf54ab86c4fe0d0119e103a3aca5217564a343a Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Sun, 4 Mar 2012 19:43:56 -0500 Subject: [PATCH] hid: fix response to HID descriptor HID driver was incorrectly giving back the HID interface descriptor when asked for the HID descriptor. This should let OP boards interact better with generic HID layer drivers and also gives us nicer output in lsusb once the HID descriptor is read. --- flight/PiOS/Common/pios_usb_desc_hid_cdc.c | 2 +- flight/PiOS/Common/pios_usb_desc_hid_only.c | 2 +- flight/PiOS/STM32F10x/pios_usbhook.c | 10 +++++----- flight/PiOS/STM32F4xx/pios_usb_hid.c | 12 ++++++------ flight/PiOS/inc/pios_usb_hid.h | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/flight/PiOS/Common/pios_usb_desc_hid_cdc.c b/flight/PiOS/Common/pios_usb_desc_hid_cdc.c index a7ff85dc7..13fd988f2 100644 --- a/flight/PiOS/Common/pios_usb_desc_hid_cdc.c +++ b/flight/PiOS/Common/pios_usb_desc_hid_cdc.c @@ -250,7 +250,7 @@ int32_t PIOS_USB_DESC_HID_CDC_Init(void) PIOS_USBHOOK_RegisterDevice((uint8_t *)&device_desc, sizeof(device_desc)); - PIOS_USB_HID_RegisterHidInterface((uint8_t *)&(config_hid_cdc.hid_if), sizeof(config_hid_cdc.hid_if)); + PIOS_USB_HID_RegisterHidDescriptor((uint8_t *)&(config_hid_cdc.hid), sizeof(config_hid_cdc.hid)); PIOS_USB_HID_RegisterHidReport((uint8_t *)hid_report_desc, sizeof(hid_report_desc)); return 0; diff --git a/flight/PiOS/Common/pios_usb_desc_hid_only.c b/flight/PiOS/Common/pios_usb_desc_hid_only.c index c0f38f5f4..b15a02b32 100644 --- a/flight/PiOS/Common/pios_usb_desc_hid_only.c +++ b/flight/PiOS/Common/pios_usb_desc_hid_only.c @@ -158,7 +158,7 @@ int32_t PIOS_USB_DESC_HID_ONLY_Init(void) PIOS_USBHOOK_RegisterDevice((uint8_t *)&device_desc, sizeof(device_desc)); - PIOS_USB_HID_RegisterHidInterface((uint8_t *)&(config_hid_only.hid_if), sizeof(config_hid_only.hid_if)); + PIOS_USB_HID_RegisterHidDescriptor((uint8_t *)&(config_hid_only.hid), sizeof(config_hid_only.hid)); PIOS_USB_HID_RegisterHidReport((uint8_t *)hid_report_desc, sizeof(hid_report_desc)); return 0; diff --git a/flight/PiOS/STM32F10x/pios_usbhook.c b/flight/PiOS/STM32F10x/pios_usbhook.c index 530f4cbef..c6a952498 100644 --- a/flight/PiOS/STM32F10x/pios_usbhook.c +++ b/flight/PiOS/STM32F10x/pios_usbhook.c @@ -65,12 +65,12 @@ void PIOS_USBHOOK_RegisterString(enum usb_string_desc string_id, const uint8_t * } } -static ONE_DESCRIPTOR Hid_Interface_Descriptor; +static ONE_DESCRIPTOR Hid_Descriptor; -void PIOS_USB_HID_RegisterHidInterface(const uint8_t * desc, uint16_t desc_size) +void PIOS_USB_HID_RegisterHidDescriptor(const uint8_t * desc, uint16_t desc_size) { - Hid_Interface_Descriptor.Descriptor = desc; - Hid_Interface_Descriptor.Descriptor_Size = desc_size; + Hid_Descriptor.Descriptor = desc; + Hid_Descriptor.Descriptor_Size = desc_size; } static ONE_DESCRIPTOR Hid_Report_Descriptor; @@ -468,7 +468,7 @@ static const uint8_t *PIOS_USBHOOK_GetReportDescriptor(uint16_t Length) *******************************************************************************/ static const uint8_t *PIOS_USBHOOK_GetHIDDescriptor(uint16_t Length) { - return Standard_GetDescriptorData(Length, &Hid_Interface_Descriptor); + return Standard_GetDescriptorData(Length, &Hid_Descriptor); } /******************************************************************************* diff --git a/flight/PiOS/STM32F4xx/pios_usb_hid.c b/flight/PiOS/STM32F4xx/pios_usb_hid.c index f380ad39a..96698c7c2 100644 --- a/flight/PiOS/STM32F4xx/pios_usb_hid.c +++ b/flight/PiOS/STM32F4xx/pios_usb_hid.c @@ -150,12 +150,12 @@ out_fail: } -static struct pios_usbhook_descriptor hid_if_desc; +static struct pios_usbhook_descriptor hid_desc; -void PIOS_USB_HID_RegisterHidInterface(const uint8_t * desc, uint16_t length) +void PIOS_USB_HID_RegisterHidDescriptor(const uint8_t * desc, uint16_t length) { - hid_if_desc.descriptor = desc; - hid_if_desc.length = length; + hid_desc.descriptor = desc; + hid_desc.length = length; } static struct pios_usbhook_descriptor hid_report_desc; @@ -358,8 +358,8 @@ static bool PIOS_USB_HID_IF_Setup(uint32_t usb_hid_id, struct usb_setup_request MIN(hid_report_desc.length, req->wLength)); break; case USB_DESC_TYPE_HID: - PIOS_USBHOOK_CtrlTx(hid_if_desc.descriptor, - MIN(hid_if_desc.length, req->wLength)); + PIOS_USBHOOK_CtrlTx(hid_desc.descriptor, + MIN(hid_desc.length, req->wLength)); break; default: /* Unhandled descriptor request */ diff --git a/flight/PiOS/inc/pios_usb_hid.h b/flight/PiOS/inc/pios_usb_hid.h index 3fc5f81b1..2f7a1d598 100644 --- a/flight/PiOS/inc/pios_usb_hid.h +++ b/flight/PiOS/inc/pios_usb_hid.h @@ -35,7 +35,7 @@ extern int32_t PIOS_USB_HID_Reenumerate(void); extern int32_t PIOS_USB_HID_ChangeConnectionState(uint32_t Connected); extern bool PIOS_USB_HID_CheckAvailable(uint8_t id); -extern void PIOS_USB_HID_RegisterHidInterface(const uint8_t * desc, uint16_t length); +extern void PIOS_USB_HID_RegisterHidDescriptor(const uint8_t * desc, uint16_t length); extern void PIOS_USB_HID_RegisterHidReport(const uint8_t * desc, uint16_t length); #endif /* PIOS_USB_HID_H */