From 47990f37d7f626707df5639390da823e9c80a922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Sun, 24 Apr 2016 10:56:31 +0200 Subject: [PATCH] dde_bsd: update audio driver to OpenBSD 5.9 In addition to updating the contrib sources the driver now uses the new Component API and will report the internal mixer state. Reporting of the mixer state is enabled by adding the 'report_mixer' attribute to the drivers configuration and setting its value to 'yes'. The following snippets illustrates the format of the report: ! ! ! ! ! ! ! The mixer state may expose other mixer fields as well, depending on the used sound card. The naming scheme of the attributes intentionally matches the naming scheme of OpenBSD's mixerctl(1) program. Each 'mixer' node can be used to configure the audio driver by using it in its configuration, e.g.: ! ! ! This configuration will set the output volume to the highest possible value. Although it is now also possible to update the configuration at run-time it should not be done while the driver is currently playing or recording because it may provoke the generation of artefacts. Fixes #1973. --- repos/dde_bsd/audio.list | 2 - repos/dde_bsd/include/audio/audio.h | 11 +- .../import/import-dde_bsd_audio_include.mk | 1 + repos/dde_bsd/lib/mk/dde_bsd_audio.inc | 43 ++--- repos/dde_bsd/lib/mk/dde_bsd_audio_include.mk | 24 +++ repos/dde_bsd/patches/notify.patch | 14 +- repos/dde_bsd/ports/dde_bsd.hash | 2 +- repos/dde_bsd/ports/dde_bsd.port | 6 +- repos/dde_bsd/run/audio_out.run | 4 +- repos/dde_bsd/src/drivers/audio/main.cc | 164 ++++++++--------- repos/dde_bsd/src/drivers/audio/target.mk | 2 +- repos/dde_bsd/src/lib/audio/bsd.h | 12 +- repos/dde_bsd/src/lib/audio/bsd_emul.c | 13 +- repos/dde_bsd/src/lib/audio/bus.cc | 69 ++++--- repos/dde_bsd/src/lib/audio/driver.cc | 170 +++++++++++------- repos/dde_bsd/src/lib/audio/dummies.cc | 19 +- .../dde_bsd/src/lib/audio/include/bsd_emul.h | 10 +- .../src/lib/audio/include/extern_c_begin.h | 4 + .../src/lib/audio/include/extern_c_end.h | 4 + .../dde_bsd/src/lib/audio/include/scheduler.h | 9 +- repos/dde_bsd/src/lib/audio/irq.cc | 23 ++- repos/dde_bsd/src/lib/audio/mem.cc | 63 ++++--- repos/dde_bsd/src/lib/audio/misc.cc | 2 - repos/dde_bsd/src/lib/audio/scheduler.cc | 83 +-------- repos/dde_bsd/src/lib/audio/timer.cc | 27 ++- 25 files changed, 395 insertions(+), 386 deletions(-) create mode 100644 repos/dde_bsd/lib/import/import-dde_bsd_audio_include.mk create mode 100644 repos/dde_bsd/lib/mk/dde_bsd_audio_include.mk diff --git a/repos/dde_bsd/audio.list b/repos/dde_bsd/audio.list index ae457ecf8..5bbe5023d 100644 --- a/repos/dde_bsd/audio.list +++ b/repos/dde_bsd/audio.list @@ -7,8 +7,6 @@ ./sys/dev/pci/eapreg.h ./sys/dev/pci/pcidevs.h ./sys/dev/pci/pcidevs_data.h -./sys/dev/auconv.c -./sys/dev/auconv.h ./sys/dev/mulaw.c ./sys/dev/mulaw.h ./sys/dev/ic/ac97.c diff --git a/repos/dde_bsd/include/audio/audio.h b/repos/dde_bsd/include/audio/audio.h index f9236db40..faccd7642 100644 --- a/repos/dde_bsd/include/audio/audio.h +++ b/repos/dde_bsd/include/audio/audio.h @@ -9,7 +9,7 @@ */ /* - * Copyright (C) 2014 Genode Labs GmbH + * Copyright (C) 2016 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. @@ -18,7 +18,10 @@ #ifndef _AUDIO__AUDIO_H_ #define _AUDIO__AUDIO_H_ -#include +/* Genode includes */ +#include +#include + /***************************** ** private Audio namespace ** @@ -38,7 +41,9 @@ namespace Audio_in { namespace Audio { - void init_driver(Server::Entrypoint &ep); + void update_config(Genode::Xml_node); + + void init_driver(Genode::Env &, Genode::Allocator &, Genode::Xml_node); bool driver_active(); diff --git a/repos/dde_bsd/lib/import/import-dde_bsd_audio_include.mk b/repos/dde_bsd/lib/import/import-dde_bsd_audio_include.mk new file mode 100644 index 000000000..6f0ca5a20 --- /dev/null +++ b/repos/dde_bsd/lib/import/import-dde_bsd_audio_include.mk @@ -0,0 +1 @@ +INC_DIR += $(LIB_CACHE_DIR)/dde_bsd_audio_include/include diff --git a/repos/dde_bsd/lib/mk/dde_bsd_audio.inc b/repos/dde_bsd/lib/mk/dde_bsd_audio.inc index fe9e966c1..4543c83a3 100644 --- a/repos/dde_bsd/lib/mk/dde_bsd_audio.inc +++ b/repos/dde_bsd/lib/mk/dde_bsd_audio.inc @@ -3,10 +3,16 @@ LIB_INC_DIR = $(LIB_DIR)/include AUDIO_CONTRIB_DIR := $(call select_from_ports,dde_bsd)/src/lib/audio +# +# Set include paths up before adding the dde_bsd_audio_include library +# because it will use INC_DIR += and must be at the end +# INC_DIR += $(LIB_DIR) INC_DIR += $(LIB_INC_DIR) INC_DIR += $(AUDIO_CONTRIB_DIR) +LIBS += dde_bsd_audio_include + SRC_CC += bus.cc dummies.cc driver.cc irq.cc mem.cc misc.cc scheduler.cc timer.cc SRC_C += bsd_emul.c SRC_S += setjmp.S @@ -19,13 +25,16 @@ CC_OPT += -fno-builtin-printf -fno-builtin-snprintf -fno-builtin-vsnprintf \ CC_OPT += -D_KERNEL +# disable false warning in audio.c:786 +CC_C_OPT += -Wno-maybe-uninitialized + # enable when debugging # CC_OPT += -DAUDIO_DEBUG # CC_OPT += -DAZALIA_DEBUG # CC_OPT += -DDIAGNOSTIC # audio interface -SRC_C += dev/audio.c dev/auconv.c +SRC_C += dev/audio.c # AC97 codec SRC_C += dev/ic/ac97.c @@ -38,38 +47,6 @@ SRC_C += dev/pci/eap.c SRC_C += dev/mulaw.c -# -# Determine the header files included by the contrib code. For each -# of these header files we create a symlink to 'bsd_emul.h'. -# -GEN_INCLUDES := $(shell grep -rh "^\#include .*" $(AUDIO_CONTRIB_DIR) |\ - sed "s/^\#include [^<\"]*[<\"]\([^>\"]*\)[>\"].*/\1/" | sort | uniq) - -# -# Filter out original BSD headers that exist in the contrib directory -# -NO_GEN_INCLUDES := $(shell cd $(AUDIO_CONTRIB_DIR); find -name "*.h" | sed "s/.\///" | sed "s/.*include\///") -GEN_INCLUDES := $(filter-out $(NO_GEN_INCLUDES),$(GEN_INCLUDES)) - -# -# Put BSD headers in 'GEN_INC' dir -# -GEN_INC := $(shell pwd)/include - -$(shell mkdir -p $(GEN_INC)) - -GEN_INCLUDES := $(addprefix $(GEN_INC)/,$(GEN_INCLUDES)) -INC_DIR += $(GEN_INC) - -# -# Make sure to create the header symlinks prior building -# -$(SRC_C:.c=.o) $(SRC_CC:.cc=.o): $(GEN_INCLUDES) - -$(GEN_INCLUDES): - $(VERBOSE)mkdir -p $(dir $@) - $(VERBOSE)ln -s $(LIB_INC_DIR)/bsd_emul.h $@ - vpath %.c $(AUDIO_CONTRIB_DIR) vpath %.c $(LIB_DIR) vpath %.cc $(LIB_DIR) diff --git a/repos/dde_bsd/lib/mk/dde_bsd_audio_include.mk b/repos/dde_bsd/lib/mk/dde_bsd_audio_include.mk new file mode 100644 index 000000000..874249e4c --- /dev/null +++ b/repos/dde_bsd/lib/mk/dde_bsd_audio_include.mk @@ -0,0 +1,24 @@ +# +# Pseudo library to generate a symlink for each header file included by the +# contrib code. Each symlink points to the same 'bsd_emul.h' file, which +# provides our emulation of the OpenBSD kernel API. +# + +ifeq ($(called_from_lib_mk),yes) + +BSD_CONTRIB_DIR := $(call select_from_ports,dde_bsd)/src/lib/audio +BSD_EMUL_H := $(REP_DIR)/src/lib/audio/include/bsd_emul.h + +GEN_INCLUDES := $(shell grep -rh "^\#include .*" $(BSD_CONTRIB_DIR) |\ + sed "s/^\#include [^<\"]*[<\"]\([^>\"]*\)[>\"].*/\1/" | sort | uniq) + +GEN_INC := $(shell pwd)/include +GEN_INCLUDES := $(addprefix $(GEN_INC)/,$(GEN_INCLUDES)) + +all: $(GEN_INCLUDES) + +$(GEN_INCLUDES): + $(VERBOSE)mkdir -p $(dir $@) + $(VERBOSE)ln -sf $(BSD_EMUL_H) $@ + +endif diff --git a/repos/dde_bsd/patches/notify.patch b/repos/dde_bsd/patches/notify.patch index c8f3a7923..fa15ae5e6 100644 --- a/repos/dde_bsd/patches/notify.patch +++ b/repos/dde_bsd/patches/notify.patch @@ -1,17 +1,19 @@ +diff --git a/dev/audio.c b/dev/audio.c +index 1271bc7..6535d10 100644 --- a/dev/audio.c +++ b/dev/audio.c -@@ -2293,6 +2293,8 @@ - sc->sc_pqui = 1; - audio_wake(&sc->sc_wchan); +@@ -411,6 +411,8 @@ audio_pintr(void *addr) + } + selwakeup(&sc->play.sel); } + + notify_play(); } /* -@@ -2400,6 +2402,8 @@ - sc->sc_rqui = 1; - audio_wake(&sc->sc_rchan); +@@ -486,6 +488,8 @@ audio_rintr(void *addr) + } + selwakeup(&sc->rec.sel); } + + notify_record(); diff --git a/repos/dde_bsd/ports/dde_bsd.hash b/repos/dde_bsd/ports/dde_bsd.hash index c8119c5ef..e942fe04e 100644 --- a/repos/dde_bsd/ports/dde_bsd.hash +++ b/repos/dde_bsd/ports/dde_bsd.hash @@ -1 +1 @@ -7efb09a93f78f7896e1a73264145e188afa3e80f +9d32d78a9e2488f993723b6d1d353dec2bc55e24 diff --git a/repos/dde_bsd/ports/dde_bsd.port b/repos/dde_bsd/ports/dde_bsd.port index dbfdf25ad..896817af4 100644 --- a/repos/dde_bsd/ports/dde_bsd.port +++ b/repos/dde_bsd/ports/dde_bsd.port @@ -3,12 +3,12 @@ VERSION := 1 DOWNLOADS := audio.archive # -# Audio drivers from OpenBSD 5.7 +# Audio drivers from OpenBSD 5.9 # SRC_DIR_AUDIO := src/lib/audio -VERSION_AUDIO := 5.7 +VERSION_AUDIO := 5.9 URL(audio) := http://mirror.switch.ch/ftp/pub/OpenBSD/$(VERSION_AUDIO)/sys.tar.gz -SHA(audio) := 1a60125a7fce6524b0d62643db47acca0b11506a +SHA(audio) := 65080ae5524ffed903dac7ecb49c1c4955afbc7f DIR(audio) := $(SRC_DIR_AUDIO) TAR_OPT(audio) := --strip-components=2 --files-from $(REP_DIR)/audio.list HASH_INPUT += $(REP_DIR)/audio.list diff --git a/repos/dde_bsd/run/audio_out.run b/repos/dde_bsd/run/audio_out.run index 8357bacab..2d4212f58 100644 --- a/repos/dde_bsd/run/audio_out.run +++ b/repos/dde_bsd/run/audio_out.run @@ -72,9 +72,7 @@ append_if $use_mixer config { append config { - - - + diff --git a/repos/dde_bsd/src/drivers/audio/main.cc b/repos/dde_bsd/src/drivers/audio/main.cc index ae38d3b16..5c9457661 100644 --- a/repos/dde_bsd/src/drivers/audio/main.cc +++ b/repos/dde_bsd/src/drivers/audio/main.cc @@ -5,7 +5,7 @@ */ /* - * Copyright (C) 2014-2015 Genode Labs GmbH + * Copyright (C) 2014-2016 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. @@ -15,21 +15,16 @@ /* Genode includes */ #include #include -#include -#include -#include -#include -#include +#include +#include +#include #include -#include -#include /* local includes */ #include