Skip to contentSkip to conversation

How can you tell if the speaker jack on your sound card has anything plugged into it???

DISCUSSION Sean Thayne 6 participants 12 messages Apr 25, 2008

lore
Share & tools
lore
#0 lore raw

Hi Everybody,

I was talking with some users in the irc channel in the free node,
and was hoping to find a way to get the information about weither or not anything was plugged into the sound card, I've seen this feature with windows vista. I search thru a bunch of documentation sites and also scanned the /proc & /sys to no avail...

Thanks,
Sean T

#1 lore raw
Quoted 5 lines · Sean Thayne

I was talking with some users in the irc channel in the free node,
and was hoping to find a way to get the information about weither or not anything was plugged into the sound card, I've seen this feature with windows vista. I search thru a bunch of documentation sites and also scanned the /proc & /sys to no avail...

There's currently no standard way of getting this information from user space even where the hardware provides it.

#2 lore raw

How would one go about getting this info? I'm trying to create a monitoring tool for a specific sound card, so the driver's standardized...

Quoted 15 lines · Mark Brown
Quoted 6 lines · Sean Thayne

I was talking with some users in the irc channel in the free node,
and was hoping to find a way to get the information about weither or not anything was plugged into the sound card, I've seen this feature with windows vista. I search thru a bunch of documentation sites and also scanned the /proc & /sys to no avail...

There's currently no standard way of getting this information from user space even where the hardware provides it.

Signature · 8 lines
Sean Thayne
Summit Media Group LLC.
5532 Lillehammer Lane, Suite 300
Park City, UT 84098
T: (435) 575-0610 ext 115
F: (435) 615-9979
E: [email protected] <mailto:[email protected]>
W: http://www.smgroupllc.com
#3 lore raw
Quoted 2 lines · Sean Thayne

How would one go about getting this info? I'm trying to create a monitoring tool for a specific sound card, so the driver's standardized...

First, the hardware has to detect insertion. Then, it has to send a signal to the driver (either via a status register or an interrupt).

