mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-07 17:08:49 +00:00
change(usb/host): Remove data buffer headers from URBs
This commit removes the ability to reserve a header in the data buffer of an allocated URB. The header was required for a now defunct implementation of a synchronous USB Host library API. Thus, headers are no longer required in URB data buffers.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -8,17 +8,16 @@
|
||||
#include "usb_private.h"
|
||||
#include "usb/usb_types_ch9.h"
|
||||
|
||||
urb_t *urb_alloc(size_t data_buffer_size, size_t header_size, int num_isoc_packets)
|
||||
urb_t *urb_alloc(size_t data_buffer_size, int num_isoc_packets)
|
||||
{
|
||||
urb_t *urb = heap_caps_calloc(1, sizeof(urb_t) + (sizeof(usb_isoc_packet_desc_t) * num_isoc_packets), MALLOC_CAP_DEFAULT);
|
||||
uint8_t *data_buffer = heap_caps_malloc(data_buffer_size + header_size, MALLOC_CAP_DMA);
|
||||
uint8_t *data_buffer = heap_caps_malloc(data_buffer_size, MALLOC_CAP_DMA);
|
||||
if (urb == NULL || data_buffer == NULL) {
|
||||
goto err;
|
||||
}
|
||||
urb->usb_host_header_size = header_size; // Indicate that this URB's data_buffer has a header in front of it.
|
||||
// Case as dummy transfer to write to initialize const fields
|
||||
// Cast as dummy transfer so that we can assign to const fields
|
||||
usb_transfer_dummy_t *dummy_transfer = (usb_transfer_dummy_t *)&urb->transfer;
|
||||
dummy_transfer->data_buffer = (uint8_t *)(data_buffer + header_size);
|
||||
dummy_transfer->data_buffer = data_buffer;
|
||||
dummy_transfer->data_buffer_size = data_buffer_size;
|
||||
dummy_transfer->num_isoc_packets = num_isoc_packets;
|
||||
return urb;
|
||||
@@ -33,6 +32,6 @@ void urb_free(urb_t *urb)
|
||||
if (urb == NULL) {
|
||||
return;
|
||||
}
|
||||
heap_caps_free((uint8_t *)(urb->transfer.data_buffer - urb->usb_host_header_size));
|
||||
heap_caps_free(urb->transfer.data_buffer);
|
||||
heap_caps_free(urb);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user