Page 1 of 1

Custom pcm5122 based DAC, driver and control

Posted: Tue Jun 23, 2015 10:39 pm
by bastien
Hi all

I'm playing around a custom made DAC board made out of pcm5122
Because I'm using SPI, rather than I2C, I cannot use the hifiberry-dacplus driver
Instead, I use hifiberry-dac (based on pcm5120a, no control, I expect only i2s data), which does not do any SPI/I2C config, and I'm using some custom C++ prog, to set the required registers to make the pcm5122 blast some good tune

The thing is that I did not manage so far to hear anything. Been playing around registers, but no success
Running out of ideas, I've checked the pcm512x.h .c files, to see exactly what's going on there. I've found a couple of more registers that I can play with, but I've also found something inconsistent between code and datasheet

In pcm512x.h:

Code: Select all

#define PCM512x_VIRT_BASE 0x100
#define PCM512x_PAGE_LEN  0x100
#define PCM512x_PAGE_BASE(n)  (PCM512x_VIRT_BASE + (PCM512x_PAGE_LEN * n))

#define PCM512x_PAGE              0

#define PCM512x_RESET             (PCM512x_PAGE_BASE(0) +   1)
And according to the PCM5122 datasheet http://www.google.fr/url?sa=t&rct=j&q=& ... 9352,d.bGg page 75, there is nothing about the PCM512x_VIRT_BASE 0x100

Does anybody has an idea about this mismatch ? Is this a datasheet mistake ? Or maybe I missed something

Also, looks like there's a PCM512x-spi.h .c, but I've found no loadable module related to this... Maybe someone knows about it ?

Finally, I there's one more question. Using mplayer, I've seen that it specifies the output caracteristics to ALSA

Code: Select all

[root@alarmpi modules]# mplayer -ao alsa file:///var/lib/mpd/music/Holden\ \(2003\)/01-american_wheeze.mp3
MPlayer SVN-r37379 (C) 2000-2015 MPlayer Team
210 audio & 441 video codecs
do_connect: could not connect to socket
connect: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing file:///var/lib/mpd/music/Holden (2003)/01-american_wheeze.mp3.
libavformat version 56.25.101 (internal)
Audio only file format detected.
Clip info:
 Title: American Wheeze               
 Artist: Sixteen Horsepower            
 Album: Holden                        
 Year: 2003
 Comment:                             
 Track: 1
 Genre: Rock
==========================================================================
Opening audio decoder: [mpg123] MPEG 1.0/2.0/2.5 layers I, II, III
AUDIO: 44100 Hz, 2 ch, s16le, 192.0 kbit/13.61% (ratio: 24000->176400)
Selected audio codec: [mpg123] afm: mpg123 (MPEG 1.0/2.0/2.5 layers I, II, III)
==========================================================================
AO: [alsa] 44100Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
A:   3.9 (03.9) of 235.0 (03:55.0)  5.9% 

Exiting... (End of file)
[root@alarmpi modules]# 
"AO: [alsa] 44100Hz 2ch s16le (2 bytes per sample)" are those the caracs that should be set to the DAC ? Or there's more resampling happening ?

Cheers
Bastien

Re: Custom pcm5122 based DAC, driver and control

Posted: Wed Jun 24, 2015 12:07 am
by mikronauts
My friend, you have a lot of googling and learning to do.

- the pcm5122 is I2S (not I2C) based
- it CANNOT work with SPI or I2C

Google "Raspberry Pi i2s"

Re: Custom pcm5122 based DAC, driver and control

Posted: Wed Jun 24, 2015 7:40 am
by bastien
mikronauts wrote:My friend, you have a lot of googling and learning to do.

- the pcm5122 is I2S (not I2C) based
- it CANNOT work with SPI or I2C

Google "Raspberry Pi i2s"
My friend, you do have a lot of googling to do....
- pcm5122 get audio data with i2s, but requires to be configured by I2C or SPI (if not soldered in hardwired mode)
- it CAN work with SPI or I2C for the CONTROL flow, not the data flow

I've put a link to the pcm5122 datasheet in my previous post, I invite you to check it out

Re: Custom pcm5122 based DAC, driver and control

Posted: Wed Jun 24, 2015 1:27 pm
by mikronauts
Thank you my friend, I was talking about the data channel.

I understand that the configuration is i2c/spi based.

I was under the (apparently mistaken) impression you were trying to feed it the I2S data stream over I2C or SPI, for which I2C is far too slow, and SPI (unless DMA driven at a precise clock rate) is inappropriate.
bastien wrote:
mikronauts wrote:My friend, you have a lot of googling and learning to do.

- the pcm5122 is I2S (not I2C) based
- it CANNOT work with SPI or I2C

Google "Raspberry Pi i2s"
My friend, you do have a lot of googling to do....
- pcm5122 get audio data with i2s, but requires to be configured by I2C or SPI (if not soldered in hardwired mode)
- it CAN work with SPI or I2C for the CONTROL flow, not the data flow

I've put a link to the pcm5122 datasheet in my previous post, I invite you to check it out