Assuming you have all that (I've never seen a sound card that provides this info), perhaps you can specify the output jack only when something is plugged in? That is, you register the output jack when something is plugged in, and then deregister it when something is removed.

#4 lore raw

How do you think Vista does it? I've used a couple of different computers (totally different hardware) and it can detect insertion for them all...

Quoted 21 lines · Timur Tabi
Quoted 3 lines · Sean Thayne

How would one go about getting this info? I'm trying to create a monitoring tool for a specific sound card, so the driver's standardized...

First, the hardware has to detect insertion. Then, it has to send a signal to the driver (either via a status register or an interrupt).

Assuming you have all that (I've never seen a sound card that provides this info), perhaps you can specify the output jack only when something is plugged in? That is, you register the output jack when something is plugged in, and then deregister it when something is removed.

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

Signature · 8 lines
Sean Thayne
Summit Media Group LLC.
5532 Lillehammer Lane, Suite 300
Park City, UT 84098
T: (435) 575-0610 ext 115
F: (435) 615-9979
E: [email protected] <mailto:[email protected]>
W: http://www.smgroupllc.com
#5 lore raw
Quoted 3 lines · Sean Thayne

How do you think Vista does it? I've used a couple of different computers (totally different hardware) and it can detect insertion for them all...

Since I've never used Vista, I have no idea how it does it. However, my point still stands: unless the hardware detects it and provide status information to the driver, there's nothing you can do.

So just figure out how your hardware provides the info, and then update your driver accordingly.

#7 lore raw
In reply to Mark Brown
Quoted 2 lines · Mark Brown

There's currently no standard way of getting this information from user space even where the hardware provides it.

Isn't the event api switch "SW_HEADPHONE_INSERT" standard ? I thought it was designed for such use.

If I'm not mistaken, the Neo teams handles it that way, as I do for the mio :
-> input_report_switch(mioa701_evdev, SW_HEADPHONE_INSERT, val);

--
Robert

#8 lore raw
Quoted 10 lines · Robert Jarzmik
Quoted 2 lines · Mark Brown

There's currently no standard way of getting this information from user space even where the hardware provides it.

Isn't the event api switch "SW_HEADPHONE_INSERT" standard ? I thought it was designed for such use.

If I'm not mistaken, the Neo teams handles it that way, as I do for the mio :
-> input_report_switch(mioa701_evdev, SW_HEADPHONE_INSERT, val);

AFAIK HDA generally supports Jack Sensing. However
it's not wired up properly on all hardware. And there's no driver support in the Linux HDA driver to generate an input device for jack sensing.

But I might be mistaken. Takashi and Jaroslav know the current state of Jack Sensing on Linux much better.

Lennart

Signature · 3 lines
Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net         ICQ# 11060553
http://0pointer.net/lennart/           GnuPG 0x1A015CC4
#9 lore raw
In reply to Robert Jarzmik

The snd_hda_intel driver does this internally to mute the speakers when headphones are plugged in. Ditto for front mic. But you are right, we need a standard way of tracking this. I am exploring the HAL interface now to see what I can learn from it. And most sound chips have an insert detection mechanism. Usually they are wired to specific jacks, but sometimes they just register a change in plug state, and read the jack's impedance levels to know which jack is used. It is documented in the Sigmatel/IDT, Realtek, and Analog Devices codec PRMs.

Tobin

Quoted 17 lines · Robert Jarzmik
Quoted 2 lines · Mark Brown

There's currently no standard way of getting this information from user space even where the hardware provides it.

Isn't the event api switch "SW_HEADPHONE_INSERT" standard ? I thought it was designed for such use.

If I'm not mistaken, the Neo teams handles it that way, as I do for the mio :
-> input_report_switch(mioa701_evdev, SW_HEADPHONE_INSERT, val);

--
Robert

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

Signature · 5 lines
Tobin Davis 


All of the true things I am about to tell you are shameless lies.
		-- The Book of Bokonon / Kurt Vonnegut Jr.
#11 lore raw
In reply to Robert Jarzmik
Quoted 2 lines · Robert Jarzmik

Isn't the event api switch "SW_HEADPHONE_INSERT" standard ? I thought it was designed for such use.

Yes. It'll also need extending to cover things that can detect jack insertions other than headphones (espcailly usefully for devices that can identify what is plugged into the jack).

Quoted 2 lines

If I'm not mistaken, the Neo teams handles it that way, as I do for the mio :
-> input_report_switch(mioa701_evdev, SW_HEADPHONE_INSERT, val);

Indeed, and hopefully it'll get more widely adopted, at least for embedded stuff. Unfortunately adoption is currently rather limited - the only in-tree users are the Zaurus machines.

I'm currently working on some helpers for ALSA for this.

#10 lore raw
In reply to Tobin Davis
Quoted 4 lines · Tobin Davis

The snd_hda_intel driver does this internally to mute the speakers when headphones are plugged in. Ditto for front mic. But you are right, we need a standard way of tracking this. I am exploring the HAL interface now to see what I can learn from it. And most sound chips have an

The interface I'd previously proposed here was to provide an input device per-jack which would do this - hal should then be able to monitor the input device. As suggested in the original message in the thread providing sysfs information would probably be helpful for scripts.

Quoted 4 lines

insert detection mechanism. Usually they are wired to specific jacks, but sometimes they just register a change in plug state, and read the jack's impedance levels to know which jack is used. It is documented in the Sigmatel/IDT, Realtek, and Analog Devices codec PRMs.

Yes, that's how all the codecs I've looked at do this.

#6 lore raw
In reply to Timur Tabi
Quoted 5 lines · Timur Tabi

First, the hardware has to detect insertion. Then, it has to send a signal to the driver (either via a status register or an interrupt).

Assuming you have all that (I've never seen a sound card that provides this info), perhaps you can specify the output jack only when something

This is supported in a reasonable proportion of CODEC chips these days, particularly those that have direct headphone and/or microphone support. It's more frequently used in mobile devices than desktops (since they tend to experience more plug/unplug events) but with the spread of laptops it's now fairly common in PC class hardware.

Quoted 2 lines

is plugged in? That is, you register the output jack when something is plugged in, and then deregister it when something is removed.

It's probably be easier from a UI perspective if the jack is always present in the UI but applications can tell if it's disabled - the physical jack is always there, after all.