One missing piece for userspace (PulseAudio etc) to actually be able to use the jack input devices that ALSA create, is that these devices are accessible by root only. This patch makes the input device nodes accessible by the same users that can access the sound card: the current logged in user, as well as users in the audio group.
Signed-off-by: David Henningsson david.henningsson@canonical.com --- extras/input_id/input_id.c | 23 +++++++++++++++++++++++ extras/udev-acl/70-acl.rules | 1 + rules/rules.d/60-persistent-input.rules | 1 + 3 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/extras/input_id/input_id.c b/extras/input_id/input_id.c index ba53df0..814ce8e 100644 --- a/extras/input_id/input_id.c +++ b/extras/input_id/input_id.c @@ -189,6 +189,25 @@ static void test_key (struct udev *udev, puts("ID_INPUT_KEYBOARD=1"); }
+static void test_sound (struct udev_device *dev, + const unsigned long* bitmask_sw) +{ + + struct udev_device *snd_dev; + + /* Ensure parent is sound card */ + snd_dev = udev_device_get_parent_with_subsystem_devtype(dev, "sound", NULL); + if (!snd_dev) + return; + + /* Check that there is at least one relevant switch type */ + if (test_bit(SW_HEADPHONE_INSERT, bitmask_sw) || + test_bit(SW_MICROPHONE_INSERT, bitmask_sw) || + test_bit(SW_LINEOUT_INSERT, bitmask_sw) || + test_bit(SW_VIDEOOUT_INSERT, bitmask_sw)) + puts("ID_INPUT_SNDJACK=1"); +} + static void help(void) { printf("Usage: input_id [options] <device path>\n" @@ -212,6 +231,7 @@ int main (int argc, char** argv) unsigned long bitmask_abs[NBITS(ABS_MAX)]; unsigned long bitmask_key[NBITS(KEY_MAX)]; unsigned long bitmask_rel[NBITS(REL_MAX)]; + unsigned long bitmask_sw[NBITS(SW_MAX)];
udev = udev_new(); if (udev == NULL) @@ -272,10 +292,13 @@ int main (int argc, char** argv) get_cap_mask (dev, "capabilities/abs", bitmask_abs, sizeof (bitmask_abs)); get_cap_mask (dev, "capabilities/rel", bitmask_rel, sizeof (bitmask_rel)); get_cap_mask (dev, "capabilities/key", bitmask_key, sizeof (bitmask_key)); + get_cap_mask (dev, "capabilities/sw", bitmask_sw, sizeof (bitmask_sw));
test_pointers(bitmask_ev, bitmask_abs, bitmask_key, bitmask_rel);
test_key(udev, bitmask_ev, bitmask_key);
+ test_sound(dev, bitmask_sw); + return 0; } diff --git a/extras/udev-acl/70-acl.rules b/extras/udev-acl/70-acl.rules index 037349d..a6f54d9 100644 --- a/extras/udev-acl/70-acl.rules +++ b/extras/udev-acl/70-acl.rules @@ -25,6 +25,7 @@ SUBSYSTEM=="scsi_generic", SUBSYSTEMS=="scsi", ATTRS{type}=="4|5", TAG+="udev-ac
# sound devices SUBSYSTEM=="sound", TAG+="udev-acl" +SUBSYSTEM=="input", ENV{ID_INPUT_SNDJACK}=="1", TAG+="udev-acl"
# ffado is an userspace driver for firewire sound cards SUBSYSTEM=="firewire", ENV{ID_FFADO}=="1", TAG+="udev-acl" diff --git a/rules/rules.d/60-persistent-input.rules b/rules/rules.d/60-persistent-input.rules index cd1de4e..d04c09e 100644 --- a/rules/rules.d/60-persistent-input.rules +++ b/rules/rules.d/60-persistent-input.rules @@ -12,6 +12,7 @@ ENV{ID_INPUT_MOUSE}=="?*", ENV{.INPUT_CLASS}="mouse" ENV{ID_INPUT_TOUCHPAD}=="?*", ENV{.INPUT_CLASS}="mouse" ENV{ID_INPUT_TABLET}=="?*", ENV{.INPUT_CLASS}="mouse" ENV{ID_INPUT_JOYSTICK}=="?*", ENV{.INPUT_CLASS}="joystick" +ENV{ID_INPUT_SNDJACK}=="?*", ENV{.INPUT_CLASS}="sndjack", GROUP="audio" DRIVERS=="pcspkr", ENV{.INPUT_CLASS}="spkr" ATTRS{name}=="*dvb*|*DVB*|* IR *", ENV{.INPUT_CLASS}="ir"