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 <bicycle.tsai@mediatek.com>
Change-Id: Ife5df291d40af9ec83d57462b6a08aba95d9119d
This commit is contained in:
Bicycle Tsai 2021-10-27 08:12:41 +08:00 committed by Bicycle Tsai
parent ea440234c7
commit 8d68a30fe1
3 changed files with 10 additions and 1 deletions

View File

@ -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);

View File

@ -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 <trace/define_trace.h>

View File

@ -26,6 +26,7 @@
#include <sound/soc-dpcm.h>
#include <sound/soc-link.h>
#include <sound/initval.h>
#include <trace/hooks/sound.h>
#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");