I have an idea of driving a stereo Class D output stage off the Raspberry Pi 2's GPIO pins, without analog filtering until just before the speakers. For that I'm using both channels of the PWM peripheral in serializer mode, clocked at PLLD/177 =~ 2824858 Hz, which is within 0.1% of the standard DSD64 sampling frequency of 2822400 Hz.
I've written two small test applications in C using bcm2835 library v1.51 from http://www.airspayce.com/mikem/bcm2835/
. I'll open a gitlab(or github) project shortly.
First app is demuxing and playing DSD64(SACD) sound files in .dsf format directly.
Second app is playing .wav/.flac files by running them through a 2nd order Sigma-Delta digital modulator with 64x upsampling to obtain the required ~2.8MHz sampling rate. The quality of conversion is not ideal, but I'm working on it (will need higher order to improve quantizer noise shaping).
These applications are CPU-intensive because DMA and VPU aren't used and the PWM FIFO is filled from the CPU.
In order to be usable, the code needs to be ported to a Linux driver to use DMA effectively, maybe with VPU acceleration for sigma-delta conversion part.
Can anyone recommend any resources about how to implement a simple playback-only ALSA driver (VPU acceleration included)?
I've found the codes to bcm2835 kernel driver, but it looks like just a glue logic to VPU firmware, which I didn't find sources to.
EDIT: I created a gitlab repository: https://gitlab.com/HITMAnsOFT/snd-bcm2835-dsd
Unfortunately, the .dsf player code was lost before the repo was created by my stupid mistake, but it's simple to reimplement. Basically all it was doing is parsing the headers, reshuffling data words and feeding the PWM FIFO, as the samples are already in correct format.