Skip to content

Commit

Permalink
Support disabling feedback format correction hathach#1234
Browse files Browse the repository at this point in the history
  • Loading branch information
vmilea committed Dec 6, 2021
1 parent 3e9bb3b commit ef879e8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/class/audio/audio_device.c
Expand Up @@ -2248,12 +2248,13 @@ static void audiod_parse_for_AS_params(audiod_function_t* audio, uint8_t const *
#if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP

// Input value feedback has to be in 16.16 format - the format will be converted according to speed settings automatically
// unless format correction is disabled.
bool tud_audio_n_fb_set(uint8_t func_id, uint32_t feedback)
{
TU_VERIFY(func_id < CFG_TUD_AUDIO && _audiod_fct[func_id].p_desc != NULL);

// Format the feedback value
#if !TUD_OPT_HIGH_SPEED
#if !TUD_OPT_HIGH_SPEED && !CFG_TUD_AUDIO_DISABLE_FEEDBACK_FORMAT_CORRECTION
uint8_t * fb = (uint8_t *) &_audiod_fct[func_id].fb_val;

// For FS format is 10.14
Expand Down
10 changes: 10 additions & 0 deletions src/class/audio/audio_device.h
Expand Up @@ -186,6 +186,11 @@
#define CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP 0 // Feedback - 0 or 1
#endif

// Disable/enable conversion from 16.16 to 10.14 format on high-speed devices. See tud_audio_n_fb_set().
#ifndef CFG_TUD_AUDIO_DISABLE_FEEDBACK_FORMAT_CORRECTION
#define CFG_TUD_AUDIO_DISABLE_FEEDBACK_FORMAT_CORRECTION 0 // 0 or 1
#endif

// Audio interrupt control EP size - disabled if 0
#ifndef CFG_TUD_AUDIO_INT_CTR_EPSIZE_IN
#define CFG_TUD_AUDIO_INT_CTR_EPSIZE_IN 0 // Audio interrupt control - if required - 6 Bytes according to UAC 2 specification (p. 74)
Expand Down Expand Up @@ -458,6 +463,11 @@ TU_ATTR_WEAK bool tud_audio_fb_done_cb(uint8_t rhport);
// Value will be corrected for FS to 10.14 format automatically.
// (see Universal Serial Bus Specification Revision 2.0 5.12.4.2).
// Feedback value will be sent at FB endpoint interval till it's changed.
//
// Note that the USB Audio 2.0 driver on Windows 10 is not following the spec and expects 16.16
// format for FS. You can define CFG_TUD_AUDIO_DISABLE_FEEDBACK_FORMAT_CORRECTION=1 as a workaround
// to transmit the feedback value unchanged. Be aware that this might break feedback on other hosts,
// though at least on Linux the ALSA driver will happily accept either format.
bool tud_audio_n_fb_set(uint8_t func_id, uint32_t feedback);
static inline bool tud_audio_fb_set(uint32_t feedback);
#endif
Expand Down

0 comments on commit ef879e8

Please sign in to comment.