questions about asoc jack detection
Hi Mark,
I have a question wrt jack detection, suppose now I have internal speaker enabled and then headphone is inserted. According to the current jack code in asoc, the Headphone pin wil be enabled, but it does nothing to Internal Speaker. There is still sound coming out from speaker.
The possible solution is to let the application make the policy to switch the output source to Headphone, because the jack event can be observed. If we decide to let the userspace application make the policy, then why do we bother to enable the jack pin at the first place?
Hope I'm not missing something here. Could you provide some insights?
Thanks!
Signature · 1 line
guanqun
Quoted 4 lines · Lu Guanqun
I have a question wrt jack detection, suppose now I have internal speaker enabled and then headphone is inserted. According to the current jack code in asoc, the Headphone pin wil be enabled, but it does nothing to Internal Speaker. There is still sound coming out from speaker.
This is a policy question - depending on the use case the application may wish to still play sound out of the speaker. One obvious example here is ringtones on phones. If the user has been doing something like listen to music on headphones but then takes the headphones off they'll probably not hear anything that plays out of only the headphones so you should play ringtones out of both outputs in order to ensure that they are audible.
If you really want to you can add an invert to the hookup for a pin, but it's not recommended unless there's some physical reason both can't be enabled simultaneously.
Quoted 4 lines
The possible solution is to let the application make the policy to switch the output source to Headphone, because the jack event can be observed. If we decide to let the userspace application make the policy, then why do we bother to enable the jack pin at the first place?
If we can detect the physical presence of the output transducer it's not really a policy decision if it's worth enabling the audio path.
Quoted 7 lines · Mark Brown
Quoted 4 lines · Lu Guanqun
I have a question wrt jack detection, suppose now I have internal speaker enabled and then headphone is inserted. According to the current jack code in asoc, the Headphone pin wil be enabled, but it does nothing to Internal Speaker. There is still sound coming out from speaker.
Quoted 7 lines
This is a policy question - depending on the use case the application may wish to still play sound out of the speaker. One obvious example here is ringtones on phones. If the user has been doing something like listen to music on headphones but then takes the headphones off they'll probably not hear anything that plays out of only the headphones so you should play ringtones out of both outputs in order to ensure that they are audible.
Yes, it's related to policy. But I see some inconsistencies in handling this stuff. In this above example, you suggest we should play out of both outputs. However in HDA code, the common way when headphone is inserted is to mute the speaker and enable the headphone. Is there some differences between the HDA code and the ASoC code? Or this is just due to legacy code?
Quoted 12 lines
If you really want to you can add an invert to the hookup for a pin, but it's not recommended unless there's some physical reason both can't be enabled simultaneously.
Quoted 4 lines
The possible solution is to let the application make the policy to switch the output source to Headphone, because the jack event can be observed. If we decide to let the userspace application make the policy, then why do we bother to enable the jack pin at the first place?
If we can detect the physical presence of the output transducer it's not really a policy decision if it's worth enabling the audio path.
Signature · 1 line
guanqun
Quoted 6 lines · Lu Guanqun
Yes, it's related to policy. But I see some inconsistencies in handling this stuff. In this above example, you suggest we should play out of both outputs. However in HDA code, the common way when headphone is inserted is to mute the speaker and enable the headphone. Is there some differences between the HDA code and the ASoC code? Or this is just due to legacy code?
HDA code does this differently. I'd argue that they've taken the wrong implementation decision and that this should be a userspace issue but the use cases for PCs are a bit more basic.
Quoted 9 lines · Mark Brown
Quoted 6 lines · Lu Guanqun
Yes, it's related to policy. But I see some inconsistencies in handling this stuff. In this above example, you suggest we should play out of both outputs. However in HDA code, the common way when headphone is inserted is to mute the speaker and enable the headphone. Is there some differences between the HDA code and the ASoC code? Or this is just due to legacy code?
Quoted 3 lines
HDA code does this differently. I'd argue that they've taken the wrong implementation decision and that this should be a userspace issue but the use cases for PCs are a bit more basic.
I agree with you that this kind of policy should be put into userspace instead of hardcoding it in kernel.
Good to hear the points from you. Thanks!
Signature · 1 line
guanqun
Quoted 10 lines · Lu Guanqun
Quoted 9 lines · Mark Brown
Quoted 6 lines · Lu Guanqun
Yes, it's related to policy. But I see some inconsistencies in handling this stuff. In this above example, you suggest we should play out of both outputs. However in HDA code, the common way when headphone is inserted is to mute the speaker and enable the headphone. Is there some differences between the HDA code and the ASoC code? Or this is just due to legacy code?
Quoted 9 lines
Quoted 3 lines
HDA code does this differently. I'd argue that they've taken the wrong implementation decision and that this should be a userspace issue but the use cases for PCs are a bit more basic.
I agree with you that this kind of policy should be put into userspace instead of hardcoding it in kernel.
Good to hear the points from you. Thanks!
IIRC, the HDA jack detection code is pretty much legacy. It has been around longer than udev and other prior userspace hw detection systems.
That That doesn't mean it can't change.
Signature · 4 lines
Tobin Davis The Angels want to wear my red shoes. -- E. Costello
Quoted 15 lines · Tobin Davis
Quoted 14 lines · Lu Guanqun
Quoted 12 lines · Mark Brown
Quoted 6 lines · Lu Guanqun
Yes, it's related to policy. But I see some inconsistencies in handling this stuff. In this above example, you suggest we should play out of both outputs. However in HDA code, the common way when headphone is inserted is to mute the speaker and enable the headphone. Is there some differences between the HDA code and the ASoC code? Or this is just due to legacy code?
HDA code does this differently. I'd argue that they've taken the wrong implementation decision and that this should be a userspace issue but the use cases for PCs are a bit more basic.
Quoted 7 lines
Quoted 5 lines
I agree with you that this kind of policy should be put into userspace instead of hardcoding it in kernel.
Good to hear the points from you. Thanks!
IIRC, the HDA jack detection code is pretty much legacy. It has been around longer than udev and other prior userspace hw detection systems.
Thanks for your input.
Quoted 2 lines
That That doesn't mean it can't change.
Do we afford the changes? I don't think so. Lots of things have to be changed accordingly and if we fail to fix one stuff out of the whole chain, the end users will scream and yell at us: "You broke my PC." :)
Signature · 1 line
guanqun