Skip to content

Commit e17527e

Browse files
crojewsk-intelbroonie
authored andcommitted
ASoC: Intel: avs: Add probe machine board
Stub machine board driver with no custom DAPM routes and single FE DAI link for userspace to interact with. Signed-off-by: Cezary Rojewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent ed914a2 commit e17527e

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed

sound/soc/intel/avs/board_selection.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,33 @@ static void board_pdev_unregister(void *data)
291291
platform_device_unregister(data);
292292
}
293293

294+
static int __maybe_unused avs_register_probe_board(struct avs_dev *adev)
295+
{
296+
struct platform_device *board;
297+
struct snd_soc_acpi_mach mach = {{0}};
298+
int ret;
299+
300+
ret = avs_probe_platform_register(adev, "probe-platform");
301+
if (ret < 0)
302+
return ret;
303+
304+
mach.mach_params.platform = "probe-platform";
305+
306+
board = platform_device_register_data(NULL, "avs_probe_mb", PLATFORM_DEVID_NONE,
307+
(const void *)&mach, sizeof(mach));
308+
if (IS_ERR(board)) {
309+
dev_err(adev->dev, "probe board register failed\n");
310+
return PTR_ERR(board);
311+
}
312+
313+
ret = devm_add_action(adev->dev, board_pdev_unregister, board);
314+
if (ret < 0) {
315+
platform_device_unregister(board);
316+
return ret;
317+
}
318+
return 0;
319+
}
320+
294321
static int avs_register_dmic_board(struct avs_dev *adev)
295322
{
296323
struct platform_device *codec, *board;
@@ -500,6 +527,12 @@ int avs_register_all_boards(struct avs_dev *adev)
500527
{
501528
int ret;
502529

530+
#ifdef CONFIG_DEBUG_FS
531+
ret = avs_register_probe_board(adev);
532+
if (ret < 0)
533+
dev_warn(adev->dev, "enumerate PROBE endpoints failed: %d\n", ret);
534+
#endif
535+
503536
ret = avs_register_dmic_board(adev);
504537
if (ret < 0)
505538
dev_warn(adev->dev, "enumerate DMIC endpoints failed: %d\n",

sound/soc/intel/avs/boards/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ config SND_SOC_INTEL_AVS_MACH_NAU8825
7777
Say Y or m if you have such a device. This is a recommended option.
7878
If unsure select "N".
7979

80+
config SND_SOC_INTEL_AVS_MACH_PROBE
81+
tristate "Probing (data) board"
82+
depends on DEBUG_FS
83+
select SND_HWDEP
84+
help
85+
This adds support for data probing board which can be used to
86+
gather data from runtime stream over compress operations.
87+
8088
config SND_SOC_INTEL_AVS_MACH_RT274
8189
tristate "rt274 in I2S mode"
8290
depends on I2C

sound/soc/intel/avs/boards/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ snd-soc-avs-max98927-objs := max98927.o
88
snd-soc-avs-max98357a-objs := max98357a.o
99
snd-soc-avs-max98373-objs := max98373.o
1010
snd-soc-avs-nau8825-objs := nau8825.o
11+
snd-soc-avs-probe-objs := probe.o
1112
snd-soc-avs-rt274-objs := rt274.o
1213
snd-soc-avs-rt286-objs := rt286.o
1314
snd-soc-avs-rt298-objs := rt298.o
@@ -22,6 +23,7 @@ obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_MAX98927) += snd-soc-avs-max98927.o
2223
obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_MAX98357A) += snd-soc-avs-max98357a.o
2324
obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_MAX98373) += snd-soc-avs-max98373.o
2425
obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_NAU8825) += snd-soc-avs-nau8825.o
26+
obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_PROBE) += snd-soc-avs-probe.o
2527
obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_RT274) += snd-soc-avs-rt274.o
2628
obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_RT286) += snd-soc-avs-rt286.o
2729
obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_RT298) += snd-soc-avs-rt298.o

sound/soc/intel/avs/boards/probe.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
//
3+
// Copyright(c) 2021-2022 Intel Corporation. All rights reserved.
4+
//
5+
// Authors: Cezary Rojewski <[email protected]>
6+
// Amadeusz Slawinski <[email protected]>
7+
//
8+
9+
#include <linux/device.h>
10+
#include <linux/module.h>
11+
#include <sound/soc.h>
12+
#include <sound/soc-acpi.h>
13+
14+
SND_SOC_DAILINK_DEF(dummy, DAILINK_COMP_ARRAY(COMP_DUMMY()));
15+
SND_SOC_DAILINK_DEF(probe_cp, DAILINK_COMP_ARRAY(COMP_CPU("Probe Extraction CPU DAI")));
16+
SND_SOC_DAILINK_DEF(platform, DAILINK_COMP_ARRAY(COMP_PLATFORM("probe-platform")));
17+
18+
static struct snd_soc_dai_link probe_mb_dai_links[] = {
19+
{
20+
.name = "Compress Probe Capture",
21+
.nonatomic = 1,
22+
SND_SOC_DAILINK_REG(probe_cp, dummy, platform),
23+
},
24+
};
25+
26+
static int avs_probe_mb_probe(struct platform_device *pdev)
27+
{
28+
struct device *dev = &pdev->dev;
29+
struct snd_soc_acpi_mach *mach;
30+
struct snd_soc_card *card;
31+
int ret;
32+
33+
mach = dev_get_platdata(dev);
34+
35+
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
36+
if (!card)
37+
return -ENOMEM;
38+
39+
card->name = "avs_probe_mb";
40+
card->dev = dev;
41+
card->owner = THIS_MODULE;
42+
card->dai_link = probe_mb_dai_links;
43+
card->num_links = ARRAY_SIZE(probe_mb_dai_links);
44+
card->fully_routed = true;
45+
46+
ret = snd_soc_fixup_dai_links_platform_name(card, mach->mach_params.platform);
47+
if (ret)
48+
return ret;
49+
50+
return devm_snd_soc_register_card(dev, card);
51+
}
52+
53+
static struct platform_driver avs_probe_mb_driver = {
54+
.probe = avs_probe_mb_probe,
55+
.driver = {
56+
.name = "avs_probe_mb",
57+
.pm = &snd_soc_pm_ops,
58+
},
59+
};
60+
61+
module_platform_driver(avs_probe_mb_driver);
62+
63+
MODULE_LICENSE("GPL");
64+
MODULE_ALIAS("platform:avs_probe_mb");

0 commit comments

Comments
 (0)