diff options
| author | Zhang, Zhenjiang <[email protected]> | 2026-07-21 11:23:27 +0800 |
|---|---|---|
| committer | Zhang, Zhenjiang <[email protected]> | 2026-07-21 11:23:27 +0800 |
| commit | e9578eb103a90d5ab059a067b2e17ca1ddcedee5 (patch) | |
| tree | c3a4419e7497d57892086e84072404b6455a0478 /examples/build_system | |
| parent | 786eef5fd29d0a1ba46eda1e907399aee5af16d0 (diff) | |
Refactor TUH_AUDIO API and simplify multi-AS interface support
This commit refactors the TUH_AUDIO (USB Audio Host) class driver to
simplify its public API and improve multi-AS (Audio Streaming) interface
support. The changes are focused on three files: the core driver
(audio_host.c/h) and the example application (audio_app.c).
Key changes in src/class/audio/audio_host.h:
- Remove tuh_audio_descriptor_cb_t and tuh_audio_mount_cb_t structures.
The mount callback no longer passes a large descriptor-info struct;
applications query per-AS info via tuh_audio_as_get_info().
- Add tuh_audio_get_dev_addr() and tuh_audio_get_feature_unit_id()
accessors to retrieve device address and feature-unit ID from an
interface index.
- Simplify control-transfer APIs by replacing (daddr, itf_num, unit_id)
parameters with a single idx parameter:
tuh_audio_set_sampling_freq(idx, as_idx, ...)
tuh_audio_get_sampling_freq(idx, as_idx, ...)
tuh_audio_feature_unit_set(idx, control_selector, channel, ...)
tuh_audio_feature_unit_get(idx, control_selector, channel, ...)
- Add synchronous wrapper APIs using TU_API_SYNC macro:
tuh_audio_get_sampling_freq_sync()
tuh_audio_set_sampling_freq_sync()
tuh_audio_feature_unit_set_sync()
tuh_audio_feature_unit_get_sync()
- Update isochronous endpoint APIs to use (idx, as_idx) instead of
(daddr, idx):
tuh_audio_receive(idx, as_idx, buffer, len)
tuh_audio_send(idx, as_idx, buffer, len)
- Remove tuh_audio_descriptor_cb() weak callback.
- Update tuh_audio_mount_cb() signature from mount_cb(param) to no param.
- Update tuh_audio_rx_cb()/tuh_audio_tx_cb() first parameter from idx to
dev_addr for consistency with other class drivers.
Key changes in src/class/audio/audio_host.c:
- Delete tuh_audio_descriptor_cb weak stub.
- Refactor get_idx_by_ep_addr() to iterate all AS interfaces per device
instead of relying on single ep_in/ep_out fields.
- Add audioh_get_ep_addr_by_dir() helper to find an endpoint address by
direction across multiple AS interfaces.
- Simplify audioh_close() cleanup: remove now-removed single-endpoint
fields (ep_in, ep_out) and rely on tu_memclr(p_audio->as, ...).
- Update audioh_xfer_cb() to pass dev_addr (not idx) to rx/tx callbacks,
matching the new callback signature.
- Simplify audioh_open(): remove descriptor-callback emission and the
temporary desc_cb structure; store only ac_itf_num instead of
bInterfaceNumber + iInterface + as_interface_num.
- Rename local descriptor pointers for clarity:
desc_input_terminal (was desc_it)
desc_output_terminal (was desc_ot)
Key changes in examples/host/audio_host/src/audio_app.c:
- Remove now-unnecessary globals: audio_ep_in, audio_ep_out, audio_ac_itf,
audio_feature_unit_id.
- Initialize audio_dev_addr, audio_idx, audiostream_in_idx,
audiostream_out_idx to 0xFF (TUSB_INDEX_INVALID_8) instead of 0.
- Update print_as_interfaces() to use tuh_audio_as_get_count() and
tuh_audio_as_get_info() instead of accessing mount_cb_data.
- Update all callback signatures and API calls to match the new driver API.
Diffstat (limited to 'examples/build_system')
0 files changed, 0 insertions, 0 deletions
