Skip to content

Conversation

peter-marcisovsky
Copy link
Collaborator

Description

This MR adds Suspend/Resume events for UAC class driver as a follow-up for the Global/Suspend resume MR in esp-idf

Changes

Added Suspend and Resume UAC Host driver events

/**
 * @brief USB UAC Device (Interface) event id
*/
typedef enum {
    UAC_HOST_DEVICE_EVENT_RX_DONE = 0x00,                /*!< RX Done: the receive buffer data size exceeds the threshold */
    UAC_HOST_DEVICE_EVENT_TX_DONE,                       /*!< TX Done: the transmit buffer data size falls below the threshold */
    UAC_HOST_DEVICE_EVENT_TRANSFER_ERROR,                /*!< UAC Device transfer error */
    UAC_HOST_DRIVER_EVENT_DISCONNECTED,                  /*!< UAC Device has been disconnected */
    UAC_HOST_DEVICE_EVENT_SUSPENDED,                     /*!< UAC Device has been suspended */
    UAC_HOST_DEVICE_EVENT_RESUMED,                       /*!< UAC Device has been resumed */
} uac_host_device_event_t;

As the global Suspend issued by the USB Host Halts and flushes all EPs of all connected devices. The UAC Host driver must submit the in transfer(s) upon Resuming the root port

Related

  • Closes Suspend/Resume support for HID Class driver

Testing

TODO add tests


Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

@peter-marcisovsky peter-marcisovsky self-assigned this Jul 17, 2025
@peter-marcisovsky peter-marcisovsky added the Status: In Progress Issue is being worked on label Jul 17, 2025
@peter-marcisovsky peter-marcisovsky force-pushed the feat/usb_host_uac_suspend_resume_events branch from bc154af to 947a07a Compare August 4, 2025 19:53
@peter-marcisovsky peter-marcisovsky force-pushed the feat/usb_host_uac_suspend_resume_events branch from d6a83d2 to 1c8eb77 Compare August 6, 2025 10:11
Comment on lines +1199 to +1206
case USB_HOST_CLIENT_EVENT_DEV_SUSPENDED:
ESP_LOGD(TAG, "Device suspended");
_uac_host_device_suspended(event->dev_suspend_resume.dev_hdl);
break;
case USB_HOST_CLIENT_EVENT_DEV_RESUMED:
ESP_LOGD(TAG, "Device resumed");
_uac_host_device_resumed(event->dev_suspend_resume.dev_hdl);
break;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @leeebo in this MR I am adding support for global suspend/resume of the root port.

In the current uac driver, there are public API functions like:

/**
 * @brief Resume a UAC stream with same stream configuration
 */
esp_err_t uac_host_device_resume(uac_host_device_handle_t uac_dev_handle);

and

/**
 * @brief Suspend a UAC stream
 *
 * @param[in] uac_dev_handle  UAC device handle
 */
esp_err_t uac_host_device_suspend(uac_host_device_handle_t uac_dev_handle);

And other static functions like uac_host_interface_suspend(), uac_host_interface_resume().

Which are suspending and resuming the UAC stream, not the device itself in terms of power consumption lowering.

My concern here is, that users might get confused with naming of those functions. And might mistakenly call uac_host_device_suspend() with intention to put a UAC device into a suspended state, to lower it's power consumption. But the function only suspends a UAC stream.

Do you thinks we should consider renaming the functions to something like uac_host_device_suspend_stream() and uac_host_device_resume_stream() ? Can you PTAL and advise how to handle this?

@peter-marcisovsky peter-marcisovsky added stall PR is stall due to low priority, or blocked by other PR and removed Status: In Progress Issue is being worked on labels Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stall PR is stall due to low priority, or blocked by other PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant