Skip to content

Commit b319bc7

Browse files
committed
.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 bf84398 commit b319bc7

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

.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: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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 the tuple format exactly:
40+
41+
```text
42+
"input-conf;output-name;variable1=value1,variable2=value2"
43+
```
44+
45+
## ID Conventions and Safety
46+
47+
* Keep PCM IDs unique within a single topology
48+
* Keep pipeline indexes unique within a single topology
49+
* Pair FE and BE pipelines as N and N+1 where applicable
50+
* For SoundWire pipelines, follow index equals PCM ID times 10 unless a documented topology-specific exception exists
51+
* For HDMI pipelines, keep stride-10 layout with host at N0 and DAI at N1
52+
* When combining features such as SDW, PCH DMIC, HDMI, deep buffer, or compress, verify there are no ID collisions after overrides
53+
54+
## Routing Rules
55+
56+
* Connect FE mixin outputs to BE mixout inputs using Object.Base.route
57+
* Keep route naming and widget references aligned with topology naming patterns
58+
* Validate that each route endpoint maps to a declared widget in the same compiled topology
59+
60+
## Widget Naming
61+
62+
* Follow naming pattern type.pipeline-index.instance
63+
* Keep naming stable and descriptive for easier graph inspection and debug
64+
65+
## Platform Overrides
66+
67+
* Use IncludeByKey.PLATFORM for platform-specific Define overrides
68+
* Restrict platform-specific tuning to platform/intel/*.conf instead of duplicating board-level logic
69+
* Ensure supported platform keys remain consistent with project usage: tgl, mtl, lnl, ptl
70+
71+
## CMake Target Placement
72+
73+
Register targets in the correct file for platform generation:
74+
75+
* Tiger Lake and Alder Lake: production/tplg-targets-cavs25.cmake
76+
* Meteor Lake: production/tplg-targets-ace1.cmake
77+
* Lunar Lake: production/tplg-targets-ace2.cmake
78+
* Panther Lake: production/tplg-targets-ace3.cmake
79+
* HDA generic: production/tplg-targets-hda-generic.cmake
80+
* Development and test topologies: development/tplg-targets.cmake
81+
82+
## Validation Expectations
83+
84+
* Keep topology2 buildable through the topologies2 target
85+
* Preserve compatibility with alsatplg pre-processing mode used by the build system
86+
* Ensure topology edits remain synchronized with nearby architecture or README documentation when design behavior changes

0 commit comments

Comments
 (0)