remove intf malloc
This commit is contained in:
@@ -373,14 +373,8 @@ static void audio_notify_handler(uint8_t event, void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
struct usbd_interface *usbd_audio_alloc_intf(void)
|
||||
struct usbd_interface *usbd_audio_init_intf(struct usbd_interface *intf)
|
||||
{
|
||||
struct usbd_interface *intf = usb_malloc(sizeof(struct usbd_interface));
|
||||
if (intf == NULL) {
|
||||
USB_LOG_ERR("no mem to alloc intf\r\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
intf->class_interface_handler = audio_class_interface_request_handler;
|
||||
#if CONFIG_USBDEV_AUDIO_VERSION < 0x0200
|
||||
intf->class_endpoint_handler = audio_class_endpoint_request_handler;
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Alloc audio interface driver */
|
||||
struct usbd_interface *usbd_audio_alloc_intf(void);
|
||||
/* Init audio interface driver */
|
||||
struct usbd_interface *usbd_audio_init_intf(struct usbd_interface *intf);
|
||||
|
||||
void usbd_audio_open(uint8_t intf);
|
||||
void usbd_audio_close(uint8_t intf);
|
||||
|
||||
@@ -90,14 +90,8 @@ static void cdc_notify_handler(uint8_t event, void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
struct usbd_interface *usbd_cdc_acm_alloc_intf(void)
|
||||
struct usbd_interface *usbd_cdc_acm_init_intf(struct usbd_interface *intf)
|
||||
{
|
||||
struct usbd_interface *intf = usb_malloc(sizeof(struct usbd_interface));
|
||||
if (intf == NULL) {
|
||||
USB_LOG_ERR("no mem to alloc intf\r\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
intf->class_interface_handler = cdc_acm_class_interface_request_handler;
|
||||
intf->class_endpoint_handler = NULL;
|
||||
intf->vendor_handler = NULL;
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Alloc cdc acm interface driver */
|
||||
struct usbd_interface *usbd_cdc_acm_alloc_intf(void);
|
||||
/* Init cdc acm interface driver */
|
||||
struct usbd_interface *usbd_cdc_acm_init_intf(struct usbd_interface *intf);
|
||||
|
||||
/* Setup request command callback api */
|
||||
void usbd_cdc_acm_set_line_coding(uint8_t intf, struct cdc_line_coding *line_coding);
|
||||
|
||||
@@ -477,14 +477,8 @@ static void dfu_notify_handler(uint8_t event, void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
struct usbd_interface *usbd_dfu_alloc_intf(void)
|
||||
struct usbd_interface *usbd_dfu_init_intf(struct usbd_interface *intf)
|
||||
{
|
||||
struct usbd_interface *intf = usb_malloc(sizeof(struct usbd_interface));
|
||||
if (intf == NULL) {
|
||||
USB_LOG_ERR("no mem to alloc intf\r\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
intf->class_interface_handler = dfu_class_interface_request_handler;
|
||||
intf->class_endpoint_handler = NULL;
|
||||
intf->vendor_handler = NULL;
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Alloc dfu interface driver */
|
||||
struct usbd_interface *usbd_dfu_alloc_intf(void);
|
||||
/* Init dfu interface driver */
|
||||
struct usbd_interface *usbd_dfu_init_intf(struct usbd_interface *intf);
|
||||
|
||||
/* Interface functions that need to be implemented by the user */
|
||||
uint8_t *dfu_read_flash(uint8_t *src, uint8_t *dest, uint32_t len);
|
||||
|
||||
@@ -6,62 +6,6 @@
|
||||
#include "usbd_core.h"
|
||||
#include "usbd_hid.h"
|
||||
|
||||
static int hid_custom_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
|
||||
{
|
||||
USB_LOG_DBG("HID Custom request: "
|
||||
"bRequest 0x%02x\r\n",
|
||||
setup->bRequest);
|
||||
|
||||
if (((setup->bmRequestType & USB_REQUEST_DIR_MASK) == USB_REQUEST_DIR_IN) &&
|
||||
setup->bRequest == USB_REQUEST_GET_DESCRIPTOR) {
|
||||
uint8_t value = (uint8_t)(setup->wValue >> 8);
|
||||
uint8_t intf_num = (uint8_t)setup->wIndex;
|
||||
|
||||
usb_slist_t *i;
|
||||
struct usbd_interface *match_intf = NULL;
|
||||
|
||||
usb_slist_for_each(i, &usbd_intf_head)
|
||||
{
|
||||
struct usbd_interface *intf = usb_slist_entry(i, struct usbd_interface, list);
|
||||
|
||||
if (intf->intf_num == intf_num) {
|
||||
match_intf = intf;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (match_intf == NULL) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
switch (value) {
|
||||
case HID_DESCRIPTOR_TYPE_HID:
|
||||
USB_LOG_INFO("get HID Descriptor\r\n");
|
||||
// *data = (uint8_t *)match_intf->hid_descriptor;
|
||||
// *len = match_intf->hid_descriptor[0];
|
||||
break;
|
||||
|
||||
case HID_DESCRIPTOR_TYPE_HID_REPORT:
|
||||
USB_LOG_INFO("get Report Descriptor\r\n");
|
||||
*data = (uint8_t *)match_intf->hid_report_descriptor;
|
||||
*len = match_intf->hid_report_descriptor_len;
|
||||
break;
|
||||
|
||||
case HID_DESCRIPTOR_TYPE_HID_PHYSICAL:
|
||||
USB_LOG_INFO("get PHYSICAL Descriptor\r\n");
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int hid_class_interface_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
|
||||
{
|
||||
USB_LOG_DBG("HID Class request: "
|
||||
@@ -105,14 +49,8 @@ static int hid_class_interface_request_handler(struct usb_setup_packet *setup, u
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct usbd_interface *usbd_hid_alloc_intf(const uint8_t *desc, uint32_t desc_len)
|
||||
struct usbd_interface *usbd_hid_init_intf(struct usbd_interface *intf, const uint8_t *desc, uint32_t desc_len)
|
||||
{
|
||||
struct usbd_interface *intf = usb_malloc(sizeof(struct usbd_interface));
|
||||
if (intf == NULL) {
|
||||
USB_LOG_ERR("no mem to alloc intf\r\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
intf->class_interface_handler = hid_class_interface_request_handler;
|
||||
intf->class_endpoint_handler = NULL;
|
||||
intf->vendor_handler = NULL;
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Alloc hid interface driver */
|
||||
struct usbd_interface *usbd_hid_alloc_intf(const uint8_t *desc, uint32_t desc_len);
|
||||
/* Init hid interface driver */
|
||||
struct usbd_interface *usbd_hid_init_intf(struct usbd_interface *intf, const uint8_t *desc, uint32_t desc_len);
|
||||
|
||||
/* Register desc api */
|
||||
void usbd_hid_descriptor_register(uint8_t intf_num, const uint8_t *desc);
|
||||
|
||||
@@ -912,14 +912,8 @@ static void usbd_msc_thread(void *argument)
|
||||
}
|
||||
#endif
|
||||
|
||||
struct usbd_interface *usbd_msc_alloc_intf(const uint8_t out_ep, const uint8_t in_ep)
|
||||
struct usbd_interface *usbd_msc_init_intf(struct usbd_interface *intf, const uint8_t out_ep, const uint8_t in_ep)
|
||||
{
|
||||
struct usbd_interface *intf = usb_malloc(sizeof(struct usbd_interface));
|
||||
if (intf == NULL) {
|
||||
USB_LOG_ERR("no mem to alloc intf\r\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
intf->class_interface_handler = msc_storage_class_interface_request_handler;
|
||||
intf->class_endpoint_handler = NULL;
|
||||
intf->vendor_handler = NULL;
|
||||
|
||||
@@ -12,8 +12,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Alloc msc interface driver */
|
||||
struct usbd_interface *usbd_msc_alloc_intf(const uint8_t out_ep, const uint8_t in_ep);
|
||||
/* Init msc interface driver */
|
||||
struct usbd_interface *usbd_msc_init_intf(struct usbd_interface *intf,
|
||||
const uint8_t out_ep,
|
||||
const uint8_t in_ep);
|
||||
|
||||
void usbd_msc_get_cap(uint8_t lun, uint32_t *block_num, uint16_t *block_size);
|
||||
int usbd_msc_sector_read(uint32_t sector, uint8_t *buffer, uint32_t length);
|
||||
|
||||
@@ -742,14 +742,11 @@ void usbd_video_probe_and_commit_controls_init(uint32_t dwFrameInterval, uint32_
|
||||
usbd_video_cfg.commit.bMaxVersion = 0;
|
||||
}
|
||||
|
||||
struct usbd_interface *usbd_video_alloc_intf(uint32_t dwFrameInterval, uint32_t dwMaxVideoFrameSize, uint32_t dwMaxPayloadTransferSize)
|
||||
struct usbd_interface *usbd_video_init_intf(struct usbd_interface *intf,
|
||||
uint32_t dwFrameInterval,
|
||||
uint32_t dwMaxVideoFrameSize,
|
||||
uint32_t dwMaxPayloadTransferSize)
|
||||
{
|
||||
struct usbd_interface *intf = usb_malloc(sizeof(struct usbd_interface));
|
||||
if (intf == NULL) {
|
||||
USB_LOG_ERR("no mem to alloc intf\r\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
intf->class_interface_handler = video_class_interface_request_handler;
|
||||
intf->class_endpoint_handler = NULL;
|
||||
intf->vendor_handler = NULL;
|
||||
@@ -780,7 +777,7 @@ uint32_t usbd_video_mjpeg_payload_fill(uint8_t *input, uint32_t input_len, uint8
|
||||
picture_pos += usbd_video_cfg.probe.dwMaxPayloadTransferSize - 2;
|
||||
}
|
||||
}
|
||||
uvc_header[1] ^=1;
|
||||
uvc_header[1] ^= 1;
|
||||
*out_len = (input_len + 2 * packets);
|
||||
return packets;
|
||||
}
|
||||
@@ -12,10 +12,11 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Alloc video interface driver */
|
||||
struct usbd_interface *usbd_video_alloc_intf(uint32_t dwFrameInterval,
|
||||
uint32_t dwMaxVideoFrameSize,
|
||||
uint32_t dwMaxPayloadTransferSize);
|
||||
/* Init video interface driver */
|
||||
struct usbd_interface *usbd_video_init_intf(struct usbd_interface *intf,
|
||||
uint32_t dwFrameInterval,
|
||||
uint32_t dwMaxVideoFrameSize,
|
||||
uint32_t dwMaxPayloadTransferSize);
|
||||
|
||||
void usbd_video_open(uint8_t intf);
|
||||
void usbd_video_close(uint8_t intf);
|
||||
|
||||
@@ -529,14 +529,11 @@ int usbd_rndis_eth_tx(struct pbuf *p)
|
||||
return usbd_ep_start_write(rndis_ep_data[RNDIS_IN_EP_IDX].ep_addr, g_rndis_tx_buffer, g_rndis_tx_data_length);
|
||||
}
|
||||
#endif
|
||||
struct usbd_interface *usbd_rndis_alloc_intf(uint8_t out_ep, uint8_t in_ep, uint8_t int_ep, uint8_t mac[6])
|
||||
struct usbd_interface *usbd_rndis_init_intf(struct usbd_interface *intf,
|
||||
const uint8_t out_ep,
|
||||
const uint8_t in_ep,
|
||||
const uint8_t int_ep, uint8_t mac[6])
|
||||
{
|
||||
struct usbd_interface *intf = (struct usbd_interface *)usb_malloc(sizeof(struct usbd_interface));
|
||||
if (intf == NULL) {
|
||||
USB_LOG_ERR("no mem to alloc intf\r\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(usbd_rndis_cfg.mac, mac, 6);
|
||||
|
||||
rndis_ep_data[RNDIS_OUT_EP_IDX].ep_addr = out_ep;
|
||||
|
||||
@@ -12,7 +12,11 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct usbd_interface *usbd_rndis_alloc_intf(uint8_t out_ep, uint8_t in_ep, uint8_t int_ep, uint8_t mac[6]);
|
||||
/* Init rndis interface driver */
|
||||
struct usbd_interface *usbd_rndis_init_intf(struct usbd_interface *intf,
|
||||
const uint8_t out_ep,
|
||||
const uint8_t in_ep,
|
||||
const uint8_t int_ep, uint8_t mac[6]);
|
||||
|
||||
#ifdef CONFIG_USBDEV_RNDIS_USING_LWIP
|
||||
struct pbuf *usbd_rndis_eth_rx(void);
|
||||
|
||||
Reference in New Issue
Block a user