greybus: audio: Add Audio Manager
This is a simple module that keeps a list of connected GB audio
modules.
Whenever a device is attached, an appropriate uevent is sent to
userspace:
UDEV [4941.803215] add /kernel/gb_audio_manager/0 (gb_audio_manager)
ACTION=add
CPORT=99
DEVICES=0x10
DEVPATH=/kernel/gb_audio_manager/0
NAME=naim
PID=64
SEQNUM=1828
SLOT=2
SUBSYSTEM=gb_audio_manager
USEC_INITIALIZED=802416
VID=128
And whenever removed:
UDEV [4941.836588] remove /kernel/gb_audio_manager/0 (gb_audio_manager)
ACTION=remove
DEVPATH=/kernel/gb_audio_manager/0
SEQNUM=1833
SUBSYSTEM=gb_audio_manager
USEC_INITIALIZED=835681
The API consists of functions for adding, removing and inspecting
added device module descriptions (struct gb_audio_module):
int gb_audio_manager_add(struct gb_audio_module_descriptor *desc);
int gb_audio_manager_remove(int id);
int gb_audio_manager_remove_all(void);
struct gb_audio_module* gb_audio_manager_get_module(int id);
void gb_audio_manager_put_module(struct gb_audio_module *module);
int gb_audio_manager_dump_module(int id);
void gb_audio_manager_dump_all(void);
Devices can be inspected through sysfs in /sys/kernel/gb_audio_manager/{id}/*
If GB_AUDIO_MANAGER_SYSFS is exported as 'true', managing devices can be done
via the SYSFS as well. For instance:
echo name=naim slot=2 vid=128 pid=64 cport=99 devices=0x10 > /sys/kernel/gb_audio_manager/add
echo all > /sys/kernel/gb_audio_manager/dump
echo 2 > /sys/kernel/gb_audio_manager/dump
echo 2 > /sys/kernel/gb_audio_manager/remove
Signed-off-by: Svetlin Ankov <ankov_svetlin@projectara.com>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
diff --git a/drivers/staging/greybus/Makefile b/drivers/staging/greybus/Makefile
index e2ae24b..4ebdc6b 100644
--- a/drivers/staging/greybus/Makefile
+++ b/drivers/staging/greybus/Makefile
@@ -32,6 +32,8 @@
gb-audio-codec-y := audio_codec.o
gb-audio-gb-y := audio_gb.o
gb-audio-apbridgea-y := audio_apbridgea.o
+gb-audio-manager-y += audio_manager.o
+gb-audio-manager-y += audio_manager_module.o
gb-camera-y := camera.o
obj-m += greybus.o
@@ -48,6 +50,7 @@
obj-m += gb-camera.o
obj-m += gb-audio-gb.o
obj-m += gb-audio-apbridgea.o
+obj-m += gb-audio-manager.o
KERNELVER ?= $(shell uname -r)
KERNELDIR ?= /lib/modules/$(KERNELVER)/build
@@ -89,6 +92,12 @@
# needed for trace events
ccflags-y += -I$(src)
+GB_AUDIO_MANAGER_SYSFS ?= true
+ifeq ($(GB_AUDIO_MANAGER_SYSFS),true)
+gb-audio-manager-y += audio_manager_sysfs.o
+ccflags-y += -DGB_AUDIO_MANAGER_SYSFS
+endif
+
all: module
tools::