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