zoukankan      html  css  js  c++  java
  • ALSA driver---DPCM

    https://www.kernel.org/doc/html/v4.11/sound/soc/dpcm.html

    Description

    Dynamic PCM allows an ALSA PCM device to digitally route its PCM audio to various digital endpoints during the PCM stream runtime. e.g. PCM0 can route digital audio to I2S DAI0, I2S DAI1 or PDM DAI2. This is useful for on SoC DSP drivers that expose several ALSA PCMs and can route to multiple DAIs.

    The DPCM runtime routing is determined by the ALSA mixer settings in the same way as the analog signal is routed in an ASoC codec driver. DPCM uses a DAPM graph representing the DSP internal audio paths and uses the mixer settings to determine the patch used by each ALSA PCM.

    DPCM re-uses all the existing component codec, platform and DAI drivers without any modifications.

    Phone Audio System with SoC based DSP

    Consider the following phone audio subsystem. This will be used in this document for all examples :-

    | Front End PCMs    |  SoC DSP  | Back End DAIs | Audio devices |
    
                        *************
    PCM0 <------------> *           * <----DAI0-----> Codec Headset
                        *           *
    PCM1 <------------> *           * <----DAI1-----> Codec Speakers
                        *   DSP     *
    PCM2 <------------> *           * <----DAI2-----> MODEM
                        *           *
    PCM3 <------------> *           * <----DAI3-----> BT
                        *           *
                        *           * <----DAI4-----> DMIC
                        *           *
                        *           * <----DAI5-----> FM
                        *************
    

    This diagram shows a simple smart phone audio subsystem. It supports Bluetooth, FM digital radio, Speakers, Headset Jack, digital microphones and cellular modem. This sound card exposes 4 DSP front end (FE) ALSA PCM devices and supports 6 back end (BE) DAIs. Each FE PCM can digitally route audio data to any of the BE DAIs. The FE PCM devices can also route audio to more than 1 BE DAI.

    DPCM machine driver

    The DPCM enabled ASoC machine driver is similar to normal machine drivers except that we also have to :-

    1. Define the FE and BE DAI links.
    2. Define any FE/BE PCM operations.
    3. Define widget graph connections.

    FE and BE DAI links

    | Front End PCMs    |  SoC DSP  | Back End DAIs | Audio devices |
    
                        *************
    PCM0 <------------> *           * <----DAI0-----> Codec Headset
                        *           *
    PCM1 <------------> *           * <----DAI1-----> Codec Speakers
                        *   DSP     *
    PCM2 <------------> *           * <----DAI2-----> MODEM
                        *           *
    PCM3 <------------> *           * <----DAI3-----> BT
                        *           *
                        *           * <----DAI4-----> DMIC
                        *           *
                        *           * <----DAI5-----> FM
                        *************
    

    For the example above we have to define 4 FE DAI links and 6 BE DAI links. The FE DAI links are defined as follows :-

    static struct snd_soc_dai_link machine_dais[] = {
          {
                  .name = "PCM0 System",
                  .stream_name = "System Playback",
                  .cpu_dai_name = "System Pin",
                  .platform_name = "dsp-audio",
                  .codec_name = "snd-soc-dummy",
                  .codec_dai_name = "snd-soc-dummy-dai",
                  .dynamic = 1,
                  .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
                  .dpcm_playback = 1,
          },
          .....< other FE and BE DAI links here >
    };
    

    This FE DAI link is pretty similar to a regular DAI link except that we also set the DAI link to a DPCM FE with the dynamic 1. The supported FE stream directions should also be set with the dpcm_playback and dpcm_capture flags. There is also an option to specify the ordering of the trigger call for each FE. This allows the ASoC core to trigger the DSP before or after the other components (as some DSPs have strong requirements for the ordering DAI/DSP start and stop sequences).

    The FE DAI above sets the codec and code DAIs to dummy devices since the BE is dynamic and will change depending on runtime config.

    The BE DAIs are configured as follows :-

    static struct snd_soc_dai_link machine_dais[] = {
          .....< FE DAI links here >
          {
                  .name = "Codec Headset",
                  .cpu_dai_name = "ssp-dai.0",
                  .platform_name = "snd-soc-dummy",
                  .no_pcm = 1,
                  .codec_name = "rt5640.0-001c",
                  .codec_dai_name = "rt5640-aif1",
                  .ignore_suspend = 1,
                  .ignore_pmdown_time = 1,
                  .be_hw_params_fixup = hswult_ssp0_fixup,
                  .ops = &haswell_ops,
                  .dpcm_playback = 1,
                  .dpcm_capture = 1,
          },
          .....< other BE DAI links here >
    };
    

    This BE DAI link connects DAI0 to the codec (in this case RT5460 AIF1). It sets the no_pcm flag to mark it has a BE and sets flags for supported stream directions using dpcm_playback and dpcm_capture above.

    The BE has also flags set for ignoring suspend and PM down time. This allows the BE to work in a hostless mode where the host CPU is not transferring data like a BT phone call :-

                        *************
    PCM0 <------------> *           * <----DAI0-----> Codec Headset
                        *           *
    PCM1 <------------> *           * <----DAI1-----> Codec Speakers
                        *   DSP     *
    PCM2 <------------> *           * <====DAI2=====> MODEM
                        *           *
    PCM3 <------------> *           * <====DAI3=====> BT
                        *           *
                        *           * <----DAI4-----> DMIC
                        *           *
                        *           * <----DAI5-----> FM
                        *************
    

    This allows the host CPU to sleep whilst the DSP, MODEM DAI and the BT DAI are still in operation.

    A BE DAI link can also set the codec to a dummy device if the code is a device that is managed externally.

    Likewise a BE DAI can also set a dummy cpu DAI if the CPU DAI is managed by the DSP firmware.

    FE/BE PCM operations

    The BE above also exports some PCM operations and a fixup callback. The fixup callback is used by the machine driver to (re)configure the DAI based upon the FE hw params. i.e. the DSP may perform SRC or ASRC from the FE to BE.

    e.g. DSP converts all FE hw params to run at fixed rate of 48k, 16bit, stereo for DAI0. This means all FE hw_params have to be fixed in the machine driver for DAI0 so that the DAI is running at desired configuration regardless of the FE configuration.

    static int dai0_fixup(struct snd_soc_pcm_runtime *rtd,
                          struct snd_pcm_hw_params *params)
    {
          struct snd_interval *rate = hw_param_interval(params,
                          SNDRV_PCM_HW_PARAM_RATE);
          struct snd_interval *channels = hw_param_interval(params,
                                                  SNDRV_PCM_HW_PARAM_CHANNELS);
    
          /* The DSP will covert the FE rate to 48k, stereo */
          rate->min = rate->max = 48000;
          channels->min = channels->max = 2;
    
          /* set DAI0 to 16 bit */
          snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT -
                                      SNDRV_PCM_HW_PARAM_FIRST_MASK],
                                      SNDRV_PCM_FORMAT_S16_LE);
          return 0;
    }
    

    The other PCM operation are the same as for regular DAI links. Use as necessary.

    Widget graph connections

    The BE DAI links will normally be connected to the graph at initialisation time by the ASoC DAPM core. However, if the BE codec or BE DAI is a dummy then this has to be set explicitly in the driver :-

    /* BE for codec Headset -  DAI0 is dummy and managed by DSP FW */
    {"DAI0 CODEC IN", NULL, "AIF1 Capture"},
    {"AIF1 Playback", NULL, "DAI0 CODEC OUT"},
    

    Writing a DPCM DSP driver

    The DPCM DSP driver looks much like a standard platform class ASoC driver combined with elements from a codec class driver. A DSP platform driver must implement :-

    1. Front End PCM DAIs - i.e. struct snd_soc_dai_driver.
    2. DAPM graph showing DSP audio routing from FE DAIs to BEs.
    3. DAPM widgets from DSP graph.
    4. Mixers for gains, routing, etc.
    5. DMA configuration.
    6. BE AIF widgets.

    Items 6 is important for routing the audio outside of the DSP. AIF need to be defined for each BE and each stream direction. e.g for BE DAI0 above we would have :-

    SND_SOC_DAPM_AIF_IN("DAI0 RX", NULL, 0, SND_SOC_NOPM, 0, 0),
    SND_SOC_DAPM_AIF_OUT("DAI0 TX", NULL, 0, SND_SOC_NOPM, 0, 0),
    

    The BE AIF are used to connect the DSP graph to the graphs for the other component drivers (e.g. codec graph).

    Example:

    FE & BE DAIs:

    sound/soc/mediatek/mt2701/mt2701-cs42448.c

    static struct snd_soc_dai_link mt2701_cs42448_dai_links[] = {
        /* FE */
        [DAI_LINK_FE_MULTI_CH_OUT] = {
            .name = "mt2701-cs42448-multi-ch-out",
            .stream_name = "mt2701-cs42448-multi-ch-out",
            .cpu_dai_name = "PCM_multi",
            .codec_name = "snd-soc-dummy",
            .codec_dai_name = "snd-soc-dummy-dai",
            .trigger = {SND_SOC_DPCM_TRIGGER_POST,
                    SND_SOC_DPCM_TRIGGER_POST},
            .ops = &mt2701_cs42448_48k_fe_ops,
            .dynamic = 1,
            .dpcm_playback = 1,
        },
        [DAI_LINK_FE_PCM0_IN] = {
            .name = "mt2701-cs42448-pcm0",
            .stream_name = "mt2701-cs42448-pcm0-data-UL",
            .cpu_dai_name = "PCM0",
            .codec_name = "snd-soc-dummy",
            .codec_dai_name = "snd-soc-dummy-dai",
            .trigger = {SND_SOC_DPCM_TRIGGER_POST,
                    SND_SOC_DPCM_TRIGGER_POST},
            .ops = &mt2701_cs42448_48k_fe_ops,
            .dynamic = 1,
            .dpcm_capture = 1,
        },
        [DAI_LINK_FE_PCM1_IN] = {
            .name = "mt2701-cs42448-pcm1-data-UL",
            .stream_name = "mt2701-cs42448-pcm1-data-UL",
            .cpu_dai_name = "PCM1",
            .codec_name = "snd-soc-dummy",
            .codec_dai_name = "snd-soc-dummy-dai",
            .trigger = {SND_SOC_DPCM_TRIGGER_POST,
                    SND_SOC_DPCM_TRIGGER_POST},
            .ops = &mt2701_cs42448_48k_fe_ops,
            .dynamic = 1,
            .dpcm_capture = 1,
        },
        [DAI_LINK_FE_BT_OUT] = {
            .name = "mt2701-cs42448-pcm-BT-out",
            .stream_name = "mt2701-cs42448-pcm-BT",
            .cpu_dai_name = "PCM_BT_DL",
            .codec_name = "snd-soc-dummy",
            .codec_dai_name = "snd-soc-dummy-dai",
            .trigger = {SND_SOC_DPCM_TRIGGER_POST,
                    SND_SOC_DPCM_TRIGGER_POST},
            .dynamic = 1,
            .dpcm_playback = 1,
        },
        [DAI_LINK_FE_BT_IN] = {
            .name = "mt2701-cs42448-pcm-BT-in",
            .stream_name = "mt2701-cs42448-pcm-BT",
            .cpu_dai_name = "PCM_BT_UL",
            .codec_name = "snd-soc-dummy",
            .codec_dai_name = "snd-soc-dummy-dai",
            .trigger = {SND_SOC_DPCM_TRIGGER_POST,
                    SND_SOC_DPCM_TRIGGER_POST},
            .dynamic = 1,
            .dpcm_capture = 1,
        },
        /* BE */
        [DAI_LINK_BE_I2S0] = {
            .name = "mt2701-cs42448-I2S0",
            .cpu_dai_name = "I2S0",
            .no_pcm = 1,
            .codec_dai_name = "cs42448",
            .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS
                 | SND_SOC_DAIFMT_GATED,
            .ops = &mt2701_cs42448_be_ops,
            .dpcm_playback = 1,
            .dpcm_capture = 1,
        },
        [DAI_LINK_BE_I2S1] = {
            .name = "mt2701-cs42448-I2S1",
            .cpu_dai_name = "I2S1",
            .no_pcm = 1,
            .codec_dai_name = "cs42448",
            .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS
                 | SND_SOC_DAIFMT_GATED,
            .ops = &mt2701_cs42448_be_ops,
            .dpcm_playback = 1,
            .dpcm_capture = 1,
        },
        [DAI_LINK_BE_I2S2] = {
            .name = "mt2701-cs42448-I2S2",
            .cpu_dai_name = "I2S2",
            .no_pcm = 1,
            .codec_dai_name = "cs42448",
            .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS
                 | SND_SOC_DAIFMT_GATED,
            .ops = &mt2701_cs42448_be_ops,
            .dpcm_playback = 1,
            .dpcm_capture = 1,
        },
        [DAI_LINK_BE_I2S3] = {
            .name = "mt2701-cs42448-I2S3",
            .cpu_dai_name = "I2S3",
            .no_pcm = 1,
            .codec_dai_name = "cs42448",
            .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS
                 | SND_SOC_DAIFMT_GATED,
            .ops = &mt2701_cs42448_be_ops,
            .dpcm_playback = 1,
            .dpcm_capture = 1,
        },
        [DAI_LINK_BE_MRG_BT] = {
            .name = "mt2701-cs42448-MRG-BT",
            .cpu_dai_name = "MRG BT",
            .no_pcm = 1,
            .codec_dai_name = "bt-sco-pcm-wb",
            .dpcm_playback = 1,
            .dpcm_capture = 1,
        },
    };
    
    static struct snd_soc_card mt2701_cs42448_soc_card = {
        .name = "mt2701-cs42448",
        .owner = THIS_MODULE,
        .dai_link = mt2701_cs42448_dai_links,
        .num_links = ARRAY_SIZE(mt2701_cs42448_dai_links),
        .controls = mt2701_cs42448_controls,
        .num_controls = ARRAY_SIZE(mt2701_cs42448_controls),
        .dapm_widgets = mt2701_cs42448_asoc_card_dapm_widgets,
        .num_dapm_widgets = ARRAY_SIZE(mt2701_cs42448_asoc_card_dapm_widgets),
    };

    DAPM graph showing DSP audio routing from FE DAIs to BEs.

    PCM_Multi(FE cpu DAI) -->DLM(FE DAI Widget)-->"Asrc0 out Switch"(ctrl)-->ASRC_O0(widget)-->"Multich I2S0 out Switch"(ctrl)-->I12I13(widget)-->I12(widget)-->"I2 Switch"(ctrl)-->O15(widget)-->I2S0 Playback(BE DAI Widget)-->I2S0(BE cpu DAI)-->cs42448(codec DAI)

    dai widgets在声卡创建阶段会去调用soc_probe_link_components函数probe所有注册进来的component(关于component看一下register相关函数和component list就明白了),soc_probe_link_components中会对每个component调用snd_soc_dapm_new_dai_widgets。这里有一点提一下,就是在创建的widget中,其name和sname都是dai driver中的stream name,这是因为后面的链接时会去匹配这个名字.

    BE cpu dai widgets后会继续调用snd_soc_dapm_connect_dai_link_widgets函数与codec dai进行链接.

    dai widgets与其他widgets链接:在声卡初始化的时候,snd_soc_instantiate_card中调用snd_soc_dapm_link_dai_widgets函数来完成的。snd_soc_dapm_link_dai_widgets函数会去遍历每一个dai widgets,然后遍历所有的非dai widgets,如果非dai widgets的stream name与dai widgets的name相同,则把两个widgets进行链接。这也是为什么创建dai widgets时name一定要是stream name的原因之一了。 

    control:

    SOC_DAPM_SINGLE_AUTODISABLE("I12 Switch", AFE_CONN15, 12, 1, 0)//register AFE_CONN15 bit12, max value:1, Invert:0. (bit12 = 1, On, bit12 = 0, off). 

    sound/soc/mediatek/mt2701/mt2701-afe-pcm.c

    static const struct snd_kcontrol_new mt2701_afe_multi_ch_out_asrc0[] = {
        SOC_DAPM_SINGLE_AUTODISABLE("Asrc0 out Switch", AUDIO_TOP_CON4, 14, 1,
                        1),
    };
    static const struct snd_kcontrol_new mt2701_afe_multi_ch_out_i2s0[] = {
        SOC_DAPM_SINGLE_AUTODISABLE("Multich I2S0 Out Switch",
                        ASYS_I2SO1_CON, 26, 1, 0),
    };
    static const struct snd_kcontrol_new mt2701_afe_o15_mix[] = {
        SOC_DAPM_SINGLE_AUTODISABLE("I12 Switch", AFE_CONN15, 12, 1, 0),
    };
    static const struct snd_soc_dapm_widget mt2701_afe_pcm_widgets[] = {
        /* inter-connections */
        SND_SOC_DAPM_MIXER("I00", SND_SOC_NOPM, 0, 0, NULL, 0),
        SND_SOC_DAPM_MIXER("I01", SND_SOC_NOPM, 0, 0, NULL, 0),
        SND_SOC_DAPM_MIXER("I02", SND_SOC_NOPM, 0, 0, mt2701_afe_i02_mix,
                   ARRAY_SIZE(mt2701_afe_i02_mix)),
        SND_SOC_DAPM_MIXER("I03", SND_SOC_NOPM, 0, 0, NULL, 0),
        SND_SOC_DAPM_MIXER("I12", SND_SOC_NOPM, 0, 0, NULL, 0),
        SND_SOC_DAPM_MIXER("I13", SND_SOC_NOPM, 0, 0, NULL, 0),
        SND_SOC_DAPM_MIXER("I14", SND_SOC_NOPM, 0, 0, NULL, 0),
        SND_SOC_DAPM_MIXER("I15", SND_SOC_NOPM, 0, 0, NULL, 0),
        SND_SOC_DAPM_MIXER("I16", SND_SOC_NOPM, 0, 0, NULL, 0),
        SND_SOC_DAPM_MIXER("I17", SND_SOC_NOPM, 0, 0, NULL, 0),
        SND_SOC_DAPM_MIXER("I18", SND_SOC_NOPM, 0, 0, NULL, 0),
        SND_SOC_DAPM_MIXER("I19", SND_SOC_NOPM, 0, 0, NULL, 0),
        SND_SOC_DAPM_MIXER("I26", SND_SOC_NOPM, 0, 0, NULL, 0),
        SND_SOC_DAPM_MIXER("I35", SND_SOC_NOPM, 0, 0, NULL, 0),
    
        SND_SOC_DAPM_MIXER("O00", SND_SOC_NOPM, 0, 0, mt2701_afe_o00_mix,
                   ARRAY_SIZE(mt2701_afe_o00_mix)),
        SND_SOC_DAPM_MIXER("O01", SND_SOC_NOPM, 0, 0, mt2701_afe_o01_mix,
                   ARRAY_SIZE(mt2701_afe_o01_mix)),
        SND_SOC_DAPM_MIXER("O02", SND_SOC_NOPM, 0, 0, mt2701_afe_o02_mix,
                   ARRAY_SIZE(mt2701_afe_o02_mix)),
        SND_SOC_DAPM_MIXER("O03", SND_SOC_NOPM, 0, 0, mt2701_afe_o03_mix,
                   ARRAY_SIZE(mt2701_afe_o03_mix)),
        SND_SOC_DAPM_MIXER("O14", SND_SOC_NOPM, 0, 0, mt2701_afe_o14_mix,
                   ARRAY_SIZE(mt2701_afe_o14_mix)),
        SND_SOC_DAPM_MIXER("O15", SND_SOC_NOPM, 0, 0, mt2701_afe_o15_mix,
                   ARRAY_SIZE(mt2701_afe_o15_mix)),
        SND_SOC_DAPM_MIXER("O16", SND_SOC_NOPM, 0, 0, mt2701_afe_o16_mix,
                   ARRAY_SIZE(mt2701_afe_o16_mix)),
        SND_SOC_DAPM_MIXER("O17", SND_SOC_NOPM, 0, 0, mt2701_afe_o17_mix,
                   ARRAY_SIZE(mt2701_afe_o17_mix)),
        SND_SOC_DAPM_MIXER("O18", SND_SOC_NOPM, 0, 0, mt2701_afe_o18_mix,
                   ARRAY_SIZE(mt2701_afe_o18_mix)),
        SND_SOC_DAPM_MIXER("O19", SND_SOC_NOPM, 0, 0, mt2701_afe_o19_mix,
                   ARRAY_SIZE(mt2701_afe_o19_mix)),
        SND_SOC_DAPM_MIXER("O20", SND_SOC_NOPM, 0, 0, mt2701_afe_o20_mix,
                   ARRAY_SIZE(mt2701_afe_o20_mix)),
        SND_SOC_DAPM_MIXER("O21", SND_SOC_NOPM, 0, 0, mt2701_afe_o21_mix,
                   ARRAY_SIZE(mt2701_afe_o21_mix)),
        SND_SOC_DAPM_MIXER("O22", SND_SOC_NOPM, 0, 0, mt2701_afe_o22_mix,
                   ARRAY_SIZE(mt2701_afe_o22_mix)),
        SND_SOC_DAPM_MIXER("O31", SND_SOC_NOPM, 0, 0, mt2701_afe_o31_mix,
                   ARRAY_SIZE(mt2701_afe_o31_mix)),
    
        SND_SOC_DAPM_MIXER("I12I13", SND_SOC_NOPM, 0, 0,
                   mt2701_afe_multi_ch_out_i2s0,
                   ARRAY_SIZE(mt2701_afe_multi_ch_out_i2s0)),
        SND_SOC_DAPM_MIXER("I14I15", SND_SOC_NOPM, 0, 0,
                   mt2701_afe_multi_ch_out_i2s1,
                   ARRAY_SIZE(mt2701_afe_multi_ch_out_i2s1)),
        SND_SOC_DAPM_MIXER("I16I17", SND_SOC_NOPM, 0, 0,
                   mt2701_afe_multi_ch_out_i2s2,
                   ARRAY_SIZE(mt2701_afe_multi_ch_out_i2s2)),
        SND_SOC_DAPM_MIXER("I18I19", SND_SOC_NOPM, 0, 0,
                   mt2701_afe_multi_ch_out_i2s3,
                   ARRAY_SIZE(mt2701_afe_multi_ch_out_i2s3)),
    
        SND_SOC_DAPM_MIXER("ASRC_O0", SND_SOC_NOPM, 0, 0,
                   mt2701_afe_multi_ch_out_asrc0,
                   ARRAY_SIZE(mt2701_afe_multi_ch_out_asrc0)),
        SND_SOC_DAPM_MIXER("ASRC_O1", SND_SOC_NOPM, 0, 0,
                   mt2701_afe_multi_ch_out_asrc1,
                   ARRAY_SIZE(mt2701_afe_multi_ch_out_asrc1)),
        SND_SOC_DAPM_MIXER("ASRC_O2", SND_SOC_NOPM, 0, 0,
                   mt2701_afe_multi_ch_out_asrc2,
                   ARRAY_SIZE(mt2701_afe_multi_ch_out_asrc2)),
        SND_SOC_DAPM_MIXER("ASRC_O3", SND_SOC_NOPM, 0, 0,
                   mt2701_afe_multi_ch_out_asrc3,
                   ARRAY_SIZE(mt2701_afe_multi_ch_out_asrc3)),
    };
    
    static const struct snd_soc_dapm_route mt2701_afe_pcm_routes[] = {
        {"I12", NULL, "DL1"},
        {"I13", NULL, "DL1"},
        {"I35", NULL, "DLBT"},
    
        {"I2S0 Playback", NULL, "O15"},
        {"I2S0 Playback", NULL, "O16"},
    
        {"I2S1 Playback", NULL, "O17"},
        {"I2S1 Playback", NULL, "O18"},
        {"I2S2 Playback", NULL, "O19"},
        {"I2S2 Playback", NULL, "O20"},
        {"I2S3 Playback", NULL, "O21"},
        {"I2S3 Playback", NULL, "O22"},
        {"BT Playback", NULL, "O31"},
    
        {"UL1", NULL, "O00"},
        {"UL1", NULL, "O01"},
        {"UL2", NULL, "O02"},
        {"UL2", NULL, "O03"},
        {"ULBT", NULL, "O14"},
    
        {"I00", NULL, "I2S0 Capture"},
        {"I01", NULL, "I2S0 Capture"},
    
        {"I02", NULL, "I2S1 Capture"},
        {"I03", NULL, "I2S1 Capture"},
        /* I02,03 link to UL2, also need to open I2S0 */
        {"I02", "I2S0 Switch", "I2S0 Capture"},
    
        {"I26", NULL, "BT Capture"},
    
        {"ASRC_O0", "Asrc0 out Switch", "DLM"},
        {"ASRC_O1", "Asrc1 out Switch", "DLM"},
        {"ASRC_O2", "Asrc2 out Switch", "DLM"},
        {"ASRC_O3", "Asrc3 out Switch", "DLM"},
    
        {"I12I13", "Multich I2S0 Out Switch", "ASRC_O0"},
        {"I14I15", "Multich I2S1 Out Switch", "ASRC_O1"},
        {"I16I17", "Multich I2S2 Out Switch", "ASRC_O2"},
        {"I18I19", "Multich I2S3 Out Switch", "ASRC_O3"},
    
        { "I12", NULL, "I12I13" },
        { "I13", NULL, "I12I13" },
        { "I14", NULL, "I14I15" },
        { "I15", NULL, "I14I15" },
        { "I16", NULL, "I16I17" },
        { "I17", NULL, "I16I17" },
        { "I18", NULL, "I18I19" },
        { "I19", NULL, "I18I19" },
    
        { "O00", "I00 Switch", "I00" },
        { "O01", "I01 Switch", "I01" },
        { "O02", "I02 Switch", "I02" },
        { "O03", "I03 Switch", "I03" },
        { "O14", "I26 Switch", "I26" },
        { "O15", "I12 Switch", "I12" },
        { "O16", "I13 Switch", "I13" },
        { "O17", "I14 Switch", "I14" },
        { "O18", "I15 Switch", "I15" },
        { "O19", "I16 Switch", "I16" },
        { "O20", "I17 Switch", "I17" },
        { "O21", "I18 Switch", "I18" },
        { "O22", "I19 Switch", "I19" },
        { "O31", "I35 Switch", "I35" },
    
    };
    
    static const struct snd_soc_component_driver mt2701_afe_pcm_dai_component = {
        .name = "mt2701-afe-pcm-dai",
        .dapm_widgets = mt2701_afe_pcm_widgets,
        .num_dapm_widgets = ARRAY_SIZE(mt2701_afe_pcm_widgets),
        .dapm_routes = mt2701_afe_pcm_routes,
        .num_dapm_routes = ARRAY_SIZE(mt2701_afe_pcm_routes),
    };

     Codec driver:

    "Playback"(Codec dai widget)--> DAC1(widget)-->AOUT1L(widget)

    sound/soc/codecs/cs42xx8.c

    static const struct snd_soc_dapm_widget cs42xx8_dapm_widgets[] = {
        SND_SOC_DAPM_DAC("DAC1", "Playback", CS42XX8_PWRCTL, 1, 1),
        SND_SOC_DAPM_DAC("DAC2", "Playback", CS42XX8_PWRCTL, 2, 1),
        SND_SOC_DAPM_DAC("DAC3", "Playback", CS42XX8_PWRCTL, 3, 1),
        SND_SOC_DAPM_DAC("DAC4", "Playback", CS42XX8_PWRCTL, 4, 1),
    
        SND_SOC_DAPM_OUTPUT("AOUT1L"),
        SND_SOC_DAPM_OUTPUT("AOUT1R"),
        SND_SOC_DAPM_OUTPUT("AOUT2L"),
        SND_SOC_DAPM_OUTPUT("AOUT2R"),
        SND_SOC_DAPM_OUTPUT("AOUT3L"),
        SND_SOC_DAPM_OUTPUT("AOUT3R"),
        SND_SOC_DAPM_OUTPUT("AOUT4L"),
        SND_SOC_DAPM_OUTPUT("AOUT4R"),
    
        SND_SOC_DAPM_ADC("ADC1", "Capture", CS42XX8_PWRCTL, 5, 1),
        SND_SOC_DAPM_ADC("ADC2", "Capture", CS42XX8_PWRCTL, 6, 1),
    
        SND_SOC_DAPM_INPUT("AIN1L"),
        SND_SOC_DAPM_INPUT("AIN1R"),
        SND_SOC_DAPM_INPUT("AIN2L"),
        SND_SOC_DAPM_INPUT("AIN2R"),
    
        SND_SOC_DAPM_SUPPLY("PWR", CS42XX8_PWRCTL, 0, 1, NULL, 0),
    };
    
    static const struct snd_soc_dapm_widget cs42xx8_adc3_dapm_widgets[] = {
        SND_SOC_DAPM_ADC("ADC3", "Capture", CS42XX8_PWRCTL, 7, 1),
    
        SND_SOC_DAPM_INPUT("AIN3L"),
        SND_SOC_DAPM_INPUT("AIN3R"),
    };
    
    static const struct snd_soc_dapm_route cs42xx8_dapm_routes[] = {
        /* Playback */
        { "AOUT1L", NULL, "DAC1" },
        { "AOUT1R", NULL, "DAC1" },
        { "DAC1", NULL, "PWR" },
    
        { "AOUT2L", NULL, "DAC2" },
        { "AOUT2R", NULL, "DAC2" },
        { "DAC2", NULL, "PWR" },
    
        { "AOUT3L", NULL, "DAC3" },
        { "AOUT3R", NULL, "DAC3" },
        { "DAC3", NULL, "PWR" },
    
        { "AOUT4L", NULL, "DAC4" },
        { "AOUT4R", NULL, "DAC4" },
        { "DAC4", NULL, "PWR" },
    
        /* Capture */
        { "ADC1", NULL, "AIN1L" },
        { "ADC1", NULL, "AIN1R" },
        { "ADC1", NULL, "PWR" },
    
        { "ADC2", NULL, "AIN2L" },
        { "ADC2", NULL, "AIN2R" },
        { "ADC2", NULL, "PWR" },
    };
    static const struct snd_soc_dapm_route cs42xx8_adc3_dapm_routes[] = {
        /* Capture */
        { "ADC3", NULL, "AIN3L" },
        { "ADC3", NULL, "AIN3R" },
        { "ADC3", NULL, "PWR" },
    };
    static struct snd_soc_dai_driver cs42xx8_dai = {
        .playback = {
            .stream_name = "Playback",
            .channels_min = 1,
            .channels_max = 8,
            .rates = SNDRV_PCM_RATE_8000_192000,
            .formats = CS42XX8_FORMATS,
        },
        .capture = {
            .stream_name = "Capture",
            .channels_min = 1,
            .rates = SNDRV_PCM_RATE_8000_192000,
            .formats = CS42XX8_FORMATS,
        },
        .ops = &cs42xx8_dai_ops,
    };
    static const struct snd_soc_codec_driver cs42xx8_driver = {
        .probe = cs42xx8_codec_probe,
        .idle_bias_off = true,
    
        .controls = cs42xx8_snd_controls,
        .num_controls = ARRAY_SIZE(cs42xx8_snd_controls),
        .dapm_widgets = cs42xx8_dapm_widgets,
        .num_dapm_widgets = ARRAY_SIZE(cs42xx8_dapm_widgets),
        .dapm_routes = cs42xx8_dapm_routes,
        .num_dapm_routes = ARRAY_SIZE(cs42xx8_dapm_routes),
    };
  • 相关阅读:
    macbook如何清理磁盘中的“容器中的其他宗卷”
    Maven本地仓库与远程仓库配置
    查看MySQL库、表所占磁盘空间大小
    数据库操作
    Mac Mysql初始密码重置
    Vue 性能优化经验总结
    【读书笔记】对象创建摘录
    【读书笔记】 函数柯里化
    js实现仿windows文件按名称排序
    本来想偷懒的今天,想了想,还是写一篇吧,前端登录界面,用的BOOTSTRAP
  • 原文地址:https://www.cnblogs.com/fellow1988/p/12546416.html
Copyright © 2011-2022 走看看