Skip to contentSkip to conversation

ALSA jack reporting API

PATCH New Mark Brown 2 participants 8 messages Jul 27, 2008 – Jul 28, 2008

Subsystems (2)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

cover ALSA jack reporting API

This patch series is a repost of the jack reporting API previously discussed on this list. Patch 1 is a cherry pick of the commit from the input subsystem (available from Linus' current tree) adding a switch type for reporting microphone insertion which could be skipped if Linus' current tree were merged in to ALSA.

author
#1 lore raw

PATCH 1/3 Input: add microphone insert switch definition

Add a new switch type to the input API for reporting microphone insertion. This will be used by the ALSA jack reporting API.

---
 include/linux/input.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
include/linux/input.h +1 -0
index d150c57..d297dec 100644
@@ -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)
 
Signature · 1 line
1.5.4.3
author
#2 lore raw

PATCH 2/3 ALSA: Add jack reporting API

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 |   72 ++++++++++++++++++++++
 sound/core/jack.c    |  163 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 236 insertions(+), 0 deletions(-)
 create mode 100644 include/sound/jack.h
 create mode 100644 sound/core/jack.c
include/sound/core.h +1 -0
index 558b962..1a4ff0b 100644
@@ -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 +72 -0

72 lines not on this page · raw message

sound/core/jack.c new file +163 -0

163 lines not on this page · raw message

Signature · 1 line
1.5.4.3
author
#3 lore raw

PATCH 3/3 ALSA: Build jack detection

Since jack detection requires the input subsystem which may not be desired on small systems it is not built unless required by a driver that is being built. Drivers using jack detection should use a pattern like this:

config SND_FOO

        tristate "..."
        ...
        select SND_JACK if INPUT=y || INPUT=SND

to ensure that the jack detection API is enabled if the input subsystem is. If the input subsystem is not enabled then a stub version of the API is provided.

---
 sound/core/Kconfig  |    3 +++
 sound/core/Makefile |    1 +
 2 files changed, 4 insertions(+), 0 deletions(-)
sound/core/Kconfig +3 -0
index 335d45e..acaa2ef 100644
@@ -12,6 +12,9 @@ config SND_HWDEP
 config SND_RAWMIDI
 	tristate
 
+config SND_JACK
+	bool
+
 config SND_SEQUENCER
 	tristate "Sequencer support"
 	select SND_TIMER
sound/core/Makefile +1 -0
index da8e685..d57125a 100644
@@ -7,6 +7,7 @@ snd-y     := sound.o init.o memory.o info.o control.o misc.o device.o
 snd-$(CONFIG_ISA_DMA_API) += isadma.o
 snd-$(CONFIG_SND_OSSEMUL) += sound_oss.o info_oss.o
 snd-$(CONFIG_SND_VMASTER) += vmaster.o
+snd-$(CONFIG_SND_JACK)	  += jack.o
 
 snd-pcm-objs := pcm.o pcm_native.o pcm_lib.o pcm_timer.o pcm_misc.o \
 		pcm_memory.o
Signature · 1 line
1.5.4.3
#4 lore raw

Re: [PATCH 3/3] ALSA: Build jack detection

At Sun, 27 Jul 2008 12:12:25 +0100,

Quoted 6 lines · Mark Brown

Since jack detection requires the input subsystem which may not be desired on small systems it is not built unless required by a driver that is being built. Drivers using jack detection should use a pattern like this:

Quoted 8 lines

config SND_FOO

        tristate "..."
        ...
        select SND_JACK if INPUT=y || INPUT=SND

to ensure that the jack detection API is enabled if the input subsystem is. If the input subsystem is not enabled then a stub version of the API is provided.

Would be nice to put this as a comment in sound/core/Kconfig.

thanks,

Takashi

author
#5 lore raw

Re: [PATCH 3/3] ALSA: Build jack detection

Quoted 1 line · Takashi Iwai

Would be nice to put this as a comment in sound/core/Kconfig.

Yeah, the need for that is one of the reasons why I originally made the requirement for INPUT unconditional - there's no good, idiomatic way to document any funny stuff like this. I suspect that once there's one user future users will just cargo cult them anyway.

#6 lore raw

Re: [PATCH 2/3] ALSA: Add jack reporting API

In reply to Mark Brown

At Sun, 27 Jul 2008 12:12:24 +0100,

Quoted 22 lines · Mark Brown
include/sound/jack.h new file +15 -0
new file mode 100644
index 0000000..6e12cae
@@ -0,0 +1,72 @@
+#ifndef __SOUND_JACK_H
+#define __SOUND_JACK_H
+#ifdef CONFIG_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);
+
+void snd_jack_report(struct snd_jack *jack, int status);
+
+#else
+
+int snd_jack_new(struct snd_card *card, const char *id, int type,
+		 struct snd_jack **jack)
+{

include/sound/jack.h line 25

Quoted 10 lines
include/sound/jack.h new file +10 -0
+	return 0;
+}
+
+void snd_jack_set_parent(struct snd_jack *jack, struct device *parent)
+{
+}
+
+void snd_jack_report(struct snd_jack *jack, int status)
+{
+}

They must be static inline.

include/sound/jack.h line 27

Quoted 2 lines
include/sound/jack.h new file +2 -0
+
+#endif

Missing #endif for __SOUND_JACK_H.

Takashi

author
#7 lore raw

Re: [PATCH 2/3] ALSA: Add jack reporting API

Quoted 5 lines · Takashi Iwai
Quoted 1 line · Mark Brown

+#endif

Missing #endif for __SOUND_JACK_H.

Dammit, wrong version of the series - will resend shortly.