ѭsphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget"/translations/zh_CN/sound/soc/dpcmmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget"/translations/zh_TW/sound/soc/dpcmmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget"/translations/it_IT/sound/soc/dpcmmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget"/translations/ja_JP/sound/soc/dpcmmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget"/translations/ko_KR/sound/soc/dpcmmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget"/translations/sp_SP/sound/soc/dpcmmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(h Dynamic PCMh]h Dynamic PCM}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhh * * <----DAI0-----> Codec Headset * * PCM1 <------------> * * <----DAI1-----> Codec Speakers * DSP * PCM2 <------------> * * <----DAI2-----> MODEM * * PCM3 <------------> * * <----DAI3-----> BT * * * * <----DAI4-----> DMIC * * * * <----DAI5-----> FM *************h]hX| 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 *************}hjsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1jhhhKhhhhubh)}(hXThis 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.h]hXThis 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.}(hj%hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK-hhhhubeh}(h]%phone-audio-system-with-soc-based-dspah ]h"]%phone audio system with soc based dspah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h3Example - DPCM Switching playback from DAI0 to DAI1h]h3Example - DPCM Switching playback from DAI0 to DAI1}(hj>hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj;hhhhhK6ubh)}(h}Audio is being played to the Headset. After a while the user removes the headset and audio continues playing on the speakers.h]h}Audio is being played to the Headset. After a while the user removes the headset and audio continues playing on the speakers.}(hjLhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK8hj;hhubh)}(h1Playback on PCM0 to Headset would look like :- ::h]h.Playback on PCM0 to Headset would look like :-}(hjZhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK;hj;hhubj)}(hXG ************* PCM0 <============> * * <====DAI0=====> Codec Headset * * PCM1 <------------> * * <----DAI1-----> Codec Speakers * DSP * PCM2 <------------> * * <----DAI2-----> MODEM * * PCM3 <------------> * * <----DAI3-----> BT * * * * <----DAI4-----> DMIC * * * * <----DAI5-----> FM *************h]hXG ************* PCM0 <============> * * <====DAI0=====> Codec Headset * * PCM1 <------------> * * <----DAI1-----> Codec Speakers * DSP * PCM2 <------------> * * <----DAI2-----> MODEM * * PCM3 <------------> * * <----DAI3-----> BT * * * * <----DAI4-----> DMIC * * * * <----DAI5-----> FM *************}hjhsbah}(h]h ]h"]h$]h&]j#j$uh1jhhhK>hj;hhubh)}(hSThe headset is removed from the jack by user so the speakers must now be used :- ::h]hPThe headset is removed from the jack by user so the speakers must now be used :-}(hjvhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKLhj;hhubj)}(hXG ************* PCM0 <============> * * <----DAI0-----> Codec Headset * * PCM1 <------------> * * <====DAI1=====> Codec Speakers * DSP * PCM2 <------------> * * <----DAI2-----> MODEM * * PCM3 <------------> * * <----DAI3-----> BT * * * * <----DAI4-----> DMIC * * * * <----DAI5-----> FM *************h]hXG ************* PCM0 <============> * * <----DAI0-----> Codec Headset * * PCM1 <------------> * * <====DAI1=====> Codec Speakers * DSP * PCM2 <------------> * * <----DAI2-----> MODEM * * PCM3 <------------> * * <----DAI3-----> BT * * * * <----DAI4-----> DMIC * * * * <----DAI5-----> FM *************}hjsbah}(h]h ]h"]h$]h&]j#j$uh1jhhhKOhj;hhubh)}(h-The audio driver processes this as follows :-h]h-The audio driver processes this as follows :-}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK]hj;hhubhenumerated_list)}(hhh](h list_item)}(h,Machine driver receives Jack removal event. h]h)}(h+Machine driver receives Jack removal event.h]h+Machine driver receives Jack removal event.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK_hjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(h7Machine driver OR audio HAL disables the Headset path. h]h)}(h6Machine driver OR audio HAL disables the Headset path.h]h6Machine driver OR audio HAL disables the Headset path.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKahjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(hvDPCM runs the PCM trigger(stop), hw_free(), shutdown() operations on DAI0 for headset since the path is now disabled. h]h)}(huDPCM runs the PCM trigger(stop), hw_free(), shutdown() operations on DAI0 for headset since the path is now disabled.h]huDPCM runs the PCM trigger(stop), hw_free(), shutdown() operations on DAI0 for headset since the path is now disabled.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKchjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(h6Machine driver or audio HAL enables the speaker path. h]h)}(h5Machine driver or audio HAL enables the speaker path.h]h5Machine driver or audio HAL enables the speaker path.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKfhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(h|DPCM runs the PCM ops for startup(), hw_params(), prepare() and trigger(start) for DAI1 Speakers since the path is enabled. h]h)}(h{DPCM runs the PCM ops for startup(), hw_params(), prepare() and trigger(start) for DAI1 Speakers since the path is enabled.h]h{DPCM runs the PCM ops for startup(), hw_params(), prepare() and trigger(start) for DAI1 Speakers since the path is enabled.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]h ]h"]h$]h&]enumtypearabicprefixhsuffix.uh1jhj;hhhhhK_ubh)}(hIn this example, the machine driver or userspace audio HAL can alter the routing and then DPCM will take care of managing the DAI PCM operations to either bring the link up or down. Audio playback does not stop during this transition.h]hIn this example, the machine driver or userspace audio HAL can alter the routing and then DPCM will take care of managing the DAI PCM operations to either bring the link up or down. Audio playback does not stop during this transition.}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKkhj;hhubeh}(h]1example-dpcm-switching-playback-from-dai0-to-dai1ah ]h"]3example - dpcm switching playback from dai0 to dai1ah$]h&]uh1hhhhhhhhK6ubeh}(h] descriptionah ]h"] descriptionah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hDPCM machine driverh]hDPCM machine driver}(hjKhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjHhhhhhKrubh)}(hhThe DPCM enabled ASoC machine driver is similar to normal machine drivers except that we also have to :-h]hhThe DPCM enabled ASoC machine driver is similar to normal machine drivers except that we also have to :-}(hjYhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKthjHhhubj)}(hhh](j)}(h Define the FE and BE DAI links. h]h)}(hDefine the FE and BE DAI links.h]hDefine the FE and BE DAI links.}(hjnhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKwhjjubah}(h]h ]h"]h$]h&]uh1jhjghhhhhNubj)}(h!Define any FE/BE PCM operations. h]h)}(h Define any FE/BE PCM operations.h]h Define any FE/BE PCM operations.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKyhjubah}(h]h ]h"]h$]h&]uh1jhjghhhhhNubj)}(h"Define widget graph connections. h]h)}(h Define widget graph connections.h]h Define widget graph connections.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK{hjubah}(h]h ]h"]h$]h&]uh1jhjghhhhhNubeh}(h]h ]h"]h$]h&]j%j&j'hj(j)uh1jhjHhhhhhKwubh)}(hhh](h)}(hFE and BE DAI linksh]hFE and BE DAI links}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubj)}(hX| 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 *************h]hX| 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 *************}hjsbah}(h]h ]h"]h$]h&]j#j$uh1jhhhKhjhhubh)}(hxFor the example above we have to define 4 FE DAI links and 6 BE DAI links. The FE DAI links are defined as follows :- ::h]huFor the example above we have to define 4 FE DAI links and 6 BE DAI links. The FE DAI links are defined as follows :-}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hXSND_SOC_DAILINK_DEFS(pcm0, DAILINK_COMP_ARRAY(COMP_CPU("System Pin")), DAILINK_COMP_ARRAY(COMP_DUMMY()), DAILINK_COMP_ARRAY(COMP_PLATFORM("dsp-audio"))); static struct snd_soc_dai_link machine_dais[] = { { .name = "PCM0 System", .stream_name = "System Playback", SND_SOC_DAILINK_REG(pcm0), .dynamic = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, }, .....< other FE and BE DAI links here > };h]hXSND_SOC_DAILINK_DEFS(pcm0, DAILINK_COMP_ARRAY(COMP_CPU("System Pin")), DAILINK_COMP_ARRAY(COMP_DUMMY()), DAILINK_COMP_ARRAY(COMP_PLATFORM("dsp-audio"))); static struct snd_soc_dai_link machine_dais[] = { { .name = "PCM0 System", .stream_name = "System Playback", SND_SOC_DAILINK_REG(pcm0), .dynamic = 1, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, }, .....< other FE and BE DAI links here > };}hjsbah}(h]h ]h"]h$]h&]j#j$uh1jhhhKhjhhubh)}(hXThis 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``. 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).h](htThis 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 }(hjhhhNhNubhliteral)}(h``dynamic = 1``h]h dynamic = 1}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh. 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).}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hThe FE DAI above sets the codec and code DAIs to dummy devices since the BE is dynamic and will change depending on runtime config.h]hThe FE DAI above sets the codec and code DAIs to dummy devices since the BE is dynamic and will change depending on runtime config.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h+The BE DAIs are configured as follows :- ::h]h(The BE DAIs are configured as follows :-}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hXESND_SOC_DAILINK_DEFS(headset, DAILINK_COMP_ARRAY(COMP_CPU("ssp-dai.0")), DAILINK_COMP_ARRAY(COMP_CODEC("rt5640.0-001c", "rt5640-aif1"))); static struct snd_soc_dai_link machine_dais[] = { .....< FE DAI links here > { .name = "Codec Headset", SND_SOC_DAILINK_REG(headset), .no_pcm = 1, .ignore_suspend = 1, .ignore_pmdown_time = 1, .be_hw_params_fixup = hswult_ssp0_fixup, .ops = &haswell_ops, }, .....< other BE DAI links here > };h]hXESND_SOC_DAILINK_DEFS(headset, DAILINK_COMP_ARRAY(COMP_CPU("ssp-dai.0")), DAILINK_COMP_ARRAY(COMP_CODEC("rt5640.0-001c", "rt5640-aif1"))); static struct snd_soc_dai_link machine_dais[] = { .....< FE DAI links here > { .name = "Codec Headset", SND_SOC_DAILINK_REG(headset), .no_pcm = 1, .ignore_suspend = 1, .ignore_pmdown_time = 1, .be_hw_params_fixup = hswult_ssp0_fixup, .ops = &haswell_ops, }, .....< other BE DAI links here > };}hj1sbah}(h]h ]h"]h$]h&]j#j$uh1jhhhKhjhhubh)}(hxThis 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.h](hTThis BE DAI link connects DAI0 to the codec (in this case RT5460 AIF1). It sets the }(hj?hhhNhNubj)}(h ``no_pcm``h]hno_pcm}(hjGhhhNhNubah}(h]h ]h"]h$]h&]uh1jhj?ubh flag to mark it has a BE.}(hj?hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hThe 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 :- ::h]hThe 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 :-}(hj_hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hXG ************* PCM0 <------------> * * <----DAI0-----> Codec Headset * * PCM1 <------------> * * <----DAI1-----> Codec Speakers * DSP * PCM2 <------------> * * <====DAI2=====> MODEM * * PCM3 <------------> * * <====DAI3=====> BT * * * * <----DAI4-----> DMIC * * * * <----DAI5-----> FM *************h]hXG ************* PCM0 <------------> * * <----DAI0-----> Codec Headset * * PCM1 <------------> * * <----DAI1-----> Codec Speakers * DSP * PCM2 <------------> * * <====DAI2=====> MODEM * * PCM3 <------------> * * <====DAI3=====> BT * * * * <----DAI4-----> DMIC * * * * <----DAI5-----> FM *************}hjmsbah}(h]h ]h"]h$]h&]j#j$uh1jhhhKhjhhubh)}(haThis allows the host CPU to sleep while the DSP, MODEM DAI and the BT DAI are still in operation.h]haThis allows the host CPU to sleep while the DSP, MODEM DAI and the BT DAI are still in operation.}(hj{hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hkA BE DAI link can also set the codec to a dummy device if the codec is a device that is managed externally.h]hkA BE DAI link can also set the codec to a dummy device if the codec is a device that is managed externally.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h]Likewise a BE DAI can also set a dummy cpu DAI if the CPU DAI is managed by the DSP firmware.h]h]Likewise a BE DAI can also set a dummy cpu DAI if the CPU DAI is managed by the DSP firmware.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]fe-and-be-dai-linksah ]h"]fe and be dai linksah$]h&]uh1hhjHhhhhhKubh)}(hhh](h)}(hFE/BE PCM operationsh]hFE/BE PCM operations}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hThe 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.h](h4The BE above also exports some PCM operations and a }(hjhhhNhNubj)}(h ``fixup``h]hfixup}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh 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.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(he.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. ::h]he.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.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hX_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 convert the FE rate to 48k, stereo */ rate->min = rate->max = 48000; channels->min = channels->max = 2; /* set DAI0 to 16 bit */ params_set_format(params, SNDRV_PCM_FORMAT_S16_LE); return 0; }h]hX_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 convert the FE rate to 48k, stereo */ rate->min = rate->max = 48000; channels->min = channels->max = 2; /* set DAI0 to 16 bit */ params_set_format(params, SNDRV_PCM_FORMAT_S16_LE); return 0; }}hjsbah}(h]h ]h"]h$]h&]j#j$uh1jhhhKhjhhubh)}(hPThe other PCM operation are the same as for regular DAI links. Use as necessary.h]hPThe other PCM operation are the same as for regular DAI links. Use as necessary.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h]fe-be-pcm-operationsah ]h"]fe/be pcm operationsah$]h&]uh1hhjHhhhhhKubh)}(hhh](h)}(hWidget graph connectionsh]hWidget graph connections}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hThe 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 :- ::h]hThe 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 :-}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjhhubj)}(h/* BE for codec Headset - DAI0 is dummy and managed by DSP FW */ {"DAI0 CODEC IN", NULL, "AIF1 Capture"}, {"AIF1 Playback", NULL, "DAI0 CODEC OUT"},h]h/* BE for codec Headset - DAI0 is dummy and managed by DSP FW */ {"DAI0 CODEC IN", NULL, "AIF1 Capture"}, {"AIF1 Playback", NULL, "DAI0 CODEC OUT"},}hj/sbah}(h]h ]h"]h$]h&]j#j$uh1jhhhMhjhhubeh}(h]widget-graph-connectionsah ]h"]widget graph connectionsah$]h&]uh1hhjHhhhhhMubeh}(h]dpcm-machine-driverah ]h"]dpcm machine driverah$]h&]uh1hhhhhhhhKrubh)}(hhh](h)}(hWriting a DPCM DSP driverh]hWriting a DPCM DSP driver}(hjPhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjMhhhhhMubh)}(hThe 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 :-h]hThe 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 :-}(hj^hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjMhhubj)}(hhh](j)}(h5Front End PCM DAIs - i.e. struct snd_soc_dai_driver. h]h)}(h4Front End PCM DAIs - i.e. struct snd_soc_dai_driver.h]h4Front End PCM DAIs - i.e. struct snd_soc_dai_driver.}(hjshhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjoubah}(h]h ]h"]h$]h&]uh1jhjlhhhhhNubj)}(h:DAPM graph showing DSP audio routing from FE DAIs to BEs. h]h)}(h9DAPM graph showing DSP audio routing from FE DAIs to BEs.h]h9DAPM graph showing DSP audio routing from FE DAIs to BEs.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jhjlhhhhhNubj)}(hDAPM widgets from DSP graph. h]h)}(hDAPM widgets from DSP graph.h]hDAPM widgets from DSP graph.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1jhjlhhhhhNubj)}(h Mixers for gains, routing, etc. h]h)}(hMixers for gains, routing, etc.h]hMixers for gains, routing, etc.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjubah}(h]h ]h"]h$]h&]uh1jhjlhhhhhNubj)}(hDMA configuration. h]h)}(hDMA configuration.h]hDMA configuration.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM"hjubah}(h]h ]h"]h$]h&]uh1jhjlhhhhhNubj)}(hBE AIF widgets. h]h)}(hBE AIF widgets.h]hBE AIF widgets.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM$hjubah}(h]h ]h"]h$]h&]uh1jhjlhhhhhNubeh}(h]h ]h"]h$]h&]j%j&j'hj(j)uh1jhjMhhhhhMubh)}(hItems 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 :- ::h]hItems 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 :-}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM&hjMhhubj)}(hzSND_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),h]hzSND_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),}hjsbah}(h]h ]h"]h$]h&]j#j$uh1jhhhM+hjMhhubh)}(hnThe BE AIF are used to connect the DSP graph to the graphs for the other component drivers (e.g. codec graph).h]hnThe BE AIF are used to connect the DSP graph to the graphs for the other component drivers (e.g. codec graph).}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM.hjMhhubeh}(h]writing-a-dpcm-dsp-driverah ]h"]writing a dpcm dsp driverah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(hHostless PCM streamsh]hHostless PCM streams}(hj:hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj7hhhhhM3ubh)}(hA hostless PCM stream is a stream that is not routed through the host CPU. An example of this would be a phone call from handset to modem. ::h]hA hostless PCM stream is a stream that is not routed through the host CPU. An example of this would be a phone call from handset to modem.}(hjHhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM5hj7hhubj)}(hXK ************* PCM0 <------------> * * <----DAI0-----> Codec Headset * * PCM1 <------------> * * <====DAI1=====> Codec Speakers/Mic * DSP * PCM2 <------------> * * <====DAI2=====> MODEM * * PCM3 <------------> * * <----DAI3-----> BT * * * * <----DAI4-----> DMIC * * * * <----DAI5-----> FM *************h]hXK ************* PCM0 <------------> * * <----DAI0-----> Codec Headset * * PCM1 <------------> * * <====DAI1=====> Codec Speakers/Mic * DSP * PCM2 <------------> * * <====DAI2=====> MODEM * * PCM3 <------------> * * <----DAI3-----> BT * * * * <----DAI4-----> DMIC * * * * <----DAI5-----> FM *************}hjVsbah}(h]h ]h"]h$]h&]j#j$uh1jhhhM9hj7hhubh)}(hIn this case the PCM data is routed via the DSP. The host CPU in this use case is only used for control and can sleep during the runtime of the stream.h]hIn this case the PCM data is routed via the DSP. The host CPU in this use case is only used for control and can sleep during the runtime of the stream.}(hjdhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMGhj7hhubh)}(h3The host can control the hostless link either by :-h]h3The host can control the hostless link either by :-}(hjrhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMJhj7hhubh block_quote)}(hX}1. Configuring the link as a CODEC <-> CODEC style link. In this case the link is enabled or disabled by the state of the DAPM graph. This usually means there is a mixer control that can be used to connect or disconnect the path between both DAIs. 2. Hostless FE. This FE has a virtual connection to the BE DAI links on the DAPM graph. Control is then carried out by the FE as regular PCM operations. This method gives more control over the DAI links, but requires much more userspace code to control the link. Its recommended to use CODEC<->CODEC unless your HW needs more fine grained sequencing of the PCM ops. h]j)}(hhh](j)}(hConfiguring the link as a CODEC <-> CODEC style link. In this case the link is enabled or disabled by the state of the DAPM graph. This usually means there is a mixer control that can be used to connect or disconnect the path between both DAIs. h]h)}(hConfiguring the link as a CODEC <-> CODEC style link. In this case the link is enabled or disabled by the state of the DAPM graph. This usually means there is a mixer control that can be used to connect or disconnect the path between both DAIs.h]hConfiguring the link as a CODEC <-> CODEC style link. In this case the link is enabled or disabled by the state of the DAPM graph. This usually means there is a mixer control that can be used to connect or disconnect the path between both DAIs.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMLhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hXlHostless FE. This FE has a virtual connection to the BE DAI links on the DAPM graph. Control is then carried out by the FE as regular PCM operations. This method gives more control over the DAI links, but requires much more userspace code to control the link. Its recommended to use CODEC<->CODEC unless your HW needs more fine grained sequencing of the PCM ops. h]h)}(hXjHostless FE. This FE has a virtual connection to the BE DAI links on the DAPM graph. Control is then carried out by the FE as regular PCM operations. This method gives more control over the DAI links, but requires much more userspace code to control the link. Its recommended to use CODEC<->CODEC unless your HW needs more fine grained sequencing of the PCM ops.h]hXjHostless FE. This FE has a virtual connection to the BE DAI links on the DAPM graph. Control is then carried out by the FE as regular PCM operations. This method gives more control over the DAI links, but requires much more userspace code to control the link. Its recommended to use CODEC<->CODEC unless your HW needs more fine grained sequencing of the PCM ops.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMQhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]j%j&j'hj(j)uh1jhjubah}(h]h ]h"]h$]h&]uh1jhhhMLhj7hhubh)}(hhh](h)}(hCODEC <-> CODEC linkh]hCODEC <-> CODEC link}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMYubh)}(hThis DAI link is enabled when DAPM detects a valid path within the DAPM graph. The machine driver sets some additional parameters to the DAI link i.e. ::h]hThis DAI link is enabled when DAPM detects a valid path within the DAPM graph. The machine driver sets some additional parameters to the DAI link i.e.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM[hjhhubj)}(hXstatic const struct snd_soc_pcm_stream dai_params = { .formats = SNDRV_PCM_FMTBIT_S32_LE, .rate_min = 8000, .rate_max = 8000, .channels_min = 2, .channels_max = 2, }; static struct snd_soc_dai_link dais[] = { < ... more DAI links above ... > { .name = "MODEM", .stream_name = "MODEM", .cpu_dai_name = "dai2", .codec_dai_name = "modem-aif1", .codec_name = "modem", .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBP_CFP, .c2c_params = &dai_params, .num_c2c_params = 1, } < ... more DAI links here ... >h]hXstatic const struct snd_soc_pcm_stream dai_params = { .formats = SNDRV_PCM_FMTBIT_S32_LE, .rate_min = 8000, .rate_max = 8000, .channels_min = 2, .channels_max = 2, }; static struct snd_soc_dai_link dais[] = { < ... more DAI links above ... > { .name = "MODEM", .stream_name = "MODEM", .cpu_dai_name = "dai2", .codec_dai_name = "modem-aif1", .codec_name = "modem", .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBP_CFP, .c2c_params = &dai_params, .num_c2c_params = 1, } < ... more DAI links here ... >}hjsbah}(h]h ]h"]h$]h&]j#j$uh1jhhhM_hjhhubh)}(hThese parameters are used to configure the DAI hw_params() when DAPM detects a valid path and then calls the PCM operations to start the link. DAPM will also call the appropriate PCM operations to disable the DAI when the path is no longer valid.h]hThese parameters are used to configure the DAI hw_params() when DAPM detects a valid path and then calls the PCM operations to start the link. DAPM will also call the appropriate PCM operations to disable the DAI when the path is no longer valid.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMvhjhhubeh}(h]codec-codec-linkah ]h"]codec <-> codec linkah$]h&]uh1hhj7hhhhhMYubh)}(hhh](h)}(h Hostless FEh]h Hostless FE}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhM}ubh)}(hXJThe DAI link(s) are enabled by a FE that does not read or write any PCM data. This means creating a new FE that is connected with a virtual path to both DAI links. The DAI links will be started when the FE PCM is started and stopped when the FE PCM is stopped. Note that the FE PCM cannot read or write data in this configuration.h]hXJThe DAI link(s) are enabled by a FE that does not read or write any PCM data. This means creating a new FE that is connected with a virtual path to both DAI links. The DAI links will be started when the FE PCM is started and stopped when the FE PCM is stopped. Note that the FE PCM cannot read or write data in this configuration.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h] hostless-feah ]h"] hostless feah$]h&]uh1hhj7hhhhhM}ubeh}(h]hostless-pcm-streamsah ]h"]hostless pcm streamsah$]h&]uh1hhhhhhhhM3ubeh}(h] dynamic-pcmah ]h"] dynamic pcmah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjberror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(j<j9jEjBj8j5j=j:jJjGjjj j jBj?j4j1j4j1jjj,j)u nametypes}(j<jEj8j=jJjj jBj4j4jj,uh}(j9hjBhj5hj:j;jGjHjjj jj?jj1jMj1j7jjj)ju footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages](hsystem_message)}(hhh]h)}(hfPossible title underline, too short for the title. Treating it as ordinary text because it's so short.h]hhPossible title underline, too short for the title. Treating it as ordinary text because it’s so short.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]levelKtypeINFOlineK<sourcehuh1jhj;hhhhhK