diff --git a/source/platform/raspberry_pi4.rst b/source/platform/raspberry_pi4.rst index ea734de..70815f9 100644 --- a/source/platform/raspberry_pi4.rst +++ b/source/platform/raspberry_pi4.rst @@ -322,6 +322,92 @@ to **agmplay** for audio playback. To use aplay with AudioReach: .. note:: The arguments ``agm:100,100`` correspond to ``CARD=100`` and ``DEV=100`` as defined in the AGM virtual sound card configuration. Card ID ``100`` identifies the AGM virtual sound card (``virtualsndcard``), and device ID ``100`` refers to ``PCM100``, the playback PCM device defined under that card. For capture, device ID ``101`` (``PCM101``) would be used instead. These IDs are not fixed by the plugin itself — they are defined in the virtual sound card definition file and must match accordingly. +Audio Capture Use Case +---------------------- + +Capturing audio on the Rasbperry PI requires adding a HATS audio board that supports mic input. Codec Zero is one such board and is chosen for this guide. Follow the instructions to install and configure the Codec Zero audio board at: `Raspbery PI Audio Docs `_ + +Additionally update /boot/config.txt with the following changes: + + * Navigate to the file "/boot/config.txt" + * Locate the line **dtoverlay=vc4-kms-v3d** + * Change this line to **dtoverlay=vc4-kms-v3d,noaudio** + * Locate the commented out line **#dtparam=i2s=on** + * Uncomment it to become: **dtparam=i2s=on** + +.. note:: + **The Codec Zero device will need to be added manually to the Linux device tree to be enumerated by default.** + To have the Codec Zero board enumerated by default apply the patch file with the required device tree changes here: :download:`codecZeroDTChanges.patch <../static/codecZeroDTChanges.patch>` + +**Applying the Device Tree Patch** + +Before building the Yocto image, apply the provided patch to your Linux kernel source tree to add Codec Zero device tree support. + + * Navigate to the root of your Linux kernel source directory: + + .. code-block:: bash + + cd + + * Apply the patch using ``git apply``: + + .. code-block:: bash + + git apply codecZeroDTChanges.patch + + * Alternatively, apply using the ``patch`` command: + + .. code-block:: bash + + patch -p1 < codecZeroDTChanges.patch + + * Verify the patch was applied successfully: + + .. code-block:: bash + + git diff --stat + + * Rebuild the kernel and device tree blobs, then reflash the image onto the Raspberry Pi. + +**Running the Capture Use Case** + +To run the audio capture use case: + + * Turn on microphones and configure controls for Zero Codec card: + + .. code-block:: bash + + amixer -c 0 cset numid=23 on # Mic 1 Switch ON + amixer -c 0 cset numid=1 5 # Mic 1 Volume + amixer -c 0 cset numid=24 on # Mic 2 Switch ON + amixer -c 0 cset numid=2 5 # Mic 2 Volume + amixer -c 0 cset numid=27 on # ADC Switch + amixer -c 0 cset numid=5 114,114 # ADC Volume + amixer -c 0 cset numid=26 on # Mixin PGA Switch + amixer -c 0 cset numid=4 7,7 # Mixin PGA Volume + amixer -c 0 cset numid=73 on # Mixin Left Mic 1 ON + amixer -c 0 cset numid=74 off # Mixin Left Mic 2 OFF + amixer -c 0 cset numid=77 on # Mixin Right Mic 2 ON + amixer -c 0 cset numid=78 off # Mixin Right Mic 1 OFF + amixer -c 0 cset name='DAI Left Source MUX' 'ADC Left' + amixer -c 0 cset name='DAI Right Source MUX' 'ADC Right' + + * Ensure the **agm_server** is running in a terminal: + + .. code-block:: bash + + agm_server + + * Run the AGM capture use case: + + .. code-block:: bash + + agmcap /etc/rec.wav -D 100 -d 101 -i PCM_RT_PROXY-TX-2 + +The file /etc/rec.wav should contain stereo audio data captured from the MEMS microphones on the Codec Zero card. +Use SCP to copy the recorded wav files to your host machine to play/edit in your favorite audio editor. + + Troubleshooting =============== @@ -343,6 +429,9 @@ forgot to enable the sound cards (see section `Configure bootup settings <#confi :figclass: fig-left :scale: 100 % +When connected to the Codec Zero device the sound card list should read: + 0 [IQaudIOCODEC ]: IQaudIOCODEC - IQaudIOCODEC + Check the sound card ID ----------------------- diff --git a/source/static/codecZeroDTChanges.patch b/source/static/codecZeroDTChanges.patch new file mode 100644 index 0000000..b0bea1a --- /dev/null +++ b/source/static/codecZeroDTChanges.patch @@ -0,0 +1,38 @@ +diff --git a/arch/arm/boot/dts/broadcom/bcm2711-rpi-4-b.dts b/arch/arm/boot/dts/broadcom/bcm2711-rpi-4-b.dts +--- a/arch/arm/boot/dts/broadcom/bcm2711-rpi-4-b.dts ++++ b/arch/arm/boot/dts/broadcom/bcm2711-rpi-4-b.dts +@@ -38,6 +38,12 @@ sd_vcc_reg: regulator-sd-vcc { + enable-active-high; + gpio = <&expgpio 6 GPIO_ACTIVE_HIGH>; + }; ++ ++ iqaudio_dac: iqaudio_dac { ++ compatible = "iqaudio,iqaudio-codec"; ++ i2s-controller = <&i2s>; ++ status = "okay"; ++ }; + }; + + &bt { +@@ -402,10 +402,21 @@ &i2c0if { + &i2c1 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c1_pins>; + clock-frequency = <100000>; ++ ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ ++ da2713@1a { ++ #sound-dai-cells = <0>; ++ compatible = "dlg,da7213"; ++ reg = <0x1a>; ++ status = "okay"; ++ }; + }; + + &i2s { + pinctrl-names = "default"; + pinctrl-0 = <&i2s_pins>; + };