Tom Rini | 53633a8 | 2024-02-29 12:33:36 -0500 | [diff] [blame] | 1 | Renesas R-Car sound |
| 2 | |
| 3 | ============================================= |
| 4 | * Modules |
| 5 | ============================================= |
| 6 | |
| 7 | Renesas R-Car and RZ/G sound is constructed from below modules |
| 8 | (for Gen2 or later) |
| 9 | |
| 10 | SCU : Sampling Rate Converter Unit |
| 11 | - SRC : Sampling Rate Converter |
| 12 | - CMD |
| 13 | - CTU : Channel Transfer Unit |
| 14 | - MIX : Mixer |
| 15 | - DVC : Digital Volume and Mute Function |
| 16 | SSIU : Serial Sound Interface Unit |
| 17 | SSI : Serial Sound Interface |
| 18 | |
| 19 | See detail of each module's channels, connection, limitation on datasheet |
| 20 | |
| 21 | ============================================= |
| 22 | * Multi channel |
| 23 | ============================================= |
| 24 | |
| 25 | Multi channel is supported by Multi-SSI, or TDM-SSI. |
| 26 | |
| 27 | Multi-SSI : 6ch case, you can use stereo x 3 SSI |
| 28 | TDM-SSI : 6ch case, you can use TDM |
| 29 | |
| 30 | ============================================= |
| 31 | * Enable/Disable each modules |
| 32 | ============================================= |
| 33 | |
| 34 | See datasheet to check SRC/CTU/MIX/DVC connect-limitation. |
| 35 | DT controls enabling/disabling module. |
| 36 | ${LINUX}/arch/arm/boot/dts/r8a7790-lager.dts can be good example. |
| 37 | This is example of |
| 38 | |
| 39 | Playback: [MEM] -> [SRC2] -> [DVC0] -> [SSIU0/SSI0] -> [codec] |
| 40 | Capture: [MEM] <- [DVC1] <- [SRC3] <- [SSIU1/SSI1] <- [codec] |
| 41 | |
| 42 | see "Example: simple sound card" |
| 43 | |
| 44 | You can use below. |
| 45 | ${LINUX}/arch/arm/boot/dts/r8a7790.dts can be good example. |
| 46 | |
| 47 | &src0 &ctu00 &mix0 &dvc0 &ssi0 |
| 48 | &src1 &ctu01 &mix1 &dvc1 &ssi1 |
| 49 | &src2 &ctu02 &ssi2 |
| 50 | &src3 &ctu03 &ssi3 |
| 51 | &src4 &ssi4 |
| 52 | &src5 &ctu10 &ssi5 |
| 53 | &src6 &ctu11 &ssi6 |
| 54 | &src7 &ctu12 &ssi7 |
| 55 | &src8 &ctu13 &ssi8 |
| 56 | &src9 &ssi9 |
| 57 | |
| 58 | ============================================= |
| 59 | * SRC (Sampling Rate Converter) |
| 60 | ============================================= |
| 61 | |
| 62 | [xx]Hz [yy]Hz |
| 63 | ------> [SRC] ------> |
| 64 | |
| 65 | SRC can convert [xx]Hz to [yy]Hz. Then, it has below 2 modes |
| 66 | |
| 67 | Asynchronous mode: input data / output data are based on different clocks. |
| 68 | you can use this mode on Playback / Capture |
| 69 | Synchronous mode: input data / output data are based on same clocks. |
| 70 | This mode will be used if system doesn't have its input clock, |
| 71 | for example digital TV case. |
| 72 | you can use this mode on Playback |
| 73 | |
| 74 | ------------------ |
| 75 | ** Asynchronous mode |
| 76 | ------------------ |
| 77 | |
| 78 | You need to use "simple-scu-audio-card" or "audio-graph-scu-card" for it. |
| 79 | see "Example: simple sound card for Asynchronous mode" |
| 80 | |
| 81 | ------------------ |
| 82 | ** Synchronous mode |
| 83 | ------------------ |
| 84 | |
| 85 | > amixer set "SRC Out Rate" on |
| 86 | > aplay xxxx.wav |
| 87 | > amixer set "SRC Out Rate" 48000 |
| 88 | > amixer set "SRC Out Rate" 44100 |
| 89 | |
| 90 | ============================================= |
| 91 | * CTU (Channel Transfer Unit) |
| 92 | ============================================= |
| 93 | |
| 94 | [xx]ch [yy]ch |
| 95 | ------> [CTU] --------> |
| 96 | |
| 97 | CTU can convert [xx]ch to [yy]ch, or exchange outputted channel. |
| 98 | CTU conversion needs matrix settings. |
| 99 | For more detail information, see below |
| 100 | |
| 101 | Renesas R-Car datasheet |
| 102 | - Sampling Rate Converter Unit (SCU) |
| 103 | - SCU Operation |
| 104 | - CMD Block |
| 105 | - Functional Blocks in CMD |
| 106 | |
| 107 | Renesas R-Car datasheet |
| 108 | - Sampling Rate Converter Unit (SCU) |
| 109 | - Register Description |
| 110 | - CTUn Scale Value exx Register (CTUn_SVxxR) |
| 111 | |
| 112 | ${LINUX}/sound/soc/sh/rcar/ctu.c |
| 113 | - comment of header |
| 114 | |
| 115 | You need to use "simple-scu-audio-card" or "audio-graph-scu-card" for it. |
| 116 | see "Example: simple sound card for channel convert" |
| 117 | |
| 118 | Ex) Exchange output channel |
| 119 | Input -> Output |
| 120 | 1ch -> 0ch |
| 121 | 0ch -> 1ch |
| 122 | |
| 123 | example of using matrix |
| 124 | output 0ch = (input 0ch x 0) + (input 1ch x 1) |
| 125 | output 1ch = (input 0ch x 1) + (input 1ch x 0) |
| 126 | |
| 127 | amixer set "CTU Reset" on |
| 128 | amixer set "CTU Pass" 9,10 |
| 129 | amixer set "CTU SV0" 0,4194304 |
| 130 | amixer set "CTU SV1" 4194304,0 |
| 131 | |
| 132 | example of changing connection |
| 133 | amixer set "CTU Reset" on |
| 134 | amixer set "CTU Pass" 2,1 |
| 135 | |
| 136 | ============================================= |
| 137 | * MIX (Mixer) |
| 138 | ============================================= |
| 139 | |
| 140 | MIX merges 2 sounds path. You can see 2 sound interface on system, |
| 141 | and these sounds will be merged by MIX. |
| 142 | |
| 143 | aplay -D plughw:0,0 xxxx.wav & |
| 144 | aplay -D plughw:0,1 yyyy.wav |
| 145 | |
| 146 | You need to use "simple-scu-audio-card" or "audio-graph-scu-card" for it. |
| 147 | Ex) |
| 148 | [MEM] -> [SRC1] -> [CTU02] -+-> [MIX0] -> [DVC0] -> [SSI0] |
| 149 | | |
| 150 | [MEM] -> [SRC2] -> [CTU03] -+ |
| 151 | |
| 152 | see "Example: simple sound card for MIXer" |
| 153 | |
| 154 | ============================================= |
| 155 | * DVC (Digital Volume and Mute Function) |
| 156 | ============================================= |
| 157 | |
| 158 | DVC controls Playback/Capture volume. |
| 159 | |
| 160 | Playback Volume |
| 161 | amixer set "DVC Out" 100% |
| 162 | |
| 163 | Capture Volume |
| 164 | amixer set "DVC In" 100% |
| 165 | |
| 166 | Playback Mute |
| 167 | amixer set "DVC Out Mute" on |
| 168 | |
| 169 | Capture Mute |
| 170 | amixer set "DVC In Mute" on |
| 171 | |
| 172 | Volume Ramp |
| 173 | amixer set "DVC Out Ramp Up Rate" "0.125 dB/64 steps" |
| 174 | amixer set "DVC Out Ramp Down Rate" "0.125 dB/512 steps" |
| 175 | amixer set "DVC Out Ramp" on |
| 176 | aplay xxx.wav & |
| 177 | amixer set "DVC Out" 80% // Volume Down |
| 178 | amixer set "DVC Out" 100% // Volume Up |
| 179 | |
| 180 | ============================================= |
| 181 | * SSIU (Serial Sound Interface Unit) |
| 182 | ============================================= |
| 183 | |
| 184 | SSIU can avoid some under/over run error, because it has some buffer. |
| 185 | But you can't use it if SSI was PIO mode. |
| 186 | In DMA mode, you can select not to use SSIU by using "no-busif" via SSI. |
| 187 | |
| 188 | SSIU handles BUSIF which will be used for TDM Split mode. |
| 189 | This driver is assuming that audio-graph card will be used. |
| 190 | |
| 191 | TDM Split mode merges 4 sounds. You can see 4 sound interface on system, |
| 192 | and these sounds will be merged SSIU/SSI. |
| 193 | |
| 194 | aplay -D plughw:0,0 xxxx.wav & |
| 195 | aplay -D plughw:0,1 xxxx.wav & |
| 196 | aplay -D plughw:0,2 xxxx.wav & |
| 197 | aplay -D plughw:0,3 xxxx.wav |
| 198 | |
| 199 | 2ch 8ch |
| 200 | [MEM] -> [SSIU 30] -+-> [SSIU 3] --> [Codec] |
| 201 | 2ch | |
| 202 | [MEM] -> [SSIU 31] -+ |
| 203 | 2ch | |
| 204 | [MEM] -> [SSIU 32] -+ |
| 205 | 2ch | |
| 206 | [MEM] -> [SSIU 33] -+ |
| 207 | |
| 208 | see "Example: simple sound card for TDM Split" |
| 209 | |
| 210 | ============================================= |
| 211 | * SSI (Serial Sound Interface) |
| 212 | ============================================= |
| 213 | |
| 214 | ** PIO mode |
| 215 | |
| 216 | You can use PIO mode which is for connection check by using. |
| 217 | Note: The system will drop non-SSI modules in PIO mode |
| 218 | even though if DT is selecting other modules. |
| 219 | |
| 220 | &ssi0 { |
| 221 | pio-transfer |
| 222 | }; |
| 223 | |
| 224 | ** DMA mode without SSIU |
| 225 | |
| 226 | You can use DMA without SSIU. |
| 227 | Note: under/over run, or noise are likely to occur |
| 228 | |
| 229 | &ssi0 { |
| 230 | no-busif; |
| 231 | }; |
| 232 | |
| 233 | ** PIN sharing |
| 234 | |
| 235 | Each SSI can share WS pin. It is based on platform. |
| 236 | This is example if SSI1 want to share WS pin with SSI0 |
| 237 | |
| 238 | &ssi1 { |
| 239 | shared-pin; |
| 240 | }; |
| 241 | |
| 242 | ** Multi-SSI |
| 243 | |
| 244 | You can use Multi-SSI. |
| 245 | This is example of SSI0/SSI1/SSI2 (= for 6ch) |
| 246 | |
| 247 | see "Example: simple sound card for Multi channel" |
| 248 | |
| 249 | ** TDM-SSI |
| 250 | |
| 251 | You can use TDM with SSI. |
| 252 | This is example of TDM 6ch. |
| 253 | Driver can automatically switches TDM <-> stereo mode in this case. |
| 254 | |
| 255 | see "Example: simple sound card for TDM" |