Back to home page

OSCL-LXR

 
 

    


0001 ==============================================
0002 Creating codec to codec dai link for ALSA dapm
0003 ==============================================
0004 
0005 Mostly the flow of audio is always from CPU to codec so your system
0006 will look as below:
0007 ::
0008 
0009    ---------          ---------
0010   |         |  dai   |         |
0011       CPU    ------->    codec
0012   |         |        |         |
0013    ---------          ---------
0014 
0015 In case your system looks as below:
0016 ::
0017 
0018                        ---------
0019                       |         |
0020                         codec-2
0021                       |         |
0022                       ---------
0023                            |
0024                          dai-2
0025                            |
0026    ----------          ---------
0027   |          |  dai-1 |         |
0028       CPU     ------->  codec-1
0029   |          |        |         |
0030    ----------          ---------
0031                            |
0032                          dai-3
0033                            |
0034                        ---------
0035                       |         |
0036                         codec-3
0037                       |         |
0038                        ---------
0039 
0040 Suppose codec-2 is a bluetooth chip and codec-3 is connected to
0041 a speaker and you have a below scenario:
0042 codec-2 will receive the audio data and the user wants to play that
0043 audio through codec-3 without involving the CPU.This
0044 aforementioned case is the ideal case when codec to codec
0045 connection should be used.
0046 
0047 Your dai_link should appear as below in your machine
0048 file:
0049 ::
0050 
0051  /*
0052   * this pcm stream only supports 24 bit, 2 channel and
0053   * 48k sampling rate.
0054   */
0055  static const struct snd_soc_pcm_stream dsp_codec_params = {
0056         .formats = SNDRV_PCM_FMTBIT_S24_LE,
0057         .rate_min = 48000,
0058         .rate_max = 48000,
0059         .channels_min = 2,
0060         .channels_max = 2,
0061  };
0062 
0063  {
0064     .name = "CPU-DSP",
0065     .stream_name = "CPU-DSP",
0066     .cpu_dai_name = "samsung-i2s.0",
0067     .codec_name = "codec-2,
0068     .codec_dai_name = "codec-2-dai_name",
0069     .platform_name = "samsung-i2s.0",
0070     .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
0071             | SND_SOC_DAIFMT_CBM_CFM,
0072     .ignore_suspend = 1,
0073     .params = &dsp_codec_params,
0074  },
0075  {
0076     .name = "DSP-CODEC",
0077     .stream_name = "DSP-CODEC",
0078     .cpu_dai_name = "wm0010-sdi2",
0079     .codec_name = "codec-3,
0080     .codec_dai_name = "codec-3-dai_name",
0081     .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
0082             | SND_SOC_DAIFMT_CBM_CFM,
0083     .ignore_suspend = 1,
0084     .params = &dsp_codec_params,
0085  },
0086 
0087 Above code snippet is motivated from sound/soc/samsung/speyside.c.
0088 
0089 Note the "params" callback which lets the dapm know that this
0090 dai_link is a codec to codec connection.
0091 
0092 In dapm core a route is created between cpu_dai playback widget
0093 and codec_dai capture widget for playback path and vice-versa is
0094 true for capture path. In order for this aforementioned route to get
0095 triggered, DAPM needs to find a valid endpoint which could be either
0096 a sink or source widget corresponding to playback and capture path
0097 respectively.
0098 
0099 In order to trigger this dai_link widget, a thin codec driver for
0100 the speaker amp can be created as demonstrated in wm8727.c file, it
0101 sets appropriate constraints for the device even if it needs no control.
0102 
0103 Make sure to name your corresponding cpu and codec playback and capture
0104 dai names ending with "Playback" and "Capture" respectively as dapm core
0105 will link and power those dais based on the name.
0106 
0107 A dai_link in a "simple-audio-card" will automatically be detected as
0108 codec to codec when all DAIs on the link belong to codec components.
0109 The dai_link will be initialized with the subset of stream parameters
0110 (channels, format, sample rate) supported by all DAIs on the link. Since
0111 there is no way to provide these parameters in the device tree, this is
0112 mostly useful for communication with simple fixed-function codecs, such
0113 as a Bluetooth controller or cellular modem.