summaryrefslogtreecommitdiff
path: root/src/class
AgeCommit message (Collapse)Author
10 daysaudio: normalize Feature Unit volume requestsHiFiPHile
Accept the defined silence value and round ordinary volume requests to the nearest supported resolution step within the cached range. Add tests for silence, clamping, and step alignment. Signed-off-by: HiFiPHile <[email protected]>
10 daysaudio: harden streaming descriptor parsingHiFiPHile
Validate descriptor lengths before typed access, keep supported alternate settings when neighboring formats are unsupported, and reject MIDI 1.0 and 2.0 streaming interfaces from the Audio host parser. Extend parser coverage for malformed and mixed descriptor layouts. Signed-off-by: HiFiPHile <[email protected]>
10 daysaudio: allow stopped duplex streams to change rateHiFiPHile
Enforce a shared capture/playback sample rate only while the opposite stream is running. This lets both stopped streams be configured in either order while preventing a live shared clock from changing underneath a transfer. Signed-off-by: HiFiPHile <[email protected]>
10 daysaudio: reduce USB-accessible control storageHiFiPHile
Move control-transfer bookkeeping out of USB memory and overlay mount-only Clock RANGE storage with cache-aligned runtime control payload buffers. Keep explicit feedback separate because it may overlap runtime requests. Signed-off-by: HiFiPHile <[email protected]>
10 daysaudio: preserve feedback scheduler remainderHiFiPHile
Keep the fractional packet accumulator when a new explicit-feedback value is latched. Repeated feedback updates no longer bias high-speed fractional rates toward alternating undersized and oversized packets. Signed-off-by: HiFiPHile <[email protected]>
10 daysaudio: add UAC2 host streaming supportHiFiPHile
Add protocol-selectable UAC1/UAC2 parsing, UAC2 terminal and Feature Unit topology, Clock Source discovery, sampling-frequency ranges, and protocol-specific stream controls. Cover UAC2 playback, capture, control discovery, and malformed descriptors with unit tests. Signed-off-by: HiFiPHile <[email protected]>
10 daysaudio: preserve descriptor sample-rate entriesHiFiPHile
Retain every valid discrete rate in descriptor order, including duplicate public tuples. Alternate settings remain independently selectable without disruptive validation or deduplication during enumeration. Signed-off-by: HiFiPHile <[email protected]>
10 daysaudio: compact alternate-setting storageHiFiPHile
Store each Audio Streaming alternate setting once and flatten its sample rates only at the public API boundary. Keep feedback and pacing state playback-only, eliminating duplicate configuration fields from capture streams. Signed-off-by: HiFiPHile <[email protected]>
12 daysimplement explicit feeback supportHiFiPHile
Signed-off-by: HiFiPHile <[email protected]>
12 daysaddress copilot review findingsHiFiPHile
Signed-off-by: HiFiPHile <[email protected]>
12 daysMerge remote-tracking branch 'origin/master' into feature/tuh-audio-uac-1.0HiFiPHile
13 daysfeat(audio): discover stream mute and volume controlsHiFiPHile
Inspect each associated Feature Unit during mount, cache master mute support and the common MIN, MAX, and RES volume range, and ignore units with neither control. Add typed asynchronous and synchronous mute and volume APIs and demonstrate them in the host example. Signed-off-by: HiFiPHile <[email protected]>
13 daysfix(audio): validate descriptors before parsingHiFiPHile
Check descriptor bounds, minimum lengths, frequency counts, and interface types with the host validation helpers before accessing fields. Malformed UAC1 functions now fail enumeration without out-of-bounds reads. Signed-off-by: HiFiPHile <[email protected]>
13 daysrefactor(audio): simplify class endpoint associationHiFiPHile
Keep the sampling-frequency control flag in the alternate-setting parser state shared by its single data endpoint. This supports either descriptor order without separate pending and unassigned endpoint flags. Signed-off-by: HiFiPHile <[email protected]>
13 daysfix(audio): decode full-speed isochronous bIntervalHiFiPHile
Treat isochronous bInterval as a power-of-two exponent for both full and high speed, using the appropriate frame unit. Packet sizing and fractional scheduling now use the actual service interval. Signed-off-by: HiFiPHile <[email protected]>
13 daysfix(audio): release instances without supported streamsHiFiPHile
Retain an audio function when at least one direction has a supported configuration, but release the tentative instance when neither direction does. Unsupported and MIDI-only functions no longer consume host slots or emit mount callbacks. Signed-off-by: HiFiPHile <[email protected]>
13 daysfix(audio): retain multiple pending Feature UnitsHiFiPHile
Keep one unresolved Feature Unit candidate per stream direction while parsing AudioControl entities. Duplex functions are now associated correctly even when both Feature Units precede their USB terminals. Signed-off-by: HiFiPHile <[email protected]>
13 daysfix(audio): reject unsupported UAC2 interfacesHiFiPHile
Require the UAC1 AudioControl protocol before allocating an instance. The current parser assumes UAC1 descriptor layouts, so accepting UAC2 would misinterpret entities and consume a host slot. Signed-off-by: HiFiPHile <[email protected]>
13 daysfix(audio): keep stream state consistent on control failuresHiFiPHile
Route asynchronous activation and sampling-frequency failures through the stream error callback. Keep a running stream active when SET_INTERFACE alt 0 cannot be submitted so stop can be retried without diverging from device state. Signed-off-by: HiFiPHile <[email protected]>
13 daysfix(audio): accept one data endpoint per AS alternateHiFiPHile
Collect one audio data endpoint for each alternate setting and ignore explicit feedback endpoints until feedback scheduling is implemented. Validate the maximum packet for every discrete rate against the endpoint, transfer buffer, and FIFO. Signed-off-by: HiFiPHile <[email protected]>
13 daysrefactor(audio): simplify UAC1 interface discoveryHiFiPHile
Parse the contiguous AudioStreaming interfaces by class and subclass instead of copying baInterfaceNr. This removes the UAC1-only collection limit and prevents MIDI AudioControl interfaces from leaving a half-allocated Audio Host instance. Signed-off-by: HiFiPHile <[email protected]>
13 daysrefactor(audio): separate stream configuration and startHiFiPHile
Make configuration a synchronous local operation that selects and opens the endpoint. Start now activates the alternate setting and sets the sampling frequency afterward, including every restart, so devices cannot reset the selected rate with SET_INTERFACE. Signed-off-by: HiFiPHile <[email protected]>
13 daysfix(audio): drive streams from transfer completionHiFiPHile
Keep capture and playback transfers continuously armed from their completion callbacks. Capture overwrites the oldest complete frames when full, while playback sends silence on underrun without consuming partial queued audio. Signed-off-by: HiFiPHile <[email protected]>
13 daysMerge master updates into the UAC1 host branchHiFiPHile
Bring the audio work onto the current host core and build files before applying the remaining review fixes. Signed-off-by: HiFiPHile <[email protected]>
13 daysfix(audio): resolve Feature Units independent of orderHiFiPHile
Record terminal and Feature Unit links while parsing the AudioControl block, then resolve the stream association after all entities are known. Common capture and playback descriptor orders are both supported. Signed-off-by: HiFiPHile <[email protected]>
13 daysfix(audio): reject continuous UAC1 sample-rate rangesHiFiPHile
Collect only format descriptors with discrete sampling frequencies. The configuration API exposes concrete tuples and cannot safely represent a continuous range as one selectable rate. Signed-off-by: HiFiPHile <[email protected]>
13 daysfix(audio): honor full-speed isochronous intervalsHiFiPHile
Convert full-speed bInterval values to the scheduler microframe timebase and size transfers for the complete service interval. Endpoints with bInterval greater than one no longer run at a one-frame cadence. Signed-off-by: HiFiPHile <[email protected]>
13 daysfeat(audio): track a Feature Unit per stream directionHiFiPHile
Associate one directly connected Feature Unit with each capture and playback stream. This lets applications control microphone and speaker paths independently. Signed-off-by: HiFiPHile <[email protected]>
13 daysfix(audio): clear stale Feature Unit associationsHiFiPHile
Reset Feature Unit state when parsing a new audio function. Devices without a matching unit must not inherit an ID collected from an earlier interface or device. Signed-off-by: HiFiPHile <[email protected]>
13 daysfix(audio): serialize Feature Unit requestsHiFiPHile
Keep Feature Unit request data in driver-owned storage until asynchronous completion and use the width defined for each control. This avoids overlapping request state and malformed one-byte controls. Signed-off-by: HiFiPHile <[email protected]>
13 daysfix(audio): retain stream state when stop failsHiFiPHile
Clear the started state only after SET_INTERFACE alt 0 succeeds. A failed control transfer can then be retried instead of leaving software and device state inconsistent. Signed-off-by: HiFiPHile <[email protected]>
13 daysfix(audio): close endpoints before stream reconfigurationHiFiPHile
Close the previously selected HCD endpoint before opening another alternate setting. This prevents stale endpoint size and controller state from surviving a format change. Signed-off-by: HiFiPHile <[email protected]>
13 daysfix(audio): place transfer buffers in configured memoryHiFiPHile
Apply the host memory section and alignment attributes to audio transfer storage. This keeps buffers accessible to controllers that require DMA-capable memory. Signed-off-by: HiFiPHile <[email protected]>
13 daysfix(audio): distinguish data and feedback endpointsHiFiPHile
Associate UAC1 AudioStreaming endpoints by their usage type. Keep data and implicit-feedback IN endpoints as streams while leaving explicit feedback endpoints unopened until feedback scheduling is supported. Signed-off-by: HiFiPHile <[email protected]>
2026-08-21vendor: remove the obsolete host vendor driverhathach
vendor_host.c/.h implemented a CFG_TUH_VENDOR class driver that no example, board or test ever enabled: usbh's driver table entry was compiled out everywhere, and the six tusb_config.h files that mentioned the macro all set it to 0. Maintainer call - dead code, not a shrinking of supported classes. Removes the sources, the usbh driver-table entry, the CFG_TUH_VENDOR default in tusb_option.h, the tusb.h include, both build-system source lists, the rp2040 family.cmake entry and the IAR project template rows.
2026-08-19Fix audio terminal type typosHiFiPHile
2026-08-18UAC2: Add more terminal typesJerzy Kasenberg
This adds more standard terminal types that can be used in descriptors to improve end user experience when operating system can present more acurate image for audio device terminal. Signed-off-by: Jerzy Kasenberg <[email protected]>
2026-08-17Merge pull request #3790 from hathach/fix/lpc43-hfp-reliabilityHa Thach
Fix HFP HIL reliability issue
2026-08-15Merge pull request #3823 from sauloverissimo/feat/midi2-fb-capsZixun LI
midi2 device: complete the UMP stream discovery responder
2026-08-15Merge pull request #3802 from dxbjavid/video-payload-capZixun LI
clamp committed video payload size to streaming ep buffer
2026-08-15Potential fix for pull request findingZixun LI
Co-authored-by: Copilot Autofix powered by AI <[email protected]> Signed-off-by: HiFiPhile <[email protected]>
2026-08-15fix(midi2): fix discovery response racingHiFiPhile
Signed-off-by: HiFiPhile <[email protected]>
2026-08-14fix(midi2): keep discovery replies valid under TX pressureSaulo Veríssimo
Text replies resume instead of dropping their tail packets, which used to leave a Start/Continue sequence without an End. A new Function Block Discovery now merges with a pending one instead of replacing it.
2026-08-14feat(midi2): complete the UMP stream discovery responderSaulo Veríssimo
Adds the Device Identity Notification with an app callback, MIDI-CI version and SysEx8 stream count in FB Info, honors the Endpoint Discovery filter bitmap, and paces discovery replies by TX FIFO room.
2026-08-14usbtmc: document why the trigger re-arm result is ignoredice458
A false return from tud_usbtmc_start_bus_read() here does not mean arming failed: it means the endpoint is already armed, either because the application re-armed it from its trigger callback or because a transfer is still queued (usbd_edpt_xfer() reports failure when the endpoint is busy). Both cases end in STATE_IDLE, so the state cannot disambiguate them either, and stalling on the result would halt a healthy endpoint. Co-Authored-By: Claude Opus 5 <[email protected]>
2026-08-14usbtmc: re-arm (or stall) the bulk-OUT endpoint after a USB488 TRIGGERice458
A single USB488 TRIGGER message left the bulk-OUT endpoint un-armed, so the host's next bulk-OUT transfer timed out. The trigger itself succeeded silently, so the failure surfaced on a later, unrelated command; only a USBTMC device clear recovered it. The bundled examples/device/usbtmc reproduced this as shipped. Every other branch of the STATE_IDLE dispatch in usbtmcd_xfer_cb() leaves the endpoint in a defined state: it either transitions out of STATE_IDLE so a later tud_usbtmc_start_bus_read() can re-arm it, or it stalls and lets the CLEAR_FEATURE(ENDPOINT_HALT) handler recover it. USBTMC_MSGID_USB488_TRIGGER did neither, and because the state stayed STATE_IDLE, even an application following the contract documented in usbtmc_device.h got a silent no-op from tud_usbtmc_start_bus_read(). Transition to STATE_NAK so the re-arm can take effect, and stall the endpoint when trigger is unsupported or the application callback rejects it, matching the existing handling for messages the driver cannot process. The callback result is deliberately not wrapped in TU_VERIFY(), which would return before the stall/re-arm and reintroduce the same hang. Since the driver now re-arms after a trigger, drop tud_usbtmc_msg_trigger_cb from the list of callbacks after which the application must do so. Fixes #3821 Co-Authored-By: Claude Opus 5 <[email protected]>
2026-08-14feat(class/audio): rework TUH_AUDIO into a WASAPI/ALSA-like stream APIZhang, Zhenjiang
Provide a high-level audio streaming API over UAC 1.0 devices while keeping the USB topology private: applications select supported {format, sample_rate, channels} configurations per logical stream, and the driver owns the mapping to AS interface, alternate setting, and endpoint. - One logical stream per direction per instance; multiple AS interfaces and alternate settings in a direction are merged into the stream's configuration list (discrete tuples; continuous ranges exposed as a single configuration at the top rate) - Asynchronous tuh_audio_configure(): SET_INTERFACE to the selected alternate setting, open/reconfigure the endpoint, set the sampling frequency when supported, initialize the FIFO and packet scheduler, then invoke the completion callback - Frame-based FIFO streaming: tuh_audio_read()/tuh_audio_write() queue whole frames; the driver owns transfer replenishment and fractional packet scheduling (44.1 kHz pays back the 0.1 frame/ms remainder via an accumulator for exact average pacing) - tuh_audio_start()/tuh_audio_stop() activate/deactivate the stream interface through SET_INTERFACE (alt n / alt 0) Driver correctness fixes: - Parse only the AC header's interface collection; MIDI Streaming and other subclasses are skipped - Keep every discrete format as a separate configuration; endpoints are opened only for the alternate setting selected by tuh_audio_configure() - Check tuh_interface_set() return values and SET_INTERFACE transfer results instead of ignoring failures - Validate instance state, direction, buffers, and frame counts in every transfer API - Feature Unit requests use the control's real width (mute/AGC/loudness 1 byte, others 2 bytes) and convert multibyte values to host order - Failed/stalled/aborted isochronous transfers reach only the error callback, never the capture/playback callbacks The audio_host example uses the new API: 48 kHz stereo by default, automatic stream restart on error callbacks, a sine test tone on the playback stream, and periodic mic-only / spk-only / echo phase switching.
2026-08-07Merge pull request #3761 from ↵Zixun LI
morse-cedricvandenbergh/fix/ncm-link-state-notify-retry ncm: retry link-state notification, fix carrier lost on collision
2026-08-07ncm: fix carrier lost on link-state notify collisionCedric Van den Bergh
tud_network_link_state() delivered the NETWORK_CONNECTION notification edge-triggered and fire-once: if a previous notification was still in flight, notification_xmit() returned early and the notification for the new link state was never queued. Because link_is_up is committed before the send, the host could be left reporting a stale carrier state - e.g. a permanent NO-CARRIER after a link up. The notification state was also mutated from both the caller and the notify xfer-completion callback with no serialisation, so on RTOS ports where tud_network_link_state() runs in a task other than tud_task() the two could race. Defer the whole link-state update onto the usbd task, so it can no longer race the completion callback. A collision with an in-flight notification is resolved by re-arming notification_xmit_state and letting the existing completion callback drive it forward on the next xfer completion, rather than adding a separate pending/retry flag. A link toggle does not change the link speed, so strictly only the NETWORK_CONNECTION notification needs (re)sending, but reusing the existing speed-then-connection state machine keeps the fix on a single, already-serialised code path. Closes #3760
2026-08-04audio_device: enforce the documented FIFO minimum in the EP-IN flow-control ↵rt-rtos
guard The comment above audiod_tx_packet_size() states flow control needs a FIFO of at least 4*Navg, but the guard tests nominal_size[1] <= fifo_depth * 4 - true for any FIFO larger than a quarter packet - instead of nominal_size[1] * 4 <= fifo_depth. As written, flow control engages on FIFOs far below its own documented minimum, where the depth/2 setpoint sits within one packet of empty and the packet_size = 0 branch (a zero-length packet, i.e. an audible 1 ms dropout for audio-class hosts) is reachable from ordinary scheduling jitter rather than only from gross clock deviation. With the guard corrected, undersized FIFOs fall back to the plain min(count, max) path as intended.