Skip to content

Commit 75b9715

Browse files
kv2019ilgirdwood
authored andcommitted
.agent/.github: add topology2 agent design guidance
Add a canonical topology2 instruction file under .github/instructions and a matching companion rule under .agent/rules. Document topology v2 structure, reuse expectations, PCM and pipeline ID conventions, routing rules, platform overrides, and target registration guidance for agents working in tools/topology/topology2. Our existing agent rules are in .agent, but github copilot doesn't understand these yet, so add the companion rule. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 11f80ab commit 75b9715

2 files changed

Lines changed: 110 additions & 0 deletions

File tree

.agent/rules/topology2_design.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
trigger: glob
3+
glob: tools/topology/topology2/**
4+
---
5+
6+
# Topology2 Design Rule
7+
8+
When working in tools/topology/topology2, follow the canonical guidance in
9+
.github/instructions/topology2-design.instructions.md.
10+
11+
Apply those instructions for topology structure, ID assignment, routing,
12+
platform overrides, and topology target registration.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
description: "Agent instructions for designing and updating ALSA topology v2 files in SOF"
3+
applyTo: 'tools/topology/topology2/**'
4+
---
5+
6+
# Topology2 Design Instructions
7+
8+
Use this guidance when creating or modifying files under tools/topology/topology2.
9+
These rules align with the topology2 README and capture expected design patterns for
10+
class-based ALSA topology v2 authoring.
11+
12+
## Scope
13+
14+
* Applies to topology2 .conf definitions, platform overrides, pipeline and DAI class files, and topology2 CMake target lists
15+
* Focuses on design consistency, ID safety, and maintainable reuse of existing class and object templates
16+
17+
## Core Model
18+
19+
* Use topology2 object model primitives consistently: Class.*, Object.*, Define, and IncludeByKey
20+
* Prefer reusable classes in include/ over one-off duplicated object blocks
21+
* Keep object instantiation explicit and readable so generated pipelines are traceable
22+
23+
## Top Level Topology Layout
24+
25+
For new top-level board .conf files, keep this order:
26+
27+
1. Search directories
28+
2. Required class includes
29+
3. Define block with defaults
30+
4. IncludeByKey.PLATFORM overrides
31+
5. Feature-gated IncludeByKey blocks
32+
6. DAI, pipeline, and PCM objects
33+
7. Route definitions
34+
35+
## Reuse Before New Base Files
36+
37+
* Prefer extending an existing base input .conf with variable overrides from CMake targets
38+
* Add a new base .conf only when existing topologies cannot represent the use case cleanly
39+
* When adding a new target, use this tuple structure. In CMake quoted strings, escape each semicolon as `\;`.
40+
41+
```text
42+
Logical tuple format:
43+
"input-conf;output-name;variable1=value1,variable2=value2"
44+
45+
CMake string form:
46+
"input-conf\;output-name\;variable1=value1,variable2=value2"
47+
```
48+
49+
## ID Conventions and Safety
50+
51+
* Keep PCM IDs unique within a single topology
52+
* Keep pipeline indexes unique within a single topology
53+
* Pair FE and BE pipelines as N and N+1 where applicable
54+
* For SoundWire pipelines, follow index equals PCM ID times 10 unless a documented topology-specific exception exists
55+
* For HDMI pipelines, keep stride-10 layout with host at N0 and DAI at N1
56+
* When combining features such as SDW, PCH DMIC, HDMI, deep buffer, or compress, verify there are no ID collisions after overrides
57+
58+
## Routing Rules
59+
60+
* Connect FE mixin outputs to BE mixout inputs using Object.Base.route
61+
* Keep route naming and widget references aligned with topology naming patterns
62+
* Validate that each route endpoint maps to a declared widget in the same compiled topology
63+
64+
## Widget Naming
65+
66+
* Follow naming pattern type.pipeline-index.instance
67+
* Keep naming stable and descriptive for easier graph inspection and debug
68+
69+
## Platform Overrides
70+
71+
* Use IncludeByKey.PLATFORM for platform-specific Define overrides
72+
* Restrict platform-specific tuning to platform/intel/*.conf instead of duplicating board-level logic
73+
* Ensure platform keys remain consistent with the authoritative in-tree overrides under tools/topology/topology2/platform/intel/*.conf; current examples include tgl, adl, mtl, lnl, ptl, and nvl
74+
75+
## CMake Target Placement
76+
77+
Register targets in the correct file for platform generation:
78+
79+
* Tiger Lake and Alder Lake: production/tplg-targets-cavs25.cmake
80+
* Meteor Lake: production/tplg-targets-ace1.cmake
81+
* Lunar Lake: production/tplg-targets-ace2.cmake
82+
* Panther Lake: production/tplg-targets-ace3.cmake
83+
* Nova Lake / sof-nvl-*: production/tplg-targets-ace4.cmake
84+
* i.MX8 platforms: production/tplg-targets-imx8.cmake
85+
* SDCA generic topologies: production/tplg-targets-sdca-generic.cmake
86+
* HDA generic: production/tplg-targets-hda-generic.cmake
87+
* Development and test topologies: development/tplg-targets.cmake
88+
89+
If a target family is not listed above, use the existing tplg-targets-*.cmake
90+
file that already contains similar topologies as the source of truth, and keep new
91+
targets grouped with the same platform or product family in either production/ or
92+
development/.
93+
94+
## Validation Expectations
95+
96+
* Keep topology2 buildable through the topologies2 target
97+
* Preserve compatibility with alsatplg pre-processing mode used by the build system
98+
* Ensure topology edits remain synchronized with nearby architecture or README documentation when design behavior changes

0 commit comments

Comments
 (0)