.. include:: /keyword.rst ===== Audio ===== .. contents:: Sections :local: :depth: 1 .. toctree:: :hidden: Genio 510/700/1200 -------------------------------------------- This chapter is designed to assist developers in the progress of porting audio drivers and software to the EVK. - :doc:`Genio 510/700/1200 ` .. _porting_codec: Integrating an External Audio Codec ----------------------------------- In some cases, customer may want to integrate an external audio codec to the platform. Here will introduce the DAI driver and DAI link, and explain what needs to be done to integrate an external audio codec. This diagram below describes the relationship between the platform device and the codec device. .. figure:: /_asset/sw_rity_porting-guide_audio_dai_link.svg :align: center :scale: 300% DAI link to connect platform and codec DAI driver is a software component that manages the audio interface and hardware. This driver is responsible for handling the data transfer between the audio processing units and the physical audio interface ports. The DAI driver reads the hardware description from the device tree, this includes information about the hardware interface, clock sources, pin multiplexing, and other platform specific settings. The DAI link abstracts the relationship between the audio interfaces on the platform side and the audio codec side. It specifies how the two components should interact, including data path, clock information, sample rate, number of channels, and format settings. When an audio stream is initiated, the ALSA framework uses the DAI link configuration to set up the audio path between the platform and codec. The DAI link ensures that both sides are synchronized in terms so that audio data is transmitted without errors and distortion. The DAI link is defined within the sound card node of the device tree. Here is an example of the DAI link for ``DL_SRC_BE`` on |G1200-EVK|. From ``codec-0``, you can determine that the codec connected to the ``DL_SRC`` DAI link is PMIC. .. prompt:: bash # auto &sound { compatible = "mediatek,mt8395-evk"; model = "mt8395-evk"; pinctrl-names = "default"; pinctrl-0 = <&aud_pins_default>; status = "okay"; dai-link-0 { sound-dai = <&afe>; dai-link-name = "DL_SRC_BE"; codec-0 { sound-dai = <&pmic 0>; }; }; For more details about the DAI link, please refer to the `mediatek,mt8395-evk.yaml `_. The codec connected by the DAI link may not always be hardware, it could also be software. Let take ``dai-link-5`` in the DTS file as an example, the codec connected to ``DMIC_BE`` is ``dmic_codec``. If you take the time to see what ``dmic_codec`` is about, you will find that this node is established in `mt8195.dtsi `_ It linked to the code `dmic.c `_ that actually adds a delay before ``dmic`` starts, aiming to prevent performance issues due to hardware not being set up yet. .. prompt:: bash # auto dai-link-5 { sound-dai = <&afe>; dai-link-name = "DMIC_BE"; codec-0 { sound-dai = <&dmic_codec>; }; }; The actual structure for the DAI link is established within the machine driver. .. prompt:: bash # auto static struct snd_soc_dai_link mt8195_mt6359_dai_links[] = { ... [DAI_LINK_DL_SRC_BE] = { .name = "DL_SRC_BE", .no_pcm = 1, .dpcm_playback = 1, SND_SOC_DAILINK_REG(DL_SRC_BE), }, For more DAI link instances, you can refer to the machine driver: `mt8395-evk.c `_. To summarize the above content, if you want to integrate an audio codec on the platform, please ensure that the following steps are completed. - Add a DTS file for the audio codec - Establish a DAI link in the ``&sound`` node in the DTS file - Connect the DAI link to the backend DAI driver - Connect the DAI link to the your codec driver After completing these steps, your platform should be able to recognize and use the external audio codec for audio processing tasks. Audio Interfaces ---------------- The following table will show the interfaces present on the SoC MT8370/MT8390. .. csv-table:: MT8370/MT8390 Audio Interfaces :file: /_asset/tables/audio-mt8390-interfaces.csv :width: 90% :header-rows: 1 The following table will show the interfaces present on the SoC MT8395. .. csv-table:: MT8395 Audio Interfaces :file: /_asset/tables/audio-mt8395-interfaces.csv :width: 90% :header-rows: 1 MT6365 is a power management system chip optimized for handsets and smart phones. This codec is used with the MT8370, MT8390, or MT8395 on the MediaTek platform. The following table will show the interfaces present on the PMIC MT6365. .. csv-table:: MT6365 Audio Interfaces :file: /_asset/tables/audio-mt6365-interfaces.csv :width: 90% :header-rows: 1