xref: /openbmc/linux/include/uapi/sound/hdspm.h (revision 0df289a2)
1 #ifndef __SOUND_HDSPM_H
2 #define __SOUND_HDSPM_H
3 /*
4  *   Copyright (C) 2003 Winfried Ritsch (IEM)
5  *   based on hdsp.h from Thomas Charbonnel (thomas@undata.org)
6  *
7  *
8  *   This program is free software; you can redistribute it and/or modify
9  *   it under the terms of the GNU General Public License as published by
10  *   the Free Software Foundation; either version 2 of the License, or
11  *   (at your option) any later version.
12  *
13  *   This program is distributed in the hope that it will be useful,
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *   GNU General Public License for more details.
17  *
18  *   You should have received a copy of the GNU General Public License
19  *   along with this program; if not, write to the Free Software
20  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */
22 
23 #ifdef __KERNEL__
24 #include <linux/types.h>
25 #else
26 #include <stdint.h>
27 #endif
28 
29 /* Maximum channels is 64 even on 56Mode you have 64playbacks to matrix */
30 #define HDSPM_MAX_CHANNELS      64
31 
32 enum hdspm_io_type {
33 	MADI,
34 	MADIface,
35 	AIO,
36 	AES32,
37 	RayDAT
38 };
39 
40 enum hdspm_speed {
41 	ss,
42 	ds,
43 	qs
44 };
45 
46 /* -------------------- IOCTL Peak/RMS Meters -------------------- */
47 
48 struct hdspm_peak_rms {
49 	uint32_t input_peaks[64];
50 	uint32_t playback_peaks[64];
51 	uint32_t output_peaks[64];
52 
53 	uint64_t input_rms[64];
54 	uint64_t playback_rms[64];
55 	uint64_t output_rms[64];
56 
57 	uint8_t speed; /* enum {ss, ds, qs} */
58 	int status2;
59 };
60 
61 #define SNDRV_HDSPM_IOCTL_GET_PEAK_RMS \
62 	_IOR('H', 0x42, struct hdspm_peak_rms)
63 
64 /* ------------ CONFIG block IOCTL ---------------------- */
65 
66 struct hdspm_config {
67 	unsigned char pref_sync_ref;
68 	unsigned char wordclock_sync_check;
69 	unsigned char madi_sync_check;
70 	unsigned int system_sample_rate;
71 	unsigned int autosync_sample_rate;
72 	unsigned char system_clock_mode;
73 	unsigned char clock_source;
74 	unsigned char autosync_ref;
75 	unsigned char line_out;
76 	unsigned int passthru;
77 	unsigned int analog_out;
78 };
79 
80 #define SNDRV_HDSPM_IOCTL_GET_CONFIG \
81 	_IOR('H', 0x41, struct hdspm_config)
82 
83 /*
84  * If there's a TCO (TimeCode Option) board installed,
85  * there are further options and status data available.
86  * The hdspm_ltc structure contains the current SMPTE
87  * timecode and some status information and can be
88  * obtained via SNDRV_HDSPM_IOCTL_GET_LTC or in the
89  * hdspm_status struct.
90  */
91 
92 enum hdspm_ltc_format {
93 	format_invalid,
94 	fps_24,
95 	fps_25,
96 	fps_2997,
97 	fps_30
98 };
99 
100 enum hdspm_ltc_frame {
101 	frame_invalid,
102 	drop_frame,
103 	full_frame
104 };
105 
106 enum hdspm_ltc_input_format {
107 	ntsc,
108 	pal,
109 	no_video
110 };
111 
112 struct hdspm_ltc {
113 	unsigned int ltc;
114 
115 	enum hdspm_ltc_format format;
116 	enum hdspm_ltc_frame frame;
117 	enum hdspm_ltc_input_format input_format;
118 };
119 
120 #define SNDRV_HDSPM_IOCTL_GET_LTC _IOR('H', 0x46, struct hdspm_ltc)
121 
122 /*
123  * The status data reflects the device's current state
124  * as determined by the card's configuration and
125  * connection status.
126  */
127 
128 enum hdspm_sync {
129 	hdspm_sync_no_lock = 0,
130 	hdspm_sync_lock = 1,
131 	hdspm_sync_sync = 2
132 };
133 
134 enum hdspm_madi_input {
135 	hdspm_input_optical = 0,
136 	hdspm_input_coax = 1
137 };
138 
139 enum hdspm_madi_channel_format {
140 	hdspm_format_ch_64 = 0,
141 	hdspm_format_ch_56 = 1
142 };
143 
144 enum hdspm_madi_frame_format {
145 	hdspm_frame_48 = 0,
146 	hdspm_frame_96 = 1
147 };
148 
149 enum hdspm_syncsource {
150 	syncsource_wc = 0,
151 	syncsource_madi = 1,
152 	syncsource_tco = 2,
153 	syncsource_sync = 3,
154 	syncsource_none = 4
155 };
156 
157 struct hdspm_status {
158 	uint8_t card_type; /* enum hdspm_io_type */
159 	enum hdspm_syncsource autosync_source;
160 
161 	uint64_t card_clock;
162 	uint32_t master_period;
163 
164 	union {
165 		struct {
166 			uint8_t sync_wc; /* enum hdspm_sync */
167 			uint8_t sync_madi; /* enum hdspm_sync */
168 			uint8_t sync_tco; /* enum hdspm_sync */
169 			uint8_t sync_in; /* enum hdspm_sync */
170 			uint8_t madi_input; /* enum hdspm_madi_input */
171 			uint8_t channel_format; /* enum hdspm_madi_channel_format */
172 			uint8_t frame_format; /* enum hdspm_madi_frame_format */
173 		} madi;
174 	} card_specific;
175 };
176 
177 #define SNDRV_HDSPM_IOCTL_GET_STATUS \
178 	_IOR('H', 0x47, struct hdspm_status)
179 
180 /*
181  * Get information about the card and its add-ons.
182  */
183 
184 #define HDSPM_ADDON_TCO 1
185 
186 struct hdspm_version {
187 	uint8_t card_type; /* enum hdspm_io_type */
188 	char cardname[20];
189 	unsigned int serial;
190 	unsigned short firmware_rev;
191 	int addons;
192 };
193 
194 #define SNDRV_HDSPM_IOCTL_GET_VERSION _IOR('H', 0x48, struct hdspm_version)
195 
196 /* ------------- get Matrix Mixer IOCTL --------------- */
197 
198 /* MADI mixer: 64inputs+64playback in 64outputs = 8192 => *4Byte =
199  * 32768 Bytes
200  */
201 
202 /* organisation is 64 channelfader in a continuous memory block */
203 /* equivalent to hardware definition, maybe for future feature of mmap of
204  * them
205  */
206 /* each of 64 outputs has 64 infader and 64 outfader:
207    Ins to Outs mixer[out].in[in], Outstreams to Outs mixer[out].pb[pb] */
208 
209 #define HDSPM_MIXER_CHANNELS HDSPM_MAX_CHANNELS
210 
211 struct hdspm_channelfader {
212 	unsigned int in[HDSPM_MIXER_CHANNELS];
213 	unsigned int pb[HDSPM_MIXER_CHANNELS];
214 };
215 
216 struct hdspm_mixer {
217 	struct hdspm_channelfader ch[HDSPM_MIXER_CHANNELS];
218 };
219 
220 struct hdspm_mixer_ioctl {
221 	struct hdspm_mixer *mixer;
222 };
223 
224 /* use indirect access due to the limit of ioctl bit size */
225 #define SNDRV_HDSPM_IOCTL_GET_MIXER _IOR('H', 0x44, struct hdspm_mixer_ioctl)
226 
227 /* typedefs for compatibility to user-space */
228 typedef struct hdspm_peak_rms hdspm_peak_rms_t;
229 typedef struct hdspm_config_info hdspm_config_info_t;
230 typedef struct hdspm_version hdspm_version_t;
231 typedef struct hdspm_channelfader snd_hdspm_channelfader_t;
232 typedef struct hdspm_mixer hdspm_mixer_t;
233 
234 
235 #endif
236