summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPuma Hsu <pumahsu@google.com>2022-08-18 11:08:32 +0800
committerPuma Hsu <pumahsu@google.com>2022-08-22 08:47:55 +0000
commit20ac39e6aefbaff9fb804ed47d323ecff7ddc377 (patch)
treec636d2fcaa87de6874047dacaa58ce64d3a6da24
parentdd2984066b2e633dbd828652faf4954e4968c5ca (diff)
downloadaoc-20ac39e6aefbaff9fb804ed47d323ecff7ddc377.tar.gz
aoc: usb: query playback/capture states only for audio devices
This suspend implementation is used to support USB audio offloading, so we don't need to check playback/capture states if the connected device is not an audio device. Bug: 241695830 Test: hub and audio device work Signed-off-by: Puma Hsu <pumahsu@google.com> Change-Id: I34042986476e4ae0c1b648792178748a6a8b926f
-rw-r--r--usb/usb_hooks_impl_whi.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/usb/usb_hooks_impl_whi.c b/usb/usb_hooks_impl_whi.c
index 6423fe9..5d03aba 100644
--- a/usb/usb_hooks_impl_whi.c
+++ b/usb/usb_hooks_impl_whi.c
@@ -92,14 +92,16 @@ static int get_usb_dev_hub_info(struct usb_device *udev)
static void usb_vendor_dev_suspend(void *unused, struct usb_device *udev,
pm_message_t msg, int *bypass)
{
+ struct xhci_hcd *xhci;
+ int usb_audio_count = 0;
bool usb_playback = false;
bool usb_capture = false;
enum usb_dev_hub usb_dev_hub;
- if (!udev) {
- *bypass = 0;
+ *bypass = 0;
+
+ if (!udev)
return;
- }
usb_dev_hub = get_usb_dev_hub_info(udev);
@@ -107,14 +109,28 @@ static void usb_vendor_dev_suspend(void *unused, struct usb_device *udev,
* We don't change dummy_hcd's behavior, the dummy_hcd is in bus 1.
* We don't change undefined device neither.
*/
- if (usb_dev_hub >= USB1 && usb_dev_hub <= USB1_1) {
- *bypass = 0;
+ if (usb_dev_hub >= USB1 && usb_dev_hub <= USB1_1)
+ return;
+
+ xhci = get_xhci_hcd_by_udev(udev);
+ if (!xhci) {
+ dev_err(&udev->dev, "%s: couldn't get xhci\n", __func__);
return;
}
- usb_playback = aoc_alsa_usb_playback_enabled();
- usb_capture = aoc_alsa_usb_capture_enabled();
- *bypass = 0;
+ usb_audio_count = xhci_get_usb_audio_count(xhci);
+
+ if (usb_audio_count > 0) {
+ /*
+ * We query playback/capture states only when there is USB
+ * audio device connected.
+ */
+ usb_playback = aoc_alsa_usb_playback_enabled();
+ usb_capture = aoc_alsa_usb_capture_enabled();
+ } else {
+ /* If no USB audio device is connected, we won't skip suspend. */
+ return;
+ }
/*
* Note: Currently we also allow the UNDEFINED case go to check