View previous topic :: View next topic |
Author |
Message |
musv Advocate
Joined: 01 Dec 2002 Posts: 3337 Location: de
|
Posted: Sun Nov 11, 2012 9:18 pm Post subject: Alsa: How to detect if headphones plugged? |
|
|
Hi there,
Currently I'm switching back from OSS4 to Alsa for several reasons. For OSS I wrote a script to change the volume by pressing some key combinations. This I want to adopt to the amixer settings.
amixer ALC269: | Simple mixer control 'Master',0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined
Playback channels: Mono
Limits: Playback 0 - 64
Mono: Playback 48 [75%] [-16.00dB] [on]
Simple mixer control 'Headphone',0
Capabilities: pvolume pswitch
Playback channels: Front Left - Front Right
Limits: Playback 0 - 64
Mono:
Front Left: Playback 54 [84%] [-9.00dB] [on]
Front Right: Playback 54 [84%] [-9.00dB] [on]
Simple mixer control 'Speaker',0
Capabilities: pvolume pswitch
Playback channels: Front Left - Front Right
Limits: Playback 0 - 64
Mono:
Front Left: Playback 53 [83%] [-10.00dB] [on]
Front Right: Playback 53 [83%] [-10.00dB] [on]
Simple mixer control 'PCM',0
Capabilities: pvolume
Playback channels: Front Left - Front Right
Limits: Playback 0 - 255
Mono:
Front Left: Playback 255 [100%] [0.00dB]
Front Right: Playback 255 [100%] [0.00dB]
Simple mixer control 'Mic',0
Capabilities: pvolume pswitch
Playback channels: Front Left - Front Right
Limits: Playback 0 - 31
Mono:
Front Left: Playback 0 [0%] [-34.50dB] [off]
Front Right: Playback 0 [0%] [-34.50dB] [off]
Simple mixer control 'Mic Boost',0
Capabilities: volume
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: 0 - 3
Front Left: 0 [0%] [0.00dB]
Front Right: 0 [0%] [0.00dB]
Simple mixer control 'Capture',0
Capabilities: cvolume cswitch
Capture channels: Front Left - Front Right
Limits: Capture 0 - 46
Front Left: Capture 29 [63%] [12.00dB] [on]
Front Right: Capture 29 [63%] [12.00dB] [on]
Simple mixer control 'Auto-Mute Mode',0
Capabilities: enum
Items: 'Disabled' 'Enabled'
Item0: 'Enabled'
Simple mixer control 'Internal Mic',0
Capabilities: pvolume pswitch
Playback channels: Front Left - Front Right
Limits: Playback 0 - 31
Mono:
Front Left: Playback 0 [0%] [-34.50dB] [off]
Front Right: Playback 0 [0%] [-34.50dB] [off]
Simple mixer control 'Internal Mic Boost',0
Capabilities: volume
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: 0 - 3
Front Left: 0 [0%] [0.00dB]
Front Right: 0 [0%] [0.00dB] |
Relevant for me are the following mixers:
Idea:
- When no headphones are plugged, my script should change the Speaker volume.
- If headphones are plugged, the script should change Headphone volume.
Problem:
I didn't find a state information, if the headphones are plugged or not. Neither in amixer settings nor in /proc/asound.
Is there a chance to find out the plugged-state? |
|
Back to top |
|
|
audiodef Watchman
Joined: 06 Jul 2005 Posts: 6639 Location: The soundosphere
|
|
Back to top |
|
|
Clad in Sky l33t
Joined: 04 May 2007 Posts: 887 Location: Germany
|
Posted: Mon Nov 12, 2012 4:40 pm Post subject: |
|
|
There's this in the kernel for SND_HDA_INTEL. So if you have an intel chip, this might work. Dunno how to actually get the information via the input layer, though.
# CONFIG_SND_HDA_INPUT_JACK is not set _________________ Kali Ma
Now it's autumn of the aeons
Dance with your sword
Now it's time for the harvest |
|
Back to top |
|
|
audiodef Watchman
Joined: 06 Jul 2005 Posts: 6639 Location: The soundosphere
|
|
Back to top |
|
|
PaulBredbury Watchman
Joined: 14 Jul 2005 Posts: 7310
|
Posted: Mon Nov 12, 2012 7:50 pm Post subject: |
|
|
audiodef wrote: | diff the contents of /dev |
Also hda-verb. |
|
Back to top |
|
|
musv Advocate
Joined: 01 Dec 2002 Posts: 3337 Location: de
|
Posted: Mon Nov 12, 2012 9:00 pm Post subject: |
|
|
audiodef wrote: | That's possible only if it's supported by hardware. |
That's not the problem. If the headphones are plugged, the speakers are mute and the sound is played via the headphones and viceversa.
Thanks, that looks like what I was looking for. I'll study that later. |
|
Back to top |
|
|
audiodef Watchman
Joined: 06 Jul 2005 Posts: 6639 Location: The soundosphere
|
|
Back to top |
|
|
|