diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2016-03-10 00:29:21 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-03-12 01:03:41 -0500 |
commit | f1511a14a4a94d063cf8f8f12f36cf2ebb0cc8a8 (patch) | |
tree | 73432e39c7f2e6405146db83aff64ed267ba9b36 | |
parent | 09e59075496517206351cc28226ad7263a1a5c4f (diff) |
ASoC: rsnd: add simplified module explanation
Renesas sound driver user needs to read its datasheet when create DT.
But it is difficult to understand, because it has many modules
(SRC/CTU/MIX/DVC/SSIU/SSI/AudioDMAC/AudioDMACperiperi),
and many features (Asynchronous/Synchronous mode on SRC, CTU matrix,
DVC volume settings feature, Multi-SSI/TDM-SSI, etc).
This patch adds simplified explanation to help setting/understanding.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | Documentation/devicetree/bindings/sound/renesas,rsnd.txt | 340 | ||||
-rw-r--r-- | sound/soc/sh/rcar/dvc.c | 23 |
2 files changed, 363 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt index 8ee0fa91e4a0..c7b29df4a963 100644 --- a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt +++ b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt | |||
@@ -1,6 +1,337 @@ | |||
1 | Renesas R-Car sound | 1 | Renesas R-Car sound |
2 | 2 | ||
3 | ============================================= | ||
4 | * Modules | ||
5 | ============================================= | ||
6 | |||
7 | Renesas R-Car 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 | &rcar_sound { | ||
43 | ... | ||
44 | rcar_sound,dai { | ||
45 | dai0 { | ||
46 | playback = <&ssi0 &src2 &dvc0>; | ||
47 | capture = <&ssi1 &src3 &dvc1>; | ||
48 | }; | ||
49 | }; | ||
50 | }; | ||
51 | |||
52 | You can use below. | ||
53 | ${LINUX}/arch/arm/boot/dts/r8a7790.dts can be good example. | ||
54 | |||
55 | &src0 &ctu00 &mix0 &dvc0 &ssi0 | ||
56 | &src1 &ctu01 &mix1 &dvc1 &ssi1 | ||
57 | &src2 &ctu02 &ssi2 | ||
58 | &src3 &ctu03 &ssi3 | ||
59 | &src4 &ssi4 | ||
60 | &src5 &ctu10 &ssi5 | ||
61 | &src6 &ctu11 &ssi6 | ||
62 | &src7 &ctu12 &ssi7 | ||
63 | &src8 &ctu13 &ssi8 | ||
64 | &src9 &ssi9 | ||
65 | |||
66 | ============================================= | ||
67 | * SRC (Sampling Rate Converter) | ||
68 | ============================================= | ||
69 | |||
70 | [xx]Hz [yy]Hz | ||
71 | ------> [SRC] ------> | ||
72 | |||
73 | SRC can convert [xx]Hz to [yy]Hz. Then, it has below 2 modes | ||
74 | |||
75 | Asynchronous mode: input data / output data are based on different clocks. | ||
76 | you can use this mode on Playback / Capture | ||
77 | Synchronous mode: input data / output data are based on same clocks. | ||
78 | This mode will be used if system doesn't have its input clock, | ||
79 | for example digital TV case. | ||
80 | you can use this mode on Playback | ||
81 | |||
82 | ------------------ | ||
83 | ** Asynchronous mode | ||
84 | ------------------ | ||
85 | |||
86 | You need to use "renesas,rsrc-card" sound card for it. | ||
87 | example) | ||
88 | |||
89 | sound { | ||
90 | compatible = "renesas,rsrc-card"; | ||
91 | ... | ||
92 | /* | ||
93 | * SRC Asynchronous mode setting | ||
94 | * Playback: | ||
95 | * All input data will be converted to 48kHz | ||
96 | * Capture: | ||
97 | * Inputed 48kHz data will be converted to | ||
98 | * system specified Hz | ||
99 | */ | ||
100 | convert-rate = <48000>; | ||
101 | ... | ||
102 | cpu { | ||
103 | sound-dai = <&rcar_sound>; | ||
104 | }; | ||
105 | codec { | ||
106 | ... | ||
107 | }; | ||
108 | }; | ||
109 | |||
110 | ------------------ | ||
111 | ** Synchronous mode | ||
112 | ------------------ | ||
113 | |||
114 | > amixer set "SRC Out Rate" on | ||
115 | > aplay xxxx.wav | ||
116 | > amixer set "SRC Out Rate" 48000 | ||
117 | > amixer set "SRC Out Rate" 44100 | ||
118 | |||
119 | ============================================= | ||
120 | * CTU (Channel Transfer Unit) | ||
121 | ============================================= | ||
122 | |||
123 | [xx]ch [yy]ch | ||
124 | ------> [CTU] --------> | ||
125 | |||
126 | CTU can convert [xx]ch to [yy]ch, or exchange outputed channel. | ||
127 | CTU conversion needs matrix settings. | ||
128 | For more detail information, see below | ||
129 | |||
130 | Renesas R-Car datasheet | ||
131 | - Sampling Rate Converter Unit (SCU) | ||
132 | - SCU Operation | ||
133 | - CMD Block | ||
134 | - Functional Blocks in CMD | ||
135 | |||
136 | Renesas R-Car datasheet | ||
137 | - Sampling Rate Converter Unit (SCU) | ||
138 | - Register Description | ||
139 | - CTUn Scale Value exx Register (CTUn_SVxxR) | ||
140 | |||
141 | ${LINUX}/sound/soc/sh/rcar/ctu.c | ||
142 | - comment of header | ||
143 | |||
144 | You need to use "renesas,rsrc-card" sound card for it. | ||
145 | example) | ||
146 | |||
147 | sound { | ||
148 | compatible = "renesas,rsrc-card"; | ||
149 | ... | ||
150 | /* | ||
151 | * CTU setting | ||
152 | * All input data will be converted to 2ch | ||
153 | * as output data | ||
154 | */ | ||
155 | convert-channels = <2>; | ||
156 | ... | ||
157 | cpu { | ||
158 | sound-dai = <&rcar_sound>; | ||
159 | }; | ||
160 | codec { | ||
161 | ... | ||
162 | }; | ||
163 | }; | ||
164 | |||
165 | Ex) Exchange output channel | ||
166 | Input -> Output | ||
167 | 1ch -> 0ch | ||
168 | 0ch -> 1ch | ||
169 | |||
170 | example of using matrix | ||
171 | output 0ch = (input 0ch x 0) + (input 1ch x 1) | ||
172 | output 1ch = (input 0ch x 1) + (input 1ch x 0) | ||
173 | |||
174 | amixer set "CTU Reset" on | ||
175 | amixer set "CTU Pass" 9,10 | ||
176 | amixer set "CTU SV0" 0,4194304 | ||
177 | amixer set "CTU SV1" 4194304,0 | ||
178 | |||
179 | example of changing connection | ||
180 | amixer set "CTU Reset" on | ||
181 | amixer set "CTU Pass" 2,1 | ||
182 | |||
183 | ============================================= | ||
184 | * MIX (Mixer) | ||
185 | ============================================= | ||
186 | |||
187 | MIX merges 2 sounds path. You can see 2 sound interface on system, | ||
188 | and these sounds will be merged by MIX. | ||
189 | |||
190 | aplay -D plughw:0,0 xxxx.wav & | ||
191 | aplay -D plughw:0,1 yyyy.wav | ||
192 | |||
193 | You need to use "renesas,rsrc-card" sound card for it. | ||
194 | Ex) | ||
195 | [MEM] -> [SRC1] -> [CTU02] -+-> [MIX0] -> [DVC0] -> [SSI0] | ||
196 | | | ||
197 | [MEM] -> [SRC2] -> [CTU03] -+ | ||
198 | |||
199 | sound { | ||
200 | compatible = "renesas,rsrc-card"; | ||
201 | ... | ||
202 | cpu@0 { | ||
203 | sound-dai = <&rcar_sound 0>; | ||
204 | }; | ||
205 | cpu@1 { | ||
206 | sound-dai = <&rcar_sound 1>; | ||
207 | }; | ||
208 | codec { | ||
209 | ... | ||
210 | }; | ||
211 | }; | ||
212 | |||
213 | &rcar_sound { | ||
214 | ... | ||
215 | rcar_sound,dai { | ||
216 | dai0 { | ||
217 | playback = <&src1 &ctu02 &mix0 &dvc0 &ssi0>; | ||
218 | }; | ||
219 | dai1 { | ||
220 | playback = <&src2 &ctu03 &mix0 &dvc0 &ssi0>; | ||
221 | }; | ||
222 | }; | ||
223 | }; | ||
224 | |||
225 | ============================================= | ||
226 | * DVC (Digital Volume and Mute Function) | ||
227 | ============================================= | ||
228 | |||
229 | DVC controls Playback/Capture volume. | ||
230 | |||
231 | Playback Volume | ||
232 | amixer set "DVC Out" 100% | ||
233 | |||
234 | Capture Volume | ||
235 | amixer set "DVC In" 100% | ||
236 | |||
237 | Playback Mute | ||
238 | amixer set "DVC Out Mute" on | ||
239 | |||
240 | Capture Mute | ||
241 | amixer set "DVC In Mute" on | ||
242 | |||
243 | Volume Ramp | ||
244 | amixer set "DVC Out Ramp Up Rate" "0.125 dB/64 steps" | ||
245 | amixer set "DVC Out Ramp Down Rate" "0.125 dB/512 steps" | ||
246 | amixer set "DVC Out Ramp" on | ||
247 | aplay xxx.wav & | ||
248 | amixer set "DVC Out" 80% // Volume Down | ||
249 | amixer set "DVC Out" 100% // Volume Up | ||
250 | |||
251 | ============================================= | ||
252 | * SSIU (Serial Sound Interface Unit) | ||
253 | ============================================= | ||
254 | |||
255 | There is no DT settings for SSIU, because SSIU will be automatically | ||
256 | selected via SSI. | ||
257 | SSIU can avoid some under/over run error, because it has some buffer. | ||
258 | But you can't use it if SSI was PIO mode. | ||
259 | In DMA mode, you can select not to use SSIU by using "no-busif" on DT. | ||
260 | |||
261 | &ssi0 { | ||
262 | no-busif; | ||
263 | }; | ||
264 | |||
265 | ============================================= | ||
266 | * SSI (Serial Sound Interface) | ||
267 | ============================================= | ||
268 | |||
269 | ** PIO mode | ||
270 | |||
271 | You can use PIO mode which is for connection check by using. | ||
272 | Note: The system will drop non-SSI modules in PIO mode | ||
273 | even though if DT is selecting other modules. | ||
274 | |||
275 | &ssi0 { | ||
276 | pio-transfer | ||
277 | }; | ||
278 | |||
279 | ** DMA mode without SSIU | ||
280 | |||
281 | You can use DMA without SSIU. | ||
282 | Note: under/over run, or noise are likely to occur | ||
283 | |||
284 | &ssi0 { | ||
285 | no-busif; | ||
286 | }; | ||
287 | |||
288 | ** PIN sharing | ||
289 | |||
290 | Each SSI can share WS pin. It is based on platform. | ||
291 | This is example if SSI1 want to share WS pin with SSI0 | ||
292 | |||
293 | &ssi1 { | ||
294 | shared-pin; | ||
295 | }; | ||
296 | |||
297 | ** Multi-SSI | ||
298 | |||
299 | You can use Multi-SSI. | ||
300 | This is example of SSI0/SSI1/SSI2 (= for 6ch) | ||
301 | |||
302 | &rcar_sound { | ||
303 | ... | ||
304 | rcar_sound,dai { | ||
305 | dai0 { | ||
306 | playback = <&ssi0 &ssi1 &ssi2 &src0 &dvc0>; | ||
307 | }; | ||
308 | }; | ||
309 | }; | ||
310 | |||
311 | ** TDM-SSI | ||
312 | |||
313 | You can use TDM with SSI. | ||
314 | This is example of TDM 6ch. | ||
315 | Driver can automatically switches TDM <-> stereo mode in this case. | ||
316 | |||
317 | rsnd_tdm: sound { | ||
318 | compatible = "simple-audio-card"; | ||
319 | ... | ||
320 | simple-audio-card,cpu { | ||
321 | /* system can use TDM 6ch */ | ||
322 | dai-tdm-slot-num = <6>; | ||
323 | sound-dai = <&rcar_sound>; | ||
324 | }; | ||
325 | simple-audio-card,codec { | ||
326 | ... | ||
327 | }; | ||
328 | }; | ||
329 | |||
330 | |||
331 | ============================================= | ||
3 | Required properties: | 332 | Required properties: |
333 | ============================================= | ||
334 | |||
4 | - compatible : "renesas,rcar_sound-<soctype>", fallbacks | 335 | - compatible : "renesas,rcar_sound-<soctype>", fallbacks |
5 | "renesas,rcar_sound-gen1" if generation1, and | 336 | "renesas,rcar_sound-gen1" if generation1, and |
6 | "renesas,rcar_sound-gen2" if generation2 | 337 | "renesas,rcar_sound-gen2" if generation2 |
@@ -64,7 +395,10 @@ DAI subnode properties: | |||
64 | - playback : list of playback modules | 395 | - playback : list of playback modules |
65 | - capture : list of capture modules | 396 | - capture : list of capture modules |
66 | 397 | ||
398 | |||
399 | ============================================= | ||
67 | Example: | 400 | Example: |
401 | ============================================= | ||
68 | 402 | ||
69 | rcar_sound: sound@ec500000 { | 403 | rcar_sound: sound@ec500000 { |
70 | #sound-dai-cells = <1>; | 404 | #sound-dai-cells = <1>; |
@@ -250,7 +584,9 @@ rcar_sound: sound@ec500000 { | |||
250 | }; | 584 | }; |
251 | }; | 585 | }; |
252 | 586 | ||
587 | ============================================= | ||
253 | Example: simple sound card | 588 | Example: simple sound card |
589 | ============================================= | ||
254 | 590 | ||
255 | rsnd_ak4643: sound { | 591 | rsnd_ak4643: sound { |
256 | compatible = "simple-audio-card"; | 592 | compatible = "simple-audio-card"; |
@@ -290,7 +626,9 @@ Example: simple sound card | |||
290 | shared-pin; | 626 | shared-pin; |
291 | }; | 627 | }; |
292 | 628 | ||
629 | ============================================= | ||
293 | Example: simple sound card for TDM | 630 | Example: simple sound card for TDM |
631 | ============================================= | ||
294 | 632 | ||
295 | rsnd_tdm: sound { | 633 | rsnd_tdm: sound { |
296 | compatible = "simple-audio-card"; | 634 | compatible = "simple-audio-card"; |
@@ -309,7 +647,9 @@ Example: simple sound card for TDM | |||
309 | }; | 647 | }; |
310 | }; | 648 | }; |
311 | 649 | ||
650 | ============================================= | ||
312 | Example: simple sound card for Multi channel | 651 | Example: simple sound card for Multi channel |
652 | ============================================= | ||
313 | 653 | ||
314 | &rcar_sound { | 654 | &rcar_sound { |
315 | pinctrl-0 = <&sound_pins &sound_clk_pins>; | 655 | pinctrl-0 = <&sound_pins &sound_clk_pins>; |
diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index 93b11e1c5d7f..02d971f69eff 100644 --- a/sound/soc/sh/rcar/dvc.c +++ b/sound/soc/sh/rcar/dvc.c | |||
@@ -8,6 +8,29 @@ | |||
8 | * it under the terms of the GNU General Public License version 2 as | 8 | * it under the terms of the GNU General Public License version 2 as |
9 | * published by the Free Software Foundation. | 9 | * published by the Free Software Foundation. |
10 | */ | 10 | */ |
11 | |||
12 | /* | ||
13 | * Playback Volume | ||
14 | * amixer set "DVC Out" 100% | ||
15 | * | ||
16 | * Capture Volume | ||
17 | * amixer set "DVC In" 100% | ||
18 | * | ||
19 | * Playback Mute | ||
20 | * amixer set "DVC Out Mute" on | ||
21 | * | ||
22 | * Capture Mute | ||
23 | * amixer set "DVC In Mute" on | ||
24 | * | ||
25 | * Volume Ramp | ||
26 | * amixer set "DVC Out Ramp Up Rate" "0.125 dB/64 steps" | ||
27 | * amixer set "DVC Out Ramp Down Rate" "0.125 dB/512 steps" | ||
28 | * amixer set "DVC Out Ramp" on | ||
29 | * aplay xxx.wav & | ||
30 | * amixer set "DVC Out" 80% // Volume Down | ||
31 | * amixer set "DVC Out" 100% // Volume Up | ||
32 | */ | ||
33 | |||
11 | #include "rsnd.h" | 34 | #include "rsnd.h" |
12 | 35 | ||
13 | #define RSND_DVC_NAME_SIZE 16 | 36 | #define RSND_DVC_NAME_SIZE 16 |