bdk: usb: remove unused endpoint from hid

This commit is contained in:
CTCaer
2025-06-22 13:10:47 +03:00
parent a1e8ddb2a7
commit 88c0d13f0b
4 changed files with 47 additions and 59 deletions

View File

@@ -1,7 +1,7 @@
/* /*
* USB driver for Tegra X1 * USB driver for Tegra X1
* *
* Copyright (c) 2019-2020 CTCaer * Copyright (c) 2019-2025 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -151,7 +151,7 @@ typedef struct _usb_cfg_hid_descr_t
usb_cfg_descr_t config; usb_cfg_descr_t config;
usb_inter_descr_t interface; usb_inter_descr_t interface;
usb_hid_descr_t hid; usb_hid_descr_t hid;
usb_ep_descr_t endpoint[2]; usb_ep_descr_t endpoint[1];
} __attribute__((packed)) usb_cfg_hid_descr_t; } __attribute__((packed)) usb_cfg_hid_descr_t;
typedef struct _usb_dev_bot_t typedef struct _usb_dev_bot_t

View File

@@ -1,7 +1,7 @@
/* /*
* USB driver for Tegra X1 * USB driver for Tegra X1
* *
* Copyright (c) 2019-2020 CTCaer * Copyright (c) 2019-2025 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -409,10 +409,10 @@ static usb_cfg_hid_descr_t usb_configuration_descriptor_hid_jc =
.interface.bDescriptorType = USB_DESCRIPTOR_INTERFACE, .interface.bDescriptorType = USB_DESCRIPTOR_INTERFACE,
.interface.bInterfaceNumber = 0, .interface.bInterfaceNumber = 0,
.interface.bAlternateSetting = 0, .interface.bAlternateSetting = 0,
.interface.bNumEndpoints = 2, .interface.bNumEndpoints = 1,
.interface.bInterfaceClass = 0x03, // Human Interface Device Class. .interface.bInterfaceClass = 0x03, // Human Interface Device Class.
.interface.bInterfaceSubClass = 0x00, // SCSI Transparent Command Set. .interface.bInterfaceSubClass = 0x00, // No Subclass.
.interface.bInterfaceProtocol = 0x00, // Bulk-Only Transport. .interface.bInterfaceProtocol = 0x00, // None.
.interface.iInterface = 0x00, .interface.iInterface = 0x00,
.hid.bLength = 9, .hid.bLength = 9,
@@ -430,14 +430,6 @@ static usb_cfg_hid_descr_t usb_configuration_descriptor_hid_jc =
.endpoint[0].bmAttributes = USB_EP_TYPE_INTR, .endpoint[0].bmAttributes = USB_EP_TYPE_INTR,
.endpoint[0].wMaxPacketSize = 0x200, .endpoint[0].wMaxPacketSize = 0x200,
.endpoint[0].bInterval = 4, // 8ms on HS. .endpoint[0].bInterval = 4, // 8ms on HS.
/* Endpoint descriptor structure EP1 OUT */
.endpoint[1].bLength = 7,
.endpoint[1].bDescriptorType = USB_DESCRIPTOR_ENDPOINT,
.endpoint[1].bEndpointAddress = 0x01, // USB_EP_ADDR_BULK_OUT.
.endpoint[1].bmAttributes = USB_EP_TYPE_INTR,
.endpoint[1].wMaxPacketSize = 0x200,
.endpoint[1].bInterval = 4 // 8ms on HS.
}; };
static u8 usb_vendor_string_descriptor_hid[22] = static u8 usb_vendor_string_descriptor_hid[22] =
@@ -478,10 +470,10 @@ static usb_cfg_hid_descr_t usb_configuration_descriptor_hid_touch =
.interface.bDescriptorType = USB_DESCRIPTOR_INTERFACE, .interface.bDescriptorType = USB_DESCRIPTOR_INTERFACE,
.interface.bInterfaceNumber = 0, .interface.bInterfaceNumber = 0,
.interface.bAlternateSetting = 0, .interface.bAlternateSetting = 0,
.interface.bNumEndpoints = 2, .interface.bNumEndpoints = 1,
.interface.bInterfaceClass = 0x03, // Human Interface Device Class. .interface.bInterfaceClass = 0x03, // Human Interface Device Class.
.interface.bInterfaceSubClass = 0x00, // SCSI Transparent Command Set. .interface.bInterfaceSubClass = 0x00, // No Subclass.
.interface.bInterfaceProtocol = 0x00, // Bulk-Only Transport. .interface.bInterfaceProtocol = 0x00, // None.
.interface.iInterface = 0x00, .interface.iInterface = 0x00,
.hid.bLength = 9, .hid.bLength = 9,
@@ -499,14 +491,6 @@ static usb_cfg_hid_descr_t usb_configuration_descriptor_hid_touch =
.endpoint[0].bmAttributes = USB_EP_TYPE_INTR, .endpoint[0].bmAttributes = USB_EP_TYPE_INTR,
.endpoint[0].wMaxPacketSize = 0x200, .endpoint[0].wMaxPacketSize = 0x200,
.endpoint[0].bInterval = 3, // 4ms on HS. .endpoint[0].bInterval = 3, // 4ms on HS.
/* Endpoint descriptor structure EP1 OUT */
.endpoint[1].bLength = 7,
.endpoint[1].bDescriptorType = USB_DESCRIPTOR_ENDPOINT,
.endpoint[1].bEndpointAddress = 0x01, // USB_EP_ADDR_BULK_OUT.
.endpoint[1].bmAttributes = USB_EP_TYPE_INTR,
.endpoint[1].wMaxPacketSize = 0x200,
.endpoint[1].bInterval = 3 // 4ms on HS.
}; };
usb_desc_t usb_gadget_ums_descriptors = usb_desc_t usb_gadget_ums_descriptors =

View File

@@ -1,7 +1,7 @@
/* /*
* Enhanced USB Device (EDCI) driver for Tegra X1 * Enhanced USB Device (EDCI) driver for Tegra X1
* *
* Copyright (c) 2019-2024 CTCaer * Copyright (c) 2019-2025 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -941,13 +941,13 @@ static void _usbd_handle_get_descriptor(bool *transmit_data, void **descriptor,
{ {
if (usbd_otg->port_speed == USB_HIGH_SPEED) // High speed. 512 bytes. if (usbd_otg->port_speed == USB_HIGH_SPEED) // High speed. 512 bytes.
{ {
usbd_otg->desc->cfg->endpoint[0].wMaxPacketSize = 0x200; for (u32 i = 0; i < usbd_otg->desc->cfg->interface.bNumEndpoints; i++)
usbd_otg->desc->cfg->endpoint[1].wMaxPacketSize = 0x200; usbd_otg->desc->cfg->endpoint[i].wMaxPacketSize = 0x200; // No burst.
} }
else // Full speed. 64 bytes. else // Full speed. 64 bytes.
{ {
usbd_otg->desc->cfg->endpoint[0].wMaxPacketSize = 0x40; for (u32 i = 0; i < usbd_otg->desc->cfg->interface.bNumEndpoints; i++)
usbd_otg->desc->cfg->endpoint[1].wMaxPacketSize = 0x40; usbd_otg->desc->cfg->endpoint[i].wMaxPacketSize = 0x40;
} }
} }
else else
@@ -955,17 +955,19 @@ static void _usbd_handle_get_descriptor(bool *transmit_data, void **descriptor,
usb_cfg_hid_descr_t *tmp = (usb_cfg_hid_descr_t *)usbd_otg->desc->cfg; usb_cfg_hid_descr_t *tmp = (usb_cfg_hid_descr_t *)usbd_otg->desc->cfg;
if (usbd_otg->port_speed == USB_HIGH_SPEED) // High speed. 512 bytes. if (usbd_otg->port_speed == USB_HIGH_SPEED) // High speed. 512 bytes.
{ {
tmp->endpoint[0].wMaxPacketSize = 0x200; for (u32 i = 0; i < tmp->interface.bNumEndpoints; i++)
tmp->endpoint[1].wMaxPacketSize = 0x200; {
tmp->endpoint[0].bInterval = usbd_otg->gadget == USB_GADGET_HID_GAMEPAD ? 4 : 3; // 8ms : 4ms. tmp->endpoint[i].wMaxPacketSize = 0x200;
tmp->endpoint[1].bInterval = usbd_otg->gadget == USB_GADGET_HID_GAMEPAD ? 4 : 3; // 8ms : 4ms. tmp->endpoint[i].bInterval = usbd_otg->gadget == USB_GADGET_HID_GAMEPAD ? 4 : 3; // 8ms : 4ms.
}
} }
else // Full speed. 64 bytes. else // Full speed. 64 bytes.
{ {
tmp->endpoint[0].wMaxPacketSize = 0x40; for (u32 i = 0; i < tmp->interface.bNumEndpoints; i++)
tmp->endpoint[1].wMaxPacketSize = 0x40; {
tmp->endpoint[0].bInterval = usbd_otg->gadget == USB_GADGET_HID_GAMEPAD ? 8 : 4; // 8ms : 4ms. tmp->endpoint[i].wMaxPacketSize = 0x40;
tmp->endpoint[1].bInterval = usbd_otg->gadget == USB_GADGET_HID_GAMEPAD ? 8 : 4; // 8ms : 4ms. tmp->endpoint[i].bInterval = usbd_otg->gadget == USB_GADGET_HID_GAMEPAD ? 8 : 4; // 8ms : 4ms.
}
} }
} }
*descriptor = usbd_otg->desc->cfg; *descriptor = usbd_otg->desc->cfg;
@@ -1011,13 +1013,13 @@ static void _usbd_handle_get_descriptor(bool *transmit_data, void **descriptor,
goto exit; goto exit;
if (usbd_otg->port_speed == USB_HIGH_SPEED) if (usbd_otg->port_speed == USB_HIGH_SPEED)
{ {
usbd_otg->desc->cfg_other->endpoint[0].wMaxPacketSize = 0x40; for (u32 i = 0; i < usbd_otg->desc->cfg_other->interface.bNumEndpoints; i++)
usbd_otg->desc->cfg_other->endpoint[1].wMaxPacketSize = 0x40; usbd_otg->desc->cfg_other->endpoint[i].wMaxPacketSize = 0x40;
} }
else else
{ {
usbd_otg->desc->cfg_other->endpoint[0].wMaxPacketSize = 0x200; for (u32 i = 0; i < usbd_otg->desc->cfg_other->interface.bNumEndpoints; i++)
usbd_otg->desc->cfg_other->endpoint[1].wMaxPacketSize = 0x200; usbd_otg->desc->cfg_other->endpoint[i].wMaxPacketSize = 0x200;
} }
if ((usbd_otg->charger_detect & 1) && (usbd_otg->charger_detect & 2)) if ((usbd_otg->charger_detect & 1) && (usbd_otg->charger_detect & 2))
usbd_otg->desc->cfg_other->config.bMaxPower = 500 / 2; usbd_otg->desc->cfg_other->config.bMaxPower = 500 / 2;

View File

@@ -1,7 +1,7 @@
/* /*
* eXtensible USB Device driver (XDCI) for Tegra X1 * eXtensible USB Device driver (XDCI) for Tegra X1
* *
* Copyright (c) 2020-2024 CTCaer * Copyright (c) 2020-2025 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -1522,13 +1522,13 @@ static int _xusb_handle_get_descriptor(const usb_ctrl_setup_t *ctrl_setup)
{ {
if (usbd_xotg->port_speed == XUSB_HIGH_SPEED) // High speed. 512 bytes. if (usbd_xotg->port_speed == XUSB_HIGH_SPEED) // High speed. 512 bytes.
{ {
usbd_xotg->desc->cfg->endpoint[0].wMaxPacketSize = 0x200; // No burst. for (u32 i = 0; i < usbd_xotg->desc->cfg->interface.bNumEndpoints; i++)
usbd_xotg->desc->cfg->endpoint[1].wMaxPacketSize = 0x200; // No burst. usbd_xotg->desc->cfg->endpoint[i].wMaxPacketSize = 0x200; // No burst.
} }
else // Full speed. 64 bytes. else // Full speed. 64 bytes.
{ {
usbd_xotg->desc->cfg->endpoint[0].wMaxPacketSize = 0x40; for (u32 i = 0; i < usbd_xotg->desc->cfg->interface.bNumEndpoints; i++)
usbd_xotg->desc->cfg->endpoint[1].wMaxPacketSize = 0x40; usbd_xotg->desc->cfg->endpoint[i].wMaxPacketSize = 0x40;
} }
} }
else else
@@ -1536,17 +1536,19 @@ static int _xusb_handle_get_descriptor(const usb_ctrl_setup_t *ctrl_setup)
usb_cfg_hid_descr_t *tmp = (usb_cfg_hid_descr_t *)usbd_xotg->desc->cfg; usb_cfg_hid_descr_t *tmp = (usb_cfg_hid_descr_t *)usbd_xotg->desc->cfg;
if (usbd_xotg->port_speed == XUSB_HIGH_SPEED) // High speed. 512 bytes. if (usbd_xotg->port_speed == XUSB_HIGH_SPEED) // High speed. 512 bytes.
{ {
tmp->endpoint[0].wMaxPacketSize = 0x200; for (u32 i = 0; i < tmp->interface.bNumEndpoints; i++)
tmp->endpoint[1].wMaxPacketSize = 0x200; {
tmp->endpoint[0].bInterval = usbd_xotg->gadget == USB_GADGET_HID_GAMEPAD ? 4 : 3; // 8ms : 4ms. tmp->endpoint[i].wMaxPacketSize = 0x200;
tmp->endpoint[1].bInterval = usbd_xotg->gadget == USB_GADGET_HID_GAMEPAD ? 4 : 3; // 8ms : 4ms. tmp->endpoint[i].bInterval = usbd_xotg->gadget == USB_GADGET_HID_GAMEPAD ? 4 : 3; // 8ms : 4ms.
}
} }
else // Full speed. 64 bytes. else // Full speed. 64 bytes.
{ {
tmp->endpoint[0].wMaxPacketSize = 0x40; for (u32 i = 0; i < tmp->interface.bNumEndpoints; i++)
tmp->endpoint[1].wMaxPacketSize = 0x40; {
tmp->endpoint[0].bInterval = usbd_xotg->gadget == USB_GADGET_HID_GAMEPAD ? 8 : 4; // 8ms : 4ms. tmp->endpoint[i].wMaxPacketSize = 0x40;
tmp->endpoint[1].bInterval = usbd_xotg->gadget == USB_GADGET_HID_GAMEPAD ? 8 : 4; // 8ms : 4ms. tmp->endpoint[i].bInterval = usbd_xotg->gadget == USB_GADGET_HID_GAMEPAD ? 8 : 4; // 8ms : 4ms.
}
} }
} }
descriptor = usbd_xotg->desc->cfg; descriptor = usbd_xotg->desc->cfg;
@@ -1595,13 +1597,13 @@ static int _xusb_handle_get_descriptor(const usb_ctrl_setup_t *ctrl_setup)
} }
if (usbd_xotg->port_speed == XUSB_HIGH_SPEED) if (usbd_xotg->port_speed == XUSB_HIGH_SPEED)
{ {
usbd_xotg->desc->cfg_other->endpoint[0].wMaxPacketSize = 0x40; for (u32 i = 0; i < usbd_xotg->desc->cfg_other->interface.bNumEndpoints; i++)
usbd_xotg->desc->cfg_other->endpoint[1].wMaxPacketSize = 0x40; usbd_xotg->desc->cfg_other->endpoint[i].wMaxPacketSize = 0x40;
} }
else else
{ {
usbd_xotg->desc->cfg_other->endpoint[0].wMaxPacketSize = 0x200; for (u32 i = 0; i < usbd_xotg->desc->cfg_other->interface.bNumEndpoints; i++)
usbd_xotg->desc->cfg_other->endpoint[1].wMaxPacketSize = 0x200; usbd_xotg->desc->cfg_other->endpoint[i].wMaxPacketSize = 0x200;
} }
descriptor = usbd_xotg->desc->cfg_other; descriptor = usbd_xotg->desc->cfg_other;
size = usbd_xotg->desc->cfg_other->config.wTotalLength; size = usbd_xotg->desc->cfg_other->config.wTotalLength;