24

The Pi has a standard 3.5mm audio jack, but this cannot be used for audio input

However, we've got a load of GPIO pins on various interfaces. Would it be possible to recieve analog audio into the Pi via the GPIO?

Elinux tells me:

It is also possible to reconfigure GPIO connector pins P1-12 and 13 (chipset GPIO 18 and 21) to provide an I2S (a hardware modification may be required [12]) or PCM interface. However, PCM_FS and PCM_DIN (chipset pins 19 and 20) are needed for I2S or PCM.

There seem to be references to this I2S connection all over the place, but nowhere giving a clear yes or no.

ACarter
  • 2,220
  • 6
  • 23
  • 39

3 Answers3

15

As shown here you can get I2S via P5:

http://elinux.org/RPi_Low-level_peripherals#P5_header

And here is a kernel driver for using it:

http://blog.koalo.de/2013/05/i2s-support-for-raspberry-pi.html

koalo
  • 251
  • 2
  • 5
  • 1
    welcome to Raspberry Pi Stack Exchange! it's usually better if you don't post a link only answer (what if the linked resource becomes unavailable?), would you consider editing your answer to summarize salient points from the webpages you linked? – nc4pk May 21 '13 at 15:20
  • 4
    @Koalo 's work on the I2S driver is admirable, he should be given 2K rep just for blessing us with his presence. – Dog Ears May 24 '13 at 11:04
  • i must admit my ignorance and beg u to explain a little bit more: where is that p5 connector ? i have Hardware : BCM2835 Revision : a02082 it's a pi3 model B – L.Trabacchin Jan 21 '18 at 17:02
  • The PI 3 has the relevant pins integrated in the main connector. – koalo Jan 22 '18 at 09:59
  • this is still supported by RPi 4 right? I can not find PCM_DIN in the schematics. – a_bet Apr 13 '20 at 19:44
  • Should be the case. I have no Raspberry Pi 4 to verify this, but at least for 3B, they should be available. See https://raspberrypi.stackexchange.com/questions/79870/confirming-the-i2s-pins-on-raspberry-pi-3-model-b – koalo Apr 14 '20 at 11:27
14

The Peripherals datasheet for the BCM2835, used on the Raspberry Pi, gives you the answer in Chapter 8. I quote:

"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."

20 pages of information on this subject alone.

Like you said: not all the pins are available from the GPIO connector! PCM_FS and PCM_DIN (the one you probably need) are not on the GPIO connector, you'll need to check the schematic to see if you can reach those in some way.

UPDATE:

According to the schematics you're out of luck:

enter image description here

Sadly connected to nothing! No chance to get anything connected to that!!

But something odd is going on, if these pins are the actual missing I2S pins then the V2.0 board should also not have these pins on a connected. But the documentation states that is does have these pins available on the newly added connector P5. These are connected to different pins then the wiki says... This needs a little further investigation... soon more....

ikku
  • 4,454
  • 1
  • 24
  • 28
  • It was all looking so hopefull... I can get the output, but not the in! Thanks for finding that :) – ACarter Jan 06 '13 at 16:33
  • Hmmm, I don't seem to be able to find any reference of the PCM pins in the schematic... – ACarter Jan 06 '13 at 16:35
  • Me neigther, but I'm not finished looking yet, but chances don't look very good. – ikku Jan 06 '13 at 16:35
  • "Eben shouts from the bath that he's not actually sure we *have* lost it - it may just be hidden behind some GPIO muxes." ([not looking too good](http://www.raspberrypi.org/phpBB3/viewtopic.php?f=7&t=2631)) – ACarter Jan 06 '13 at 16:37
  • 1
    I guess I checked that already some time ago, that might be the reason why I ordered a USB audio plug on ebay like [this one](http://www.ebay.com/itm/New-Generic-USB-2-0-Audio-Headset-Microphone-Jack-Converter-Adapter-/120977066913?pt=Other_MP3_Player_Accessories&hash=item1c2acb8ba1) – ikku Jan 06 '13 at 16:39
  • I am searching for exactly that option.... – ikku Jan 06 '13 at 16:40
  • £1.13!!! I might just by one of those! DO you have it working with the Pi? – ACarter Jan 06 '13 at 16:53
  • Pitty those two pins aren't connected to anything... :( – ACarter Jan 06 '13 at 16:55
  • I must admit, I haven't gotten it out of the box yet.. no time to test with that thing yet, but I guess it will work.. (but it stays a guess).. Anyway the Rev 2.0 RPi board seems to HAVE these missing pins connected! – ikku Jan 06 '13 at 16:56
  • That's just annoying! – ACarter Jan 06 '13 at 17:00
  • Correction: the Rev 2.0 board do also NOT have these pins connected! – ikku Jan 06 '13 at 17:04
  • Oh? [this](http://www.raspberrypi.org/archives/1929) (scroll down to Additional I/O Expansion) seems to suggest they are, and you can use them! – ACarter Jan 06 '13 at 17:05
  • I did read the same, let me check & double check for a moment... – ikku Jan 06 '13 at 17:13
5

What revision of the board is this? The Rev B 512M has all four PCM pins mapped to the P5 connector. You'll have to add your own pins to the board but use the under side to still make use of the GPIO connector on the front.

On the schematic, Page 2, bottom left, look BCM2835-IO2 chip for the GPIO28-31 pins labelled as GEN7-10 corresponding to PCM Clk, Fs, DIn, DOut mapping to the P5 holes 3-6 respectively. This pin out would provide PCM when assigned as the Alt2 functionality.

gb

Gary
  • 51
  • 1