.. include:: /keyword.rst ======================= MT6365 PMIC Audio Codec ======================= .. contents:: Sections :local: :depth: 2 This section discusses the PMIC Audio Codec, the ADC/DAC within the PMIC is used to convert between analog and digital signals. It will introduce operations related to the PMIC Audio Codec, such as headphone playback, microphone recording, etc., as well as explanations of the configuration of hardware gains within the PMIC. Finally, it will also explain the different configuration methods for microphone modes in the DTS. .. figure:: /_asset/sw_rity_porting-guide_audio_pmic-mt6365.svg :align: center :scale: 80% PMIC MT6365 Driver Command Usage -------------------- - Analog microphone The following commands are for analog microphones recording from AU_VIN0 and AU_VIN2. .. prompt:: bash # auto # amixer -c 0 cset name='O040 I168 Switch' 1 # amixer -c 0 cset name='O041 I169 Switch' 1 # amixer -c 0 cset name='ADC_L_Mux' 'Left Preamplifier' # amixer -c 0 cset name='PGA_L_Mux' 'AIN0' # amixer -c 0 cset name='ADC_R_Mux' 'Right Preamplifier' # amixer -c 0 cset name='PGA_R_Mux' 'AIN2' # arecord -Dhw:0,8 -c 2 -r 48000 -f S32_LE -d 10 amic_rec.wav - Headset microphone The following commands are for headset MIC recording from AU_VIN1. .. prompt:: bash # auto # amixer -c 0 cset name='O040 I168 Switch' 1 # amixer -c 0 cset name='O041 I169 Switch' 1 # amixer -c 0 cset name='MISO0_MUX' UL1_CH1 # amixer -c 0 cset name='MISO1_MUX' UL1_CH1 # amixer -c 0 cset name='ADC_L_Mux' 'Left Preamplifier' # amixer -c 0 cset name='PGA_L_Mux' 'AIN1' # arecord -Dhw:0,8 -c 2 -r 48000 -f S32_LE -d 10 hp_mic_rec.wav - Headset playback The following commands are for headset playback. .. prompt:: bash # auto # amixer -c 0 cset name='O176 I000 Switch' 1 # amixer -c 0 cset name='O177 I001 Switch' 1 # amixer -c 0 cset name='DAC In Mux' 'Normal Path' # amixer -c 0 cset name='HP Mux' 'Audio Playback' # amixer -c 0 cset name='LOL Mux' 'Open' # aplay -Dhw:0,2 -c 2 -r 48000 -f S32_LE -d 10 test.wav - Lineout playback The following commands are for lineout playback. .. prompt:: bash # auto # amixer -c 0 cset name='O176 I000 Switch' 1 # amixer -c 0 cset name='O177 I001 Switch' 1 # amixer -c 0 cset name='DAC In Mux' 'Normal Path' # amixer -c 0 cset name='HP Mux' 'Open' # amixer -c 0 cset name='LOL Mux' 'Playback_L_DAC' # aplay -Dhw:0,2 -c 2 -r 48000 -f S32_LE test.wav PGA Gain Setting and Block Diagram ---------------------------------- - PGA gain Within an audio signal chain, the gain of an audio signal can be adjusted via a PGA before it is fed into an analog-to-digital converter. For a PGA on a PMIC, it modifies the gain of the input signal directly without processing the volume of the signal in software. .. figure:: /_asset/sw_rity_porting-guide_audio_gain-pga.svg :align: center :scale: 100% PGA gain block diagram This is a reference table mapping PGA gain values with actual decibels. .. csv-table:: PGA gain setting :header: "Value", "dB" :encoding: utf-8 :width: 100% :widths: 50 50 "0", "0 dB" "1", "6 dB" "2", "12 dB" "3", "18 dB" "4", "24 dB" The PGA gain on the PMIC can be programmatically adjusted via ALSA control. These are the commands you can use to achieve dynamic volume control. .. prompt:: bash # auto # amixer -c 0 cset name='PGA1 Volume' 4 # amixer -c 0 cset name='PGA2 Volume' 4 # amixer -c 0 cset name='PGA3 Volume' 4 - Headset Gain This is a reference table mapping Headset Volume values with actual decibels. .. figure:: /_asset/sw_rity_porting-guide_audio_gain-headset.svg :align: center :scale: 100% Headset gain block diagram .. csv-table:: Headset volume setting :header: "Value", "dB" :encoding: utf-8 :width: 100% :widths: 50 50 "0", "+8 dB" "1", "+7 dB" "18", "-10 dB" "31", "-40 dB (mute)" This is the command you can use to achieve dynamic volume control: .. prompt:: bash # auto # amixer -c 0 cset name='Headset Volume' 0 - Lineout Gain This is a reference table mapping Lineout Volume values with actual decibels. .. figure:: /_asset/sw_rity_porting-guide_audio_gain-lineout.svg :align: center :scale: 100% Lineout gain block diagram .. csv-table:: Lineout volume setting :header: "Value", "dB" :encoding: utf-8 :width: 100% :widths: 50 50 "0", "+8 dB" "1", "+7 dB" "18", "-10 dB" "31", "-40 dB (mute)" This is the command you can use to achieve dynamic volume control: .. prompt:: bash # auto # amixer -c 0 cset name='Lineout Volume' 0 DTS Setting ----------- - There are different modes of microphones, you could update it for your selected microphone in the DTS file. .. csv-table:: Microphone modes :header: "Index", "Mode", "Description" :encoding: utf-8 :width: 100% :widths: 10 40 50 "1", "ACC", "for ACC mode input" "2", "DMIC", "for digital microphone" "3", "DCC", "for DCC mode input excluding ECM MIC" "4", "DCC_ECM_DIFF", "for ECM MIC differential mode" "5", "DCC_ECM_SINGLE", "for ECM MIC single-end mode" - Difference between ACC mode and DCC mode - ACC mode: analog microphone with alternating coupling (A capacitor is connected to AU_VINx) - DCC mode: analog microphone with direct coupling .. figure:: /_asset/sw_rity_porting-guide_audio_mic-acc.svg :align: center :scale: 60% ACC mode .. figure:: /_asset/sw_rity_porting-guide_audio_mic-dcc.svg :align: center :scale: 60% DCC mode On Genio 510/700/1200, **mic-type-0** is used for **AU_VIN0**, **mic-type-1** is used for **AU_VIN_1**, and **mic-type-2** is used for **AU_VIN2** and **AU_VIN3** in DTS file. Here is an example for setting the mic type in the |G1200-EVK| DTS file. .. prompt:: bash # auto &mt6359codec { mediatek,mic-type-0 = <1>; /* ACC */ mediatek,mic-type-1 = <3>; /* DCC */ mediatek,mic-type-2 = <1>; /* ACC */ }; If you want to integrate an external audio codec into the platform, please refer to :ref:`here `.