116 lines · plain
1==============================================2Creating codec to codec dai link for ALSA dapm3==============================================4 5Mostly the flow of audio is always from CPU to codec so your system6will look as below:7::8 9 --------- ---------10 | | dai | |11 CPU -------> codec12 | | | |13 --------- ---------14 15In case your system looks as below:16::17 18 ---------19 | |20 codec-221 | |22 ---------23 |24 dai-225 |26 ---------- ---------27 | | dai-1 | |28 CPU -------> codec-129 | | | |30 ---------- ---------31 |32 dai-333 |34 ---------35 | |36 codec-337 | |38 ---------39 40Suppose codec-2 is a bluetooth chip and codec-3 is connected to41a speaker and you have a below scenario:42codec-2 will receive the audio data and the user wants to play that43audio through codec-3 without involving the CPU.This44aforementioned case is the ideal case when codec to codec45connection should be used.46 47Your dai_link should appear as below in your machine48file:49::50 51 /*52 * this pcm stream only supports 24 bit, 2 channel and53 * 48k sampling rate.54 */55 static const struct snd_soc_pcm_stream dsp_codec_params = {56 .formats = SNDRV_PCM_FMTBIT_S24_LE,57 .rate_min = 48000,58 .rate_max = 48000,59 .channels_min = 2,60 .channels_max = 2,61 };62 63 {64 .name = "CPU-DSP",65 .stream_name = "CPU-DSP",66 .cpu_dai_name = "samsung-i2s.0",67 .codec_name = "codec-2,68 .codec_dai_name = "codec-2-dai_name",69 .platform_name = "samsung-i2s.0",70 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF71 | SND_SOC_DAIFMT_CBM_CFM,72 .ignore_suspend = 1,73 .c2c_params = &dsp_codec_params,74 .num_c2c_params = 1,75 },76 {77 .name = "DSP-CODEC",78 .stream_name = "DSP-CODEC",79 .cpu_dai_name = "wm0010-sdi2",80 .codec_name = "codec-3,81 .codec_dai_name = "codec-3-dai_name",82 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF83 | SND_SOC_DAIFMT_CBM_CFM,84 .ignore_suspend = 1,85 .c2c_params = &dsp_codec_params,86 .num_c2c_params = 1,87 },88 89Above code snippet is motivated from sound/soc/samsung/speyside.c.90 91Note the "c2c_params" callback which lets the dapm know that this92dai_link is a codec to codec connection.93 94In dapm core a route is created between cpu_dai playback widget95and codec_dai capture widget for playback path and vice-versa is96true for capture path. In order for this aforementioned route to get97triggered, DAPM needs to find a valid endpoint which could be either98a sink or source widget corresponding to playback and capture path99respectively.100 101In order to trigger this dai_link widget, a thin codec driver for102the speaker amp can be created as demonstrated in wm8727.c file, it103sets appropriate constraints for the device even if it needs no control.104 105Make sure to name your corresponding cpu and codec playback and capture106dai names ending with "Playback" and "Capture" respectively as dapm core107will link and power those dais based on the name.108 109A dai_link in a "simple-audio-card" will automatically be detected as110codec to codec when all DAIs on the link belong to codec components.111The dai_link will be initialized with the subset of stream parameters112(channels, format, sample rate) supported by all DAIs on the link. Since113there is no way to provide these parameters in the device tree, this is114mostly useful for communication with simple fixed-function codecs, such115as a Bluetooth controller or cellular modem.116