Support for button reporting on jacks
cover Support for button reporting on jacks
This patch series adds support for key reporting to the generic ALSA jack API. Currently a series of switches are supported, with the jack implementation assuming that only switches will be used. This isn't ideal for things like the simple buttons implemented in headsets which are used in the same way as keyboard keys and physically resemble them more closely than switches.
If this is applied I'd like if possible to merge the topic into the ASoC tree so that I can use it in machine drivers there.
The following changes since commit 57d54889cd00db2752994b389ba714138652e60c:
Linus Torvalds (1):
Linux 2.6.34-rc1
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound-2.6.git topic/jack
Mark Brown (2):
ALSA: Rename jack switch table in preparation for button support
ALSA: Add support for key reporting via the jack interface
include/sound/jack.h | 8 +++++ sound/core/jack.c | 71 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 73 insertions(+), 6 deletions(-)
PATCH 1/2 ALSA: Rename jack switch table in preparation for button support
Avoids confusion when we have button support.
--- sound/core/jack.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
sound/core/jack.c +6 -5
@@ -23,7 +23,7 @@#include <sound/jack.h> #include <sound/core.h> -static int jack_types[] = { +static int jack_switch_types[] = {SW_HEADPHONE_INSERT ,SW_MICROPHONE_INSERT ,SW_LINEOUT_INSERT ,
@@ -112,10 +112,10 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, jack->type = type; -for (i =0 ; i <ARRAY_SIZE (jack_types); i++) +for (i =0 ; i <ARRAY_SIZE (jack_switch_types); i++)if (type & (1 << i))input_set_capability (jack->input_dev,EV_SW , - jack_types[i]); + jack_switch_types[i]); err =snd_device_new (card,SNDRV_DEV_JACK , jack, &ops);if (err <0 )
@@ -163,10 +163,11 @@ void snd_jack_report(struct snd_jack *jack, int status)if (!jack)return ; -for (i =0 ; i <ARRAY_SIZE (jack_types); i++) { +for (i =0 ; i <ARRAY_SIZE (jack_switch_types); i++) {int testbit =1 << i;if (jack->type & testbit) -input_report_switch (jack->input_dev, jack_types[i], +input_report_switch (jack->input_dev, + jack_switch_types[i], status & testbit); }
Signature · 1 line
1.7.0
PATCH 2/2 ALSA: Add support for key reporting via the jack interface
In reply to Mark BrownSome devices provide support for detection of a small number of buttons on their jacks. One common implementation provides a single button, implemented by shorting the microphone to ground and detected along with microphone presence detection by detecting varying current draws on the microphone bias signal.
Provide support for up to three buttons via the jack interface. These default to reporting BTN_n but an API is provided to allow these to be remapped to other keys by the machine driver where it knows what the keys are. More keys can be added with ease if required.
This is only intended to support simple accessory button designs. If the interface is limiting then either creating a child device for the accessory or accessing the input device in the jack directly is recommended.
--- include/sound/jack.h | 8 ++++++ sound/core/jack.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 1 deletions(-)
include/sound/jack.h +8 -0
@@ -42,6 +42,11 @@ enum snd_jack_types {SND_JACK_MECHANICAL =0x0008 ,/* If detected separately */ SND_JACK_VIDEOOUT =0x0010 ,SND_JACK_AVOUT =SND_JACK_LINEOUT |SND_JACK_VIDEOOUT , + +/* Kept separate from switches to facilitate implementation */ +SND_JACK_BTN_0 =0x4000 , +SND_JACK_BTN_1 =0x2000 , + SND_JACK_BTN_2 = 0x1000, }; struct snd_jack {
@@ -50,6 +55,7 @@ struct snd_jack {int type;const char *id;char name[100 ]; +unsigned int key[3 ];/* Keep in sync with definitions above */ void *private_data;void (*private_free)(struct snd_jack *); };
@@ -59,6 +65,8 @@ struct snd_jack {int snd_jack_new (struct snd_card *card,const char *id,int type,struct snd_jack **jack);void snd_jack_set_parent (struct snd_jack *jack,struct device *parent); +int snd_jack_set_key (struct snd_jack *jack,enum snd_jack_types type, +int keytype);void snd_jack_report (struct snd_jack *jack,int status);
sound/core/jack.c +59 -1
84 lines not on this page · raw message
Signature · 1 line
1.7.0
At Wed, 17 Mar 2010 18:22:43 +0000,
Quoted 11 lines · Mark Brown
This patch series adds support for key reporting to the generic ALSA jack API. Currently a series of switches are supported, with the jack implementation assuming that only switches will be used. This isn't ideal for things like the simple buttons implemented in headsets which are used in the same way as keyboard keys and physically resemble them more closely than switches.
If this is applied I'd like if possible to merge the topic into the ASoC tree so that I can use it in machine drivers there.
Quoted 7 lines
The following changes since commit
57d54889cd00db2752994b389ba714138652e60c:
Linus Torvalds (1):Linux 2.6.34-rc1are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound-2.6.gittopic/jack
Looks good to me. I pulled the branch now.
Feel free to merge it back to asoc tree.
thanks,
Takashi
Quoted 8 lines
Mark Brown (2):
ALSA: Rename jack switch table in preparation for button support
ALSA: Add support for key reporting via the jack interfaceinclude/sound/jack.h | 8 +++++ sound/core/jack.c | 71 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 73 insertions(+), 6 deletions(-)