From 386c29da3416d86b66430e590aaa5c51f2942477 Mon Sep 17 00:00:00 2001 From: James O'Shannessy Date: Thu, 13 Sep 2018 16:13:48 -0700 Subject: Add docs folder for in depth breakdown of module. After discussion at AGL F2F, it was suggested to have simpler readmes that summarise the system/architecture/build process/etc. Starting to dotpoint out that process with these readmes. Signed-off-by: James O'Shannessy --- docs/1. Introduction.md | 0 docs/2. Building.md | 0 docs/3. Usage.md | 0 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 docs/1. Introduction.md create mode 100644 docs/2. Building.md create mode 100644 docs/3. Usage.md (limited to 'docs') diff --git a/docs/1. Introduction.md b/docs/1. Introduction.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/2. Building.md b/docs/2. Building.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/3. Usage.md b/docs/3. Usage.md new file mode 100644 index 0000000..e69de29 -- cgit 1.2.3-korg From 5a2a915287e7cd12a347a03d37861310701a72fb Mon Sep 17 00:00:00 2001 From: James O'Shannessy Date: Thu, 13 Sep 2018 16:34:25 -0700 Subject: Changes to readme files Dot points to introduction, and shifting the build instructions to docs/2.\ Building.md Signed-off-by: James O'Shannessy --- docs/1. Introduction.md | 18 ++++++++++++++++++ docs/2. Building.md | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) (limited to 'docs') diff --git a/docs/1. Introduction.md b/docs/1. Introduction.md index e69de29..f2d088d 100644 --- a/docs/1. Introduction.md +++ b/docs/1. Introduction.md @@ -0,0 +1,18 @@ +Introduction +=================== + +## Problem +- Insecure +- Limited +- Not fully optimised for use case (ie. Routing Audio to DSP vs. Loopback) +- Not generic interface for highly configurable hardware +- + +## Solution + +## Added Features +- Dynamic Runtime Alsa Front end +- Adjustable Audio Path +- Mappable Audio Path +- Secure Audio Routing w/ SMACK +- \ No newline at end of file diff --git a/docs/2. Building.md b/docs/2. Building.md index e69de29..983db8d 100644 --- a/docs/2. Building.md +++ b/docs/2. Building.md @@ -0,0 +1,39 @@ +Building AVIRT +=================================== + +## Table of Contents +1. [Out of Tree](#out-of-tree) +2. [In Tree](#in-tree) + + + +## Out Of Tree + +The kernel modules can be built either in-tree, or out-of-tree. +To build both AVIRT and the dummy Audio Path out-of-tree, use the following command: + +```sh +$ CONFIG_AVIRT=m CONFIG_AVIRT_BUILDLOCAL=y CONFIG_AVIRT_DUMMYAP=m make -C /lib/modules/$(uname -r)/build/ M=$(pwd) +``` + +To build both AVIRT and the dummy Audio Path out-of-tree for [AGL](http://docs.automotivelinux.org/) (`aarch64` currently supported), use the [XDS](http://docs.automotivelinux.org/docs/devguides/en/dev/reference/xds/part-1/0_Abstract.html) build system together with the `make_agl.sh` script: + +```sh +$ ./make_agl.sh ${XDS_SDK_ID} +``` + + + +## In tree + + +To build in tree, use the [Fiberdyne Linux fork](https://github.com/fiberdyne/linux), which will automatically clone the AVIRT Driver and required AudioPath modules to the `drivers/staging` directory. You can then turn AVIRT Support on by setting to ``. The drivers can be found here: +``` +$ make menuconfig + +# Navigate to: Device Drivers--->Staging Drivers--->AVIRT Support +``` +Finally build the kernel with the configuration selected by making. +``` +$ make +``` \ No newline at end of file -- cgit 1.2.3-korg From 72499de21381625577160fac2e1e31af0d1f104d Mon Sep 17 00:00:00 2001 From: James O'Shannessy Date: Thu, 13 Sep 2018 17:20:37 -0700 Subject: Updating build instructions Cleaning up build instructions for building AVIRT Signed-off-by: James O'Shannessy --- docs/2. Building.md | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'docs') diff --git a/docs/2. Building.md b/docs/2. Building.md index 983db8d..0016822 100644 --- a/docs/2. Building.md +++ b/docs/2. Building.md @@ -2,20 +2,34 @@ Building AVIRT =================================== ## Table of Contents -1. [Out of Tree](#out-of-tree) -2. [In Tree](#in-tree) +1. [Introduction](#intro) +2. [Out of Tree](#out-of-tree) +3. [In Tree](#in-tree) + + + +## Introduction +The AVIRT module and submodules can be built using a variety of methods. There are Visual Code build tasks for in and out of tree builds, make file support for CLI building (both in and out of tree), and xds build support. + ## Out Of Tree -The kernel modules can be built either in-tree, or out-of-tree. -To build both AVIRT and the dummy Audio Path out-of-tree, use the following command: +### Building with CLI +To build both AVIRT and the additional Audio Paths out-of-tree, use the following command: + +```sh +$ make +``` +or ```sh $ CONFIG_AVIRT=m CONFIG_AVIRT_BUILDLOCAL=y CONFIG_AVIRT_DUMMYAP=m make -C /lib/modules/$(uname -r)/build/ M=$(pwd) ``` +The latter is executed internally with the make file. +### Building with XDS SDK To build both AVIRT and the dummy Audio Path out-of-tree for [AGL](http://docs.automotivelinux.org/) (`aarch64` currently supported), use the [XDS](http://docs.automotivelinux.org/docs/devguides/en/dev/reference/xds/part-1/0_Abstract.html) build system together with the `make_agl.sh` script: ```sh @@ -26,6 +40,7 @@ $ ./make_agl.sh ${XDS_SDK_ID} ## In tree +The kernal modules can be built in tree, dependent on the avirt repository being located in drivers/staging - If using your own fork of the linux kernel, you will need to update the staging Makefiles and Kconfigs accordingly. To build in tree, use the [Fiberdyne Linux fork](https://github.com/fiberdyne/linux), which will automatically clone the AVIRT Driver and required AudioPath modules to the `drivers/staging` directory. You can then turn AVIRT Support on by setting to ``. The drivers can be found here: ``` @@ -33,6 +48,7 @@ $ make menuconfig # Navigate to: Device Drivers--->Staging Drivers--->AVIRT Support ``` + Finally build the kernel with the configuration selected by making. ``` $ make -- cgit 1.2.3-korg From 819bbaa22430988a88999e283ceb02368ad0f7b3 Mon Sep 17 00:00:00 2001 From: James O'Shannessy Date: Mon, 8 Oct 2018 12:22:32 +1100 Subject: Committing usage document Updated usage document with loading/unloading, configuration information Signed-off-by: James O'Shannessy --- docs/3. Usage.md | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'docs') diff --git a/docs/3. Usage.md b/docs/3. Usage.md index e69de29..b5ec136 100644 --- a/docs/3. Usage.md +++ b/docs/3. Usage.md @@ -0,0 +1,70 @@ +Using AVIRT +=================================== + +## Introduction + +## Table of Contents +1. [Load/Unload AVIRT](#un-load-avirt) +2. [Configuring AVIRT](#configuring-avirt) + + + +## Loading and Unloading AVIRT + +To run, we must load the kernel modules using the `loadDrivers.sh` script, which contains sample module parameters to AVIRT: +```sh +$ ./loadDrivers.sh +``` +To unload the drivers use: +```sh +$ ./unload.sh +``` + + + +## Configuring AVIRT + +AVIRT is configured using configfs. +### Note: +A sample script for the following is supplied inside the ```scripts``` folder. + +First, verify the kernel supports the use of configfs. +```sh +fgrep configfs /proc/filesystems +``` + +the expected output is: +``` +nodev configfs +``` + +Once confirmed, we can mount the configfs at the conventional point: +```sh +#Check configfs is mounted on the system +mkdir -p /config +mount -t configfs none /config +``` + +Finally, we can configure AVIRT: + +```sh +# Set up each of the cards channels +mkdir /config/avirt/streams/playback_media +echo "2">/config/avirt/streams/playback_media/channels + +mkdir /config/avirt/streams/playback_navigation +echo "1">/config/avirt/streams/playback_navigation/channels + +mkdir /config/avirt/streams/playback_emergency +echo "1">/config/avirt/streams/playback_emergency/channels + +mkdir /config/avirt/streams/capture_voice +echo "1">/config/avirt/streams/capture_voice/channels + +# Finally, seal the card, and initiate configuration +echo "1">/config/avirt/streams/sealed +``` + +### Note: +A simplified helper library, libavirt, is available [here](https://github.com/fiberdyne/libavirt). +Please refer to the readme in libavirt for further details. -- cgit 1.2.3-korg From a3e9a9eb2b927ef05161f1c2bf5feb62db84c5b3 Mon Sep 17 00:00:00 2001 From: James O'Shannessy Date: Mon, 8 Oct 2018 12:26:39 +1100 Subject: Added load/unload documentation. Updated documentation to use load/unload Signed-off-by: James O'Shannessy --- docs/3. Usage.md | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'docs') diff --git a/docs/3. Usage.md b/docs/3. Usage.md index b5ec136..7eb46d3 100644 --- a/docs/3. Usage.md +++ b/docs/3. Usage.md @@ -11,6 +11,16 @@ Using AVIRT ## Loading and Unloading AVIRT +As root, load the required ```avirt_core.ko``` and subsequent audio path. +As an example, the Dummy Audiopath is being loaded here. + +```sh +insmod avirt_core.ko +insmod dummy/dummy_audiopath.ko +``` + +### Note: +The loading and unloading of drivers can be performed using the helper scripts. To run, we must load the kernel modules using the `loadDrivers.sh` script, which contains sample module parameters to AVIRT: ```sh $ ./loadDrivers.sh -- cgit 1.2.3-korg From 83ab0cdf84def71eebdebf0c813cebfce8f99d06 Mon Sep 17 00:00:00 2001 From: James O'Shannessy Date: Thu, 13 Sep 2018 16:34:25 -0700 Subject: Changes to readme files Dot points to introduction, and shifting the build instructions to docs/2.\ Building.md Signed-off-by: James O'Shannessy --- docs/2. Building.md | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'docs') diff --git a/docs/2. Building.md b/docs/2. Building.md index 0016822..983db8d 100644 --- a/docs/2. Building.md +++ b/docs/2. Building.md @@ -2,34 +2,20 @@ Building AVIRT =================================== ## Table of Contents -1. [Introduction](#intro) -2. [Out of Tree](#out-of-tree) -3. [In Tree](#in-tree) - - - -## Introduction -The AVIRT module and submodules can be built using a variety of methods. There are Visual Code build tasks for in and out of tree builds, make file support for CLI building (both in and out of tree), and xds build support. - +1. [Out of Tree](#out-of-tree) +2. [In Tree](#in-tree) ## Out Of Tree -### Building with CLI -To build both AVIRT and the additional Audio Paths out-of-tree, use the following command: - -```sh -$ make -``` +The kernel modules can be built either in-tree, or out-of-tree. +To build both AVIRT and the dummy Audio Path out-of-tree, use the following command: -or ```sh $ CONFIG_AVIRT=m CONFIG_AVIRT_BUILDLOCAL=y CONFIG_AVIRT_DUMMYAP=m make -C /lib/modules/$(uname -r)/build/ M=$(pwd) ``` -The latter is executed internally with the make file. -### Building with XDS SDK To build both AVIRT and the dummy Audio Path out-of-tree for [AGL](http://docs.automotivelinux.org/) (`aarch64` currently supported), use the [XDS](http://docs.automotivelinux.org/docs/devguides/en/dev/reference/xds/part-1/0_Abstract.html) build system together with the `make_agl.sh` script: ```sh @@ -40,7 +26,6 @@ $ ./make_agl.sh ${XDS_SDK_ID} ## In tree -The kernal modules can be built in tree, dependent on the avirt repository being located in drivers/staging - If using your own fork of the linux kernel, you will need to update the staging Makefiles and Kconfigs accordingly. To build in tree, use the [Fiberdyne Linux fork](https://github.com/fiberdyne/linux), which will automatically clone the AVIRT Driver and required AudioPath modules to the `drivers/staging` directory. You can then turn AVIRT Support on by setting to ``. The drivers can be found here: ``` @@ -48,7 +33,6 @@ $ make menuconfig # Navigate to: Device Drivers--->Staging Drivers--->AVIRT Support ``` - Finally build the kernel with the configuration selected by making. ``` $ make -- cgit 1.2.3-korg From 7e4db2ff6865d723a2a6233a9542730876d06260 Mon Sep 17 00:00:00 2001 From: James O'Shannessy Date: Thu, 13 Sep 2018 17:20:37 -0700 Subject: Updating build instructions Cleaning up build instructions for building AVIRT Signed-off-by: James O'Shannessy --- README.md | 89 ------------------------------------------------- docs/1. Introduction.md | 21 +++++------- docs/2. Building.md | 24 ++++++++++--- docs/4. 4A Integration | 17 ++++++++++ 4 files changed, 45 insertions(+), 106 deletions(-) create mode 100644 docs/4. 4A Integration (limited to 'docs') diff --git a/README.md b/README.md index d6564fa..3ed571f 100644 --- a/README.md +++ b/README.md @@ -11,95 +11,6 @@ A sample dummy Audio Path is provided as an example to show how a low-level audi Currently, the Fiberdyne DSP hardmixer is supported on the Renesas R-Car M3 AGL reference platform, and a default loopback softmixer is in development. -## Building - -### Out Of Tree - -The kernel modules can be built either in-tree, or out-of-tree. -To build both AVIRT and the dummy Audio Path out-of-tree, use the following command: - -```sh -$ make all -``` - -If building for [AGL](http://docs.automotivelinux.org/), use the [XDS](http://docs.automotivelinux.org/docs/devguides/en/dev/reference/xds/part-1/0_Abstract.html) build system together with the `make_agl.sh` script: - -```sh -$ ./make_agl.sh ${XDS_SDK_ID} -``` - -### In tree - -To build in tree, use the [Fiberdyne Linux fork](https://github.com/fiberdyne/linux), which will automatically clone the AVIRT Driver and required AudioPath modules to the `drivers/staging` directory. You can then turn AVIRT Support on by setting to ``. The drivers can be found here: - -``` -$ make menuconfig - -# Navigate to: Device Drivers--->Staging Drivers--->AVIRT Support -``` - -Finally build the kernel with the configuration selected by making. - -``` -$ make -``` - -## Running - -Firstly, install the resulting kernel modules to the appropriate modules -directory, and run`depmod`. For example, in AGL: - -```sh -cp avirt_core.ko avirt_dummyap.ko /lib/modules/4.14.0-yocto-standard/ -depmod -``` - -Now we can load the modules: - -```sh -modprobe avirt_core -modprobe avirt_dummyap -``` - -We must now configure AVIRT. We can do this with the test script: - -```sh -source scripts/test_configfs.sh -``` - -We can see the newly created streams by using the `aplay` utility. For example: - -```sh -aplay -l -... -card 2: avirt [avirt], device 0: multimedia [multimedia] - Subdevices: 1/1 - Subdevice #0: subdevice #0 -card 2: avirt [avirt], device 1: navigation [navigation] - Subdevices: 1/1 - Subdevice #0: subdevice #0 -card 2: avirt [avirt], device 2: emergency [emergency] - Subdevices: 1/1 - Subdevice #0: subdevice #0 -``` - -## 4A Integration - -AVIRT has been integrated with [4a-softmixer](https://github.com/iotbzh/4a-softmixer) -and [4a-hal-generic](https://github.com/iotbzh/4a-hal-generic) to provide a smooth -transition from the existing aloop implementation to the future AVIRT loopback implementation. - -### User-space Library - -The user-space library [libavirt](https://github.com/fiberdyne/libavirt) can be used to configure AVIRT from within a given AGL 4A binding. - -### Hardmixer - -A new 4A mixer binding has been developed to demonstrate the capabilities of the -Fiberdyne DSP mixer operating on the HiFi2 core on-board the Renesas R-Car M3 M3ULCB -AGL reference platform. This is called the 'hardmixer', and is a faster, lower -latency alternative to the softmixer. - ## TODO - Currently, playback only - implementing capture is WIP. diff --git a/docs/1. Introduction.md b/docs/1. Introduction.md index f2d088d..29cac71 100644 --- a/docs/1. Introduction.md +++ b/docs/1. Introduction.md @@ -1,18 +1,13 @@ Introduction =================== -## Problem -- Insecure -- Limited -- Not fully optimised for use case (ie. Routing Audio to DSP vs. Loopback) -- Not generic interface for highly configurable hardware -- +The ALSA Virtual Sound Driver (AVIRT) aims to provide a Linux kernel solution to the issue of audio routing in kernel-space, as well as security per-stream, and dynamic configuration of streams at the kernel level. -## Solution +A top-level abstract dynamic audio driver is presented to the user-space via an ALSA middle-layer card. From there, respective low-level "real" audio drivers can subscribe to it as an "Audio Path". -## Added Features -- Dynamic Runtime Alsa Front end -- Adjustable Audio Path -- Mappable Audio Path -- Secure Audio Routing w/ SMACK -- \ No newline at end of file +The top-level driver is configured (currently) using module parameters, as is the norm for sound drivers in the Linux tree, however this will utilise a configfs configuration implementation in future. + +A sample dummy Audio Path is provided as an example to show how a low-level audio driver would subscribe to AVIRT, and accept audio routing for playback. + +Currently, the Fiberdyne DSP hardmixer is supported on the Renesas R-Car M3 AGL +reference platform, and a default loopback softmixer is in development. \ No newline at end of file diff --git a/docs/2. Building.md b/docs/2. Building.md index 983db8d..0016822 100644 --- a/docs/2. Building.md +++ b/docs/2. Building.md @@ -2,20 +2,34 @@ Building AVIRT =================================== ## Table of Contents -1. [Out of Tree](#out-of-tree) -2. [In Tree](#in-tree) +1. [Introduction](#intro) +2. [Out of Tree](#out-of-tree) +3. [In Tree](#in-tree) + + + +## Introduction +The AVIRT module and submodules can be built using a variety of methods. There are Visual Code build tasks for in and out of tree builds, make file support for CLI building (both in and out of tree), and xds build support. + ## Out Of Tree -The kernel modules can be built either in-tree, or out-of-tree. -To build both AVIRT and the dummy Audio Path out-of-tree, use the following command: +### Building with CLI +To build both AVIRT and the additional Audio Paths out-of-tree, use the following command: + +```sh +$ make +``` +or ```sh $ CONFIG_AVIRT=m CONFIG_AVIRT_BUILDLOCAL=y CONFIG_AVIRT_DUMMYAP=m make -C /lib/modules/$(uname -r)/build/ M=$(pwd) ``` +The latter is executed internally with the make file. +### Building with XDS SDK To build both AVIRT and the dummy Audio Path out-of-tree for [AGL](http://docs.automotivelinux.org/) (`aarch64` currently supported), use the [XDS](http://docs.automotivelinux.org/docs/devguides/en/dev/reference/xds/part-1/0_Abstract.html) build system together with the `make_agl.sh` script: ```sh @@ -26,6 +40,7 @@ $ ./make_agl.sh ${XDS_SDK_ID} ## In tree +The kernal modules can be built in tree, dependent on the avirt repository being located in drivers/staging - If using your own fork of the linux kernel, you will need to update the staging Makefiles and Kconfigs accordingly. To build in tree, use the [Fiberdyne Linux fork](https://github.com/fiberdyne/linux), which will automatically clone the AVIRT Driver and required AudioPath modules to the `drivers/staging` directory. You can then turn AVIRT Support on by setting to ``. The drivers can be found here: ``` @@ -33,6 +48,7 @@ $ make menuconfig # Navigate to: Device Drivers--->Staging Drivers--->AVIRT Support ``` + Finally build the kernel with the configuration selected by making. ``` $ make diff --git a/docs/4. 4A Integration b/docs/4. 4A Integration new file mode 100644 index 0000000..7c9b980 --- /dev/null +++ b/docs/4. 4A Integration @@ -0,0 +1,17 @@ +4A Integration +=================== + +AVIRT has been integrated with [4a-softmixer](https://github.com/iotbzh/4a-softmixer) +and [4a-hal-generic](https://github.com/iotbzh/4a-hal-generic) to provide a smooth +transition from the existing aloop implementation to the future AVIRT loopback implementation. + +### User-space Library + +The user-space library [libavirt](https://github.com/fiberdyne/libavirt) can be used to configure AVIRT from within a given AGL 4A binding. + +### Hardmixer + +A new 4A mixer binding has been developed to demonstrate the capabilities of the +Fiberdyne DSP mixer operating on the HiFi2 core on-board the Renesas R-Car M3 M3ULCB +AGL reference platform. This is called the 'hardmixer', and is a faster, lower +latency alternative to the softmixer. \ No newline at end of file -- cgit 1.2.3-korg From 056c3754bc7be349de1a41ac6d4819f3d032bd0c Mon Sep 17 00:00:00 2001 From: James O'Shannessy Date: Mon, 8 Oct 2018 15:19:34 +1100 Subject: Fixing table of contents in README documentation Restructure docs file tree Signed-off-by: James O'Shannessy --- README.md | 5 ++- docs/1. Introduction.md | 13 -------- docs/1.Introduction.md | 13 ++++++++ docs/2. Building.md | 55 --------------------------------- docs/2.Building.md | 56 +++++++++++++++++++++++++++++++++ docs/3. Usage.md | 80 ------------------------------------------------ docs/3.Usage.md | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ docs/4. 4A Integration | 17 ---------- docs/4.4A-Integration.md | 17 ++++++++++ 9 files changed, 170 insertions(+), 166 deletions(-) delete mode 100644 docs/1. Introduction.md create mode 100644 docs/1.Introduction.md delete mode 100644 docs/2. Building.md create mode 100644 docs/2.Building.md delete mode 100644 docs/3. Usage.md create mode 100644 docs/3.Usage.md delete mode 100644 docs/4. 4A Integration create mode 100644 docs/4.4A-Integration.md (limited to 'docs') diff --git a/README.md b/README.md index fe4a883..f19e7d5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ ## Alsa Virtual Sound Driver -[1. Introduction](docs/1. Introduction.md) +[1. Introduction](docs/1.Introduction.md) +[2. Building](docs/2.Building.md) +[3. Usage](docs/3.Usage.md) +[4. 4A Integration](docs/4.4A-Integration.md) ## TODO diff --git a/docs/1. Introduction.md b/docs/1. Introduction.md deleted file mode 100644 index 29cac71..0000000 --- a/docs/1. Introduction.md +++ /dev/null @@ -1,13 +0,0 @@ -Introduction -=================== - -The ALSA Virtual Sound Driver (AVIRT) aims to provide a Linux kernel solution to the issue of audio routing in kernel-space, as well as security per-stream, and dynamic configuration of streams at the kernel level. - -A top-level abstract dynamic audio driver is presented to the user-space via an ALSA middle-layer card. From there, respective low-level "real" audio drivers can subscribe to it as an "Audio Path". - -The top-level driver is configured (currently) using module parameters, as is the norm for sound drivers in the Linux tree, however this will utilise a configfs configuration implementation in future. - -A sample dummy Audio Path is provided as an example to show how a low-level audio driver would subscribe to AVIRT, and accept audio routing for playback. - -Currently, the Fiberdyne DSP hardmixer is supported on the Renesas R-Car M3 AGL -reference platform, and a default loopback softmixer is in development. \ No newline at end of file diff --git a/docs/1.Introduction.md b/docs/1.Introduction.md new file mode 100644 index 0000000..29cac71 --- /dev/null +++ b/docs/1.Introduction.md @@ -0,0 +1,13 @@ +Introduction +=================== + +The ALSA Virtual Sound Driver (AVIRT) aims to provide a Linux kernel solution to the issue of audio routing in kernel-space, as well as security per-stream, and dynamic configuration of streams at the kernel level. + +A top-level abstract dynamic audio driver is presented to the user-space via an ALSA middle-layer card. From there, respective low-level "real" audio drivers can subscribe to it as an "Audio Path". + +The top-level driver is configured (currently) using module parameters, as is the norm for sound drivers in the Linux tree, however this will utilise a configfs configuration implementation in future. + +A sample dummy Audio Path is provided as an example to show how a low-level audio driver would subscribe to AVIRT, and accept audio routing for playback. + +Currently, the Fiberdyne DSP hardmixer is supported on the Renesas R-Car M3 AGL +reference platform, and a default loopback softmixer is in development. \ No newline at end of file diff --git a/docs/2. Building.md b/docs/2. Building.md deleted file mode 100644 index 0016822..0000000 --- a/docs/2. Building.md +++ /dev/null @@ -1,55 +0,0 @@ -Building AVIRT -=================================== - -## Table of Contents -1. [Introduction](#intro) -2. [Out of Tree](#out-of-tree) -3. [In Tree](#in-tree) - - - -## Introduction -The AVIRT module and submodules can be built using a variety of methods. There are Visual Code build tasks for in and out of tree builds, make file support for CLI building (both in and out of tree), and xds build support. - - - - -## Out Of Tree - -### Building with CLI -To build both AVIRT and the additional Audio Paths out-of-tree, use the following command: - -```sh -$ make -``` - -or -```sh -$ CONFIG_AVIRT=m CONFIG_AVIRT_BUILDLOCAL=y CONFIG_AVIRT_DUMMYAP=m make -C /lib/modules/$(uname -r)/build/ M=$(pwd) -``` -The latter is executed internally with the make file. - -### Building with XDS SDK -To build both AVIRT and the dummy Audio Path out-of-tree for [AGL](http://docs.automotivelinux.org/) (`aarch64` currently supported), use the [XDS](http://docs.automotivelinux.org/docs/devguides/en/dev/reference/xds/part-1/0_Abstract.html) build system together with the `make_agl.sh` script: - -```sh -$ ./make_agl.sh ${XDS_SDK_ID} -``` - - - -## In tree - -The kernal modules can be built in tree, dependent on the avirt repository being located in drivers/staging - If using your own fork of the linux kernel, you will need to update the staging Makefiles and Kconfigs accordingly. - -To build in tree, use the [Fiberdyne Linux fork](https://github.com/fiberdyne/linux), which will automatically clone the AVIRT Driver and required AudioPath modules to the `drivers/staging` directory. You can then turn AVIRT Support on by setting to ``. The drivers can be found here: -``` -$ make menuconfig - -# Navigate to: Device Drivers--->Staging Drivers--->AVIRT Support -``` - -Finally build the kernel with the configuration selected by making. -``` -$ make -``` \ No newline at end of file diff --git a/docs/2.Building.md b/docs/2.Building.md new file mode 100644 index 0000000..237d834 --- /dev/null +++ b/docs/2.Building.md @@ -0,0 +1,56 @@ +Building AVIRT +=================================== + +## Table of Contents +1. [Introduction](#intro) +2. [Out of Tree](#out-of-tree) +3. [In Tree](#in-tree) + + + +## Introduction +The AVIRT module and submodules can be built using a variety of methods. There are Visual Code build tasks for in and out of tree builds, make file support for CLI building (both in and out of tree), and xds build support. + + + + +## Out Of Tree + +### Building with CLI +To build both AVIRT and the additional Audio Paths out-of-tree, use the following command: + +```sh +$ make +``` + +or +```sh +$ CONFIG_AVIRT=m CONFIG_AVIRT_BUILDLOCAL=y CONFIG_AVIRT_DUMMYAP=m make -C /lib/modules/$(uname -r)/build/ M=$(pwd) +``` +The latter is executed internally with the make file. + +### Building with XDS SDK +To build both AVIRT and the dummy Audio Path out-of-tree for [AGL](http://docs.automotivelinux.org/) (`aarch64` currently supported), use the [XDS](http://docs.automotivelinux.org/docs/devguides/en/dev/reference/xds/part-1/0_Abstract.html) build system together with the `make_agl.sh` script: + +```sh +$ ./make_agl.sh ${XDS_SDK_ID} +``` + + + +## In tree + +The kernal modules can be built in tree, dependent on the avirt repository being located in drivers/staging - If using your own fork of the linux kernel, you will need to update the staging Makefiles and Kconfigs accordingly. + +To build in tree, use the [Fiberdyne Linux fork](https://github.com/fiberdyne/linux), which will automatically clone the AVIRT Driver and required AudioPath modules to the `drivers/staging` directory. You can then turn AVIRT Support on by setting to ``. The drivers can be found here: + +``` +$ make menuconfig + +# Navigate to: Device Drivers--->Staging Drivers--->AVIRT Support +``` + +Finally build the kernel with the configuration selected by making. +``` +$ make +``` \ No newline at end of file diff --git a/docs/3. Usage.md b/docs/3. Usage.md deleted file mode 100644 index 7eb46d3..0000000 --- a/docs/3. Usage.md +++ /dev/null @@ -1,80 +0,0 @@ -Using AVIRT -=================================== - -## Introduction - -## Table of Contents -1. [Load/Unload AVIRT](#un-load-avirt) -2. [Configuring AVIRT](#configuring-avirt) - - - -## Loading and Unloading AVIRT - -As root, load the required ```avirt_core.ko``` and subsequent audio path. -As an example, the Dummy Audiopath is being loaded here. - -```sh -insmod avirt_core.ko -insmod dummy/dummy_audiopath.ko -``` - -### Note: -The loading and unloading of drivers can be performed using the helper scripts. -To run, we must load the kernel modules using the `loadDrivers.sh` script, which contains sample module parameters to AVIRT: -```sh -$ ./loadDrivers.sh -``` -To unload the drivers use: -```sh -$ ./unload.sh -``` - - - -## Configuring AVIRT - -AVIRT is configured using configfs. -### Note: -A sample script for the following is supplied inside the ```scripts``` folder. - -First, verify the kernel supports the use of configfs. -```sh -fgrep configfs /proc/filesystems -``` - -the expected output is: -``` -nodev configfs -``` - -Once confirmed, we can mount the configfs at the conventional point: -```sh -#Check configfs is mounted on the system -mkdir -p /config -mount -t configfs none /config -``` - -Finally, we can configure AVIRT: - -```sh -# Set up each of the cards channels -mkdir /config/avirt/streams/playback_media -echo "2">/config/avirt/streams/playback_media/channels - -mkdir /config/avirt/streams/playback_navigation -echo "1">/config/avirt/streams/playback_navigation/channels - -mkdir /config/avirt/streams/playback_emergency -echo "1">/config/avirt/streams/playback_emergency/channels - -mkdir /config/avirt/streams/capture_voice -echo "1">/config/avirt/streams/capture_voice/channels - -# Finally, seal the card, and initiate configuration -echo "1">/config/avirt/streams/sealed -``` - -### Note: -A simplified helper library, libavirt, is available [here](https://github.com/fiberdyne/libavirt). -Please refer to the readme in libavirt for further details. diff --git a/docs/3.Usage.md b/docs/3.Usage.md new file mode 100644 index 0000000..7eb46d3 --- /dev/null +++ b/docs/3.Usage.md @@ -0,0 +1,80 @@ +Using AVIRT +=================================== + +## Introduction + +## Table of Contents +1. [Load/Unload AVIRT](#un-load-avirt) +2. [Configuring AVIRT](#configuring-avirt) + + + +## Loading and Unloading AVIRT + +As root, load the required ```avirt_core.ko``` and subsequent audio path. +As an example, the Dummy Audiopath is being loaded here. + +```sh +insmod avirt_core.ko +insmod dummy/dummy_audiopath.ko +``` + +### Note: +The loading and unloading of drivers can be performed using the helper scripts. +To run, we must load the kernel modules using the `loadDrivers.sh` script, which contains sample module parameters to AVIRT: +```sh +$ ./loadDrivers.sh +``` +To unload the drivers use: +```sh +$ ./unload.sh +``` + + + +## Configuring AVIRT + +AVIRT is configured using configfs. +### Note: +A sample script for the following is supplied inside the ```scripts``` folder. + +First, verify the kernel supports the use of configfs. +```sh +fgrep configfs /proc/filesystems +``` + +the expected output is: +``` +nodev configfs +``` + +Once confirmed, we can mount the configfs at the conventional point: +```sh +#Check configfs is mounted on the system +mkdir -p /config +mount -t configfs none /config +``` + +Finally, we can configure AVIRT: + +```sh +# Set up each of the cards channels +mkdir /config/avirt/streams/playback_media +echo "2">/config/avirt/streams/playback_media/channels + +mkdir /config/avirt/streams/playback_navigation +echo "1">/config/avirt/streams/playback_navigation/channels + +mkdir /config/avirt/streams/playback_emergency +echo "1">/config/avirt/streams/playback_emergency/channels + +mkdir /config/avirt/streams/capture_voice +echo "1">/config/avirt/streams/capture_voice/channels + +# Finally, seal the card, and initiate configuration +echo "1">/config/avirt/streams/sealed +``` + +### Note: +A simplified helper library, libavirt, is available [here](https://github.com/fiberdyne/libavirt). +Please refer to the readme in libavirt for further details. diff --git a/docs/4. 4A Integration b/docs/4. 4A Integration deleted file mode 100644 index 7c9b980..0000000 --- a/docs/4. 4A Integration +++ /dev/null @@ -1,17 +0,0 @@ -4A Integration -=================== - -AVIRT has been integrated with [4a-softmixer](https://github.com/iotbzh/4a-softmixer) -and [4a-hal-generic](https://github.com/iotbzh/4a-hal-generic) to provide a smooth -transition from the existing aloop implementation to the future AVIRT loopback implementation. - -### User-space Library - -The user-space library [libavirt](https://github.com/fiberdyne/libavirt) can be used to configure AVIRT from within a given AGL 4A binding. - -### Hardmixer - -A new 4A mixer binding has been developed to demonstrate the capabilities of the -Fiberdyne DSP mixer operating on the HiFi2 core on-board the Renesas R-Car M3 M3ULCB -AGL reference platform. This is called the 'hardmixer', and is a faster, lower -latency alternative to the softmixer. \ No newline at end of file diff --git a/docs/4.4A-Integration.md b/docs/4.4A-Integration.md new file mode 100644 index 0000000..7c9b980 --- /dev/null +++ b/docs/4.4A-Integration.md @@ -0,0 +1,17 @@ +4A Integration +=================== + +AVIRT has been integrated with [4a-softmixer](https://github.com/iotbzh/4a-softmixer) +and [4a-hal-generic](https://github.com/iotbzh/4a-hal-generic) to provide a smooth +transition from the existing aloop implementation to the future AVIRT loopback implementation. + +### User-space Library + +The user-space library [libavirt](https://github.com/fiberdyne/libavirt) can be used to configure AVIRT from within a given AGL 4A binding. + +### Hardmixer + +A new 4A mixer binding has been developed to demonstrate the capabilities of the +Fiberdyne DSP mixer operating on the HiFi2 core on-board the Renesas R-Car M3 M3ULCB +AGL reference platform. This is called the 'hardmixer', and is a faster, lower +latency alternative to the softmixer. \ No newline at end of file -- cgit 1.2.3-korg From 94eb09750343f0adc8f4bf56eb4ee05ce9def8f1 Mon Sep 17 00:00:00 2001 From: James O'Shannessy Date: Mon, 8 Oct 2018 16:03:12 +1100 Subject: Updating Introduction doc Signed-off-by: James O'Shannessy --- README.md | 2 +- docs/1.Introduction.md | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'docs') diff --git a/README.md b/README.md index f19e7d5..dc72ff1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## Alsa Virtual Sound Driver -[1. Introduction](docs/1.Introduction.md) +1. [Introduction](docs/1.Introduction.md) [2. Building](docs/2.Building.md) [3. Usage](docs/3.Usage.md) [4. 4A Integration](docs/4.4A-Integration.md) diff --git a/docs/1.Introduction.md b/docs/1.Introduction.md index 29cac71..25b3ea8 100644 --- a/docs/1.Introduction.md +++ b/docs/1.Introduction.md @@ -1,13 +1,27 @@ Introduction =================== +## Problem +The existing solution contains the following drawbacks: + 1. Non-generic interface for configurable hardware cases + - Unable to configure streams mapped to outputs + 2. Not fully optimized for certain use cases (ie. Routing Audio to DSP vs. aloop) + - Routing audio to hardware to reduce overhead + 3. Inability to secure on all audio streams + - Substreams cannot have SMACK labels applied, inherently leaving different audio streams insecure, or a single label applied to all. + +## AVIRTs Solution The ALSA Virtual Sound Driver (AVIRT) aims to provide a Linux kernel solution to the issue of audio routing in kernel-space, as well as security per-stream, and dynamic configuration of streams at the kernel level. A top-level abstract dynamic audio driver is presented to the user-space via an ALSA middle-layer card. From there, respective low-level "real" audio drivers can subscribe to it as an "Audio Path". -The top-level driver is configured (currently) using module parameters, as is the norm for sound drivers in the Linux tree, however this will utilise a configfs configuration implementation in future. +The top-level driver is configured (currently) using by utilising configfs. + +AVIRT attempts to address the aforementioned problems by: + 1. Providing a standard interface through configfs to configure a variable number of 'streams' which can be mapped to audio paths. + 2. Optimize the audio routing by connecting directly with the desired audio path. This can include routing audio through directly to hardware, or to an implemented loopback interface. + 3. Each 'stream' is separated to its own device, therefore security can be applied to each 'stream'. This means that each of the audio roles can be separately secured from each other. A sample dummy Audio Path is provided as an example to show how a low-level audio driver would subscribe to AVIRT, and accept audio routing for playback. -Currently, the Fiberdyne DSP hardmixer is supported on the Renesas R-Car M3 AGL -reference platform, and a default loopback softmixer is in development. \ No newline at end of file +Currently, the Fiberdyne DSP hardmixer is supported on the Renesas R-Car M3 AGL reference platform, and a default loopback softmixer is in development. \ No newline at end of file -- cgit 1.2.3-korg From c6c2c324c13fec5a3e1d52059454e4d8b17b1e28 Mon Sep 17 00:00:00 2001 From: James O'Shannessy Date: Mon, 8 Oct 2018 15:20:38 +1100 Subject: Update README.md Fix table of contents Markdown links Fixing whitespace problems in Markdown docs Fix alignment of table of contents Signed-off-by: James O'Shannessy --- README.md | 9 +++++---- docs/1.Introduction.md | 18 +++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'docs') diff --git a/README.md b/README.md index dc72ff1..9c70cfb 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ ## Alsa Virtual Sound Driver 1. [Introduction](docs/1.Introduction.md) -[2. Building](docs/2.Building.md) -[3. Usage](docs/3.Usage.md) -[4. 4A Integration](docs/4.4A-Integration.md) +2. [Building](docs/2.Building.md) +3. [Usage](docs/3.Usage.md) +4. [4A Integration](docs/4.4A-Integration.md) + ## TODO - Currently, playback only - implementing capture is WIP. -- Create a loopback Audio Path for use with AVIRT, to demonstrate standard AGL soft-mixing capabilities. + diff --git a/docs/1.Introduction.md b/docs/1.Introduction.md index 25b3ea8..7bf3ebe 100644 --- a/docs/1.Introduction.md +++ b/docs/1.Introduction.md @@ -3,12 +3,12 @@ Introduction ## Problem The existing solution contains the following drawbacks: - 1. Non-generic interface for configurable hardware cases - - Unable to configure streams mapped to outputs - 2. Not fully optimized for certain use cases (ie. Routing Audio to DSP vs. aloop) - - Routing audio to hardware to reduce overhead - 3. Inability to secure on all audio streams - - Substreams cannot have SMACK labels applied, inherently leaving different audio streams insecure, or a single label applied to all. +1. Non-generic interface for configurable hardware cases + - Unable to configure streams mapped to outputs +2. Not fully optimized for certain use cases (ie. Routing Audio to DSP vs. aloop) + - Routing audio to hardware to reduce overhead +3. Inability to secure on all audio streams + - Substreams cannot have SMACK labels applied, inherently leaving different audio streams insecure, or a single label applied to all. ## AVIRTs Solution The ALSA Virtual Sound Driver (AVIRT) aims to provide a Linux kernel solution to the issue of audio routing in kernel-space, as well as security per-stream, and dynamic configuration of streams at the kernel level. @@ -18,9 +18,9 @@ A top-level abstract dynamic audio driver is presented to the user-space via an The top-level driver is configured (currently) using by utilising configfs. AVIRT attempts to address the aforementioned problems by: - 1. Providing a standard interface through configfs to configure a variable number of 'streams' which can be mapped to audio paths. - 2. Optimize the audio routing by connecting directly with the desired audio path. This can include routing audio through directly to hardware, or to an implemented loopback interface. - 3. Each 'stream' is separated to its own device, therefore security can be applied to each 'stream'. This means that each of the audio roles can be separately secured from each other. +1. Providing a standard interface through configfs to configure a variable number of 'streams' which can be mapped to audio paths. +2. Optimize the audio routing by connecting directly with the desired audio path. This can include routing audio through directly to hardware, or to an implemented loopback interface. +3. Each 'stream' is separated to its own device, therefore security can be applied to each 'stream'. This means that each of the audio roles can be separately secured from each other. A sample dummy Audio Path is provided as an example to show how a low-level audio driver would subscribe to AVIRT, and accept audio routing for playback. -- cgit 1.2.3-korg From 3b62055c816764ff02aeb3a548e9bba36df8aae4 Mon Sep 17 00:00:00 2001 From: Mark Farrugia Date: Mon, 8 Oct 2018 16:47:25 +1100 Subject: Update documentation Add 'map' to configfs test, remove old mentions of module parameters Signed-off-by: Mark Farrugia --- docs/1.Introduction.md | 17 ++++++++++++---- docs/2.Building.md | 12 ++++++++--- docs/3.Usage.md | 53 +++++++++++++++++++++++++++++++++++++++++------- docs/4.4A-Integration.md | 4 ++-- 4 files changed, 70 insertions(+), 16 deletions(-) (limited to 'docs') diff --git a/docs/1.Introduction.md b/docs/1.Introduction.md index 7bf3ebe..2ddaf57 100644 --- a/docs/1.Introduction.md +++ b/docs/1.Introduction.md @@ -2,15 +2,23 @@ Introduction =================== ## Problem + The existing solution contains the following drawbacks: + 1. Non-generic interface for configurable hardware cases - - Unable to configure streams mapped to outputs + + - Unable to configure streams mapped to outputs + 2. Not fully optimized for certain use cases (ie. Routing Audio to DSP vs. aloop) - - Routing audio to hardware to reduce overhead + + - Routing audio to hardware to reduce overhead + 3. Inability to secure on all audio streams - - Substreams cannot have SMACK labels applied, inherently leaving different audio streams insecure, or a single label applied to all. + + - Substreams cannot have SMACK labels applied, inherently leaving different audio streams insecure, or a single label applied to all. ## AVIRTs Solution + The ALSA Virtual Sound Driver (AVIRT) aims to provide a Linux kernel solution to the issue of audio routing in kernel-space, as well as security per-stream, and dynamic configuration of streams at the kernel level. A top-level abstract dynamic audio driver is presented to the user-space via an ALSA middle-layer card. From there, respective low-level "real" audio drivers can subscribe to it as an "Audio Path". @@ -18,10 +26,11 @@ A top-level abstract dynamic audio driver is presented to the user-space via an The top-level driver is configured (currently) using by utilising configfs. AVIRT attempts to address the aforementioned problems by: + 1. Providing a standard interface through configfs to configure a variable number of 'streams' which can be mapped to audio paths. 2. Optimize the audio routing by connecting directly with the desired audio path. This can include routing audio through directly to hardware, or to an implemented loopback interface. 3. Each 'stream' is separated to its own device, therefore security can be applied to each 'stream'. This means that each of the audio roles can be separately secured from each other. A sample dummy Audio Path is provided as an example to show how a low-level audio driver would subscribe to AVIRT, and accept audio routing for playback. -Currently, the Fiberdyne DSP hardmixer is supported on the Renesas R-Car M3 AGL reference platform, and a default loopback softmixer is in development. \ No newline at end of file +Currently, the Fiberdyne DSP hardmixer is supported on the Renesas R-Car M3 AGL reference platform, and a default loopback softmixer is in development. diff --git a/docs/2.Building.md b/docs/2.Building.md index 237d834..3e42746 100644 --- a/docs/2.Building.md +++ b/docs/2.Building.md @@ -2,21 +2,23 @@ Building AVIRT =================================== ## Table of Contents + 1. [Introduction](#intro) -2. [Out of Tree](#out-of-tree) +2. [Out of Tree](#out-of-tree) 3. [In Tree](#in-tree) ## Introduction -The AVIRT module and submodules can be built using a variety of methods. There are Visual Code build tasks for in and out of tree builds, make file support for CLI building (both in and out of tree), and xds build support. +The AVIRT module and submodules can be built using a variety of methods. There are Visual Code build tasks for in and out of tree builds, make file support for CLI building (both in and out of tree), and xds build support. ## Out Of Tree ### Building with CLI + To build both AVIRT and the additional Audio Paths out-of-tree, use the following command: ```sh @@ -24,12 +26,15 @@ $ make ``` or + ```sh $ CONFIG_AVIRT=m CONFIG_AVIRT_BUILDLOCAL=y CONFIG_AVIRT_DUMMYAP=m make -C /lib/modules/$(uname -r)/build/ M=$(pwd) ``` + The latter is executed internally with the make file. ### Building with XDS SDK + To build both AVIRT and the dummy Audio Path out-of-tree for [AGL](http://docs.automotivelinux.org/) (`aarch64` currently supported), use the [XDS](http://docs.automotivelinux.org/docs/devguides/en/dev/reference/xds/part-1/0_Abstract.html) build system together with the `make_agl.sh` script: ```sh @@ -51,6 +56,7 @@ $ make menuconfig ``` Finally build the kernel with the configuration selected by making. + ``` $ make -``` \ No newline at end of file +``` diff --git a/docs/3.Usage.md b/docs/3.Usage.md index 7eb46d3..6d4d9f1 100644 --- a/docs/3.Usage.md +++ b/docs/3.Usage.md @@ -4,6 +4,7 @@ Using AVIRT ## Introduction ## Table of Contents + 1. [Load/Unload AVIRT](#un-load-avirt) 2. [Configuring AVIRT](#configuring-avirt) @@ -11,7 +12,9 @@ Using AVIRT ## Loading and Unloading AVIRT -As root, load the required ```avirt_core.ko``` and subsequent audio path. +### Load Out of Tree + +As root, load the required `avirt_core.ko` and subsequent audio path. As an example, the Dummy Audiopath is being loaded here. ```sh @@ -20,14 +23,38 @@ insmod dummy/dummy_audiopath.ko ``` ### Note: + The loading and unloading of drivers can be performed using the helper scripts. -To run, we must load the kernel modules using the `loadDrivers.sh` script, which contains sample module parameters to AVIRT: +To run, we must load the kernel modules using the `scripts/load.sh` script: + ```sh -$ ./loadDrivers.sh +$ ./scripts/load.sh ``` + To unload the drivers use: + +```sh +$ ./scripts/unload.sh +``` + +### Load In Tree + +#### Note: + +Either build the module in tree, or you can copy the modules manually and then run `depmod` to generate dependencies. +For example, in AGL: + ```sh -$ ./unload.sh +mkdir -p /lib/modules/$(uname -r)/extra +cp avirt_core.ko avirt_dummyap.ko /lib/modules/$(uname -r)/extra +depmod +``` + +Once the modules are in place, we can load the modules using: + +```sh +modprobe avirt_core +modprobe avirt_dummyap ``` @@ -35,22 +62,27 @@ $ ./unload.sh ## Configuring AVIRT AVIRT is configured using configfs. -### Note: -A sample script for the following is supplied inside the ```scripts``` folder. + +### Note: + +A sample script for the following is supplied inside the `scripts` folder. First, verify the kernel supports the use of configfs. + ```sh fgrep configfs /proc/filesystems ``` the expected output is: + ``` nodev configfs ``` Once confirmed, we can mount the configfs at the conventional point: + ```sh -#Check configfs is mounted on the system +# Check configfs is mounted on the system mkdir -p /config mount -t configfs none /config ``` @@ -61,20 +93,27 @@ Finally, we can configure AVIRT: # Set up each of the cards channels mkdir /config/avirt/streams/playback_media echo "2">/config/avirt/streams/playback_media/channels +echo "ap_dummy">/config/avirt/streams/playback_media/map mkdir /config/avirt/streams/playback_navigation echo "1">/config/avirt/streams/playback_navigation/channels +echo "ap_dummy">/config/avirt/streams/playback_navigation/map mkdir /config/avirt/streams/playback_emergency echo "1">/config/avirt/streams/playback_emergency/channels +echo "ap_dummy">/config/avirt/streams/playback_emergency/map mkdir /config/avirt/streams/capture_voice echo "1">/config/avirt/streams/capture_voice/channels +echo "ap_dummy">/config/avirt/streams/capture_voice/map # Finally, seal the card, and initiate configuration echo "1">/config/avirt/streams/sealed ``` +Alternatively, the test script at `scripts/test_configfs.sh` can be used. + ### Note: + A simplified helper library, libavirt, is available [here](https://github.com/fiberdyne/libavirt). Please refer to the readme in libavirt for further details. diff --git a/docs/4.4A-Integration.md b/docs/4.4A-Integration.md index 7c9b980..da4eeb7 100644 --- a/docs/4.4A-Integration.md +++ b/docs/4.4A-Integration.md @@ -13,5 +13,5 @@ The user-space library [libavirt](https://github.com/fiberdyne/libavirt) can be A new 4A mixer binding has been developed to demonstrate the capabilities of the Fiberdyne DSP mixer operating on the HiFi2 core on-board the Renesas R-Car M3 M3ULCB -AGL reference platform. This is called the 'hardmixer', and is a faster, lower -latency alternative to the softmixer. \ No newline at end of file +AGL reference platform. This is called the '**hardmixer**', and is a faster, lower +latency alternative to the softmixer. -- cgit 1.2.3-korg From cd128853f392960ceec44476f37f0d569a680db5 Mon Sep 17 00:00:00 2001 From: Mark Farrugia Date: Mon, 8 Oct 2018 17:59:15 +1100 Subject: Update docs to include loopback Signed-off-by: Mark Farrugia --- docs/1.Introduction.md | 2 +- docs/3.Usage.md | 6 ++++-- docs/4.4A-Integration.md | 7 ++++++- 3 files changed, 11 insertions(+), 4 deletions(-) (limited to 'docs') diff --git a/docs/1.Introduction.md b/docs/1.Introduction.md index 2ddaf57..e189c7c 100644 --- a/docs/1.Introduction.md +++ b/docs/1.Introduction.md @@ -33,4 +33,4 @@ AVIRT attempts to address the aforementioned problems by: A sample dummy Audio Path is provided as an example to show how a low-level audio driver would subscribe to AVIRT, and accept audio routing for playback. -Currently, the Fiberdyne DSP hardmixer is supported on the Renesas R-Car M3 AGL reference platform, and a default loopback softmixer is in development. +Currently, the Fiberdyne DSP hardmixer is supported on the Renesas R-Car M3 AGL reference platform, and the default loopback softmixer can be used to emulate this in cases where the former is not available. diff --git a/docs/3.Usage.md b/docs/3.Usage.md index 6d4d9f1..df56cf1 100644 --- a/docs/3.Usage.md +++ b/docs/3.Usage.md @@ -19,7 +19,8 @@ As an example, the Dummy Audiopath is being loaded here. ```sh insmod avirt_core.ko -insmod dummy/dummy_audiopath.ko +insmod dummy/avirt_dummyap.ko +insmod loopback/avirt_loopbackap.ko ``` ### Note: @@ -46,7 +47,7 @@ For example, in AGL: ```sh mkdir -p /lib/modules/$(uname -r)/extra -cp avirt_core.ko avirt_dummyap.ko /lib/modules/$(uname -r)/extra +cp avirt_core.ko avirt_dummyap.ko avirt_loopbackap.ko /lib/modules/$(uname -r)/extra depmod ``` @@ -55,6 +56,7 @@ Once the modules are in place, we can load the modules using: ```sh modprobe avirt_core modprobe avirt_dummyap +modprobe avirt_loopbackap ``` diff --git a/docs/4.4A-Integration.md b/docs/4.4A-Integration.md index da4eeb7..cb88dd3 100644 --- a/docs/4.4A-Integration.md +++ b/docs/4.4A-Integration.md @@ -9,9 +9,14 @@ transition from the existing aloop implementation to the future AVIRT loopback i The user-space library [libavirt](https://github.com/fiberdyne/libavirt) can be used to configure AVIRT from within a given AGL 4A binding. +### Softmixer + +The AVIRT loopback can be used in-place of the standard aloop module. Modifications are currently underway +to port the current 4a-softmixer to the new AVIRT loopback. + ### Hardmixer -A new 4A mixer binding has been developed to demonstrate the capabilities of the +A new 4A mixer controller plugin (`.ctlso`) has been developed to demonstrate the capabilities of the Fiberdyne DSP mixer operating on the HiFi2 core on-board the Renesas R-Car M3 M3ULCB AGL reference platform. This is called the '**hardmixer**', and is a faster, lower latency alternative to the softmixer. -- cgit 1.2.3-korg From 964987727646a7139a3d259830f25a739937fa73 Mon Sep 17 00:00:00 2001 From: Mark Farrugia Date: Tue, 9 Oct 2018 10:10:49 +1100 Subject: Add docs: Add architecture diagram for 4A Tidy other docs Signed-off-by: Mark Farrugia --- README.md | 2 +- docs/1.Introduction.md | 24 +++++++++++++----------- docs/3.Usage.md | 30 ++++++++++++++++++++++++------ docs/images/arch-4a.png | Bin 0 -> 282311 bytes 4 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 docs/images/arch-4a.png (limited to 'docs') diff --git a/README.md b/README.md index 9c70cfb..a653f0e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Alsa Virtual Sound Driver +# Alsa Virtual Sound Driver 1. [Introduction](docs/1.Introduction.md) 2. [Building](docs/2.Building.md) diff --git a/docs/1.Introduction.md b/docs/1.Introduction.md index e189c7c..c36717c 100644 --- a/docs/1.Introduction.md +++ b/docs/1.Introduction.md @@ -3,7 +3,7 @@ Introduction ## Problem -The existing solution contains the following drawbacks: +The existing audio solution in [AGL](https://www.automotivelinux.org/) (Automotive Grade Linux) utilizes the ALSA loopback module together with [4a-softmixer](https://github.com/iotbzh/4a-softmixer). There are drawbacks to this solution: 1. Non-generic interface for configurable hardware cases @@ -17,20 +17,22 @@ The existing solution contains the following drawbacks: - Substreams cannot have SMACK labels applied, inherently leaving different audio streams insecure, or a single label applied to all. -## AVIRTs Solution +## The AVIRT Solution -The ALSA Virtual Sound Driver (AVIRT) aims to provide a Linux kernel solution to the issue of audio routing in kernel-space, as well as security per-stream, and dynamic configuration of streams at the kernel level. +The ALSA Virtual Sound Driver (AVIRT) aims to provide a Linux kernel solution to the issue of audio routing in kernel-space, as well as security per audio stream, and dynamic configuration of audio streams at the kernel level. -A top-level abstract dynamic audio driver is presented to the user-space via an ALSA middle-layer card. From there, respective low-level "real" audio drivers can subscribe to it as an "Audio Path". +AVIRT addresses the aforementioned problems by: -The top-level driver is configured (currently) using by utilising configfs. +1. Providing a standard user-space interface via `configfs` to configure a variable number of 'streams' which can be mapped to audio paths. +2. Optimize the audio routing by connecting directly with the desired audio path. This can include routing audio through directly to hardware, to an implemented loopback interface, or to a DSP. +3. Each 'stream' is separated to its own ALSA PCM device, therefore differing security attributes can be applied to each 'stream'. This means that each of the audio roles can have separate security contexts from one another. -AVIRT attempts to address the aforementioned problems by: +A top-level abstract dynamic audio driver is presented to the user-space via an ALSA middle-layer card. The card's PCM devices are configured using `configfs` via the accompanying userspace library [libavirt](https://github.com/fiberdyne/libavirt). The low-level "real" audio drivers can subscribe to the top-level as an "Audio Path". The Audio Path accepts routed audio streams from the abstracted top-level, and is then able to direct the audio streams accordingly. -1. Providing a standard interface through configfs to configure a variable number of 'streams' which can be mapped to audio paths. -2. Optimize the audio routing by connecting directly with the desired audio path. This can include routing audio through directly to hardware, or to an implemented loopback interface. -3. Each 'stream' is separated to its own device, therefore security can be applied to each 'stream'. This means that each of the audio roles can be separately secured from each other. +![alt text](images/arch-4a.png "AVIRT Architecture") -A sample dummy Audio Path is provided as an example to show how a low-level audio driver would subscribe to AVIRT, and accept audio routing for playback. +The following Audio Paths are currently implemented for AVIRT: -Currently, the Fiberdyne DSP hardmixer is supported on the Renesas R-Car M3 AGL reference platform, and the default loopback softmixer can be used to emulate this in cases where the former is not available. +- **ap_dummy** - This is provided as an example to show how a low-level audio driver would subscribe to AVIRT, and accept audio routing for playback. +- **ap_fddsp** - This is the Fiberdyne DSP hardmixer. This is only supported on the Renesas R-Car M3 AGL reference platform, and utilizes the HiFi2 DSP core to provide advanced DSP and audio mixing. An accompanying UI can be used to control the DSP parameters. +- **ap_loopback** - This is the default loopback for use with the softmixer. This is the stock AGL solution to be used to emulate the hardmixer when not available. diff --git a/docs/3.Usage.md b/docs/3.Usage.md index df56cf1..d65d50d 100644 --- a/docs/3.Usage.md +++ b/docs/3.Usage.md @@ -75,13 +75,13 @@ First, verify the kernel supports the use of configfs. fgrep configfs /proc/filesystems ``` -the expected output is: +The expected output is: ``` nodev configfs ``` -Once confirmed, we can mount the configfs at the conventional point: +Once confirmed, we can mount the `configfs` filesystem at the conventional point: ```sh # Check configfs is mounted on the system @@ -89,7 +89,7 @@ mkdir -p /config mount -t configfs none /config ``` -Finally, we can configure AVIRT: +Finally, we can configure AVIRT, for example: ```sh # Set up each of the cards channels @@ -115,7 +115,25 @@ echo "1">/config/avirt/streams/sealed Alternatively, the test script at `scripts/test_configfs.sh` can be used. -### Note: +The user-space library, [libavirt](https://github.com/fiberdyne/libavirt) can be used to interact with the configfs interface. Please refer to the README in libavirt for further details. + + + +## 3. Checking AVIRT Loaded Correctly -A simplified helper library, libavirt, is available [here](https://github.com/fiberdyne/libavirt). -Please refer to the readme in libavirt for further details. +We can see the newly created streams by using the `aplay` utility. For example, the device list might look a little like this: + +```sh +aplay -l +... +card 2: avirt [avirt], device 0: multimedia [multimedia] + Subdevices: 1/1 + Subdevice #0: subdevice #0 +card 2: avirt [avirt], device 1: navigation [navigation] + Subdevices: 1/1 + Subdevice #0: subdevice #0 +card 2: avirt [avirt], device 2: emergency [emergency] + Subdevices: 1/1 + Subdevice #0: subdevice #0 +... +``` diff --git a/docs/images/arch-4a.png b/docs/images/arch-4a.png new file mode 100644 index 0000000..6f085db Binary files /dev/null and b/docs/images/arch-4a.png differ -- cgit 1.2.3-korg From d66dbf0820e9e7e14a6f723c1ce92b7ac4e0280d Mon Sep 17 00:00:00 2001 From: Mark Farrugia Date: Thu, 25 Oct 2018 17:37:07 +1100 Subject: Refactor all avirt_ symbols to have have snd prefix, as per Linux sound This will aid the eventual migration the the upstream mainline Linux kernel Fix some checkpatch warnings, and other compiler warnings Signed-off-by: Mark Farrugia --- Makefile | 16 ++-- alsa-pcm.c | 70 ++++++++--------- configfs.c | 116 +++++++++++++++------------- core.c | 197 ++++++++++++++++++++++++----------------------- core.h | 33 ++++---- docs/2.Building.md | 2 +- docs/3.Usage.md | 40 +++++----- dummy/Makefile | 4 +- dummy/dummy.c | 22 +++--- loopback/Makefile | 4 +- loopback/loopback.c | 32 ++++---- scripts/load.sh | 6 +- scripts/make-agl.sh | 6 +- scripts/test_configfs.sh | 26 +++---- scripts/unload.sh | 10 +-- sound/avirt.h | 54 ++++++------- 16 files changed, 325 insertions(+), 313 deletions(-) (limited to 'docs') diff --git a/Makefile b/Makefile index 791a60a..84b8b4d 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_AVIRT) += avirt_core.o -avirt_core-y := core.o -avirt_core-y += alsa-pcm.o -avirt_core-y += configfs.o +obj-$(CONFIG_AVIRT) += snd-avirt-core.o +snd-avirt-core-y := core.o +snd-avirt-core-y += alsa-pcm.o +snd-avirt-core-y += configfs.o ifeq ($(CONFIG_AVIRT_BUILDLOCAL),) CCFLAGS_AVIRT := "drivers/staging/" @@ -13,8 +13,8 @@ endif ccflags-y += -I${CCFLAGS_AVIRT} $(info $(KERNELRELEASE)) -obj-$(CONFIG_AVIRT_DUMMYAP) += dummy/ -obj-$(CONFIG_AVIRT_LOOPBACKAP) += loopback/ +obj-$(CONFIG_AVIRT_AP_DUMMY) += dummy/ +obj-$(CONFIG_AVIRT_AP_LOOPBACK) += loopback/ ### # For out-of-tree building @@ -29,8 +29,8 @@ endif all: CONFIG_AVIRT=m CONFIG_AVIRT_BUILDLOCAL=y \ - CONFIG_AVIRT_DUMMYAP=m \ - CONFIG_AVIRT_LOOPBACKAP=m \ + CONFIG_AVIRT_AP_DUMMY=m \ + CONFIG_AVIRT_AP_LOOPBACK=m \ make -C $(KERNEL_SRC) M=$(PWD) clean: diff --git a/alsa-pcm.c b/alsa-pcm.c index 4d7b549..603c096 100644 --- a/alsa-pcm.c +++ b/alsa-pcm.c @@ -3,7 +3,7 @@ * AVIRT - ALSA Virtual Soundcard * * Copyright (c) 2010-2018 Fiberdyne Systems Pty Ltd - * + * * alsa-pcm.c - AVIRT PCM interface */ @@ -15,24 +15,24 @@ #define D_PRINTK(fmt, args...) DDEBUG(D_LOGNAME, fmt, ##args) #define D_ERRORK(fmt, args...) DERROR(D_LOGNAME, fmt, ##args) -#define DO_AUDIOPATH_CB(ap, callback, substream, ...) \ - (((ap)->pcm_ops->callback) ? \ - (ap)->pcm_ops->callback((substream), ##__VA_ARGS__) : \ +#define DO_AUDIOPATH_CB(ap, callback, substream, ...) \ + (((ap)->pcm_ops->callback) ? \ + (ap)->pcm_ops->callback((substream), ##__VA_ARGS__) : \ 0) /** - * avirt_pcm_period_elapsed - PCM buffer complete callback + * snd_avirt_pcm_period_elapsed - PCM buffer complete callback * @substreamid: pointer to ALSA PCM substream * - * This should be called from a child Audio Path once it has finished processing - * the pcm buffer + * This should be called from a child Audio Path once it has finished + * processing the pcm buffer */ -void avirt_pcm_period_elapsed(struct snd_pcm_substream *substream) +void snd_avirt_pcm_period_elapsed(struct snd_pcm_substream *substream) { // Notify ALSA middle layer of the elapsed period boundary snd_pcm_period_elapsed(substream); } -EXPORT_SYMBOL_GPL(avirt_pcm_period_elapsed); +EXPORT_SYMBOL_GPL(snd_avirt_pcm_period_elapsed); /******************************************************************************* * ALSA PCM Callbacks @@ -41,20 +41,20 @@ EXPORT_SYMBOL_GPL(avirt_pcm_period_elapsed); * pcm_open - Implements 'open' callback for PCM middle layer * @substream: pointer to ALSA PCM substream * - * This is called when an ALSA PCM substream is opened. The substream device is - * configured here. + * This is called when an ALSA PCM substream is opened. The substream device + * is configured here. * * Returns 0 on success or error code otherwise. */ static int pcm_open(struct snd_pcm_substream *substream) { - struct avirt_audiopath *audiopath; - struct avirt_stream *stream; + struct snd_avirt_audiopath *audiopath; + struct snd_avirt_stream *stream; struct snd_pcm_hardware *hw; unsigned int chans = 0; - stream = __avirt_stream_find_by_device(substream->pcm->device); - audiopath = avirt_audiopath_get(stream->map); + stream = snd_avirt_stream_find_by_device(substream->pcm->device); + audiopath = snd_avirt_audiopath_get(stream->map); CHK_NULL_V(audiopath, "Cannot find Audio Path uid: '%s'!", stream->map); substream->private_data = audiopath; @@ -62,7 +62,7 @@ static int pcm_open(struct snd_pcm_substream *substream) hw = &substream->runtime->hw; memcpy(hw, audiopath->hw, sizeof(struct snd_pcm_hardware)); - stream = __avirt_stream_find_by_device(substream->pcm->device); + stream = snd_avirt_stream_find_by_device(substream->pcm->device); if (IS_ERR_VALUE(stream) || !stream) return PTR_ERR(stream); @@ -87,7 +87,7 @@ static int pcm_close(struct snd_pcm_substream *substream) { // Do additional Audio Path 'close' callback return DO_AUDIOPATH_CB( - ((struct avirt_audiopath *)substream->private_data), close, + ((struct snd_avirt_audiopath *)substream->private_data), close, substream); } @@ -106,10 +106,10 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, { int retval; size_t bufsz; - struct avirt_audiopath *audiopath; - struct avirt_stream *stream; + struct snd_avirt_audiopath *audiopath; + struct snd_avirt_stream *stream; - stream = __avirt_stream_find_by_device(substream->pcm->device); + stream = snd_avirt_stream_find_by_device(substream->pcm->device); if (IS_ERR_VALUE(stream) || !stream) return PTR_ERR(stream); @@ -120,7 +120,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - audiopath = ((struct avirt_audiopath *)substream->private_data); + audiopath = ((struct snd_avirt_audiopath *)substream->private_data); bufsz = params_buffer_bytes(hw_params) * audiopath->hw->periods_max; retval = snd_pcm_lib_alloc_vmalloc_buffer(substream, bufsz); @@ -145,8 +145,8 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) // Do additional Audio Path 'hw_free' callback err = DO_AUDIOPATH_CB( - ((struct avirt_audiopath *)substream->private_data), hw_free, - substream); + ((struct snd_avirt_audiopath *)substream->private_data), + hw_free, substream); return snd_pcm_lib_free_vmalloc_buffer(substream); } @@ -165,8 +165,8 @@ static int pcm_prepare(struct snd_pcm_substream *substream) { // Do additional Audio Path 'prepare' callback return DO_AUDIOPATH_CB( - ((struct avirt_audiopath *)substream->private_data), prepare, - substream); + ((struct snd_avirt_audiopath *)substream->private_data), + prepare, substream); } /** @@ -194,8 +194,8 @@ static int pcm_trigger(struct snd_pcm_substream *substream, int cmd) // Do additional Audio Path 'trigger' callback return DO_AUDIOPATH_CB( - ((struct avirt_audiopath *)substream->private_data), trigger, - substream, cmd); + ((struct snd_avirt_audiopath *)substream->private_data), + trigger, substream, cmd); } /** @@ -212,8 +212,8 @@ static snd_pcm_uframes_t pcm_pointer(struct snd_pcm_substream *substream) { // Do additional Audio Path 'pointer' callback return DO_AUDIOPATH_CB( - ((struct avirt_audiopath *)substream->private_data), pointer, - substream); + ((struct snd_avirt_audiopath *)substream->private_data), + pointer, substream); } /** @@ -235,7 +235,7 @@ static int pcm_get_time_info( struct snd_pcm_audio_tstamp_report *audio_tstamp_report) { return DO_AUDIOPATH_CB( - ((struct avirt_audiopath *)substream->private_data), + ((struct snd_avirt_audiopath *)substream->private_data), get_time_info, substream, system_ts, audio_ts, audio_tstamp_config, audio_tstamp_report); } @@ -265,8 +265,8 @@ static int pcm_copy_user(struct snd_pcm_substream *substream, int channel, // Do additional Audio Path 'copy_user' callback return DO_AUDIOPATH_CB( - ((struct avirt_audiopath *)substream->private_data), copy_user, - substream, channel, pos, src, count); + ((struct snd_avirt_audiopath *)substream->private_data), + copy_user, substream, channel, pos, src, count); } /** @@ -286,7 +286,7 @@ static int pcm_copy_kernel(struct snd_pcm_substream *substream, int channel, unsigned long pos, void *buf, unsigned long count) { return DO_AUDIOPATH_CB( - ((struct avirt_audiopath *)substream->private_data), + ((struct snd_avirt_audiopath *)substream->private_data), copy_kernel, substream, channel, pos, buf, count); } @@ -302,7 +302,7 @@ static int pcm_copy_kernel(struct snd_pcm_substream *substream, int channel, static int pcm_ack(struct snd_pcm_substream *substream) { return DO_AUDIOPATH_CB( - ((struct avirt_audiopath *)substream->private_data), ack, + ((struct snd_avirt_audiopath *)substream->private_data), ack, substream); } @@ -310,7 +310,7 @@ static int pcm_silence(struct snd_pcm_substream *substream, int channel, snd_pcm_uframes_t pos, snd_pcm_uframes_t count) { return DO_AUDIOPATH_CB( - ((struct avirt_audiopath *)substream->private_data), + ((struct snd_avirt_audiopath *)substream->private_data), fill_silence, substream, channel, pos, count); } diff --git a/configfs.c b/configfs.c index 1a7e7c5..12e95a5 100644 --- a/configfs.c +++ b/configfs.c @@ -1,9 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 -/* +/* * AVIRT - ALSA Virtual Soundcard * * Copyright (c) 2010-2018 Fiberdyne Systems Pty Ltd - * + * * configfs.c - AVIRT configfs support */ @@ -17,54 +17,61 @@ #define D_PRINTK(fmt, args...) DDEBUG(D_LOGNAME, fmt, ##args) #define D_ERRORK(fmt, args...) DERROR(D_LOGNAME, fmt, ##args) -static ssize_t cfg_avirt_stream_direction_show(struct config_item *item, - char *page) +static ssize_t cfg_snd_avirt_stream_direction_show(struct config_item *item, + char *page) { ssize_t count; - struct avirt_stream *stream = avirt_stream_from_config_item(item); + struct snd_avirt_stream *stream = + snd_avirt_stream_from_config_item(item); count = sprintf(page, "%d\n", stream->direction); return count; } -CONFIGFS_ATTR_RO(cfg_avirt_stream_, direction); +CONFIGFS_ATTR_RO(cfg_snd_avirt_stream_, direction); -static ssize_t cfg_avirt_stream_map_show(struct config_item *item, char *page) +static ssize_t cfg_snd_avirt_stream_map_show(struct config_item *item, + char *page) { - struct avirt_stream *stream = avirt_stream_from_config_item(item); + struct snd_avirt_stream *stream = + snd_avirt_stream_from_config_item(item); return sprintf(page, "%s\n", stream->map); } -static ssize_t cfg_avirt_stream_map_store(struct config_item *item, - const char *page, size_t count) +static ssize_t cfg_snd_avirt_stream_map_store(struct config_item *item, + const char *page, size_t count) { char *split; - struct avirt_stream *stream = avirt_stream_from_config_item(item); + struct snd_avirt_stream *stream = + snd_avirt_stream_from_config_item(item); split = strsep((char **)&page, "\n"); memcpy(stream->map, (char *)split, count); return count; } -CONFIGFS_ATTR(cfg_avirt_stream_, map); +CONFIGFS_ATTR(cfg_snd_avirt_stream_, map); -static ssize_t cfg_avirt_stream_channels_show(struct config_item *item, - char *page) +static ssize_t cfg_snd_avirt_stream_channels_show(struct config_item *item, + char *page) { ssize_t count; - struct avirt_stream *stream = avirt_stream_from_config_item(item); + struct snd_avirt_stream *stream = + snd_avirt_stream_from_config_item(item); count = sprintf(page, "%d\n", stream->channels); return count; } -static ssize_t cfg_avirt_stream_channels_store(struct config_item *item, - const char *page, size_t count) +static ssize_t cfg_snd_avirt_stream_channels_store(struct config_item *item, + const char *page, + size_t count) { int err; - struct avirt_stream *stream = avirt_stream_from_config_item(item); + struct snd_avirt_stream *stream = + snd_avirt_stream_from_config_item(item); unsigned long tmp; char *p = (char *)page; @@ -79,37 +86,37 @@ static ssize_t cfg_avirt_stream_channels_store(struct config_item *item, return count; } -CONFIGFS_ATTR(cfg_avirt_stream_, channels); +CONFIGFS_ATTR(cfg_snd_avirt_stream_, channels); -static struct configfs_attribute *cfg_avirt_stream_attrs[] = { - &cfg_avirt_stream_attr_channels, - &cfg_avirt_stream_attr_map, - &cfg_avirt_stream_attr_direction, +static struct configfs_attribute *cfg_snd_avirt_stream_attrs[] = { + &cfg_snd_avirt_stream_attr_channels, + &cfg_snd_avirt_stream_attr_map, + &cfg_snd_avirt_stream_attr_direction, NULL, }; -static void cfg_avirt_stream_release(struct config_item *item) +static void cfg_snd_avirt_stream_release(struct config_item *item) { D_INFOK("item->name:%s", item->ci_namebuf); - kfree(avirt_stream_from_config_item(item)); + kfree(snd_avirt_stream_from_config_item(item)); } -static struct configfs_item_operations cfg_avirt_stream_ops = { - .release = cfg_avirt_stream_release, +static struct configfs_item_operations cfg_snd_avirt_stream_ops = { + .release = cfg_snd_avirt_stream_release, }; -static struct config_item_type cfg_avirt_stream_type = { - .ct_item_ops = &cfg_avirt_stream_ops, - .ct_attrs = cfg_avirt_stream_attrs, +static struct config_item_type cfg_snd_avirt_stream_type = { + .ct_item_ops = &cfg_snd_avirt_stream_ops, + .ct_attrs = cfg_snd_avirt_stream_attrs, .ct_owner = THIS_MODULE, }; static struct config_item * - cfg_avirt_stream_make_item(struct config_group *group, const char *name) +cfg_snd_avirt_stream_make_item(struct config_group *group, const char *name) { char *split; int direction; - struct avirt_stream *stream; + struct snd_avirt_stream *stream; // Get prefix (playback_ or capture_) split = strsep((char **)&name, "_"); @@ -130,24 +137,25 @@ static struct config_item * // Get stream name, and create PCM for stream split = strsep((char **)&name, "\n"); - stream = __avirt_stream_create(split, direction); + stream = snd_avirt_stream_create(split, direction); if (IS_ERR(stream)) return ERR_PTR(PTR_ERR(stream)); - config_item_init_type_name(&stream->item, name, &cfg_avirt_stream_type); + config_item_init_type_name(&stream->item, name, + &cfg_snd_avirt_stream_type); return &stream->item; } -static ssize_t cfg_avirt_stream_group_sealed_show(struct config_item *item, - char *page) +static ssize_t cfg_snd_avirt_stream_group_sealed_show(struct config_item *item, + char *page) { - return snprintf(page, PAGE_SIZE, "%d\n", __avirt_streams_sealed()); + return snprintf(page, PAGE_SIZE, "%d\n", snd_avirt_streams_sealed()); } -static ssize_t cfg_avirt_stream_group_sealed_store(struct config_item *item, - const char *page, - size_t count) +static ssize_t cfg_snd_avirt_stream_group_sealed_store(struct config_item *item, + const char *page, + size_t count) { unsigned long tmp; char *p = (char *)page; @@ -159,24 +167,24 @@ static ssize_t cfg_avirt_stream_group_sealed_store(struct config_item *item, return -ERANGE; } - __avirt_streams_seal(); + snd_avirt_streams_seal(); return count; } -CONFIGFS_ATTR(cfg_avirt_stream_group_, sealed); +CONFIGFS_ATTR(cfg_snd_avirt_stream_group_, sealed); -static struct configfs_attribute *cfg_avirt_stream_group_attrs[] = { - &cfg_avirt_stream_group_attr_sealed, +static struct configfs_attribute *cfg_snd_avirt_stream_group_attrs[] = { + &cfg_snd_avirt_stream_group_attr_sealed, NULL, }; -static struct configfs_group_operations cfg_avirt_stream_group_ops = { - .make_item = cfg_avirt_stream_make_item +static struct configfs_group_operations cfg_snd_avirt_stream_group_ops = { + .make_item = cfg_snd_avirt_stream_make_item }; static struct config_item_type cfg_stream_group_type = { - .ct_group_ops = &cfg_avirt_stream_group_ops, - .ct_attrs = cfg_avirt_stream_group_attrs, + .ct_group_ops = &cfg_snd_avirt_stream_group_ops, + .ct_attrs = cfg_snd_avirt_stream_group_attrs, .ct_owner = THIS_MODULE }; @@ -185,17 +193,15 @@ static struct config_item_type cfg_avirt_group_type = { }; static struct configfs_subsystem cfg_subsys = { - .su_group = - { - .cg_item = - { - .ci_namebuf = "avirt", + .su_group = { + .cg_item = { + .ci_namebuf = "snd-avirt", .ci_type = &cfg_avirt_group_type, }, }, }; -int __init __avirt_configfs_init(struct avirt_core *core) +int __init snd_avirt_configfs_init(struct snd_avirt_core *core) { int err; @@ -222,7 +228,7 @@ exit_configfs: return err; } -void __exit __avirt_configfs_exit(struct avirt_core *core) +void __exit snd_avirt_configfs_exit(struct snd_avirt_core *core) { configfs_unregister_default_group(core->stream_group); configfs_unregister_subsystem(&cfg_subsys); diff --git a/core.c b/core.c index 08381e5..aacc0a1 100644 --- a/core.c +++ b/core.c @@ -3,7 +3,7 @@ * AVIRT - ALSA Virtual Soundcard * * Copyright (c) 2010-2018 Fiberdyne Systems Pty Ltd - * + * * core.c - AVIRT core internals */ @@ -27,44 +27,43 @@ MODULE_LICENSE("GPL v2"); #define SND_AVIRTUAL_DRIVER "snd_avirt" -extern struct snd_pcm_ops pcm_ops; - -static struct avirt_core core = { +static struct snd_avirt_core core = { .stream_count = 0, .streams_sealed = false, }; -struct avirt_coreinfo coreinfo = { - .version = {0, 0, 1}, +struct snd_avirt_coreinfo coreinfo = { + .version = { 0, 0, 1 }, }; static LIST_HEAD(audiopath_list); -struct avirt_audiopath_obj { +struct snd_avirt_audiopath_obj { struct kobject kobj; struct list_head list; - struct avirt_audiopath *path; + struct snd_avirt_audiopath *path; }; -static struct kset *avirt_audiopath_kset; +static struct kset *snd_avirt_audiopath_kset; static struct kobject *kobj; -#define to_audiopath_obj(d) container_of(d, struct avirt_audiopath_obj, kobj) -#define to_audiopath_attr(a) \ - container_of(a, struct avirt_audiopath_attribute, attr) +#define to_audiopath_obj(d) \ + container_of(d, struct snd_avirt_audiopath_obj, kobj) +#define to_audiopath_attr(a) \ + container_of(a, struct snd_avirt_audiopath_attribute, attr) /** - * struct avirt_audiopath_attribute - access the attributes of Audio Path + * struct snd_avirt_audiopath_attribute - access the attributes of Audio Path * @attr: attributes of an Audio Path * @show: pointer to the show function * @store: pointer to the store function */ -struct avirt_audiopath_attribute { +struct snd_avirt_audiopath_attribute { struct attribute attr; - ssize_t (*show)(struct avirt_audiopath_obj *d, - struct avirt_audiopath_attribute *attr, char *buf); - ssize_t (*store)(struct avirt_audiopath_obj *d, - struct avirt_audiopath_attribute *attr, + ssize_t (*show)(struct snd_avirt_audiopath_obj *d, + struct snd_avirt_audiopath_attribute *attr, char *buf); + ssize_t (*store)(struct snd_avirt_audiopath_obj *d, + struct snd_avirt_audiopath_attribute *attr, const char *buf, size_t count); }; @@ -77,8 +76,8 @@ struct avirt_audiopath_attribute { static ssize_t audiopath_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) { - struct avirt_audiopath_attribute *audiopath_attr; - struct avirt_audiopath_obj *audiopath_obj; + struct snd_avirt_audiopath_attribute *audiopath_attr; + struct snd_avirt_audiopath_obj *audiopath_obj; audiopath_attr = to_audiopath_attr(attr); audiopath_obj = to_audiopath_obj(kobj); @@ -100,8 +99,8 @@ static ssize_t audiopath_attr_store(struct kobject *kobj, struct attribute *attr, const char *buf, size_t len) { - struct avirt_audiopath_attribute *audiopath_attr; - struct avirt_audiopath_obj *audiopath_obj; + struct snd_avirt_audiopath_attribute *audiopath_attr; + struct snd_avirt_audiopath_obj *audiopath_obj; audiopath_attr = to_audiopath_attr(attr); audiopath_obj = to_audiopath_obj(kobj); @@ -111,84 +110,88 @@ static ssize_t audiopath_attr_store(struct kobject *kobj, return audiopath_attr->store(audiopath_obj, audiopath_attr, buf, len); } -static const struct sysfs_ops avirt_audiopath_sysfs_ops = { +static const struct sysfs_ops snd_avirt_audiopath_sysfs_ops = { .show = audiopath_attr_show, .store = audiopath_attr_store, }; /** - * avirt_audiopath_release - Audio Path release function + * snd_avirt_audiopath_release - Audio Path release function * @kobj: pointer to Audio Paths's kobject */ -static void avirt_audiopath_release(struct kobject *kobj) +static void snd_avirt_audiopath_release(struct kobject *kobj) { - struct avirt_audiopath_obj *audiopath_obj = to_audiopath_obj(kobj); + struct snd_avirt_audiopath_obj *audiopath_obj = to_audiopath_obj(kobj); kfree(audiopath_obj); } -static ssize_t audiopath_name_show(struct avirt_audiopath_obj *audiopath_obj, - struct avirt_audiopath_attribute *attr, - char *buf) +static ssize_t + audiopath_name_show(struct snd_avirt_audiopath_obj *audiopath_obj, + struct snd_avirt_audiopath_attribute *attr, + char *buf) { return sprintf(buf, "%s\n", audiopath_obj->path->name); } -static ssize_t audiopath_version_show(struct avirt_audiopath_obj *audiopath_obj, - struct avirt_audiopath_attribute *attr, - char *buf) +static ssize_t + audiopath_version_show(struct snd_avirt_audiopath_obj *audiopath_obj, + struct snd_avirt_audiopath_attribute *attr, + char *buf) { - struct avirt_audiopath *audiopath = audiopath_obj->path; + struct snd_avirt_audiopath *audiopath = audiopath_obj->path; return sprintf(buf, "%d.%d.%d\n", audiopath->version[0], audiopath->version[1], audiopath->version[2]); } -static struct avirt_audiopath_attribute avirt_audiopath_attrs[] = { +static struct snd_avirt_audiopath_attribute snd_avirt_audiopath_attrs[] = { __ATTR_RO(audiopath_name), __ATTR_RO(audiopath_version), }; -static struct attribute *avirt_audiopath_def_attrs[] = { - &avirt_audiopath_attrs[0].attr, - &avirt_audiopath_attrs[1].attr, +static struct attribute *snd_avirt_audiopath_def_attrs[] = { + &snd_avirt_audiopath_attrs[0].attr, + &snd_avirt_audiopath_attrs[1].attr, NULL, }; -static struct kobj_type avirt_audiopath_ktype = { - .sysfs_ops = &avirt_audiopath_sysfs_ops, - .release = avirt_audiopath_release, - .default_attrs = avirt_audiopath_def_attrs, +static struct kobj_type snd_avirt_audiopath_ktype = { + .sysfs_ops = &snd_avirt_audiopath_sysfs_ops, + .release = snd_avirt_audiopath_release, + .default_attrs = snd_avirt_audiopath_def_attrs, }; /** - * create_avirt_audiopath_obj - creates an Audio Path object + * create_snd_avirt_audiopath_obj - creates an Audio Path object * @uid: Unique ID of the Audio Path * * This creates an Audio Path object and assigns the kset and registers * it with sysfs. * @return: Pointer to the Audio Path object or NULL if it failed. */ -static struct avirt_audiopath_obj *create_avirt_audiopath_obj(const char *uid) +static struct snd_avirt_audiopath_obj * + create_snd_avirt_audiopath_obj(const char *uid) { - struct avirt_audiopath_obj *avirt_audiopath; + struct snd_avirt_audiopath_obj *snd_avirt_audiopath; int retval; - avirt_audiopath = kzalloc(sizeof(*avirt_audiopath), GFP_KERNEL); - if (!avirt_audiopath) + snd_avirt_audiopath = kzalloc(sizeof(*snd_avirt_audiopath), GFP_KERNEL); + if (!snd_avirt_audiopath) return NULL; - avirt_audiopath->kobj.kset = avirt_audiopath_kset; - retval = kobject_init_and_add(&avirt_audiopath->kobj, - &avirt_audiopath_ktype, kobj, "%s", uid); + snd_avirt_audiopath->kobj.kset = snd_avirt_audiopath_kset; + retval = kobject_init_and_add(&snd_avirt_audiopath->kobj, + &snd_avirt_audiopath_ktype, kobj, "%s", + uid); if (retval) { - kobject_put(&avirt_audiopath->kobj); + kobject_put(&snd_avirt_audiopath->kobj); return NULL; } - kobject_uevent(&avirt_audiopath->kobj, KOBJ_ADD); - return avirt_audiopath; + kobject_uevent(&snd_avirt_audiopath->kobj, KOBJ_ADD); + return snd_avirt_audiopath; } -static struct snd_pcm *pcm_create(struct avirt_stream *stream) +static struct snd_pcm *pcm_create(struct snd_avirt_stream *stream) { bool playback = false, capture = false; struct snd_pcm *pcm; @@ -224,25 +227,24 @@ static struct snd_pcm *pcm_create(struct avirt_stream *stream) } /** - * destroy_avirt_audiopath_obj - destroys an Audio Path object + * destroy_snd_avirt_audiopath_obj - destroys an Audio Path object * @name: the Audio Path object */ -static void destroy_avirt_audiopath_obj(struct avirt_audiopath_obj *p) +static void destroy_snd_avirt_audiopath_obj(struct snd_avirt_audiopath_obj *p) { kobject_put(&p->kobj); } /** - * avirt_audiopath_get - retrieves the Audio Path by its UID + * snd_avirt_audiopath_get - retrieves the Audio Path by its UID * @uid: Unique ID for the Audio Path * @return: Corresponding Audio Path */ -struct avirt_audiopath *avirt_audiopath_get(const char *uid) +struct snd_avirt_audiopath *snd_avirt_audiopath_get(const char *uid) { - struct avirt_audiopath_obj *ap_obj; + struct snd_avirt_audiopath_obj *ap_obj; - list_for_each_entry(ap_obj, &audiopath_list, list) - { + list_for_each_entry(ap_obj, &audiopath_list, list) { // pr_info("get_ap %s\n", ap_obj->path->uid); if (!strcmp(ap_obj->path->uid, uid)) return ap_obj->path; @@ -252,22 +254,22 @@ struct avirt_audiopath *avirt_audiopath_get(const char *uid) } /** - * avirt_audiopath_register - register Audio Path with ALSA virtual driver + * snd_avirt_audiopath_register - register Audio Path with AVIRT * @audiopath: Audio Path to be registered * @core: ALSA virtual driver core info * @return: 0 on success or error code otherwise */ -int avirt_audiopath_register(struct avirt_audiopath *audiopath, - struct avirt_coreinfo **info) +int snd_avirt_audiopath_register(struct snd_avirt_audiopath *audiopath, + struct snd_avirt_coreinfo **info) { - struct avirt_audiopath_obj *audiopath_obj; + struct snd_avirt_audiopath_obj *audiopath_obj; if (!audiopath) { D_ERRORK("Audio Path is NULL!"); return -EINVAL; } - audiopath_obj = create_avirt_audiopath_obj(audiopath->uid); + audiopath_obj = create_snd_avirt_audiopath_obj(audiopath->uid); if (!audiopath_obj) { D_INFOK("Failed to alloc driver object"); return -ENOMEM; @@ -288,16 +290,16 @@ int avirt_audiopath_register(struct avirt_audiopath *audiopath, return 0; } -EXPORT_SYMBOL_GPL(avirt_audiopath_register); +EXPORT_SYMBOL_GPL(snd_avirt_audiopath_register); /** - * avirt_audiopath_deregister - deregister Audio Path with ALSA virtual driver + * snd_avirt_audiopath_deregister - deregister Audio Path with AVIRT * @audiopath: Audio Path to be deregistered * @return: 0 on success or error code otherwise */ -int avirt_audiopath_deregister(struct avirt_audiopath *audiopath) +int snd_avirt_audiopath_deregister(struct snd_avirt_audiopath *audiopath) { - struct avirt_audiopath_obj *audiopath_obj; + struct snd_avirt_audiopath_obj *audiopath_obj; // Check if audio path is registered if (!audiopath) { @@ -312,32 +314,31 @@ int avirt_audiopath_deregister(struct avirt_audiopath *audiopath) } list_del(&audiopath_obj->list); - destroy_avirt_audiopath_obj(audiopath_obj); + destroy_snd_avirt_audiopath_obj(audiopath_obj); D_INFOK("Deregistered Audio Path %s", audiopath->uid); return 0; } -EXPORT_SYMBOL_GPL(avirt_audiopath_deregister); +EXPORT_SYMBOL_GPL(snd_avirt_audiopath_deregister); /** - * avirt_stream_count - get the stream count for the given direction + * snd_avirt_stream_count - get the stream count for the given direction * @direction: The direction to get the stream count for * @return: The stream count */ -int avirt_stream_count(unsigned int direction) +int snd_avirt_stream_count(unsigned int direction) { struct list_head *entry; struct config_item *item; - struct avirt_stream *stream; + struct snd_avirt_stream *stream; unsigned int count = 0; if (direction > 1) return -ERANGE; - list_for_each(entry, &core.stream_group->cg_children) - { + list_for_each(entry, &core.stream_group->cg_children) { item = container_of(entry, struct config_item, ci_entry); - stream = avirt_stream_from_config_item(item); + stream = snd_avirt_stream_from_config_item(item); if (!stream) return -EFAULT; if (stream->direction == direction) @@ -346,18 +347,19 @@ int avirt_stream_count(unsigned int direction) return count; } -EXPORT_SYMBOL_GPL(avirt_stream_count); +EXPORT_SYMBOL_GPL(snd_avirt_stream_count); /** - * __avirt_stream_create - Create audio stream, including it's ALSA PCM device + * snd_avirt_stream_create - Create audio stream, including it's ALSA PCM device * @name: The name designated to the audio stream * @direction: The PCM direction (SNDRV_PCM_STREAM_PLAYBACK or * SNDRV_PCM_STREAM_CAPTURE) * @return: The newly created audio stream if successful, or an error pointer */ -struct avirt_stream *__avirt_stream_create(const char *name, int direction) +struct snd_avirt_stream *snd_avirt_stream_create(const char *name, + int direction) { - struct avirt_stream *stream; + struct snd_avirt_stream *stream; stream = kzalloc(sizeof(*stream), GFP_KERNEL); if (!stream) @@ -374,11 +376,11 @@ struct avirt_stream *__avirt_stream_create(const char *name, int direction) return stream; } -int __avirt_streams_seal(void) +int snd_avirt_streams_seal(void) { int err = 0; - struct avirt_audiopath_obj *ap_obj; - struct avirt_stream *stream; + struct snd_avirt_audiopath_obj *ap_obj; + struct snd_avirt_stream *stream; struct config_item *item; struct list_head *entry; @@ -387,9 +389,9 @@ int __avirt_streams_seal(void) return -1; } - list_for_each (entry, &core.stream_group->cg_children) { + list_for_each(entry, &core.stream_group->cg_children) { item = container_of(entry, struct config_item, ci_entry); - stream = avirt_stream_from_config_item(item); + stream = snd_avirt_stream_from_config_item(item); if (!stream) return -EFAULT; stream->pcm = pcm_create(stream); @@ -397,7 +399,7 @@ int __avirt_streams_seal(void) return (PTR_ERR(stream->pcm)); } - list_for_each_entry (ap_obj, &audiopath_list, list) { + list_for_each_entry(ap_obj, &audiopath_list, list) { D_INFOK("configure() AP uid: %s", ap_obj->path->uid); ap_obj->path->configure(core.card, core.stream_group, core.stream_count); @@ -414,14 +416,14 @@ int __avirt_streams_seal(void) return err; } -bool __avirt_streams_sealed(void) +bool snd_avirt_streams_sealed(void) { return core.streams_sealed; } -struct avirt_stream *__avirt_stream_find_by_device(unsigned int device) +struct snd_avirt_stream *snd_avirt_stream_find_by_device(unsigned int device) { - struct avirt_stream *stream; + struct snd_avirt_stream *stream; struct config_item *item; struct list_head *entry; @@ -430,10 +432,9 @@ struct avirt_stream *__avirt_stream_find_by_device(unsigned int device) return ERR_PTR(-EINVAL); } - list_for_each(entry, &core.stream_group->cg_children) - { + list_for_each(entry, &core.stream_group->cg_children) { item = container_of(entry, struct config_item, ci_entry); - stream = avirt_stream_from_config_item(item); + stream = snd_avirt_stream_from_config_item(item); if (!stream) return ERR_PTR(-EFAULT); if (stream->device == device) @@ -478,14 +479,14 @@ static int __init core_init(void) strncpy(core.card->longname, "A virtual sound card driver for ALSA", 80); - avirt_audiopath_kset = + snd_avirt_audiopath_kset = kset_create_and_add("audiopaths", NULL, &core.dev->kobj); - if (!avirt_audiopath_kset) { + if (!snd_avirt_audiopath_kset) { err = -ENOMEM; goto exit_snd_card; } - err = __avirt_configfs_init(&core); + err = snd_avirt_configfs_init(&core); if (err < 0) goto exit_snd_card; @@ -506,9 +507,9 @@ exit_class: */ static void __exit core_exit(void) { - __avirt_configfs_exit(&core); + snd_avirt_configfs_exit(&core); - kset_unregister(avirt_audiopath_kset); + kset_unregister(snd_avirt_audiopath_kset); snd_card_free(core.card); device_destroy(core.avirt_class, 0); class_destroy(core.avirt_class); diff --git a/core.h b/core.h index ca47067..735df65 100644 --- a/core.h +++ b/core.h @@ -14,7 +14,9 @@ #include "utils.h" -struct avirt_core { +extern struct snd_pcm_ops pcm_ops; + +struct snd_avirt_core { struct snd_card *card; struct device *dev; struct class *avirt_class; @@ -24,44 +26,45 @@ struct avirt_core { }; /** - * __avirt_configfs_init - Initialise the configfs system - * @core: The avirt_core pointer + * snd_avirt_configfs_init - Initialise the configfs system + * @core: The snd_avirt_core pointer * @return: 0 on success, negative ERRNO on failure */ -int __init __avirt_configfs_init(struct avirt_core *core); +int __init snd_avirt_configfs_init(struct snd_avirt_core *core); /** - * __avirt_configfs_exit - Clean up and exit the configfs system - * @core: The avirt_core pointer + * snd_avirt_configfs_exit - Clean up and exit the configfs system + * @core: The snd_avirt_core pointer */ -void __exit __avirt_configfs_exit(struct avirt_core *core); +void __exit snd_avirt_configfs_exit(struct snd_avirt_core *core); /** - * __avirt_streams_seal - Register the sound card to user space + * snd_avirt_streams_seal - Register the sound card to user space * @return: 0 on success, negative ERRNO on failure */ -int __avirt_streams_seal(void); +int snd_avirt_streams_seal(void); /** - * __avirt_streams_sealed - Check whether the streams have been sealed or not + * snd_avirt_streams_sealed - Check if the streams have been sealed or not * @return: true if sealed, false otherwise */ -bool __avirt_streams_sealed(void); +bool snd_avirt_streams_sealed(void); /** - * __avirt_stream_find_by_device - Get audio stream from device number + * snd_avirt_stream_find_by_device - Get audio stream from device number * @device: The PCM device number corresponding to the desired stream * @return: The audio stream if found, or an error pointer otherwise */ -struct avirt_stream *__avirt_stream_find_by_device(unsigned int device); +struct snd_avirt_stream *snd_avirt_stream_find_by_device(unsigned int device); /** - * __avirt_stream_create - Create audio stream, including it's ALSA PCM device + * snd_avirt_stream_create - Create audio stream, including it's ALSA PCM device * @name: The name designated to the audio stream * @direction: The PCM direction (SNDRV_PCM_STREAM_PLAYBACK or * SNDRV_PCM_STREAM_CAPTURE) * @return: The newly created audio stream if successful, or an error pointer */ -struct avirt_stream *__avirt_stream_create(const char *name, int direction); +struct snd_avirt_stream *snd_avirt_stream_create(const char *name, + int direction); #endif /* __SOUND_AVIRT_CORE_H */ diff --git a/docs/2.Building.md b/docs/2.Building.md index 3e42746..5fd9d23 100644 --- a/docs/2.Building.md +++ b/docs/2.Building.md @@ -28,7 +28,7 @@ $ make or ```sh -$ CONFIG_AVIRT=m CONFIG_AVIRT_BUILDLOCAL=y CONFIG_AVIRT_DUMMYAP=m make -C /lib/modules/$(uname -r)/build/ M=$(pwd) +$ CONFIG_AVIRT=m CONFIG_AVIRT_BUILDLOCAL=y CONFIG_AVIRT_AP_DUMMY=m CONFIG_AVIRT_AP_LOOPBACK=m make -C /lib/modules/$(uname -r)/build/ M=$(pwd) ``` The latter is executed internally with the make file. diff --git a/docs/3.Usage.md b/docs/3.Usage.md index d65d50d..f535a07 100644 --- a/docs/3.Usage.md +++ b/docs/3.Usage.md @@ -18,9 +18,9 @@ As root, load the required `avirt_core.ko` and subsequent audio path. As an example, the Dummy Audiopath is being loaded here. ```sh -insmod avirt_core.ko -insmod dummy/avirt_dummyap.ko -insmod loopback/avirt_loopbackap.ko +insmod snd-avirt-core.ko +insmod dummy/snd-avirt-ap-dummy.ko +insmod loopback/snd-avirt-ap-loopback.ko ``` ### Note: @@ -47,16 +47,16 @@ For example, in AGL: ```sh mkdir -p /lib/modules/$(uname -r)/extra -cp avirt_core.ko avirt_dummyap.ko avirt_loopbackap.ko /lib/modules/$(uname -r)/extra +cp snd-avirt-core.ko snd-avirt-ap-dummy.ko snd-avirt-ap-loopback.ko /lib/modules/$(uname -r)/extra depmod ``` Once the modules are in place, we can load the modules using: ```sh -modprobe avirt_core -modprobe avirt_dummyap -modprobe avirt_loopbackap +modprobe snd-avirt-core +modprobe snd-avirt-ap-dummy +modprobe snd-avirt-ap-loopback ``` @@ -93,24 +93,24 @@ Finally, we can configure AVIRT, for example: ```sh # Set up each of the cards channels -mkdir /config/avirt/streams/playback_media -echo "2">/config/avirt/streams/playback_media/channels -echo "ap_dummy">/config/avirt/streams/playback_media/map +mkdir /config/snd-avirt/streams/playback_media +echo "2">/config/snd-avirt/streams/playback_media/channels +echo "ap_dummy">/config/snd-avirt/streams/playback_media/map -mkdir /config/avirt/streams/playback_navigation -echo "1">/config/avirt/streams/playback_navigation/channels -echo "ap_dummy">/config/avirt/streams/playback_navigation/map +mkdir /config/snd-avirt/streams/playback_navigation +echo "1">/config/snd-avirt/streams/playback_navigation/channels +echo "ap_dummy">/config/snd-avirt/streams/playback_navigation/map -mkdir /config/avirt/streams/playback_emergency -echo "1">/config/avirt/streams/playback_emergency/channels -echo "ap_dummy">/config/avirt/streams/playback_emergency/map +mkdir /config/snd-avirt/streams/playback_emergency +echo "1">/config/snd-avirt/streams/playback_emergency/channels +echo "ap_dummy">/config/snd-avirt/streams/playback_emergency/map -mkdir /config/avirt/streams/capture_voice -echo "1">/config/avirt/streams/capture_voice/channels -echo "ap_dummy">/config/avirt/streams/capture_voice/map +mkdir /config/snd-avirt/streams/capture_voice +echo "1">/config/snd-avirt/streams/capture_voice/channels +echo "ap_dummy">/config/snd-avirt/streams/capture_voice/map # Finally, seal the card, and initiate configuration -echo "1">/config/avirt/streams/sealed +echo "1">/config/snd-avirt/streams/sealed ``` Alternatively, the test script at `scripts/test_configfs.sh` can be used. diff --git a/dummy/Makefile b/dummy/Makefile index 78579d7..11ceceb 100644 --- a/dummy/Makefile +++ b/dummy/Makefile @@ -1,6 +1,6 @@ -obj-$(CONFIG_AVIRT_DUMMYAP) += avirt_dummyap.o +obj-$(CONFIG_AVIRT_AP_DUMMY) += snd-avirt-ap-dummy.o $(info $(src)) -avirt_dummyap-objs := dummy.o +snd-avirt-ap-dummy-objs := dummy.o ccflags-y += -Idrivers/staging/ ccflags-y += -I$(src)/../ diff --git a/dummy/dummy.c b/dummy/dummy.c index 100972a..5f19564 100644 --- a/dummy/dummy.c +++ b/dummy/dummy.c @@ -34,7 +34,7 @@ MODULE_LICENSE("GPL v2"); #define get_dummy_ops(substream) \ (*(const struct dummy_timer_ops **)(substream)->runtime->private_data) -static struct avirt_coreinfo *coreinfo; +static struct snd_avirt_coreinfo *coreinfo; /******************************************************************************* * System Timer Interface @@ -140,7 +140,7 @@ static void dummy_systimer_callback(struct timer_list *t) dpcm->elapsed = 0; spin_unlock_irqrestore(&dpcm->lock, flags); if (elapsed) - avirt_pcm_period_elapsed(dpcm->substream); + snd_avirt_pcm_period_elapsed(dpcm->substream); } static snd_pcm_uframes_t @@ -241,18 +241,18 @@ static struct snd_pcm_ops dummyap_pcm_ops = { /******************************************************************************* * Dummy Audio Path AVIRT registration ******************************************************************************/ -int dummy_configure(struct snd_card *card, - struct config_group *avirt_stream_group, - unsigned int stream_count) +static int dummy_configure(struct snd_card *card, + struct config_group *snd_avirt_stream_group, + unsigned int stream_count) { // Do something with streams struct list_head *entry; - list_for_each (entry, &avirt_stream_group->cg_children) { + list_for_each (entry, &snd_avirt_stream_group->cg_children) { struct config_item *item = container_of(entry, struct config_item, ci_entry); - struct avirt_stream *stream = - avirt_stream_from_config_item(item); + struct snd_avirt_stream *stream = + snd_avirt_stream_from_config_item(item); AP_INFOK("stream name:%s device:%d channels:%d", stream->name, stream->device, stream->channels); } @@ -272,7 +272,7 @@ static struct snd_pcm_hardware dummyap_hw = { .periods_max = DUMMY_PERIODS_MAX, }; -static struct avirt_audiopath dummyap_module = { +static struct snd_avirt_audiopath dummyap_module = { .uid = "ap_dummy", .name = "Dummy Audio Path", .version = { 0, 0, 1 }, @@ -287,7 +287,7 @@ static int __init dummy_init(void) pr_info("init()\n"); - err = avirt_audiopath_register(&dummyap_module, &coreinfo); + err = snd_avirt_audiopath_register(&dummyap_module, &coreinfo); if ((err < 0) || (!coreinfo)) { pr_err("%s: coreinfo is NULL!\n", __func__); return err; @@ -300,7 +300,7 @@ static void __exit dummy_exit(void) { pr_info("exit()\n"); - avirt_audiopath_deregister(&dummyap_module); + snd_avirt_audiopath_deregister(&dummyap_module); } module_init(dummy_init); diff --git a/loopback/Makefile b/loopback/Makefile index 9d3c606..0546168 100644 --- a/loopback/Makefile +++ b/loopback/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_AVIRT_LOOPBACKAP) += avirt_loopbackap.o +obj-$(CONFIG_AVIRT_AP_LOOPBACK) += snd-avirt-ap-loopback.o $(info $(src)) -avirt_loopbackap-objs := loopback.o +snd-avirt-ap-loopback-objs := loopback.o ccflags-y += -Idrivers/staging/ ccflags-y += -I$(src)/../ diff --git a/loopback/loopback.c b/loopback/loopback.c index ba9225e..b4a82e5 100644 --- a/loopback/loopback.c +++ b/loopback/loopback.c @@ -46,7 +46,7 @@ MODULE_LICENSE("GPL"); #define NO_PITCH 100000 -static struct avirt_coreinfo *coreinfo; +static struct snd_avirt_coreinfo *coreinfo; static struct loopback *loopback; struct loopback_pcm; @@ -509,7 +509,7 @@ static void loopback_timer_function(struct timer_list *t) dpcm->period_update_pending = 0; spin_unlock_irqrestore(&dpcm->cable->lock, flags); /* need to unlock before calling below */ - avirt_pcm_period_elapsed(dpcm->substream); + snd_avirt_pcm_period_elapsed(dpcm->substream); return; } } @@ -529,7 +529,7 @@ static snd_pcm_uframes_t loopback_pointer(struct snd_pcm_substream *substream) return bytes_to_frames(runtime, pos); } -static const struct snd_pcm_hardware loopback_pcm_hardware = { +static const struct snd_pcm_hardware loopbackap_pcm_hardware = { .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME), @@ -661,7 +661,7 @@ static int loopback_open(struct snd_pcm_substream *substream) goto unlock; } spin_lock_init(&cable->lock); - cable->hw = loopback_pcm_hardware; + cable->hw = loopbackap_pcm_hardware; loopback->cables[substream->pcm->device] = cable; } dpcm->cable = cable; @@ -689,7 +689,7 @@ static int loopback_open(struct snd_pcm_substream *substream) runtime->private_data = dpcm; runtime->private_free = loopback_runtime_free; if (get_notify(dpcm)) - runtime->hw = loopback_pcm_hardware; + runtime->hw = loopbackap_pcm_hardware; else runtime->hw = cable->hw; @@ -936,7 +936,7 @@ static int loopback_mixer_new(struct loopback *loopback, int notify) int dev, dev_count, idx, err; strcpy(card->mixername, "Loopback Mixer"); - dev_count = avirt_stream_count(SNDRV_PCM_STREAM_PLAYBACK); + dev_count = snd_avirt_stream_count(SNDRV_PCM_STREAM_PLAYBACK); for (dev = 0; dev < dev_count; dev++) { pcm = loopback->pcm[dev]; setup = &loopback->setup[dev]; @@ -1043,9 +1043,9 @@ static int loopback_proc_new(struct loopback *loopback, int cidx) return 0; } -int loopbackap_configure(struct snd_card *card, - struct config_group *avirt_stream_group, - unsigned int stream_count) +static int loopbackap_configure(struct snd_card *card, + struct config_group *snd_avirt_stream_group, + unsigned int stream_count) { int err; struct list_head *entry; @@ -1056,11 +1056,11 @@ int loopbackap_configure(struct snd_card *card, loopback->card = card; mutex_init(&loopback->cable_lock); - list_for_each (entry, &avirt_stream_group->cg_children) { + list_for_each (entry, &snd_avirt_stream_group->cg_children) { struct config_item *item = container_of(entry, struct config_item, ci_entry); - struct avirt_stream *stream = - avirt_stream_from_config_item(item); + struct snd_avirt_stream *stream = + snd_avirt_stream_from_config_item(item); loopback->pcm[stream->device] = stream->pcm; AP_INFOK("stream name:%s device:%d channels:%d", stream->name, @@ -1080,11 +1080,11 @@ int loopbackap_configure(struct snd_card *card, /******************************************************************************* * Loopback Audio Path AVIRT registration ******************************************************************************/ -static struct avirt_audiopath loopbackap_module = { +static struct snd_avirt_audiopath loopbackap_module = { .uid = AP_UID, .name = "Loopback Audio Path", .version = { 0, 0, 1 }, - .hw = &loopback_pcm_hardware, + .hw = &loopbackap_pcm_hardware, .pcm_ops = &loopbackap_pcm_ops, .configure = loopbackap_configure, }; @@ -1093,7 +1093,7 @@ static int __init alsa_card_loopback_init(void) { int err = 0; - err = avirt_audiopath_register(&loopbackap_module, &coreinfo); + err = snd_avirt_audiopath_register(&loopbackap_module, &coreinfo); if ((err < 0) || (!coreinfo)) { AP_ERRORK("coreinfo is NULL!"); return err; @@ -1104,7 +1104,7 @@ static int __init alsa_card_loopback_init(void) static void __exit alsa_card_loopback_exit(void) { - avirt_audiopath_deregister(&loopbackap_module); + snd_avirt_audiopath_deregister(&loopbackap_module); } module_init(alsa_card_loopback_init); diff --git a/scripts/load.sh b/scripts/load.sh index 82f613a..103a63b 100755 --- a/scripts/load.sh +++ b/scripts/load.sh @@ -1,11 +1,11 @@ #!/bin/sh # Load the core -insmod avirt_core.ko +insmod snd-avirt-core.ko # Load the additional Audio Paths -insmod dummy/avirt_dummyap.ko -insmod loopback/avirt_loopbackap.ko +insmod dummy/snd-avirt-ap-dummy.ko +insmod loopback/snd-avirt-ap-loopback.ko # Run the test script ./scripts/test_configfs.sh diff --git a/scripts/make-agl.sh b/scripts/make-agl.sh index 4421af8..6c94fbb 100755 --- a/scripts/make-agl.sh +++ b/scripts/make-agl.sh @@ -7,6 +7,8 @@ long_sdkpath=$(xds-cli sdks get $sdk_id | grep Path) sdkpath=${long_sdkpath:4} # Build -/opt/AGL/bin/xds-cli exec --config xds-project.conf -- \ - LDFLAGS= CONFIG_AVIRT=m CONFIG_AVIRT_BUILDLOCAL=y CONFIG_AVIRT_DUMMYAP=m \ +/opt/AGL/bin/xds-cli exec --config xds-project.conf -- \ + LDFLAGS= CONFIG_AVIRT=m CONFIG_AVIRT_BUILDLOCAL=y \ + CONFIG_AVIRT_AP_DUMMY=m \ + CONFIG_AVIRT_AP_LOOPBACK=m \ make -C $sdkpath/sysroots/aarch64-agl-linux/usr/src/kernel M=$(pwd) $@ diff --git a/scripts/test_configfs.sh b/scripts/test_configfs.sh index baa5e58..b6a56f6 100755 --- a/scripts/test_configfs.sh +++ b/scripts/test_configfs.sh @@ -2,20 +2,20 @@ mkdir -p /config && mount -t configfs none /config -mkdir /config/avirt/streams/playback_media -echo "2">/config/avirt/streams/playback_media/channels -echo "ap_loopback">/config/avirt/streams/playback_media/map +mkdir /config/snd-avirt/streams/playback_media +echo "2">/config/snd-avirt/streams/playback_media/channels +echo "ap_loopback">/config/snd-avirt/streams/playback_media/map -mkdir /config/avirt/streams/playback_navigation -echo "1">/config/avirt/streams/playback_navigation/channels -echo "ap_loopback">/config/avirt/streams/playback_navigation/map +mkdir /config/snd-avirt/streams/playback_navigation +echo "1">/config/snd-avirt/streams/playback_navigation/channels +echo "ap_loopback">/config/snd-avirt/streams/playback_navigation/map -mkdir /config/avirt/streams/playback_emergency -echo "1">/config/avirt/streams/playback_emergency/channels -echo "ap_loopback">/config/avirt/streams/playback_emergency/map +mkdir /config/snd-avirt/streams/playback_emergency +echo "1">/config/snd-avirt/streams/playback_emergency/channels +echo "ap_loopback">/config/snd-avirt/streams/playback_emergency/map -mkdir /config/avirt/streams/capture_voice -echo "1">/config/avirt/streams/capture_voice/channels -echo "ap_loopback">/config/avirt/streams/capture_voice/map +mkdir /config/snd-avirt/streams/capture_voice +echo "1">/config/snd-avirt/streams/capture_voice/channels +echo "ap_loopback">/config/snd-avirt/streams/capture_voice/map -echo "1">/config/avirt/streams/sealed +echo "1">/config/snd-avirt/streams/sealed diff --git a/scripts/unload.sh b/scripts/unload.sh index 2c158d5..a18e1f5 100755 --- a/scripts/unload.sh +++ b/scripts/unload.sh @@ -1,13 +1,13 @@ #!/bin/sh -rmdir /config/avirt/streams/playback_* -rmdir /config/avirt/streams/capture_* +rmdir /config/snd-avirt/streams/playback_* +rmdir /config/snd-avirt/streams/capture_* rm_module() { lsmod |grep "^$1\>" && rmmod $1 || true } -rm_module avirt_loopbackap -rm_module avirt_dummyap -rm_module avirt_core +rm_module snd_avirt_ap_loopback +rm_module snd_avirt_ap_dummy +rm_module snd_avirt_core echo "Drivers Removed!" diff --git a/sound/avirt.h b/sound/avirt.h index 5df84fe..1a5c546 100644 --- a/sound/avirt.h +++ b/sound/avirt.h @@ -17,34 +17,34 @@ #define MAX_STREAMS 16 #define MAX_NAME_LEN 80 -#define DINFO(logname, fmt, args...) \ +#define DINFO(logname, fmt, args...) \ snd_printk(KERN_INFO "AVIRT: %s: " fmt "\n", logname, ##args) -#define DERROR(logname, fmt, args...) \ +#define DERROR(logname, fmt, args...) \ snd_printk(KERN_ERR "AVIRT: %s: " fmt "\n", logname, ##args) -#define DDEBUG(logname, fmt, args...) \ +#define DDEBUG(logname, fmt, args...) \ snd_printk(KERN_DEBUG "AVIRT: %s: " fmt "\n", logname, ##args) /** * AVIRT Audio Path configure function type - * Each Audio Path registers this at avirt_audiopath_register time. + * Each Audio Path registers this at snd_avirt_audiopath_register time. * It is then called by the core once AVIRT has been configured */ -typedef int (*avirt_audiopath_configure)(struct snd_card *card, - struct config_group *stream_group, - unsigned int stream_count); +typedef int (*snd_avirt_audiopath_configure)(struct snd_card *card, + struct config_group *stream_group, + unsigned int stream_count); /** * AVIRT Audio Path info */ -struct avirt_audiopath { +struct snd_avirt_audiopath { const char *uid; /* Unique identifier */ const char *name; /* Pretty name */ unsigned int version[3]; /* Version - Major.Minor.Ext */ const struct snd_pcm_hardware *hw; /* ALSA PCM HW conf */ const struct snd_pcm_ops *pcm_ops; /* ALSA PCM op table */ - avirt_audiopath_configure configure; /* Configure callback function */ + snd_avirt_audiopath_configure configure; /* Config callback function */ void *context; }; @@ -52,7 +52,7 @@ struct avirt_audiopath { /* * Audio stream configuration */ -struct avirt_stream { +struct snd_avirt_stream { char name[MAX_NAME_LEN]; /* Stream name */ char map[MAX_NAME_LEN]; /* Stream Audio Path mapping */ unsigned int channels; /* Stream channel count */ @@ -65,58 +65,58 @@ struct avirt_stream { /** * AVIRT core info */ -struct avirt_coreinfo { +struct snd_avirt_coreinfo { unsigned int version[3]; }; /** - * avirt_audiopath_register - register Audio Path with ALSA virtual driver + * snd_avirt_audiopath_register - register Audio Path with AVIRT * @audiopath: Audio Path to be registered * @core: ALSA virtual driver core info * @return: 0 on success or error code otherwise */ -int avirt_audiopath_register(struct avirt_audiopath *audiopath, - struct avirt_coreinfo **coreinfo); +int snd_avirt_audiopath_register(struct snd_avirt_audiopath *audiopath, + struct snd_avirt_coreinfo **coreinfo); /** - * avirt_audiopath_deregister - deregister Audio Path with ALSA virtual driver + * snd_avirt_audiopath_deregister - deregister Audio Path with AVIRT * @audiopath: Audio Path to be deregistered * @return: 0 on success or error code otherwise */ -int avirt_audiopath_deregister(struct avirt_audiopath *audiopath); +int snd_avirt_audiopath_deregister(struct snd_avirt_audiopath *audiopath); /** - * avirt_audiopath_get - retrieves the Audio Path by it's UID + * snd_avirt_audiopath_get - retrieves the Audio Path by it's UID * @uid: Unique ID for the Audio Path * @return: Corresponding Audio Path */ -struct avirt_audiopath *avirt_audiopath_get(const char *uid); +struct snd_avirt_audiopath *snd_avirt_audiopath_get(const char *uid); /** - * avirt_stream_count - get the stream count for the given direction + * snd_avirt_stream_count - get the stream count for the given direction * @direction: The direction to get the stream count for * @return: The stream count */ -int avirt_stream_count(unsigned int direction); +int snd_avirt_stream_count(unsigned int direction); /** - * avirt_stream_from_config_item - Convert a config_item to an avirt_stream + * snd_avirt_stream_from_config_item - Convert config_item to a snd_avirt_stream * @item: The config_item to convert from - * @return: The item's avirt_stream if successful, NULL otherwise + * @return: The item's snd_avirt_stream if successful, NULL otherwise */ -static inline struct avirt_stream * -avirt_stream_from_config_item(struct config_item *item) +static inline struct snd_avirt_stream * + snd_avirt_stream_from_config_item(struct config_item *item) { - return item ? container_of(item, struct avirt_stream, item) : NULL; + return item ? container_of(item, struct snd_avirt_stream, item) : NULL; } /** - * avirt_pcm_period_elapsed - PCM buffer complete callback + * snd_avirt_pcm_period_elapsed - PCM buffer complete callback * @substream: pointer to ALSA PCM substream * * This should be called from a child Audio Path once it has finished processing * the PCM buffer */ -void avirt_pcm_period_elapsed(struct snd_pcm_substream *substream); +void snd_avirt_pcm_period_elapsed(struct snd_pcm_substream *substream); #endif // __SOUND_AVIRT_H -- cgit 1.2.3-korg From 188712f58b309d94d26d7468a792326c464a7eda Mon Sep 17 00:00:00 2001 From: Mark Farrugia Date: Fri, 26 Oct 2018 17:30:31 +1100 Subject: Add missing changes after GitHub rebase Some Usage doc changes Signed-off-by: Mark Farrugia --- docs/3.Usage.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/3.Usage.md b/docs/3.Usage.md index f535a07..ba5c3e6 100644 --- a/docs/3.Usage.md +++ b/docs/3.Usage.md @@ -7,10 +7,11 @@ Using AVIRT 1. [Load/Unload AVIRT](#un-load-avirt) 2. [Configuring AVIRT](#configuring-avirt) +3. [Checking AVIRT](#checking-avirt) -## Loading and Unloading AVIRT +## 1. Loading and Unloading AVIRT ### Load Out of Tree @@ -61,7 +62,7 @@ modprobe snd-avirt-ap-loopback -## Configuring AVIRT +## 2. Configuring AVIRT AVIRT is configured using configfs. -- cgit 1.2.3-korg