summaryrefslogtreecommitdiffstats
path: root/docs/3.Usage.md
blob: ba5c3e60e95e3aad09bcf8529a9748d2f2d25dda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
Using AVIRT
===================================

## Introduction

## Table of Contents

1. [Load/Unload AVIRT](#un-load-avirt)
2. [Configuring AVIRT](#configuring-avirt)
3. [Checking AVIRT](#checking-avirt)

<a name="un-load-avirt"/>

## 1. Loading and Unloading AVIRT

### 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
insmod snd-avirt-core.ko
insmod dummy/snd-avirt-ap-dummy.ko
insmod loopback/snd-avirt-ap-loopback.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 `scripts/load.sh` script:

```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
mkdir -p /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 snd-avirt-core
modprobe snd-avirt-ap-dummy
modprobe snd-avirt-ap-loopback
```

<a name="configure-avirt" />

## 2. 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` filesystem 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, for example:

```sh
# Set up each of the cards channels
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/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/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/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/snd-avirt/streams/sealed
```

Alternatively, the test script at `scripts/test_configfs.sh` can be used.

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.

<a name="checking-avirt" />

## 3. Checking AVIRT Loaded Correctly

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
...
```