2.2 Using CLASSD under Linux
In a Linux environment, the CLASSD must be declared in the device tree. Examples can be derived from the demo board description files located here.
Adapt to your application case either by changing the .dts file and recompiling it or through an overlay.
For example, the SAM9X75-Curiosity board (EV31H43A)1 implements a single-ended mono (L-channel) power amplifier, visible in the at91-sam9x75_curiosity.dts file as a peripheral in the block:
&classd {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_classd_default>;
atmel,pwm-type = "single";
atmel,non-overlap-time = <20>;
status = "okay";
};
The amplifier also appears in the pin description:
&pinctrl {
classd {
pinctrl_classd_default: classd-default {
atmel,pins =
<AT91_PIOA 18 AT91_PERIPH_C (AT91_PINCTRL_PULL_UP | AT91_PINCTRL_SLEWRATE_DIS)>,
<AT91_PIOA 19 AT91_PERIPH_C (AT91_PINCTRL_PULL_UP | AT91_PINCTRL_SLEWRATE_DIS)>;
};
};
If your board does not use extra pins that can be attributed to the CLASSD, DTS can be extended to support Stereo Differential mode:
&classd {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_classd_default>;
atmel,pwm-type = "diff";
atmel,non-overlap-time = <20>;
status = "okay";
};
&pinctrl {
classd {
pinctrl_classd_default: classd-default {
atmel,pins =
<AT91_PIOA 15 AT91_PERIPH_C (AT91_PINCTRL_PULL_UP |
AT91_PINCTRL_SLEWRATE_DIS)>,
<AT91_PIOA 16 AT91_PERIPH_C (AT91_PINCTRL_PULL_UP |
AT91_PINCTRL_SLEWRATE_DIS)>,
<AT91_PIOA 17 AT91_PERIPH_C (AT91_PINCTRL_PULL_UP |
AT91_PINCTRL_SLEWRATE_DIS)>,
<AT91_PIOA 18 AT91_PERIPH_C (AT91_PINCTRL_PULL_UP |
AT91_PINCTRL_SLEWRATE_DIS)>,
<AT91_PIOA 19 AT91_PERIPH_C (AT91_PINCTRL_PULL_UP | AT91_PINCTRL_SLEWRATE_DIS)>;
<AT91_PIOA 20 AT91_PERIPH_C (AT91_PINCTRL_PULL_UP |
AT91_PINCTRL_SLEWRATE_DIS)>,
<AT91_PIOA 21 AT91_PERIPH_C (AT91_PINCTRL_PULL_UP |
AT91_PINCTRL_SLEWRATE_DIS)>,
<AT91_PIOA 22 AT91_PERIPH_C (AT91_PINCTRL_PULL_UP |
AT91_PINCTRL_SLEWRATE_DIS)>,
};
};
Once the CLASSD is correctly defined, it is recognized as an ALSA device and can be set up and volume-controlled by the Alsamixer program. The Aplay player can be used to stream sound from .wav files.
For example, on a Boot SD card, you can create a third partition called DATA and store a set of audio files in .wav format inside it. Once the processor has booted and launched Linux, type:
root (as the login password)
cd /mnt
mkdir DATA (to be done at first use only)
mount /dev/mmcblk0p3 /mnt/DATA
cd DATA
aplay YourFile.wav & (to execute in background)
alsamixer (to set volume whilst the stream operation runs in background, press Escape to close)
fg
Ctrl-C (to stop aplay before end of file)
- In early versions of the SAM9X75-Curiosity board, the Class D MOS transistor complementary pair SI3552DV must be replaced with FDC6327C for correct operation under load.
- The CLASSD power stage on the SAM9X75 Curiosity Pro board is functional but not optimized for the best audio quality. In some cases, audio performance may be limited. For better sound quality, use a separate and stable power supply for the CLASSD power stage.
