29#ifndef _TUSB_AUDIO_DEVICE_H_
30#define _TUSB_AUDIO_DEVICE_H_
40#ifndef CFG_TUD_AUDIO_FUNC_1_DESC_LEN
41#error You must tell the driver the length of the audio function descriptor including IAD descriptor
44#ifndef CFG_TUD_AUDIO_FUNC_2_DESC_LEN
45#error You must tell the driver the length of the audio function descriptor including IAD descriptor
49#ifndef CFG_TUD_AUDIO_FUNC_3_DESC_LEN
50#error You must tell the driver the length of the audio function descriptor including IAD descriptor
55#ifndef CFG_TUD_AUDIO_FUNC_1_N_AS_INT
56#error You must tell the driver the number of Standard AS Interface Descriptors you have defined in the audio function descriptor!
59#ifndef CFG_TUD_AUDIO_FUNC_2_N_AS_INT
60#error You must tell the driver the number of Standard AS Interface Descriptors you have defined in the audio function descriptor!
64#ifndef CFG_TUD_AUDIO_FUNC_3_N_AS_INT
65#error You must tell the driver the number of Standard AS Interface Descriptors you have defined in the audio function descriptor!
70#ifndef CFG_TUD_AUDIO_FUNC_1_CTRL_BUF_SZ
71#error You must define an audio class control request buffer size!
75#ifndef CFG_TUD_AUDIO_FUNC_2_CTRL_BUF_SZ
76#error You must define an audio class control request buffer size!
81#ifndef CFG_TUD_AUDIO_FUNC_3_CTRL_BUF_SZ
82#error You must define an audio class control request buffer size!
87#ifndef CFG_TUD_AUDIO_ENABLE_EP_IN
88#define CFG_TUD_AUDIO_ENABLE_EP_IN 0
91#ifndef CFG_TUD_AUDIO_ENABLE_EP_OUT
92#define CFG_TUD_AUDIO_ENABLE_EP_OUT 0
96#if CFG_TUD_AUDIO_ENABLE_EP_IN
97#ifndef CFG_TUD_AUDIO_FUNC_1_EP_IN_SZ_MAX
98#error You must tell the driver the biggest EP IN size!
101#ifndef CFG_TUD_AUDIO_FUNC_2_EP_IN_SZ_MAX
102#error You must tell the driver the biggest EP IN size!
106#ifndef CFG_TUD_AUDIO_FUNC_3_EP_IN_SZ_MAX
107#error You must tell the driver the biggest EP IN size!
112#if CFG_TUD_AUDIO_ENABLE_EP_OUT
113#ifndef CFG_TUD_AUDIO_FUNC_1_EP_OUT_SZ_MAX
114#error You must tell the driver the biggest EP OUT size!
117#ifndef CFG_TUD_AUDIO_FUNC_2_EP_OUT_SZ_MAX
118#error You must tell the driver the biggest EP OUT size!
122#ifndef CFG_TUD_AUDIO_FUNC_3_EP_OUT_SZ_MAX
123#error You must tell the driver the biggest EP OUT size!
129#ifndef CFG_TUD_AUDIO_FUNC_1_EP_IN_SW_BUF_SZ
130#define CFG_TUD_AUDIO_FUNC_1_EP_IN_SW_BUF_SZ 0
132#ifndef CFG_TUD_AUDIO_FUNC_2_EP_IN_SW_BUF_SZ
133#define CFG_TUD_AUDIO_FUNC_2_EP_IN_SW_BUF_SZ 0
135#ifndef CFG_TUD_AUDIO_FUNC_3_EP_IN_SW_BUF_SZ
136#define CFG_TUD_AUDIO_FUNC_3_EP_IN_SW_BUF_SZ 0
139#ifndef CFG_TUD_AUDIO_FUNC_1_EP_OUT_SW_BUF_SZ
140#define CFG_TUD_AUDIO_FUNC_1_EP_OUT_SW_BUF_SZ 0
142#ifndef CFG_TUD_AUDIO_FUNC_2_EP_OUT_SW_BUF_SZ
143#define CFG_TUD_AUDIO_FUNC_2_EP_OUT_SW_BUF_SZ 0
145#ifndef CFG_TUD_AUDIO_FUNC_3_EP_OUT_SW_BUF_SZ
146#define CFG_TUD_AUDIO_FUNC_3_EP_OUT_SW_BUF_SZ 0
149#if CFG_TUD_AUDIO_ENABLE_EP_IN
150#if CFG_TUD_AUDIO_FUNC_1_EP_IN_SW_BUF_SZ < CFG_TUD_AUDIO_FUNC_1_EP_IN_SZ_MAX
151#error EP software buffer size MUST BE at least as big as maximum EP size
155#if CFG_TUD_AUDIO_FUNC_2_EP_IN_SW_BUF_SZ < CFG_TUD_AUDIO_FUNC_2_EP_IN_SZ_MAX
156#error EP software buffer size MUST BE at least as big as maximum EP size
161#if CFG_TUD_AUDIO_FUNC_3_EP_IN_SW_BUF_SZ < CFG_TUD_AUDIO_FUNC_3_EP_IN_SZ_MAX
162#error EP software buffer size MUST BE at least as big as maximum EP size
167#if CFG_TUD_AUDIO_ENABLE_EP_OUT
168#if CFG_TUD_AUDIO_FUNC_1_EP_OUT_SW_BUF_SZ < CFG_TUD_AUDIO_FUNC_1_EP_OUT_SZ_MAX
169#error EP software buffer size MUST BE at least as big as maximum EP size
173#if CFG_TUD_AUDIO_FUNC_2_EP_OUT_SW_BUF_SZ < CFG_TUD_AUDIO_FUNC_2_EP_OUT_SZ_MAX
174#error EP software buffer size MUST BE at least as big as maximum EP size
179#if CFG_TUD_AUDIO_FUNC_3_EP_OUT_SW_BUF_SZ < CFG_TUD_AUDIO_FUNC_3_EP_OUT_SZ_MAX
180#error EP software buffer size MUST BE at least as big as maximum EP size
186#ifndef CFG_TUD_AUDIO_EP_IN_FLOW_CONTROL
187#define CFG_TUD_AUDIO_EP_IN_FLOW_CONTROL 1
191#ifndef CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
192#define CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP 0
197#ifndef CFG_TUD_AUDIO_ENABLE_FEEDBACK_FORMAT_CORRECTION
198#define CFG_TUD_AUDIO_ENABLE_FEEDBACK_FORMAT_CORRECTION 0
202#ifndef CFG_TUD_AUDIO_ENABLE_INTERRUPT_EP
203#define CFG_TUD_AUDIO_ENABLE_INTERRUPT_EP 0
253#ifndef CFG_TUD_AUDIO_ENABLE_ENCODING
254#define CFG_TUD_AUDIO_ENABLE_ENCODING 0
257#ifndef CFG_TUD_AUDIO_ENABLE_DECODING
258#define CFG_TUD_AUDIO_ENABLE_DECODING 0
262#ifndef CFG_TUD_AUDIO_ENABLE_TYPE_I_ENCODING
263#define CFG_TUD_AUDIO_ENABLE_TYPE_I_ENCODING 0
266#ifndef CFG_TUD_AUDIO_ENABLE_TYPE_I_DECODING
267#define CFG_TUD_AUDIO_ENABLE_TYPE_I_DECODING 0
272#if CFG_TUD_AUDIO_ENABLE_EP_IN && CFG_TUD_AUDIO_ENABLE_ENCODING && CFG_TUD_AUDIO_ENABLE_TYPE_I_ENCODING
273#ifndef CFG_TUD_AUDIO_FUNC_1_CHANNEL_PER_FIFO_TX
274#error You must tell the driver the number of channels per FIFO for the interleaved encoding! E.g. for an I2S interface having two channels, CHANNEL_PER_FIFO = 2 as the I2S stream having two channels is usually saved within one FIFO
277#ifndef CFG_TUD_AUDIO_FUNC_2_CHANNEL_PER_FIFO_TX
278#error You must tell the driver the number of channels per FIFO for the interleaved encoding! E.g. for an I2S interface having two channels, CHANNEL_PER_FIFO = 2 as the I2S stream having two channels is usually saved within one FIFO
282#ifndef CFG_TUD_AUDIO_FUNC_3_CHANNEL_PER_FIFO_TX
283#error You must tell the driver the number of channels per FIFO for the interleaved encoding! E.g. for an I2S interface having two channels, CHANNEL_PER_FIFO = 2 as the I2S stream having two channels is usually saved within one FIFO
288#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_DECODING && CFG_TUD_AUDIO_ENABLE_TYPE_I_DECODING
289#ifndef CFG_TUD_AUDIO_FUNC_1_CHANNEL_PER_FIFO_RX
290#error You must tell the driver the number of channels per FIFO for the interleaved encoding! E.g. for an I2S interface having two channels, CHANNEL_PER_FIFO = 2 as the I2S stream having two channels is usually saved within one FIFO
293#ifndef CFG_TUD_AUDIO_FUNC_2_CHANNEL_PER_FIFO_RX
294#error You must tell the driver the number of channels per FIFO for the interleaved encoding! E.g. for an I2S interface having two channels, CHANNEL_PER_FIFO = 2 as the I2S stream having two channels is usually saved within one FIFO
298#ifndef CFG_TUD_AUDIO_FUNC_3_CHANNEL_PER_FIFO_RX
299#error You must tell the driver the number of channels per FIFO for the interleaved encoding! E.g. for an I2S interface having two channels, CHANNEL_PER_FIFO = 2 as the I2S stream having two channels is usually saved within one FIFO
307#ifndef CFG_TUD_AUDIO_FUNC_1_N_TX_SUPP_SW_FIFO
308#define CFG_TUD_AUDIO_FUNC_1_N_TX_SUPP_SW_FIFO 0
310#ifndef CFG_TUD_AUDIO_FUNC_2_N_TX_SUPP_SW_FIFO
311#define CFG_TUD_AUDIO_FUNC_2_N_TX_SUPP_SW_FIFO 0
313#ifndef CFG_TUD_AUDIO_FUNC_3_N_TX_SUPP_SW_FIFO
314#define CFG_TUD_AUDIO_FUNC_3_N_TX_SUPP_SW_FIFO 0
317#ifndef CFG_TUD_AUDIO_FUNC_1_N_RX_SUPP_SW_FIFO
318#define CFG_TUD_AUDIO_FUNC_1_N_RX_SUPP_SW_FIFO 0
320#ifndef CFG_TUD_AUDIO_FUNC_2_N_RX_SUPP_SW_FIFO
321#define CFG_TUD_AUDIO_FUNC_2_N_RX_SUPP_SW_FIFO 0
323#ifndef CFG_TUD_AUDIO_FUNC_3_N_RX_SUPP_SW_FIFO
324#define CFG_TUD_AUDIO_FUNC_3_N_RX_SUPP_SW_FIFO 0
328#ifndef CFG_TUD_AUDIO_FUNC_1_TX_SUPP_SW_FIFO_SZ
329#define CFG_TUD_AUDIO_FUNC_1_TX_SUPP_SW_FIFO_SZ 0
331#ifndef CFG_TUD_AUDIO_FUNC_2_TX_SUPP_SW_FIFO_SZ
332#define CFG_TUD_AUDIO_FUNC_2_TX_SUPP_SW_FIFO_SZ 0
334#ifndef CFG_TUD_AUDIO_FUNC_3_TX_SUPP_SW_FIFO_SZ
335#define CFG_TUD_AUDIO_FUNC_3_TX_SUPP_SW_FIFO_SZ 0
338#ifndef CFG_TUD_AUDIO_FUNC_1_RX_SUPP_SW_FIFO_SZ
339#define CFG_TUD_AUDIO_FUNC_1_RX_SUPP_SW_FIFO_SZ 0
341#ifndef CFG_TUD_AUDIO_FUNC_2_RX_SUPP_SW_FIFO_SZ
342#define CFG_TUD_AUDIO_FUNC_2_RX_SUPP_SW_FIFO_SZ 0
344#ifndef CFG_TUD_AUDIO_FUNC_3_RX_SUPP_SW_FIFO_SZ
345#define CFG_TUD_AUDIO_FUNC_3_RX_SUPP_SW_FIFO_SZ 0
368#if CFG_TUD_AUDIO_ENABLE_EP_OUT && !CFG_TUD_AUDIO_ENABLE_DECODING
375#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_DECODING
382#if CFG_TUD_AUDIO_ENABLE_EP_IN && !CFG_TUD_AUDIO_ENABLE_ENCODING
388#if CFG_TUD_AUDIO_ENABLE_EP_IN && CFG_TUD_AUDIO_ENABLE_ENCODING
395#if CFG_TUD_AUDIO_ENABLE_INTERRUPT_EP
408#if CFG_TUD_AUDIO_ENABLE_EP_OUT && !CFG_TUD_AUDIO_ENABLE_DECODING
415#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_DECODING
424#if CFG_TUD_AUDIO_ENABLE_EP_IN && !CFG_TUD_AUDIO_ENABLE_ENCODING
430#if CFG_TUD_AUDIO_ENABLE_EP_IN && CFG_TUD_AUDIO_ENABLE_ENCODING
439#if CFG_TUD_AUDIO_ENABLE_INTERRUPT_EP
455#if CFG_TUD_AUDIO_ENABLE_EP_IN
460#if CFG_TUD_AUDIO_ENABLE_EP_OUT
465#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
554#if CFG_TUD_AUDIO_ENABLE_INTERRUPT_EP
593#if CFG_TUD_AUDIO_ENABLE_EP_OUT && !CFG_TUD_AUDIO_ENABLE_DECODING
617#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_DECODING
643#if CFG_TUD_AUDIO_ENABLE_EP_IN && !CFG_TUD_AUDIO_ENABLE_ENCODING
662#if CFG_TUD_AUDIO_ENABLE_EP_IN && CFG_TUD_AUDIO_ENABLE_ENCODING
686#if CFG_TUD_AUDIO_ENABLE_INTERRUPT_EP
693#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
uint16_t audiod_open(uint8_t rhport, tusb_desc_interface_t const *itf_desc, uint16_t max_len)
void audiod_sof_isr(uint8_t rhport, uint32_t frame_count)
void tud_audio_int_done_cb(uint8_t rhport)
bool tud_audio_buffer_and_schedule_control_xfer(uint8_t rhport, tusb_control_request_t const *p_request, void *data, uint16_t len)
static tu_fifo_t * tud_audio_get_ep_out_ff(void)
bool audiod_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const *request)
bool tud_audio_int_n_write(uint8_t func_id, const audio_interrupt_data_t *data)
bool tud_audio_get_req_itf_cb(uint8_t rhport, tusb_control_request_t const *p_request)
bool tud_audio_rx_done_post_read_cb(uint8_t rhport, uint16_t n_bytes_received, uint8_t func_id, uint8_t ep_out, uint8_t cur_alt_setting)
bool audiod_xfer_cb(uint8_t rhport, uint8_t edpt_addr, xfer_result_t result, uint32_t xferred_bytes)
static uint16_t tud_audio_write(const void *data, uint16_t len)
bool tud_audio_tx_done_pre_load_cb(uint8_t rhport, uint8_t func_id, uint8_t ep_in, uint8_t cur_alt_setting)
static uint16_t tud_audio_clear_tx_support_ff(uint8_t ff_idx)
static uint16_t tud_audio_read_support_ff(uint8_t ff_idx, void *buffer, uint16_t bufsize)
static tu_fifo_t * tud_audio_get_rx_support_ff(uint8_t ff_idx)
static bool tud_audio_int_write(const audio_interrupt_data_t *data)
bool tud_audio_tx_done_post_load_cb(uint8_t rhport, uint16_t n_bytes_copied, uint8_t func_id, uint8_t ep_in, uint8_t cur_alt_setting)
void tud_audio_fb_done_cb(uint8_t func_id)
bool tud_audio_get_req_ep_cb(uint8_t rhport, tusb_control_request_t const *p_request)
tu_fifo_t * tud_audio_n_get_ep_out_ff(uint8_t func_id)
uint16_t tud_audio_n_available_support_ff(uint8_t func_id, uint8_t ff_idx)
uint16_t tud_audio_n_read(uint8_t func_id, void *buffer, uint16_t bufsize)
bool tud_audio_n_fb_set(uint8_t func_id, uint32_t feedback)
tu_fifo_t * tud_audio_n_get_rx_support_ff(uint8_t func_id, uint8_t ff_idx)
tu_fifo_t * tud_audio_n_get_ep_in_ff(uint8_t func_id)
static bool tud_audio_mounted(void)
bool tud_audio_n_clear_ep_in_ff(uint8_t func_id)
static uint16_t tud_audio_read(void *buffer, uint16_t bufsize)
TU_ATTR_FAST_FUNC void tud_audio_feedback_interval_isr(uint8_t func_id, uint32_t frame_number, uint8_t interval_shift)
uint16_t tud_audio_n_write(uint8_t func_id, const void *data, uint16_t len)
Write data to EP in buffer.
static uint16_t tud_audio_available(void)
void audiod_reset(uint8_t rhport)
uint16_t tud_audio_n_write_support_ff(uint8_t func_id, uint8_t ff_idx, const void *data, uint16_t len)
bool tud_audio_rx_done_pre_read_cb(uint8_t rhport, uint16_t n_bytes_received, uint8_t func_id, uint8_t ep_out, uint8_t cur_alt_setting)
static uint16_t tud_audio_write_support_ff(uint8_t ff_idx, const void *data, uint16_t len)
void tud_audio_feedback_params_cb(uint8_t func_id, uint8_t alt_itf, audio_feedback_params_t *feedback_param)
uint32_t tud_audio_feedback_update(uint8_t func_id, uint32_t cycles)
static bool tud_audio_clear_rx_support_ff(uint8_t ff_idx)
tu_fifo_t * tud_audio_n_get_tx_support_ff(uint8_t func_id, uint8_t ff_idx)
static bool tud_audio_clear_ep_out_ff(void)
bool tud_audio_feedback_format_correction_cb(uint8_t func_id)
bool tud_audio_get_req_entity_cb(uint8_t rhport, tusb_control_request_t const *p_request)
bool tud_audio_set_req_ep_cb(uint8_t rhport, tusb_control_request_t const *p_request, uint8_t *pBuff)
static bool tud_audio_clear_ep_in_ff(void)
bool tud_audio_n_clear_tx_support_ff(uint8_t func_id, uint8_t ff_idx)
bool tud_audio_n_clear_ep_out_ff(uint8_t func_id)
bool tud_audio_n_clear_rx_support_ff(uint8_t func_id, uint8_t ff_idx)
static uint16_t tud_audio_available_support_ff(uint8_t ff_idx)
static bool tud_audio_fb_set(uint32_t feedback)
uint16_t tud_audio_n_flush_tx_support_ff(uint8_t func_id)
uint16_t tud_audio_n_available(uint8_t func_id)
bool tud_audio_set_itf_cb(uint8_t rhport, tusb_control_request_t const *p_request)
static tu_fifo_t * tud_audio_get_tx_support_ff(uint8_t ff_idx)
bool tud_audio_set_itf_close_EP_cb(uint8_t rhport, tusb_control_request_t const *p_request)
uint16_t tud_audio_n_read_support_ff(uint8_t func_id, uint8_t ff_idx, void *buffer, uint16_t bufsize)
bool tud_audio_n_mounted(uint8_t func_id)
bool tud_audio_set_req_entity_cb(uint8_t rhport, tusb_control_request_t const *p_request, uint8_t *pBuff)
static uint16_t tud_audio_flush_tx_support_ff(void)
bool tud_audio_set_req_itf_cb(uint8_t rhport, tusb_control_request_t const *p_request, uint8_t *pBuff)
static tu_fifo_t * tud_audio_get_ep_in_ff(void)
@ AUDIO_FEEDBACK_METHOD_FIFO_COUNT
@ AUDIO_FEEDBACK_METHOD_FREQUENCY_FIXED
@ AUDIO_FEEDBACK_METHOD_DISABLED
@ AUDIO_FEEDBACK_METHOD_FREQUENCY_POWER_OF_2
@ AUDIO_FEEDBACK_METHOD_FREQUENCY_FLOAT
AUDIO Channel Cluster Descriptor (4.1)
CFG_TUH_MEM_ALIGN tusb_control_request_t request