xref: /src/usr.sbin/virtual_oss/virtual_oss/virtual_oss.h (revision 6d5a428056b52c7ce47b01d6af8aaaff6feecfdd)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2012-2022 Hans Petter Selasky
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  */
27 
28 #ifndef _VIRTUAL_OSS_H_
29 #define	_VIRTUAL_OSS_H_
30 
31 #include <sys/ioccom.h>
32 
33 #define	VIRTUAL_OSS_NAME_MAX	32
34 #define	VIRTUAL_OSS_VERSION 0x00010008
35 #define	VIRTUAL_OSS_OPTIONS_MAX	1024	/* bytes */
36 #define	VIRTUAL_OSS_FILTER_MAX 65536	/* samples */
37 
38 #define	VIRTUAL_OSS_GET_VERSION		_IOR('O', 0, int)
39 
40 struct virtual_oss_io_info {
41 	int	number;			/* must be first */
42 	int	channel;
43 	char	name[VIRTUAL_OSS_NAME_MAX];
44 	int	bits;
45 	int	rx_amp;
46 	int	tx_amp;
47 	int	rx_chan;
48 	int	tx_chan;
49 	int	rx_mute;
50 	int	tx_mute;
51 	int	rx_pol;
52 	int	tx_pol;
53 	int	rx_delay;		/* in samples */
54 	int	rx_delay_limit;		/* in samples */
55 };
56 
57 #define	VIRTUAL_OSS_GET_DEV_INFO	_IOWR('O', 1, struct virtual_oss_io_info)
58 #define	VIRTUAL_OSS_SET_DEV_INFO	 _IOW('O', 2, struct virtual_oss_io_info)
59 
60 #define	VIRTUAL_OSS_GET_LOOP_INFO	_IOWR('O', 3, struct virtual_oss_io_info)
61 #define	VIRTUAL_OSS_SET_LOOP_INFO	 _IOW('O', 4, struct virtual_oss_io_info)
62 
63 struct virtual_oss_mon_info {
64 	int	number;
65 	int	bits;
66 	int	src_chan;
67 	int	dst_chan;
68 	int	pol;
69 	int	mute;
70 	int	amp;
71 };
72 
73 #define	VIRTUAL_OSS_GET_INPUT_MON_INFO	_IOWR('O', 5, struct virtual_oss_mon_info)
74 #define	VIRTUAL_OSS_SET_INPUT_MON_INFO	 _IOW('O', 6, struct virtual_oss_mon_info)
75 
76 #define	VIRTUAL_OSS_GET_OUTPUT_MON_INFO	_IOWR('O', 7, struct virtual_oss_mon_info)
77 #define	VIRTUAL_OSS_SET_OUTPUT_MON_INFO	 _IOW('O', 8, struct virtual_oss_mon_info)
78 
79 #define	VIRTUAL_OSS_GET_LOCAL_MON_INFO	_IOWR('O', 43, struct virtual_oss_mon_info)
80 #define	VIRTUAL_OSS_SET_LOCAL_MON_INFO	 _IOW('O', 44, struct virtual_oss_mon_info)
81 
82 struct virtual_oss_io_peak {
83 	int	number;			/* must be first */
84 	int	channel;
85 	char	name[VIRTUAL_OSS_NAME_MAX];
86 	int	bits;
87 	long long rx_peak_value;
88 	long long tx_peak_value;
89 };
90 
91 #define	VIRTUAL_OSS_GET_DEV_PEAK	_IOWR('O', 9, struct virtual_oss_io_peak)
92 #define	VIRTUAL_OSS_GET_LOOP_PEAK	_IOWR('O', 10, struct virtual_oss_io_peak)
93 
94 struct virtual_oss_mon_peak {
95 	int	number;
96 	int	bits;
97 	long long peak_value;
98 };
99 
100 #define	VIRTUAL_OSS_GET_INPUT_MON_PEAK	_IOWR('O', 11, struct virtual_oss_mon_peak)
101 #define	VIRTUAL_OSS_GET_OUTPUT_MON_PEAK	_IOWR('O', 12, struct virtual_oss_mon_peak)
102 #define	VIRTUAL_OSS_GET_LOCAL_MON_PEAK	_IOWR('O', 45, struct virtual_oss_mon_peak)
103 
104 #define	VIRTUAL_OSS_ADD_INPUT_MON	 _IOR('O', 13, int)
105 #define	VIRTUAL_OSS_ADD_OUTPUT_MON	 _IOR('O', 14, int)
106 #define	VIRTUAL_OSS_ADD_LOCAL_MON	 _IOR('O', 46, int)
107 
108 struct virtual_oss_compressor {
109 	int	enabled;
110 	int	knee;
111 #define	VIRTUAL_OSS_KNEE_MAX 255	/* inclusive */
112 #define	VIRTUAL_OSS_KNEE_MIN 0
113 	int	attack;
114 #define	VIRTUAL_OSS_ATTACK_MAX 62	/* inclusive */
115 #define	VIRTUAL_OSS_ATTACK_MIN 0
116 	int	decay;
117 #define	VIRTUAL_OSS_DECAY_MAX 62	/* inclusive */
118 #define	VIRTUAL_OSS_DECAY_MIN 0
119 	int	gain;			/* read only */
120 #define	VIRTUAL_OSS_GAIN_MAX 1000	/* inclusive */
121 #define	VIRTUAL_OSS_GAIN_MIN 0
122 };
123 
124 #define	VIRTUAL_OSS_SET_OUTPUT_LIMIT	_IOW('O', 17, struct virtual_oss_compressor)
125 #define	VIRTUAL_OSS_GET_OUTPUT_LIMIT   _IOWR('O', 18, struct virtual_oss_compressor)
126 
127 struct virtual_oss_io_limit {
128 	int	number;			/* must be first */
129 	struct virtual_oss_compressor param;
130 };
131 
132 #define	VIRTUAL_OSS_SET_DEV_LIMIT	_IOW('O', 19, struct virtual_oss_io_limit)
133 #define	VIRTUAL_OSS_GET_DEV_LIMIT      _IOWR('O', 20, struct virtual_oss_io_limit)
134 
135 #define	VIRTUAL_OSS_SET_LOOP_LIMIT	_IOW('O', 21, struct virtual_oss_io_limit)
136 #define	VIRTUAL_OSS_GET_LOOP_LIMIT      _IOWR('O', 22, struct virtual_oss_io_limit)
137 
138 struct virtual_oss_master_peak {
139 	int	channel;
140 	int	bits;
141 	long long peak_value;
142 };
143 
144 #define	VIRTUAL_OSS_GET_OUTPUT_PEAK	_IOWR('O', 23, struct virtual_oss_master_peak)
145 #define	VIRTUAL_OSS_GET_INPUT_PEAK	_IOWR('O', 24, struct virtual_oss_master_peak)
146 
147 #define	VIRTUAL_OSS_SET_RECORDING	_IOW('O', 25, int)
148 #define	VIRTUAL_OSS_GET_RECORDING	_IOR('O', 26, int)
149 
150 struct virtual_oss_audio_delay_locator {
151 	int	channel_output;
152 	int	channel_input;
153 	int	channel_last;
154 	int	signal_output_level;	/* 2**n */
155 	int	signal_input_delay;	/* in samples, roundtrip */
156 	int	signal_delay_hz;	/* in samples, HZ */
157 	int	locator_enabled;
158 };
159 
160 #define	VIRTUAL_OSS_SET_AUDIO_DELAY_LOCATOR	_IOW('O', 27, struct virtual_oss_audio_delay_locator)
161 #define	VIRTUAL_OSS_GET_AUDIO_DELAY_LOCATOR	_IOR('O', 28, struct virtual_oss_audio_delay_locator)
162 #define	VIRTUAL_OSS_RST_AUDIO_DELAY_LOCATOR	_IO('O', 29)
163 
164 struct virtual_oss_midi_delay_locator {
165 	int	channel_output;
166 	int	channel_input;
167 	int	signal_delay;
168 	int	signal_delay_hz;	/* in samples, HZ */
169 	int	locator_enabled;
170 };
171 
172 #define	VIRTUAL_OSS_SET_MIDI_DELAY_LOCATOR	_IOW('O', 30, struct virtual_oss_midi_delay_locator)
173 #define	VIRTUAL_OSS_GET_MIDI_DELAY_LOCATOR	_IOR('O', 31, struct virtual_oss_midi_delay_locator)
174 #define	VIRTUAL_OSS_RST_MIDI_DELAY_LOCATOR	_IO('O', 32)
175 
176 #define	VIRTUAL_OSS_ADD_OPTIONS			_IOWR('O', 33, char [VIRTUAL_OSS_OPTIONS_MAX])
177 
178 struct virtual_oss_fir_filter {
179 	int	number;			/* must be first */
180 	int	channel;
181 	int	filter_size;
182 	double *filter_data;
183 };
184 
185 #define	VIRTUAL_OSS_GET_RX_DEV_FIR_FILTER	_IOWR('O', 34, struct virtual_oss_fir_filter)
186 #define	VIRTUAL_OSS_SET_RX_DEV_FIR_FILTER	_IOWR('O', 35, struct virtual_oss_fir_filter)
187 #define	VIRTUAL_OSS_GET_TX_DEV_FIR_FILTER	_IOWR('O', 36, struct virtual_oss_fir_filter)
188 #define	VIRTUAL_OSS_SET_TX_DEV_FIR_FILTER	_IOWR('O', 37, struct virtual_oss_fir_filter)
189 #define	VIRTUAL_OSS_GET_RX_LOOP_FIR_FILTER	_IOWR('O', 38, struct virtual_oss_fir_filter)
190 #define	VIRTUAL_OSS_SET_RX_LOOP_FIR_FILTER	_IOWR('O', 39, struct virtual_oss_fir_filter)
191 #define	VIRTUAL_OSS_GET_TX_LOOP_FIR_FILTER	_IOWR('O', 40, struct virtual_oss_fir_filter)
192 #define	VIRTUAL_OSS_SET_TX_LOOP_FIR_FILTER	_IOWR('O', 41, struct virtual_oss_fir_filter)
193 
194 #define	VIRTUAL_OSS_GET_SAMPLE_RATE		_IOR('O', 42, int)
195 
196 struct virtual_oss_system_info {
197 	unsigned tx_jitter_up;
198 	unsigned tx_jitter_down;
199 	unsigned sample_rate;
200 	unsigned sample_bits;
201 	unsigned sample_channels;
202 	char rx_device_name[64];
203 	char tx_device_name[64];
204 };
205 
206 #define	VIRTUAL_OSS_GET_SYSTEM_INFO		_IOR('O', 43, struct virtual_oss_system_info)
207 
208 #endif					/* _VIRTUAL_OSS_H_ */
209