Skip to content

audio: Implement support for variable EP in flow control fifo level#3321

Merged
HiFiPhile merged 6 commits intohathach:masterfrom
gabChouin:audio_ep_in_target_fifo_size
Nov 7, 2025
Merged

audio: Implement support for variable EP in flow control fifo level#3321
HiFiPhile merged 6 commits intohathach:masterfrom
gabChouin:audio_ep_in_target_fifo_size

Conversation

@gabChouin
Copy link
Contributor

Describe the PR
This PR adds a tud_audio_set_ep_in_target_fifo_size function that allows the user to set the target fifo level of the EP IN flow control.

Additional context
For applications that require dynamic configuration of the audio EP IN, having the target fifo size set to half of the fifo depth can be limiting. In some cases the input latency might be very big. This MR aims to add the ability to configure this value at run time using the tud_audio_set_ep_in_target_fifo_size function.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@HiFiPhile
Copy link
Collaborator

Thank you, it's something I've in mind (also for OUT transfer)

Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Copilot AI review requested due to automatic review settings November 7, 2025 13:35
codescene-delta-analysis[bot]

This comment was marked as outdated.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds FIFO threshold configuration support for USB audio devices, enabling fine-tuned control over both EP IN (transmit) and EP OUT (receive via feedback) FIFO buffer management for better latency control.

  • Adds getter/setter API functions for EP IN FIFO threshold configuration
  • Extends audio_feedback_params_t struct with fifo_count.fifo_threshold field for EP OUT feedback control
  • Updates flow control logic to use configurable thresholds instead of hardcoded half-depth values

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/class/audio/audio_device.h Adds API function declarations for EP IN FIFO threshold control and extends feedback params struct with threshold field
src/class/audio/audio_device.c Implements threshold getter/setter functions, updates packet sizing logic to use configurable thresholds, and refactors feedback parameter handling
examples/device/uac2_speaker_fb/src/main.c Reorganizes sample_rates array scope and adds documentation explaining FIFO threshold usage in feedback callback

codescene-delta-analysis[bot]

This comment was marked as outdated.

Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
@HiFiPhile HiFiPhile force-pushed the audio_ep_in_target_fifo_size branch from 5468954 to f188a40 Compare November 7, 2025 14:52
Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gates Failed
Prevent hotspot decline (1 hotspot with Complex Method)
Enforce advisory code health rules (1 file with Complex Method)

Gates Passed
2 Quality Gates Passed

See analysis details in CodeScene

Reason for failure
Prevent hotspot decline Violations Code Health Impact
audio_device.c 1 rule in this hotspot 3.44 → 3.43 Suppress
Enforce advisory code health rules Violations Code Health Impact
audio_device.c 1 advisory rule 3.44 → 3.43 Suppress

Quality Gate Profile: Clean Code Collective
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.

Copy link
Collaborator

@HiFiPhile HiFiPhile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done the fixup and also added RX FIFO threshold adjustment.

@HiFiPhile HiFiPhile merged commit 91c3a4f into hathach:master Nov 7, 2025
82 of 86 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants