IBM Portable PC
Posts: 46
Joined: Sun Apr 26, 2015 10:18 am
Location: Melbourne, Australia

GPIO G.711 PCM (not I2S) capture for VOIP apps etc

Sun Apr 26, 2015 11:27 am

I've Googled for hours but can't seem to find a clear answer to this question; is raw PCM input supported as yet? Clearly I2S is supported, at least for output, I guess there's not as much interest in capturing other PCM formats, such as G.711..........
Last edited by IBM Portable PC on Wed Apr 29, 2015 3:12 am, edited 2 times in total.

User avatar
DougieLawson
Posts: 41900
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: GPIO PCM (not I2S) capture

Sun Apr 26, 2015 1:25 pm

You can't run that stuff without additional hardware. It's a HifiBerry, IQAudio or Cirrus logic add-on that adds that stuff.
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on Twitter/LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: GPIO PCM (not I2S) capture

Sun Apr 26, 2015 2:24 pm

DougieLawson wrote:You can't run that stuff without additional hardware. It's a HifiBerry, IQAudio or Cirrus logic add-on that adds that stuff.
They are all I2S devices so out of scope for the OP. And I think they are all DACs not ADCs.
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

m-h
Posts: 18
Joined: Sun Jan 11, 2015 10:36 pm

Re: GPIO PCM (not I2S) capture

Sun Apr 26, 2015 2:56 pm

PeterO wrote: They are all I2S devices so out of scope for the OP. And I think they are all DACs not ADCs.
PeterO
Hi PeterO,
The Clac can record from Analogue, so it is a ADC
The others seem to be DAC only.
Greetz Marcel

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: GPIO PCM (not I2S) capture

Sun Apr 26, 2015 4:35 pm

marcel-heijkoop wrote:
PeterO wrote: They are all I2S devices so out of scope for the OP. And I think they are all DACs not ADCs.
PeterO
Hi PeterO,
The Clac can record from Analogue, so it is a ADC
The others seem to be DAC only.
Greetz Marcel
CLAC ?
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

IBM Portable PC
Posts: 46
Joined: Sun Apr 26, 2015 10:18 am
Location: Melbourne, Australia

Re: GPIO PCM (not I2S) capture

Sun Apr 26, 2015 11:39 pm

I've not played with raw PCM before, however if I have:

Serial stream
Stream Clock
Stream Framing
Master Clock (if required)

Then why do I need more logic?

I have the stream ready to connect, whilst the BCM2835 clearly supports PCM, and quite possibly down to 8 bits as telephony applications are a target market. From the Broadcom manual:


"The PCM audio interface is an APB peripheral providing input and output of telephony or high quality serial audio streams. It supports many classic PCM formats including I2S.
The PCM audio interface has 4 interface signals; PCM_CLK - bit clock.
PCM_FS - frame sync signal. PCM_DIN - serial data input. PCM_DOUT - serial data output.
PCM is a serial format with a single bit data_in and single bit data_out. Data is always serialised MS-bit first.
The frame sync signal (PCM_FS) is used to delimit the serial data into individual frames. The length of the frame and the size and position of the frame sync are fully programmable." (Page 119)



This thread look interesting, I'll try what's suggested:

viewtopic.php?f=51&t=105712&p=729330&hi ... io#p729330

IBM Portable PC
Posts: 46
Joined: Sun Apr 26, 2015 10:18 am
Location: Melbourne, Australia

Re: GPIO PCM (not I2S) capture

Mon Apr 27, 2015 11:55 am

From the link I posted in my previous post, thanks to slashusrbin.

I tried, his Broadcom 2835 suggestion and found an additional playback device via HDMI. However no additional recording devices:

pi@raspberrypi ~ $ modprobe snd_bcm2835
pi@raspberrypi ~ $ alsactl init
Found hardware: "bcm2835" "Broadcom Mixer" "" "" ""
Hardware is initialized using a generic method

pi@raspberrypi ~ $ modprobe snd_bcm2836
FATAL: Module snd_bcm2836 not found.

pi@raspberrypi ~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: UA1A [EDIROL UA-1A], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

pi@raspberrypi ~ $ arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: UA1A [EDIROL UA-1A], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0
pi@raspberrypi ~ $


So, I now believe that I don't need any more logic (between my PCM source and the Pi), however I do need a driver that adds a PCM capture device to the 2836/2835?

User avatar
DougieLawson
Posts: 41900
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: GPIO PCM (not I2S) capture

Mon Apr 27, 2015 12:04 pm

You need extra hardware. There's NO AUDIO OR VIDEO CAPTURE on a raspberry pi.
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on Twitter/LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: GPIO PCM (not I2S) capture

Mon Apr 27, 2015 12:07 pm

Am I missing something ?

Your title explicitly says "NOT I2S", yet everything in your last but one post points towards you using I2S.

Have you researched I2S to understand what it is and what it can do ?

"From Wikipedia, the free encyclopedia
I2S, also known as Inter-IC Sound, Integrated Interchip Sound, or IIS, is an electrical serial bus interface standard used for connecting digital audio devices together. It is used to communicate PCM audio data between integrated circuits in an electronic device."

PeterO
Last edited by PeterO on Mon Apr 27, 2015 12:16 pm, edited 1 time in total.
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

IBM Portable PC
Posts: 46
Joined: Sun Apr 26, 2015 10:18 am
Location: Melbourne, Australia

Re: GPIO PCM (not I2S) capture

Mon Apr 27, 2015 12:16 pm

PeterO wrote:Am I missing something ?

Your title explicitly says "NOT I2S", yet everything in your last post points towards you using I2S.

Have you researched I2S to understand what it is and what it can do ?

PeterO
PCM is not just I2S:

From Wikipedia "The I2S protocol outlines one specific type of PCM digital audio communication with defined parameters outlined in the Philips specification."
http://en.wikipedia.org/wiki/I%C2%B2S

From Page 119 of the Broadcom manual "The PCM audio interface is an APB peripheral providing input and output of telephony or high quality serial audio streams. It supports many classic PCM formats including I2S."

I am trying to capture a PCM stream that is another "classic PCM format" and not I2S formatted PCM.

IBM Portable PC
Posts: 46
Joined: Sun Apr 26, 2015 10:18 am
Location: Melbourne, Australia

Re: GPIO PCM (not I2S) capture

Mon Apr 27, 2015 12:19 pm

DougieLawson wrote:You need extra hardware. There's NO AUDIO OR VIDEO CAPTURE on a raspberry pi.
The Broadcom2836 DOES have an audio input i.e. discrete PCM.

This means that I either need:

1. A PCM stream to feed it.

2. A CODEC which will take another format, like analogue sound, and convert it to a PCM format the 2836 will accept i.e. a suitable ADC.

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: GPIO PCM (not I2S) capture

Mon Apr 27, 2015 12:26 pm

