Add basic functions to initialize and probe class drivers.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Signed-off-by: Josuah Demangeon <josuah.demangeon@nordicsemi.no>
Add helpers to parse and validate USB descriptors.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Signed-off-by: Josuah Demangeon <josuah.demangeon@nordicsemi.no>
In addition to storing the interface pointers, also store the pointers
for the interface association. Also add comments to the other fields
of the structs to adapt to a new CI check.
Signed-off-by: Josuah Demangeon <josuah.demangeon@nordicsemi.no>
Add API wrappers around the function pointers in struct usbh_class_api,
while also documenting the USB host class internal API.
Signed-off-by: Josuah Demangeon <josuah.demangeon@nordicsemi.no>
Make USBD_HWINFO_DEVID_LENGTH prompt optional so that the code compiles
even if HWINFO is disabled.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
When the USB Bus is reset, the USBD stack will disable and re-enable
all Classes. If this occurs while streaming audio with UAC2, the
terminals remain active when re-enabled, yet the endpoints have
yet to be enabled (resulting in -ENODEV logspam). This change
disables all active terminals when the class is disabled.
Signed-off-by: Victor Brzeski <vbrzeski@gmail.com>
In c52c206e26 &
32059d7414 the USB code was changed to
use the Zephyr native net_ prefixed API, but some were forgotten
(nto[hn][ls]()). Let's change it now.
Without this fix/change the code still builds as we are by now setting
CONFIG_NET_NAMESPACE_COMPAT_MODE. But when this is not set, things
fail to build.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
In 32059d7414 this code was changed to
use the Zephyr native net_ prefixed API, but some were forgotten
(ntohs()). Let's change it now.
Without this fix/change the code still builds as we are by now setting
CONFIG_NET_NAMESPACE_COMPAT_MODE. But when this is not set, things
fail to build.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
In c52c206e26 this code was changed to use
the Zephyr native net_ prefixed API, but some were forgotten
(ntohs()). Let's change it now.
Without this fix/change the code still builds as we are by now setting
CONFIG_NET_NAMESPACE_COMPAT_MODE. But when this is not set, things
fail to build.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Remove duplicated #include directives within the same
preprocessor scope across the Zephyr tree.
Duplicates inside different #ifdef branches are preserved
as they may be intentional.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
The qsort() function takes a callback argument that is having the
same semantics as strcmp(). Fix uvc_compare_frmival_desc() sorting
to make qsort() list frame intervals in increasing values.
Fix a bug where Windows would not enumerate devices when the video device
have multiple frame interval supported.
Signed-off-by: Josuah Demangeon <me@josuah.net>
Multiple submitted requests are getting merged to single cancelled
net_buf on endpoint dequeue. While MSC class was correctly decrementing
the usage counters, it was not freeing SCSI buffer pointed to by frags.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
USBD_MAX_UDC_MSG configures the number of events coming from the UDC
driver that the stack can keep. This can be filled very quickly if there
would be multiple bus events for some reason, or function handlers of
those events are blocked for long time. As a consequence, subsequent
events could be dropped, and completed transfers not handled. To avoid
it, we can store completed transfer requests in a slist and check it on
every event.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
MSC BOT can work with just one buffer because buffer to receive CBW is
never queued at the same time as CSW. SCSI buffer needs to be multiple
of bulk endpoint wMaxPacketSize and therefore is suitable for handling
both CBW and CSW. Take advantage of this to reduce memory usage.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Double buffering make it possible to significantly increase the transfer
rates by avoiding idle states. With two SCSI buffers, one buffer can be
used by disk subsystem while the other is being used by UDC (ideally
with DMA).
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
When endpoint enqueue fails the device has no reliable means of recovery
other than a reset. Implement 6.6.2 Internal Device Error handling on
failed enqueue.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
actual_length needs to be set also for the OUT transfers. Assume that
requested length was transferred when there are no errors.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
When CDC ACM instance gets enabled and there is some data in TX FIFO,
the TX FIFO work will not be triggered if no UART API is used. And if TX
FIFO was full before CDC ACM instance get enabled, TX work will never be
triggered. To fix it TX FIFO should always be drained when CDC ACM gets
enabled.
Signed-off-by: Alexandre Boeglin <alexandre.boeglin@qorvo.com>
Use zu% format for size_t type.
Use d% format for int type.
Use u% format for uint32_t type.
Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
Signed-off-by: Jony Zhang <jony.zhang@nxp.com>
The frame_based descriptors differ from the frame descriptors
in that there is no dwMaxVideoFrameBufferSize field.
In order to do that, add a new uvc_frame_based_discrete_descriptor
structure to be used to fill in proper information into the
frame descriptor. In addition to that, a new format descriptor
is also added for frame based transfer.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
This commit prepares introduction of the UVC Frame Based support by
using the struct uvc_frame_descriptor as parameter of most of the UVC
functions. struct uvc_frame_descriptor contains the common fields for
all supported frame type and then depending on the DescriptorSubtype
the pointer is casted in the correct struct definition.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Support only power-of-two disk sector sizes to enable significant
throughput improvements:
* SCSI data zero-copy
* allow queuing multi-packet transfers
Previously large SCSI buffers did not improve performance. With this
change, larger SCSI buffer allows scheduling bigger USB transfers which
reduces overhead.
Co-authored-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
The UVC class was deciding itself which formats were sent to the host.
Remove this logic out of the UVC class and introduce uvc_add_format() to
give the application the freedom of which format to list.
Signed-off-by: Josuah Demangeon <me@josuah.net>
Make use of the recently merged fmt->size to know the maximum size of the
frame to be allocated, which works for both compressed and uncompressed
video.
Signed-off-by: Josuah Demangeon <me@josuah.net>
When running out of descriptor, return an error instead of ignoring it.
The application need to make sure to adjust the Kconfig macros to have
enough descriptors for all formats to add.
Signed-off-by: Josuah Demangeon <me@josuah.net>
Do not register the device when the class instance has already been
initialised. Fail on initialization if no HID device is registered.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Since a new device-tree property has been introduced to describe if a
UMP group is limited to 31.25kb/s (like a physical MIDI DIN-5 port),
this can be used in the USB UMP group terminal block descriptors, as
specified in the USB-MIDI2.0 reference document [1], (in 5.4.2.1
Group Terminal Block Descriptor):
Maximum Output Bandwidth Capability in 4KB/second. 0x0000 – 0xFFFF.
Bandwidth is total for this Block, shared among all OUT Group Terminals.
0x0000 = Unknown or Not Fixed.
0x0001 = Rounded version of 31.25kb/s
[1] https://www.usb.org/sites/default/files/USB%20MIDI%20v2_0.pdf
Signed-off-by: Titouan Christophe <titouan.christophe@mind.be>
Initialize the UART configuration from the default line coding
when the CDC ACM device is started. This ensures that the UART
configuration matches the default line coding until the host sets
the line coding for the first time.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Hide the mutex lock details inside a wrapper call, like done for the
device stack API. This is not used for the per-device lock of the host
stack which use a different mutex lock.
Signed-off-by: Josuah Demangeon <josuah.demangeon@nordicsemi.no>
In the while loop parsing descriptors, check that the descriptor is past
the end just before dereferencing it to check if it is seemingly valid.
Signed-off-by: Josuah Demangeon <josuah.demangeon@nordicsemi.no>
Make the struct name match the device naming for ease of use, although
slightly longer name. Propagate the change to the subsystem, includes,
tests and samples.
Signed-off-by: Josuah Demangeon <josuah.demangeon@nordicsemi.no>
Rate limit the get_recv_buf() callback from the application to
reduce system trash when buffer pressure gets high.
Signed-off-by: Victor Brzeski <vbrzeski@gmail.com>
The interface descriptor and its associated string descriptor are shared
between different speed configurations. Do not try to add a string
descriptor if it has already been added and the index is not zero.
Similar to commit ec851ba7c7
("usb: device_next: avoid false error logging in CDC ACM").
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Disable the data interface when the device is disconnected or when the
CDC-NCM and CDC-ECM instances are disabled for any reason.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Enable double buffering on isochronous feedback endpoint to avoid
sending ZLP instead of feedback information.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Enable double buffering on data OUT endpoints to allow USB stack to
enqueue next transfer as soon as possible. This is especially useful
when operating at High-Speed where there is significantly less time
between subsequent SOF packets.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Change the macros to have only one plus operator per term. This is
purely stylistic change, no functional changes.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>