Jack reporting
Subsystems (3)
cover Jack reporting
This is a repost of the the jack reporting API I posted recently. There are no chances since the last submission - as discussed in that thread the existing users and the need to support buttons implemented in jacks pushes me towards use of an input device to represent jacks.
PATCH 1/2 Add jack reporting API for ALSA
Currently very few systems provide information about jack status to user space, even though many have hardware facilities to do detection. Those systems that do use an input device with the existing SW_HEADPHONE_INSERT switch type to do so, often independently of ALSA.
This patch introduces a standard method for representing jacks to user space into ALSA. It allows drivers to register jacks for a sound card with the input subsystem, binding the input device to the card to help user space associate the input devices with their sound cards. The created input devices are named in the form "card longname jack" where jack is provided by the driver when allocating a jack. By default the parent for the input device is the sound card but this can be overridden by the card driver.
The existing user space API with SW_HEADPHONE_INSERT is preserved.
--- include/sound/core.h | 1 + include/sound/jack.h | 52 +++++++++++++++++ sound/Kconfig | 1 + sound/core/Makefile | 3 +- sound/core/jack.c | 157 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 213 insertions(+), 1 deletions(-) create mode 100644 include/sound/jack.h create mode 100644 sound/core/jack.c
include/sound/core.h +1 -0
@@ -63,6 +63,7 @@ typedef int __bitwise snd_device_type_t;#define SNDRV_DEV_INFO ((__force snd_device_type_t) 0x1006)#define SNDRV_DEV_BUS ((__force snd_device_type_t) 0x1007)#define SNDRV_DEV_CODEC ((__force snd_device_type_t) 0x1008) +#define SNDRV_DEV_JACK ((__force snd_device_type_t) 0x1009)#define SNDRV_DEV_LOWLEVEL ((__force snd_device_type_t) 0x2000)typedef int __bitwise snd_device_state_t ;
include/sound/jack.h new file +52 -0
52 lines not on this page · raw message
sound/Kconfig +1 -0
@@ -38,6 +38,7 @@ menu "Advanced Linux Sound Architecture" config SND tristate "Advanced Linux Sound Architecture" depends on SOUND + depends on INPUT help Say 'Y' or 'M' to enable ALSA (Advanced Linux Sound Architecture), the new base sound system.
sound/core/Makefile +2 -1
@@ -3,7 +3,8 @@ # Copyright (c) 1999,2001 by Jaroslav Kysela <[email protected]> # -snd-y := sound.o init.o memory.o info.o control.o misc.o device.o +snd-y := sound.o init.o memory.o info.o control.o misc.o device.o \ + jack.o snd-$(CONFIG_ISA_DMA_API) += isadma.o snd-$(CONFIG_SND_OSSEMUL) += sound_oss.o info_oss.o snd-$(CONFIG_SND_VMASTER) += vmaster.o
sound/core/jack.c new file +157 -0
157 lines not on this page · raw message
Signature · 1 line
1.5.6
PATCH 2/2 Add microphone and headset reporting
Add a new switch type to the input API for reporting microphone insertion and extend the ALSA jack reporting API to include this. Since a headset is a combination of a microphone and at least a mono headphone a convenience defintion is provided for describing them.
--- include/linux/input.h | 1 + include/sound/jack.h | 4 +++- sound/core/jack.c | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletions(-)
include/linux/input.h +1 -0
@@ -640,6 +640,7 @@ struct input_absinfo {#define SW_RFKILL_ALL 0x03/* rfkill master switch, type "any" set = radio enabled */ #define SW_RADIO SW_RFKILL_ALL/* deprecated */ +#define SW_MICROPHONE_INSERT 0x04/* set = inserted */ #define SW_MAX 0x0f#define SW_CNT (SW_MAX+1)
include/sound/jack.h +3 -1
@@ -32,7 +32,9 @@ struct input_dev;* bitmask. */ enum snd_jack_types { -SND_JACK_HEADPHONE =0x0001 , +SND_JACK_HEADPHONE =0x0001 , +SND_JACK_MICROPHONE =0x0002 , +SND_JACK_HEADSET =0x0003 ,/* Both microphone and headphone */ };struct snd_jack {
sound/core/jack.c +6 -0
@@ -102,6 +102,9 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,if (type &SND_JACK_HEADPHONE )input_set_capability (jack->input_dev,EV_SW ,SW_HEADPHONE_INSERT ); +if (type &SND_JACK_MICROPHONE ) +input_set_capability (jack->input_dev,EV_SW , +SW_MICROPHONE_INSERT ); err =snd_device_new (card,SNDRV_DEV_JACK , jack, &ops);if (err <0 )
@@ -147,6 +150,9 @@ void snd_jack_report(struct snd_jack *jack, int status)if (jack->type &SND_JACK_HEADPHONE )input_report_switch (jack->input_dev,SW_HEADPHONE_INSERT , status &SND_JACK_HEADPHONE ); +if (jack->type &SND_JACK_MICROPHONE ) +input_report_switch (jack->input_dev,SW_MICROPHONE_INSERT , + status &SND_JACK_MICROPHONE );input_sync (jack->input_dev); }
Signature · 1 line
1.5.6
Quoted 4 lines · Mark Brown
This is a repost of the the jack reporting API I posted recently. There are no chances since the last submission - as discussed in that thread the existing users and the need to support buttons implemented in jacks pushes me towards use of an input device to represent jacks.
Takashi, do you have any comments on these patches?
At Mon, 14 Jul 2008 16:11:00 +0100,
Quoted 8 lines · Mark Brown
Quoted 4 lines · Mark Brown
This is a repost of the the jack reporting API I posted recently. There are no chances since the last submission - as discussed in that thread the existing users and the need to support buttons implemented in jacks pushes me towards use of an input device to represent jacks.
Takashi, do you have any comments on these patches?
I have no strong opinion about this. Your implementation looks small enough. But, if Dmitry finds the input layer not suitable for such a purpose, this isn't a good way to go.
I think the question is how general and how extensible these features should be. If it's just a jack reporting, there are bunch of other possible implementations. Even ALSA control API could provide a similar functionality.
Takashi
Quoted 7 lines · Takashi Iwai
Quoted 1 line · Mark Brown
Takashi, do you have any comments on these patches?
I have no strong opinion about this. Your implementation looks small enough. But, if Dmitry finds the input layer not suitable for such a purpose, this isn't a good way to go.
Unfortunately Dimitry hasn't been responding to any of the e-mails on this subject since his initial one. :/
Quoted 2 lines
I think the question is how general and how extensible these features should be. If it's just a jack reporting, there are bunch of other
To reiterate points I've previously made:
As well as detecting the presence of a connected device typical jack detection implementations also support the implementation of at least one button which would require an input device for at least some jacks even if something else were done. This is consistent with existing usage of the input layer - it's similar to multimedia keys which are normally reported via the input layer. Things like sleep and power buttons are implemented as individual input devices.
We do also already have existing in-kernel users of the input API to report jack status (usually done via GPIOs outside of ALSA). From that point of view this ALSA helper is simply implementing the existing user space interface for reporting jacks. I feel that if we want to do something different we should work out how to transition these existing users to it too. We can always add the existing code while working out what that transition plan might be.
The concern Dmirty raised about requring an ioctl() to get the initial switch state seems to be something that ought to be addressed anyway regardless of what happens here. Similarly, the concerns about the resouce consumption of the input layer seem to be a general issue (and to be honest I'm not convinced that they're a practical problem).
Without the existing users of this interface and the button I'd probably agree with Dmitry but those two factors persuade me otherwise.
Quoted 2 lines
possible implementations. Even ALSA control API could provide a similar functionality.
This has most of the concerns that applied to the existing input API :(
Dmitry Torokhov
maintainerQuoted 12 lines · Mark Brown
Quoted 7 lines · Takashi Iwai
Quoted 1 line · Mark Brown
Takashi, do you have any comments on these patches?
I have no strong opinion about this. Your implementation looks small enough. But, if Dmitry finds the input layer not suitable for such a purpose, this isn't a good way to go.
Unfortunately Dimitry hasn't been responding to any of the e-mails on this subject since his initial one. :/
Completely my fault, I am verry sorry.
Quoted 5 lines
Quoted 2 lines
I think the question is how general and how extensible these features should be. If it's just a jack reporting, there are bunch of other
To reiterate points I've previously made:
Quoted 8 lines
As well as detecting the presence of a connected device typical jack detection implementations also support the implementation of at least one button which would require an input device for at least some jacks even if something else were done. This is consistent with existing usage of the input layer - it's similar to multimedia keys which are normally reported via the input layer. Things like sleep and power buttons are implemented as individual input devices.
It really depends on what you can do with this button. If it is just a simple circuit breaker then it is not really an input device. However is you can remap it for different purposes or map a regular key on a keybaord to perform this function then I will agree with you. For example sleep and power buttons can be anywhere. They can be implemented as ACPI button but there also a bunch of keyboards that have a sleep button on them. Or, like you said, multimedia keys - they not always control hardware directly, often you have an option to remap and re-use them.
Quoted 7 lines
We do also already have existing in-kernel users of the input API to report jack status (usually done via GPIOs outside of ALSA). From that point of view this ALSA helper is simply implementing the existing user space interface for reporting jacks. I feel that if we want to do something different we should work out how to transition these existing users to it too. We can always add the existing code while working out what that transition plan might be.
Yes, I agree, we would need to transit the existing users to the new scheme.
Signature · 1 line
Dmitry
Quoted 10 lines · Dmitry Torokhov
Quoted 3 lines · Mark Brown
As well as detecting the presence of a connected device typical jack detection implementations also support the implementation of at least one button which would require an input device for at least some jacks
It really depends on what you can do with this button. If it is just a simple circuit breaker then it is not really an input device. However is you can remap it for different purposes or map a regular key on a keybaord to perform this function then I will agree with you. For example
As far as the hardware is concerned it's just a button - if it's visible to software then there's no fixed function for it and any action taken will be application/system specific. There will normally be a side effect in hardware muting the microphone but that's not intended to be the main effect.
Dmitry Torokhov
maintainerQuoted 12 lines · Mark Brown
Quoted 10 lines · Dmitry Torokhov
Quoted 3 lines · Mark Brown
As well as detecting the presence of a connected device typical jack detection implementations also support the implementation of at least one button which would require an input device for at least some jacks
It really depends on what you can do with this button. If it is just a simple circuit breaker then it is not really an input device. However is you can remap it for different purposes or map a regular key on a keybaord to perform this function then I will agree with you. For example
Quoted 5 lines
As far as the hardware is concerned it's just a button - if it's visible to software then there's no fixed function for it and any action taken will be application/system specific. There will normally be a side effect in hardware muting the microphone but that's not intended to be the main effect.
Ok, let's add it to the input subsystem then. If we see lots of switch types sprnging up we cam talk about the new subsystem again.
I added the switch definition to input.h and it shoudl hit the mainline when I ask Linus to pull early next week.
Signature · 1 line
Dmitry
Quoted 2 lines · Dmitry Torokhov
I added the switch definition to
input.hand it shoudl hit the mainline when I ask Linus to pull early next week.
Excellent, thanks.
Takashi, what's the best way to handle the ALSA bits? The first patch doesn't depend on the new switch type so could be applied as-is but the second (adding the microphone switch type) depends on the input switch type being added - should I resubmit that when the switch type has been merged?
At Sun, 20 Jul 2008 13:17:48 +0100,
Quoted 6 lines · Mark Brown
Quoted 2 lines · Dmitry Torokhov
I added the switch definition to
input.hand it shoudl hit the mainline when I ask Linus to pull early next week.
Quoted 7 lines
Excellent, thanks.
Takashi, what's the best way to handle the ALSA bits? The first patch doesn't depend on the new switch type so could be applied as-is but the second (adding the microphone switch type) depends on the input switch type being added - should I resubmit that when the switch type has been merged?
Yes, please. We need also some consensus how to handle these patches covering both areas.
BTW, I'll be on vacation for the next week, so the reply will be delayed.
thanks,
Takashi
Quoted 10 lines · Takashi Iwai
Quoted 5 lines · Mark Brown
Takashi, what's the best way to handle the ALSA bits? The first patch doesn't depend on the new switch type so could be applied as-is but the second (adding the microphone switch type) depends on the input switch type being added - should I resubmit that when the switch type has been merged?
Yes, please. We need also some consensus how to handle these patches covering both areas.
OK, I'll add all the bits that apply to my patch queue for you. Hopefully we shouldn't find too many changes that need to touch both sides of things. For those that do hopefully we can do something similar to what we do with ARM and agree to merge both via one of the trees.
Quoted 2 lines
BTW, I'll be on vacation for the next week, so the reply will be delayed.
Enjoy your holiday!