DougieLawson wrote:You need extra hardware. There's NO AUDIO OR VIDEO CAPTURE on a raspberry pi.
No one is asking about VIIDEO, and the PI DOES have pcm audio input which is what is being discussed (I now realise)
IBM Portable PC wrote:[
The Broadcom2836 DOES have an audio input i.e. discrete PCM.
This means that I either need:
1. A PCM stream to feed it.
2. A CODEC which will take another format, like analogue sound, and convert it to a PCM format the 2836 will accept i.e. a suitable ADC.
Yes either will work. I've used a PCM1803A as CODEC/ADC and it works just fine as long as it is clock master.

PeterO

PS
The manual says (top of page 121) "The length and polarity of the frame sync is fully programmable and it can be used as a standard frame sync signal, or as an L-R signal for I2S."

So it would seem a simple task to convert exisiting I2S setup code to generate PCM timing signals.

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
DougieLawson
Posts: 41900
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: GPIO PCM (not I2S) capture

Mon Apr 27, 2015 12:39 pm

How are you going to get the input signal into the RPi? Can it use a regular GPIO pin or does it need specialist hardware?
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on Twitter/LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

IBM Portable PC
Posts: 46
Joined: Sun Apr 26, 2015 10:18 am
Location: Melbourne, Australia

Re: GPIO PCM (not I2S) capture

Mon Apr 27, 2015 12:45 pm

DougieLawson wrote:How are you going to get the input signal into the RPi? Can it use a regular GPIO pin or does it need specialist hardware?
The GPIO on the Pi 2 Model B includes PCM input pins:

Pin 12 GPIO18 PCM_CLK
Pin 35 GPIO19 PCM_FS
Pin 38 GPIO20 PCM_DIN

For PCM Output:
Pin 40 GPIO21 PCM_DOUT

IBM Portable PC
Posts: 46
Joined: Sun Apr 26, 2015 10:18 am
Location: Melbourne, Australia

Re: GPIO PCM (not I2S) capture

Mon Apr 27, 2015 12:47 pm

PeterO wrote:
DougieLawson wrote:
So it would seem a simple task to convert exisiting I2S setup code to generate PCM timing signals.

PeterO
Simple it should be, however my preferred programming language is solder......... someone must be onto this? A PCM driver opens up all sorts of possibilities.

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: GPIO PCM (not I2S) capture

Mon Apr 27, 2015 12:49 pm

Someone will have to modify the I2S driver ! I'll have a look at the kernel code this evening :-)

Dougie, have a look at http://www.peteronion.org.uk/I2S/
I know it needs updating to include the working configuration I use when using Device Tree.
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
DougieLawson
Posts: 41900
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: GPIO PCM (not I2S) capture

Mon Apr 27, 2015 1:53 pm

PeterO wrote: Dougie, have a look at http://www.peteronion.org.uk/I2S/
I know it needs updating to include the working configuration I use when using Device Tree.
There's some extra external hardware you're using for that. So you're not doing it with an un-modified RPi.
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on Twitter/LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: GPIO PCM (not I2S) capture

Mon Apr 27, 2015 2:16 pm

DougieLawson wrote:
PeterO wrote: Dougie, have a look at http://www.peteronion.org.uk/I2S/
I know it needs updating to include the working configuration I use when using Device Tree.
There's some extra external hardware you're using for that. So you're not doing it with an un-modified RPi.
Are you asleep Dougie, because you seem to not be paying much attention to what is being written. No where have I said it was without extra hardware, infact I clearly said I was using an PCM1803 CODEC. And I've NOT modified the PI either !

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

drgeoff
Posts: 12417
Joined: Wed Jan 25, 2012 6:39 pm

Re: GPIO PCM (not I2S) capture

Mon Apr 27, 2015 6:10 pm

PeterO wrote:Are you asleep Dougie, because you seem to not be paying much attention to what is being written.
He's not asleep, far from it. But his unbounded enthusiasm to answer as many posts as possible forces him to speed read. He spots a few keywords and then responds to what he imagines was written. :(

It's a pity because when he does imagine correctly his replies are usually helpful.
Quis custodiet ipsos custodes?

IBM Portable PC
Posts: 46
Joined: Sun Apr 26, 2015 10:18 am
Location: Melbourne, Australia

Re: GPIO PCM (not I2S) capture

Mon Apr 27, 2015 10:48 pm

I'm going to take a closer look at the data sheets for existing Pi sound cards. There's a chance not all of the chips used talk I2S format with the 8253 on the Pi. One may just be PCM and that driver may work, provided its a play and capture driver.

I can't believe PCM has been so neglected, possible projects include:

Streams from DSP based devices (like my application)
MD players can be modded for PCM out
Set top boxes can be modded for PCM out
Digital radio also
Satellite radio
DAT players
Possible VOIP and other telephony applications
Some Bluetooth modules offer PCM in and out
Etc etc etc

IBM Portable PC
Posts: 46
Joined: Sun Apr 26, 2015 10:18 am
Location: Melbourne, Australia

Re: GPIO PCM (not I2S) capture

Mon Apr 27, 2015 10:49 pm

PeterO wrote:Someone will have to modify the I2S driver ! I'll have a look at the kernel code this evening :-)
PeterO
Many thanks! :D

IBM Portable PC
Posts: 46
Joined: Sun Apr 26, 2015 10:18 am
Location: Melbourne, Australia

Re: GPIO PCM (not I2S) capture

Mon Apr 27, 2015 11:11 pm

My application by the way, is to capture a stream from a DSP based device, specifically a TM320LC17, from the data sheet:

"In the serial mode, sign-magnitude linear PCM (13 magnitude bits plus 1 sign bit for μ-law format or 12 magnitude bits plus 1 sign bit for A-law format) is compressed to 8-bit sign-magnitude logarithmic PCM by the encoder and sent to the transmit register for transmission on an active framing pulse. The decoder converts 8-bit sign-magnitude log PCM from the serial port receive registers to sign-magnitude linear PCM.
Page 96

The specification for μ-law and A-law log PCM coding is part of the CCITT G.711 recommendation."

So a driver that works for me, will suit many telephony/VOIP projects and others.


Googling further, it appears that some have avoided the driver issue to some extender by using a VLSI DSP to transcode the PCM data:

search.php?keywords=Vs1063

The VS1063 appears to be able to convert G.711 to 16 bit PCM...........


A little more research and the VS1063 needs some code too operate.

I'm certain there's a software CODEC, used by VOIP apps, that works with ALSA. I'll keep searching along those lines.

IBM Portable PC
Posts: 46
Joined: Sun Apr 26, 2015 10:18 am
Location: Melbourne, Australia

Re: GPIO PCM (not I2S) capture

Tue Apr 28, 2015 2:57 am

After all of the above, it is clear that my application needs a BCM2836 driver which will capture PCM streams other than I2S from the GPIO, specifically in my case, G.711.

I guess I'll have to wait until Pi users turn their attention to VOIP and related applications.........

http://en.wikipedia.org/wiki/G.711




Although, like PeterO, I find this post by plugh, very interesting:
viewtopic.php?f=44&t=8496&p=604231#p604231

I may work through this, if all goes well, in the end (after a little tweaking), apart from the arecord example given by Plugh, I will hopefully be able to:

g.711 A-law mono: arecord -D hw:1,0 -f A_LAW -r 8000 -c 1 output.g711
g.711 mu-law mono: arecord -D hw:1,0 -f MU_LAW -r 8000 -c 1 output.g711

IBM Portable PC
Posts: 46
Joined: Sun Apr 26, 2015 10:18 am
Location: Melbourne, Australia

Re: GPIO G.711 PCM (not I2S) capture for VOIP apps etc

Thu Apr 30, 2015 11:50 am

Okay, so I'm not the first to go down this path:

Mefodey tried to connect a GSM module which also had a non I2S PCM connection.

viewtopic.php?f=44&t=8496&p=445697#p445697

glnmr
Posts: 1
Joined: Thu Mar 01, 2018 3:42 pm

Re: GPIO G.711 PCM (not I2S) capture for VOIP apps etc

Thu Mar 01, 2018 3:51 pm

Hi,

Has anyone had any success with Raspberry Pi's PCM (not I2S) interface?

To recap, in my case I'd like to connect a 3G device which has a PCM interface for voice (bothway) to the PCM pins on the RPi. (PCM_SYNC, PCM_DOUT, PCM_DIN & PCM_CLK).

I was expecting that I could configure the RPi to run aplay and arecord on the device to send and receive audio data respectively.

Any pointers as to how to configure the RPi appreciated.

Return to “Advanced users”