From 8a34d21577b5b8047e993ee332ce0f2cf8af331d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Fri, 15 May 2015 22:22:46 +0200 Subject: [PATCH] dde_bsd: add recording support to audio driver The driver is now able to record audio samples. In contrast to playback it has to be enabled explicitly by setting the configuration attribute 'recording' to 'yes'. Playback is by default enabled but may be disabled by setting 'playback' to 'no'. Furthermore it is now possible to configure the mixer from the configuration. For now, the interface used by vanilla OpenBSD is just exported. The following snippet shows how to enable and configure recording on an Thinkpad X220 where the headset rather than the internal mic is used as recording source: ! ! ! ! ! ! ! ! ! ! ! ! In addition to selecting the recording source the playback as well as the recording volume are set to 255 (maximum). Information about the available mixers and settings in general may be obtained by setting the 'verbose' to 'yes' in the config node. Issue #1644. --- repos/dde_bsd/include/audio/audio.h | 18 +- repos/dde_bsd/patches/notify.patch | 20 + repos/dde_bsd/ports/dde_bsd.hash | 2 +- repos/dde_bsd/ports/dde_bsd.port | 1 + repos/dde_bsd/src/drivers/audio_out/main.cc | 337 +++++++++++--- repos/dde_bsd/src/lib/audio/driver.cc | 431 ++++++++++++++++-- .../dde_bsd/src/lib/audio/include/bsd_emul.h | 18 + repos/dde_bsd/src/lib/audio/irq.cc | 11 - repos/dde_bsd/src/lib/audio/mem.cc | 15 +- 9 files changed, 740 insertions(+), 113 deletions(-) create mode 100644 repos/dde_bsd/patches/notify.patch diff --git a/repos/dde_bsd/include/audio/audio.h b/repos/dde_bsd/include/audio/audio.h index 3c3c255a79..f9236db405 100644 --- a/repos/dde_bsd/include/audio/audio.h +++ b/repos/dde_bsd/include/audio/audio.h @@ -24,17 +24,31 @@ ** private Audio namespace ** *****************************/ -namespace Audio { +namespace Audio_out { enum Channel_number { LEFT, RIGHT, MAX_CHANNELS, INVALID = MAX_CHANNELS }; +} + + +namespace Audio_in { + + enum Channel_number { LEFT, MAX_CHANNELS, INVALID = MAX_CHANNELS }; +} + + +namespace Audio { void init_driver(Server::Entrypoint &ep); bool driver_active(); - void dma_notifier(Genode::Signal_context_capability cap); + void play_sigh(Genode::Signal_context_capability cap); + + void record_sigh(Genode::Signal_context_capability cap); int play(short *data, Genode::size_t size); + + int record(short *data, Genode::size_t size); } #endif /* _AUDIO__AUDIO_H_ */ diff --git a/repos/dde_bsd/patches/notify.patch b/repos/dde_bsd/patches/notify.patch new file mode 100644 index 0000000000..c8f3a79237 --- /dev/null +++ b/repos/dde_bsd/patches/notify.patch @@ -0,0 +1,20 @@ +--- a/dev/audio.c ++++ b/dev/audio.c +@@ -2293,6 +2293,8 @@ + sc->sc_pqui = 1; + audio_wake(&sc->sc_wchan); + } ++ ++ notify_play(); + } + + /* +@@ -2400,6 +2402,8 @@ + sc->sc_rqui = 1; + audio_wake(&sc->sc_rchan); + } ++ ++ notify_record(); + } + + int diff --git a/repos/dde_bsd/ports/dde_bsd.hash b/repos/dde_bsd/ports/dde_bsd.hash index 3423971e99..061de5f27b 100644 --- a/repos/dde_bsd/ports/dde_bsd.hash +++ b/repos/dde_bsd/ports/dde_bsd.hash @@ -1 +1 @@ -8a8864f346418a483832c0fa28419f35fa3d5b78 +c560befb7c9f80152fcd720a2cef4272eded0e0f diff --git a/repos/dde_bsd/ports/dde_bsd.port b/repos/dde_bsd/ports/dde_bsd.port index 48a79f3317..606397b369 100644 --- a/repos/dde_bsd/ports/dde_bsd.port +++ b/repos/dde_bsd/ports/dde_bsd.port @@ -21,5 +21,6 @@ PATCHES := $(addprefix patches/,$(notdir $(wildcard $(REP_DIR)/patches/*.patch)) AUDIO_OPT := -p1 -d$(SRC_DIR_AUDIO) PATCH_OPT(patches/oppress_warning.patch) := $(AUDIO_OPT) PATCH_OPT(patches/azalia_c.patch) := $(AUDIO_OPT) +PATCH_OPT(patches/notify.patch) := $(AUDIO_OPT) # vi: set ft=make : diff --git a/repos/dde_bsd/src/drivers/audio_out/main.cc b/repos/dde_bsd/src/drivers/audio_out/main.cc index d4d74df699..720b18e0bc 100644 --- a/repos/dde_bsd/src/drivers/audio_out/main.cc +++ b/repos/dde_bsd/src/drivers/audio_out/main.cc @@ -4,22 +4,39 @@ * \date 2014-11-09 */ +/* + * Copyright (C) 2014-2015 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + + +/* Genode includes */ +#include #include #include #include #include +#include #include #include #include +#include +/* local includes */ #include