I was wondering whether it is possible to write Linux Drivers for the 3.5mm jack to use it for non-audio purposes. How does the linux kernel identify that a device is inserted into the 3.5mm slot? What are the interfaces in the linux kernel I could use for this purpose?

  • Notice that many phones and tablets (running android/linux) detect whether some serial adaptor is connected to the 3.5mm jack upon starting up and redirect the serial console there -- but I don't think that the linux kernel has anything to say into it, or that it could just turn that on and off (I may be wrong, though). Anyways, that's highly device specific, you'll have to obtain some (possibly confidential) hardware manual. – mosvy Feb 12 at 8:35
  • and beware that that's 3.3v not 5v ! – mosvy Feb 12 at 8:39
  • Gautam are you talking about a specific piece of hardware here? There's no requirement for a computer to have a 3.5mm jack. Perhaps you're referring to a Pi or some other common SOC? But if this is the case you need to say so. – roaima Feb 12 at 9:43
  • No specific hardware in mind. Just wanted to ask in a general sense. – Gautam Ramakrishnan Feb 13 at 1:34

That jack is a part of your (possibly integrated) sound card, so you would have to write a driver for your sound card that treats it as something other than a sound card.


Not all 3.5mm jacks are capable of detecting that something is plugged in. It requires an extra hardware contact in the jack that is designed to become grounded if a plug is inserted, a pull-up resistor and a connection to a suitable GPIO input pin that can then be used for detection.

ALSA includes a programming interface for such detection, as most 3.5mm jacks tend to be connected to sound cards. If you are using such a jack for some other purpose (e.g. as an alternative serial port connector) and it has a plug detection contact, you might wire it into any suitable GPIO (General-Purpose Input/Output) input pin in your hardware. Then, if the chip the plug detection pin is wired to does not already have a GPIO driver, you might first write a generic GPIO driver for it, and then your design-specific plug detection driver on top of it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.