ANDROID: ALSA: compress: add vendor hook to support pause in draining

Add a hook to query from vendor's compress driver if it is support pause
in draining and if the platform need to keep in draining state.

Bug: 184020292
Bug: 178992384

Change-Id: Id2e2ff72d7ee66fc633473ec109ed3d8a2baaeff
Signed-off-by: Robert Lee <lerobert@google.com>
This commit is contained in:
Robert Lee
2021-07-14 13:56:16 +08:00
committed by Greg Kroah-Hartman
parent 2faed77792
commit 13bc06efd9
3 changed files with 53 additions and 0 deletions

View File

@@ -71,6 +71,7 @@
#include <trace/hooks/usb.h> #include <trace/hooks/usb.h>
#include <trace/hooks/ipv6.h> #include <trace/hooks/ipv6.h>
#include <trace/hooks/sound.h> #include <trace/hooks/sound.h>
#include <trace/hooks/snd_compr.h>
/* /*
* Export tracepoints that act as a bare tracehook (ie: have no trace event * Export tracepoints that act as a bare tracehook (ie: have no trace event
@@ -360,3 +361,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_usb_dev_suspend);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_usb_dev_resume); 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_ipv6_gen_linklocal_addr);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sound_usb_support_cpu_suspend); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sound_usb_support_cpu_suspend);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_snd_compr_use_pause_in_drain);

View File

@@ -0,0 +1,25 @@
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM snd_compr
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH trace/hooks
#if !defined(_TRACE_HOOK_SND_COMPR_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_HOOK_SND_COMPR_H
#include <linux/tracepoint.h>
#include <trace/hooks/vendor_hooks.h>
/*
* Following tracepoints are not exported in tracefs and provide a
* mechanism for vendor modules to hook and extend functionality
*/
DECLARE_HOOK(android_vh_snd_compr_use_pause_in_drain,
TP_PROTO(bool *use_pause_in_drain, bool *leave_draining),
TP_ARGS(use_pause_in_drain, leave_draining));
#endif /* _TRACE_HOOK_SND_COMPR_H */
/* This part must be outside protection */
#include <trace/define_trace.h>

View File

@@ -33,6 +33,10 @@
#include <sound/compress_offload.h> #include <sound/compress_offload.h>
#include <sound/compress_driver.h> #include <sound/compress_driver.h>
#ifndef __GENKSYMS__
#include <trace/hooks/snd_compr.h>
#endif
/* struct snd_compr_codec_caps overflows the ioctl bit size for some /* struct snd_compr_codec_caps overflows the ioctl bit size for some
* architectures, so we need to disable the relevant ioctls. * architectures, so we need to disable the relevant ioctls.
*/ */
@@ -708,6 +712,20 @@ snd_compr_tstamp(struct snd_compr_stream *stream, unsigned long arg)
static int snd_compr_pause(struct snd_compr_stream *stream) static int snd_compr_pause(struct snd_compr_stream *stream)
{ {
int retval; int retval;
bool use_pause_in_drain = false;
bool leave_draining_state = false;
trace_android_vh_snd_compr_use_pause_in_drain(&use_pause_in_drain,
&leave_draining_state);
if (use_pause_in_drain && stream->runtime->state == SNDRV_PCM_STATE_DRAINING) {
retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_PAUSE_PUSH);
if (!retval && leave_draining_state) {
stream->runtime->state = SNDRV_PCM_STATE_PAUSED;
wake_up(&stream->runtime->sleep);
}
return retval;
}
if (stream->runtime->state != SNDRV_PCM_STATE_RUNNING) if (stream->runtime->state != SNDRV_PCM_STATE_RUNNING)
return -EPERM; return -EPERM;
@@ -720,6 +738,14 @@ static int snd_compr_pause(struct snd_compr_stream *stream)
static int snd_compr_resume(struct snd_compr_stream *stream) static int snd_compr_resume(struct snd_compr_stream *stream)
{ {
int retval; int retval;
bool use_pause_in_drain = false;
bool leave_draining_state = false;
trace_android_vh_snd_compr_use_pause_in_drain(&use_pause_in_drain,
&leave_draining_state);
if (use_pause_in_drain && stream->runtime->state == SNDRV_PCM_STATE_DRAINING)
return stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_PAUSE_RELEASE);
if (stream->runtime->state != SNDRV_PCM_STATE_PAUSED) if (stream->runtime->state != SNDRV_PCM_STATE_PAUSED)
return -EPERM; return -EPERM;