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