|
| 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