5

Hello fellow Stackers,

Is there a way to detect when a 3.5mm jack is placed into\ removed from the audio out that is on board for use in a script?

I also have one of these:

https://www.element14.com/community/community/raspberry-pi/raspberry-pi-accessories/cirrus_logic_audio_card

Mounted on a pi2 that I would like to be able to do the same with in the way of detection on its 3.5mm jacks.

I know that most modern computers are capable of this. Are our Pi's able to do this to?

Long version:

This will be so that I can use the Cirrus/Wolfson card outputs to play content from the Pi but pick up when an external source is plugged in (say my phone) and have a script. Be it bash or python etc. Mute the playing content to allow the connected device to play either directly to the speakers or be routed through the pi to the speakers somehow, presumable in the software, without having to use a manual toggle switch somewhere.

EDIT: Raspbian will be my go to distro but if anyone wants to suggest other distros more suited to this task feel free to suggest them. I will probably start out trying the distro listed on the element 14 site and work out form there.

Lime
  • 51
  • 4

2 Answers2

2

To the best of my knowledge, no models of the Pi or the Cirrus audio card offer this functionality.

Jack detection is generally done using additional contacts/switches in the jack socket which are closed when an object is inserted. The image below shows how this is achieved in the Fairchild FSA8049 switch. Without these contacts it will be complicated, if not impossible, to detect a jack insertion.

Fairchild FSA8049 audio jack detection switch

goobering
  • 10,750
  • 4
  • 40
  • 64
0

For the Cirrus audio card, i think they DO offer this functionality (at least on hardware). I am not sure on the software side, but i think you can hack the driver?

According to the schematic of the Cirrus card, at page 6, line in (mic in) jack have a detection pin goes to GPIO2, this applies to line out and headphone out as whell which goes to GPIO1 and JACKDET respectively. These 3 pins are all connected to the main WM5102 audio codec IC.

For RPi2, the 4-POLE A/V JACK did not provide jack detection functionality on hardware.

Glorfindel
  • 620
  • 1
  • 9
  • 16
Kong Chun Ho
  • 239
  • 2
  • 8