|
| 1 | +# IPC3 Architecture |
| 2 | + |
| 3 | +This directory houses the Version 3 Inter-Processor Communication handling components. IPC3 is the older, legacy framework structure used extensively across initial Sound Open Firmware releases before the transition to IPC4 compound pipeline commands. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The IPC3 architecture treats streaming, DAI configurations, and pipeline management as distinct scalar events. Messages arrive containing a specific `sof_ipc_cmd_hdr` denoting the "Global Message Type" (e.g., Stream, DAI, Trace, PM) and the targeted command within that type. |
| 8 | + |
| 9 | +## Command Structure and Routing |
| 10 | + |
| 11 | +Every message received is placed into an Rx buffer and initially routed to `ipc_cmd()`. Based on the `cmd` inside the `sof_ipc_cmd_hdr`, it delegates to one of the handler subsystems: |
| 12 | + |
| 13 | +* `ipc_glb_stream_message`: Stream/Pipeline configuration and states |
| 14 | +* `ipc_glb_dai_message`: DAI parameters and formats |
| 15 | +* `ipc_glb_pm_message`: Power Management operations |
| 16 | + |
| 17 | +```mermaid |
| 18 | +graph TD |
| 19 | + Mailbox[IPC Mailbox Interrupt] --> Valid[mailbox_validate] |
| 20 | + Valid --> Disp[IPC Core Dispatcher] |
| 21 | +
|
| 22 | + Disp -->|Global Type 1| StreamMsg[ipc_glb_stream_message] |
| 23 | + Disp -->|Global Type 2| DAIMsg[ipc_glb_dai_message] |
| 24 | + Disp -->|Global Type 3| PMMsg[ipc_glb_pm_message] |
| 25 | + Disp -->|Global Type ...| TraceMsg[ipc_glb_trace_message] |
| 26 | +
|
| 27 | + subgraph Stream Commands |
| 28 | + StreamMsg --> StreamAlloc[ipc_stream_pcm_params] |
| 29 | + StreamMsg --> StreamTrig[ipc_stream_trigger] |
| 30 | + StreamMsg --> StreamFree[ipc_stream_pcm_free] |
| 31 | + StreamMsg --> StreamPos[ipc_stream_position] |
| 32 | + end |
| 33 | +
|
| 34 | + subgraph DAI Commands |
| 35 | + DAIMsg --> DAIConf[ipc_msg_dai_config] |
| 36 | + end |
| 37 | +
|
| 38 | + subgraph PM Commands |
| 39 | + PMMsg --> PMCore[ipc_pm_core_enable] |
| 40 | + PMMsg --> PMContext[ipc_pm_context_save / restore] |
| 41 | + end |
| 42 | +``` |
| 43 | + |
| 44 | +## Processing Flows |
| 45 | + |
| 46 | +### Stream Triggering (`ipc_stream_trigger`) |
| 47 | + |
| 48 | +Triggering is strictly hierarchical via IPC3. It expects pipelines built and components fully parsed prior to active streaming commands. |
| 49 | + |
| 50 | +1. **Validation**: The IPC fetches the host component ID. |
| 51 | +2. **Device Lookup**: It searches the components list (`ipc_get_comp_dev`) for the PCM device matching the pipeline. |
| 52 | +3. **Execution**: If valid, the pipeline graph is crawled recursively and its state altered via `pipeline_trigger`. |
| 53 | + |
| 54 | +```mermaid |
| 55 | +sequenceDiagram |
| 56 | + participant Host |
| 57 | + participant IPC3 as IPC3 Handler (ipc_stream_trigger) |
| 58 | + participant Pipe as Pipeline Framework |
| 59 | + participant Comp as Connected Component |
| 60 | +
|
| 61 | + Host->>IPC3: Send SOF_IPC_STREAM_TRIG_START |
| 62 | + activate IPC3 |
| 63 | + IPC3->>IPC3: ipc_get_comp_dev(stream_id) |
| 64 | + IPC3->>Pipe: pipeline_trigger(COMP_TRIGGER_START) |
| 65 | + activate Pipe |
| 66 | + Pipe->>Comp: pipeline_for_each_comp(COMP_TRIGGER_START) |
| 67 | + Comp-->>Pipe: Success (Component ACTIVE) |
| 68 | + Pipe-->>IPC3: Return Status |
| 69 | + deactivate Pipe |
| 70 | +
|
| 71 | + alt If Success |
| 72 | + IPC3-->>Host: Acknowledge Success Header |
| 73 | + else If Error |
| 74 | + IPC3-->>Host: Acknowledge Error Header (EINVAL / EIO) |
| 75 | + end |
| 76 | + deactivate IPC3 |
| 77 | +``` |
| 78 | + |
| 79 | +### DAI Configuration (`ipc_msg_dai_config`) |
| 80 | + |
| 81 | +DAI (Digital Audio Interface) configuration involves setting up physical I2S, ALH, SSP, or HDA parameters. |
| 82 | + |
| 83 | +1. **Format Unpacking**: Converts the `sof_ipc_dai_config` payload sent from the ALSA driver into an internal DSP structure `ipc_config_dai`. |
| 84 | +2. **Device Selection**: Identifies the exact DAI interface and finds its tracking device ID via `dai_get`. |
| 85 | +3. **Hardware Config**: Applies the unpacked settings directly to the hardware via the specific DAI driver's `set_config` function. |
| 86 | + |
| 87 | +```mermaid |
| 88 | +sequenceDiagram |
| 89 | + participant Host |
| 90 | + participant IPC3 as IPC3 Handler (ipc_msg_dai_config) |
| 91 | + participant DAIDev as DAI Framework (dai_get) |
| 92 | + participant HWDriver as HW Specific Driver (e.g. SSP) |
| 93 | +
|
| 94 | + Host->>IPC3: Send SOF_IPC_DAI_CONFIG (e.g., SSP1, I2S Format) |
| 95 | + activate IPC3 |
| 96 | +
|
| 97 | + IPC3->>IPC3: build_dai_config() |
| 98 | + IPC3->>DAIDev: dai_get(type, index) |
| 99 | + DAIDev-->>IPC3: pointer to dai instance |
| 100 | +
|
| 101 | + IPC3->>HWDriver: dai_set_config() |
| 102 | + activate HWDriver |
| 103 | + HWDriver-->>HWDriver: configures registers |
| 104 | + HWDriver-->>IPC3: hardware configured |
| 105 | + deactivate HWDriver |
| 106 | +
|
| 107 | + IPC3-->>Host: Acknowledged Setting |
| 108 | + deactivate IPC3 |
| 109 | +``` |
| 110 | + |
| 111 | +## Mailbox and Validation (`mailbox_validate`) |
| 112 | + |
| 113 | +All commands passing through this layer enforce rigid payload boundaries. `mailbox_validate()` reads the first word directly from the mailbox memory, identifying the command type before parsing parameters out of shared RAM to prevent host/DSP mismatches from cascading. |
0 commit comments