ASoC: rt5514: Unconfuse the rt5514 at probe / resume time
[sfrench/cifs-2.6.git] / Documentation / sound / alsa / soc / codec_to_codec.txt
1 Creating codec to codec dai link for ALSA dapm
2 ===================================================
3
4 Mostly the flow of audio is always from CPU to codec so your system
5 will look as below:
6
7  ---------          ---------
8 |         |  dai   |         |
9     CPU    ------->    codec
10 |         |        |         |
11  ---------          ---------
12
13 In case your system looks as below:
14                      ---------
15                     |         |
16                       codec-2
17                     |         |
18                      ---------
19                          |
20                        dai-2
21                          |
22  ----------          ---------
23 |          |  dai-1 |         |
24     CPU     ------->  codec-1
25 |          |        |         |
26  ----------          ---------
27                          |
28                        dai-3
29                          |
30                      ---------
31                     |         |
32                       codec-3
33                     |         |
34                      ---------
35
36 Suppose codec-2 is a bluetooth chip and codec-3 is connected to
37 a speaker and you have a below scenario:
38 codec-2 will receive the audio data and the user wants to play that
39 audio through codec-3 without involving the CPU.This
40 aforementioned case is the ideal case when codec to codec
41 connection should be used.
42
43 Your dai_link should appear as below in your machine
44 file:
45
46 /*
47  * this pcm stream only supports 24 bit, 2 channel and
48  * 48k sampling rate.
49  */
50 static const struct snd_soc_pcm_stream dsp_codec_params = {
51         .formats = SNDRV_PCM_FMTBIT_S24_LE,
52         .rate_min = 48000,
53         .rate_max = 48000,
54         .channels_min = 2,
55         .channels_max = 2,
56 };
57
58 {
59     .name = "CPU-DSP",
60     .stream_name = "CPU-DSP",
61     .cpu_dai_name = "samsung-i2s.0",
62     .codec_name = "codec-2,
63     .codec_dai_name = "codec-2-dai_name",
64     .platform_name = "samsung-i2s.0",
65     .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
66             | SND_SOC_DAIFMT_CBM_CFM,
67     .ignore_suspend = 1,
68     .params = &dsp_codec_params,
69 },
70 {
71     .name = "DSP-CODEC",
72     .stream_name = "DSP-CODEC",
73     .cpu_dai_name = "wm0010-sdi2",
74     .codec_name = "codec-3,
75     .codec_dai_name = "codec-3-dai_name",
76     .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
77             | SND_SOC_DAIFMT_CBM_CFM,
78     .ignore_suspend = 1,
79     .params = &dsp_codec_params,
80 },
81
82 Above code snippet is motivated from sound/soc/samsung/speyside.c.
83
84 Note the "params" callback which lets the dapm know that this
85 dai_link is a codec to codec connection.
86
87 In dapm core a route is created between cpu_dai playback widget
88 and codec_dai capture widget for playback path and vice-versa is
89 true for capture path. In order for this aforementioned route to get
90 triggered, DAPM needs to find a valid endpoint which could be either
91 a sink or source widget corresponding to playback and capture path
92 respectively.
93
94 In order to trigger this dai_link widget, a thin codec driver for
95 the speaker amp can be created as demonstrated in wm8727.c file, it
96 sets appropriate constraints for the device even if it needs no control.
97
98 Make sure to name your corresponding cpu and codec playback and capture
99 dai names ending with "Playback" and "Capture" respectively as dapm core
100 will link and power those dais based on the name.
101
102 Note that in current device tree there is no way to mark a dai_link
103 as codec to codec. However, it may change in future.