From 8d68a30fe15f6fcf396a9f5b3b5a0a389d440250 Mon Sep 17 00:00:00 2001 From: Bicycle Tsai Date: Wed, 27 Oct 2021 08:12:41 +0800 Subject: [PATCH] ANDROID: ASoC: soc-pcm: Get all BEs along DAPM path dpcm_end_walk_at_be() stops the graph walk when first BE is found for the given FE component. In a component model we may want to connect multiple DAIs from different components. android_vh_snd_soc_card_get_comp_chain can be registered here to allows DAI/component chaining. Later PCM operations can be called for all these listed components for a valid DAPM path. ALSA machine driver can setup component_chaining like below code slice. static void my_board_component_chaining_hook(void *data, bool *ret) { *ret = true; } static int my_board_dev_probe(struct platform_device *pdev) { register_trace_android_vh_snd_soc_card_get_comp_chain( my_board_component_chaining_hook, NULL); return 0; } static int my_board_dev_remove(struct platform_device *pdev) { unregister_trace_android_vh_snd_soc_card_get_comp_chain( my_board_component_chaining_hook, NULL); return 0; } static struct platform_driver my_board_driver = { ... .probe = my_board_dev_probe, .remove = my_board_dev_remove, ... }; Bug: 198732156 Signed-off-by: Bicycle Tsai Change-Id: Ife5df291d40af9ec83d57462b6a08aba95d9119d --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/sound.h | 4 ++++ sound/soc/soc-pcm.c | 6 +++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index b44972ad1b93..46f71a3def2b 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -374,6 +374,7 @@ 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); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_snd_compr_use_pause_in_drain); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_snd_soc_card_get_comp_chain); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_show_max_freq); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_tcp_sendmsg_locked); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_tcp_recvmsg); diff --git a/include/trace/hooks/sound.h b/include/trace/hooks/sound.h index 2bf018edf392..6eb8bc326cf8 100644 --- a/include/trace/hooks/sound.h +++ b/include/trace/hooks/sound.h @@ -15,6 +15,10 @@ DECLARE_HOOK(android_vh_sound_usb_support_cpu_suspend, bool *is_support), TP_ARGS(udev, direction, is_support)); +DECLARE_HOOK(android_vh_snd_soc_card_get_comp_chain, + TP_PROTO(bool *component_chaining), + TP_ARGS(component_chaining)); + #endif /* _TRACE_HOOK_SOUND_H */ /* This part must be outside protection */ #include diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 69c78fd59e41..f7aff87849fc 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -26,6 +26,7 @@ #include #include #include +#include #define DPCM_MAX_BE_USERS 8 @@ -1275,6 +1276,7 @@ int dpcm_path_get(struct snd_soc_pcm_runtime *fe, { struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0); int paths; + bool chaining = false; if (fe->num_cpus > 1) { dev_err(fe->dev, @@ -1282,9 +1284,11 @@ int dpcm_path_get(struct snd_soc_pcm_runtime *fe, return -EINVAL; } + trace_android_vh_snd_soc_card_get_comp_chain(&chaining); + /* get number of valid DAI paths and their widgets */ paths = snd_soc_dapm_dai_get_connected_widgets(cpu_dai, stream, list, - dpcm_end_walk_at_be); + chaining ? NULL : dpcm_end_walk_at_be); dev_dbg(fe->dev, "ASoC: found %d audio %s paths\n", paths, stream ? "capture" : "playback");