sound/soc/soc-topology-test.c
Source file repositories/reference/linux-study-clean/sound/soc/soc-topology-test.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/soc-topology-test.c- Extension
.c- Size
- 24224 bytes
- Lines
- 822
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/firmware.hsound/core.hsound/soc.hsound/soc-topology.hkunit/device.hkunit/test.h
Detected Declarations
struct kunit_soc_componentstruct tplg_tmpl_001struct tplg_tmpl_002function snd_soc_tplg_test_initfunction snd_soc_tplg_test_exitfunction d_probefunction d_removefunction d_probe_null_compfunction snd_soc_tplg_test_load_with_null_compfunction snd_soc_tplg_test_load_with_null_opsfunction d_probe_null_fwfunction snd_soc_tplg_test_load_with_null_fwfunction snd_soc_tplg_test_load_empty_tplgfunction snd_soc_tplg_test_load_empty_tplg_bad_magicfunction snd_soc_tplg_test_load_empty_tplg_bad_abifunction snd_soc_tplg_test_load_empty_tplg_bad_sizefunction snd_soc_tplg_test_load_empty_tplg_bad_payload_sizefunction snd_soc_tplg_test_load_pcm_tplgfunction snd_soc_tplg_test_load_pcm_tplg_reload_compfunction snd_soc_tplg_test_load_pcm_tplg_reload_card
Annotated Snippet
struct kunit_soc_component {
struct kunit *kunit;
int expect; /* what result we expect when loading topology */
struct snd_soc_component comp;
struct snd_soc_card card;
struct firmware fw;
};
static int d_probe(struct snd_soc_component *component)
{
struct kunit_soc_component *kunit_comp =
container_of(component, struct kunit_soc_component, comp);
int ret;
ret = snd_soc_tplg_component_load(component, NULL, &kunit_comp->fw);
KUNIT_EXPECT_EQ_MSG(kunit_comp->kunit, kunit_comp->expect, ret,
"Failed topology load");
return 0;
}
static void d_remove(struct snd_soc_component *component)
{
struct kunit_soc_component *kunit_comp =
container_of(component, struct kunit_soc_component, comp);
int ret;
ret = snd_soc_tplg_component_remove(component);
KUNIT_EXPECT_EQ(kunit_comp->kunit, 0, ret);
}
/*
* ASoC minimal boiler plate
*/
SND_SOC_DAILINK_DEF(dummy, DAILINK_COMP_ARRAY(COMP_DUMMY()));
SND_SOC_DAILINK_DEF(platform, DAILINK_COMP_ARRAY(COMP_PLATFORM("sound-soc-topology-test")));
static struct snd_soc_dai_link kunit_dai_links[] = {
{
.name = "KUNIT Audio Port",
.id = 0,
.stream_name = "Audio Playback/Capture",
.nonatomic = 1,
.dynamic = 1,
.trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
SND_SOC_DAILINK_REG(dummy, dummy, platform),
},
};
static const struct snd_soc_component_driver test_component = {
.name = "sound-soc-topology-test",
.probe = d_probe,
.remove = d_remove,
};
/* ===== TOPOLOGY TEMPLATES ================================================= */
// Structural representation of topology which can be generated with:
// $ touch empty
// $ alsatplg -c empty -o empty.tplg
// $ xxd -i empty.tplg
struct tplg_tmpl_001 {
struct snd_soc_tplg_hdr header;
struct snd_soc_tplg_manifest manifest;
} __packed;
static struct tplg_tmpl_001 tplg_tmpl_empty = {
.header = {
.magic = cpu_to_le32(SND_SOC_TPLG_MAGIC),
.abi = cpu_to_le32(5),
.version = 0,
.type = cpu_to_le32(SND_SOC_TPLG_TYPE_MANIFEST),
.size = cpu_to_le32(sizeof(struct snd_soc_tplg_hdr)),
.vendor_type = 0,
.payload_size = cpu_to_le32(sizeof(struct snd_soc_tplg_manifest)),
.index = 0,
.count = cpu_to_le32(1),
},
.manifest = {
.size = cpu_to_le32(sizeof(struct snd_soc_tplg_manifest)),
/* rest of fields is 0 */
},
};
// Structural representation of topology containing SectionPCM
struct tplg_tmpl_002 {
Annotation
- Immediate include surface: `linux/firmware.h`, `sound/core.h`, `sound/soc.h`, `sound/soc-topology.h`, `kunit/device.h`, `kunit/test.h`.
- Detected declarations: `struct kunit_soc_component`, `struct tplg_tmpl_001`, `struct tplg_tmpl_002`, `function snd_soc_tplg_test_init`, `function snd_soc_tplg_test_exit`, `function d_probe`, `function d_remove`, `function d_probe_null_comp`, `function snd_soc_tplg_test_load_with_null_comp`, `function snd_soc_tplg_test_load_with_null_ops`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.