ANDROID: sound: usb: add vendor hook for cpu suspend support

Add vendor hook android_vh_sound_check_support_cpu_suspend
to allow ACPU to suspend during USB playback/capture,
if this is supported.

Bug: 192206510
Change-Id: Ia8d4c335db27de5fcefab13cab653fd1ae34f691
Signed-off-by: JJ Lee <leejj@google.com>
This commit is contained in:
JJ Lee 2021-07-12 17:50:02 +08:00
parent d820d22b5d
commit e8516fd3af
3 changed files with 35 additions and 0 deletions

View File

@ -69,6 +69,7 @@
#include <trace/hooks/syscall_check.h>
#include <trace/hooks/usb.h>
#include <trace/hooks/ipv6.h>
#include <trace/hooks/sound.h>
/*
* Export tracepoints that act as a bare tracehook (ie: have no trace event
@ -355,3 +356,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_bpf_syscall);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_usb_dev_suspend);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_usb_dev_resume);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ipv6_gen_linklocal_addr);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sound_usb_support_cpu_suspend);

View File

@ -0,0 +1,20 @@
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM sound
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH trace/hooks
#if !defined(_TRACE_HOOK_SOUND_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_HOOK_SOUND_H
#include <linux/tracepoint.h>
#include <trace/hooks/vendor_hooks.h>
#include <linux/usb.h>
DECLARE_HOOK(android_vh_sound_usb_support_cpu_suspend,
TP_PROTO(struct usb_device *udev,
int direction,
bool *is_support),
TP_ARGS(udev, direction, is_support));
#endif /* _TRACE_HOOK_SOUND_H */
/* This part must be outside protection */
#include <trace/define_trace.h>

View File

@ -14,6 +14,8 @@
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <trace/hooks/sound.h>
#include "usbaudio.h"
#include "card.h"
#include "quirks.h"
@ -1508,6 +1510,7 @@ static int snd_usb_pcm_open(struct snd_pcm_substream *substream)
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_usb_substream *subs = &as->substream[direction];
int ret;
bool is_support = false;
ret = snd_vendor_set_pcm_connection(subs->dev, SOUND_PCM_OPEN,
direction);
@ -1532,6 +1535,11 @@ static int snd_usb_pcm_open(struct snd_pcm_substream *substream)
if (ret)
snd_usb_autosuspend(subs->stream->chip);
}
trace_android_vh_sound_usb_support_cpu_suspend(subs->dev, direction, &is_support);
if (!ret && is_support)
snd_usb_autosuspend(subs->stream->chip);
return ret;
}
@ -1541,12 +1549,17 @@ static int snd_usb_pcm_close(struct snd_pcm_substream *substream)
struct snd_usb_stream *as = snd_pcm_substream_chip(substream);
struct snd_usb_substream *subs = &as->substream[direction];
int ret;
bool is_support = false;
ret = snd_vendor_set_pcm_connection(subs->dev, SOUND_PCM_CLOSE,
direction);
if (ret)
return ret;
trace_android_vh_sound_usb_support_cpu_suspend(subs->dev, direction, &is_support);
if (!ret && is_support)
snd_usb_autoresume(subs->stream->chip);
snd_media_stop_pipeline(subs);
if (!as->chip->keep_iface &&