xref: /openbmc/linux/include/uapi/sound/hdspm.h (revision 76a3aeac)
1674e95caSDavid Howells #ifndef __SOUND_HDSPM_H
2674e95caSDavid Howells #define __SOUND_HDSPM_H
3674e95caSDavid Howells /*
4674e95caSDavid Howells  *   Copyright (C) 2003 Winfried Ritsch (IEM)
5674e95caSDavid Howells  *   based on hdsp.h from Thomas Charbonnel (thomas@undata.org)
6674e95caSDavid Howells  *
7674e95caSDavid Howells  *
8674e95caSDavid Howells  *   This program is free software; you can redistribute it and/or modify
9674e95caSDavid Howells  *   it under the terms of the GNU General Public License as published by
10674e95caSDavid Howells  *   the Free Software Foundation; either version 2 of the License, or
11674e95caSDavid Howells  *   (at your option) any later version.
12674e95caSDavid Howells  *
13674e95caSDavid Howells  *   This program is distributed in the hope that it will be useful,
14674e95caSDavid Howells  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15674e95caSDavid Howells  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16674e95caSDavid Howells  *   GNU General Public License for more details.
17674e95caSDavid Howells  *
18674e95caSDavid Howells  *   You should have received a copy of the GNU General Public License
19674e95caSDavid Howells  *   along with this program; if not, write to the Free Software
20674e95caSDavid Howells  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21674e95caSDavid Howells  */
22674e95caSDavid Howells 
2376a3aeacSMikko Rapeli #ifdef __KERNEL__
2476a3aeacSMikko Rapeli #include <linux/types.h>
2576a3aeacSMikko Rapeli #else
2676a3aeacSMikko Rapeli #include <stdint.h>
2776a3aeacSMikko Rapeli #endif
2876a3aeacSMikko Rapeli 
29674e95caSDavid Howells /* Maximum channels is 64 even on 56Mode you have 64playbacks to matrix */
30674e95caSDavid Howells #define HDSPM_MAX_CHANNELS      64
31674e95caSDavid Howells 
32674e95caSDavid Howells enum hdspm_io_type {
33674e95caSDavid Howells 	MADI,
34674e95caSDavid Howells 	MADIface,
35674e95caSDavid Howells 	AIO,
36674e95caSDavid Howells 	AES32,
37674e95caSDavid Howells 	RayDAT
38674e95caSDavid Howells };
39674e95caSDavid Howells 
40674e95caSDavid Howells enum hdspm_speed {
41674e95caSDavid Howells 	ss,
42674e95caSDavid Howells 	ds,
43674e95caSDavid Howells 	qs
44674e95caSDavid Howells };
45674e95caSDavid Howells 
46674e95caSDavid Howells /* -------------------- IOCTL Peak/RMS Meters -------------------- */
47674e95caSDavid Howells 
48674e95caSDavid Howells struct hdspm_peak_rms {
49674e95caSDavid Howells 	uint32_t input_peaks[64];
50674e95caSDavid Howells 	uint32_t playback_peaks[64];
51674e95caSDavid Howells 	uint32_t output_peaks[64];
52674e95caSDavid Howells 
53674e95caSDavid Howells 	uint64_t input_rms[64];
54674e95caSDavid Howells 	uint64_t playback_rms[64];
55674e95caSDavid Howells 	uint64_t output_rms[64];
56674e95caSDavid Howells 
57674e95caSDavid Howells 	uint8_t speed; /* enum {ss, ds, qs} */
58674e95caSDavid Howells 	int status2;
59674e95caSDavid Howells };
60674e95caSDavid Howells 
61674e95caSDavid Howells #define SNDRV_HDSPM_IOCTL_GET_PEAK_RMS \
62674e95caSDavid Howells 	_IOR('H', 0x42, struct hdspm_peak_rms)
63674e95caSDavid Howells 
64674e95caSDavid Howells /* ------------ CONFIG block IOCTL ---------------------- */
65674e95caSDavid Howells 
66674e95caSDavid Howells struct hdspm_config {
67674e95caSDavid Howells 	unsigned char pref_sync_ref;
68674e95caSDavid Howells 	unsigned char wordclock_sync_check;
69674e95caSDavid Howells 	unsigned char madi_sync_check;
70674e95caSDavid Howells 	unsigned int system_sample_rate;
71674e95caSDavid Howells 	unsigned int autosync_sample_rate;
72674e95caSDavid Howells 	unsigned char system_clock_mode;
73674e95caSDavid Howells 	unsigned char clock_source;
74674e95caSDavid Howells 	unsigned char autosync_ref;
75674e95caSDavid Howells 	unsigned char line_out;
76674e95caSDavid Howells 	unsigned int passthru;
77674e95caSDavid Howells 	unsigned int analog_out;
78674e95caSDavid Howells };
79674e95caSDavid Howells 
80674e95caSDavid Howells #define SNDRV_HDSPM_IOCTL_GET_CONFIG \
81674e95caSDavid Howells 	_IOR('H', 0x41, struct hdspm_config)
82674e95caSDavid Howells 
83ddcecf6bSTakashi Iwai /*
84674e95caSDavid Howells  * If there's a TCO (TimeCode Option) board installed,
85674e95caSDavid Howells  * there are further options and status data available.
86674e95caSDavid Howells  * The hdspm_ltc structure contains the current SMPTE
87674e95caSDavid Howells  * timecode and some status information and can be
88674e95caSDavid Howells  * obtained via SNDRV_HDSPM_IOCTL_GET_LTC or in the
89674e95caSDavid Howells  * hdspm_status struct.
90ddcecf6bSTakashi Iwai  */
91674e95caSDavid Howells 
92674e95caSDavid Howells enum hdspm_ltc_format {
93674e95caSDavid Howells 	format_invalid,
94674e95caSDavid Howells 	fps_24,
95674e95caSDavid Howells 	fps_25,
96674e95caSDavid Howells 	fps_2997,
97674e95caSDavid Howells 	fps_30
98674e95caSDavid Howells };
99674e95caSDavid Howells 
100674e95caSDavid Howells enum hdspm_ltc_frame {
101674e95caSDavid Howells 	frame_invalid,
102674e95caSDavid Howells 	drop_frame,
103674e95caSDavid Howells 	full_frame
104674e95caSDavid Howells };
105674e95caSDavid Howells 
106674e95caSDavid Howells enum hdspm_ltc_input_format {
107674e95caSDavid Howells 	ntsc,
108674e95caSDavid Howells 	pal,
109674e95caSDavid Howells 	no_video
110674e95caSDavid Howells };
111674e95caSDavid Howells 
112674e95caSDavid Howells struct hdspm_ltc {
113674e95caSDavid Howells 	unsigned int ltc;
114674e95caSDavid Howells 
115674e95caSDavid Howells 	enum hdspm_ltc_format format;
116674e95caSDavid Howells 	enum hdspm_ltc_frame frame;
117674e95caSDavid Howells 	enum hdspm_ltc_input_format input_format;
118674e95caSDavid Howells };
119674e95caSDavid Howells 
120b43dd416SAdrian Knoth #define SNDRV_HDSPM_IOCTL_GET_LTC _IOR('H', 0x46, struct hdspm_ltc)
121674e95caSDavid Howells 
122ddcecf6bSTakashi Iwai /*
123674e95caSDavid Howells  * The status data reflects the device's current state
124674e95caSDavid Howells  * as determined by the card's configuration and
125674e95caSDavid Howells  * connection status.
126ddcecf6bSTakashi Iwai  */
127674e95caSDavid Howells 
128674e95caSDavid Howells enum hdspm_sync {
129674e95caSDavid Howells 	hdspm_sync_no_lock = 0,
130674e95caSDavid Howells 	hdspm_sync_lock = 1,
131674e95caSDavid Howells 	hdspm_sync_sync = 2
132674e95caSDavid Howells };
133674e95caSDavid Howells 
134674e95caSDavid Howells enum hdspm_madi_input {
135674e95caSDavid Howells 	hdspm_input_optical = 0,
136674e95caSDavid Howells 	hdspm_input_coax = 1
137674e95caSDavid Howells };
138674e95caSDavid Howells 
139674e95caSDavid Howells enum hdspm_madi_channel_format {
140674e95caSDavid Howells 	hdspm_format_ch_64 = 0,
141674e95caSDavid Howells 	hdspm_format_ch_56 = 1
142674e95caSDavid Howells };
143674e95caSDavid Howells 
144674e95caSDavid Howells enum hdspm_madi_frame_format {
145674e95caSDavid Howells 	hdspm_frame_48 = 0,
146674e95caSDavid Howells 	hdspm_frame_96 = 1
147674e95caSDavid Howells };
148674e95caSDavid Howells 
149674e95caSDavid Howells enum hdspm_syncsource {
150674e95caSDavid Howells 	syncsource_wc = 0,
151674e95caSDavid Howells 	syncsource_madi = 1,
152674e95caSDavid Howells 	syncsource_tco = 2,
153674e95caSDavid Howells 	syncsource_sync = 3,
154674e95caSDavid Howells 	syncsource_none = 4
155674e95caSDavid Howells };
156674e95caSDavid Howells 
157674e95caSDavid Howells struct hdspm_status {
158674e95caSDavid Howells 	uint8_t card_type; /* enum hdspm_io_type */
159674e95caSDavid Howells 	enum hdspm_syncsource autosync_source;
160674e95caSDavid Howells 
161674e95caSDavid Howells 	uint64_t card_clock;
162674e95caSDavid Howells 	uint32_t master_period;
163674e95caSDavid Howells 
164674e95caSDavid Howells 	union {
165674e95caSDavid Howells 		struct {
166674e95caSDavid Howells 			uint8_t sync_wc; /* enum hdspm_sync */
167674e95caSDavid Howells 			uint8_t sync_madi; /* enum hdspm_sync */
168674e95caSDavid Howells 			uint8_t sync_tco; /* enum hdspm_sync */
169674e95caSDavid Howells 			uint8_t sync_in; /* enum hdspm_sync */
170674e95caSDavid Howells 			uint8_t madi_input; /* enum hdspm_madi_input */
171674e95caSDavid Howells 			uint8_t channel_format; /* enum hdspm_madi_channel_format */
172674e95caSDavid Howells 			uint8_t frame_format; /* enum hdspm_madi_frame_format */
173674e95caSDavid Howells 		} madi;
174674e95caSDavid Howells 	} card_specific;
175674e95caSDavid Howells };
176674e95caSDavid Howells 
177674e95caSDavid Howells #define SNDRV_HDSPM_IOCTL_GET_STATUS \
178674e95caSDavid Howells 	_IOR('H', 0x47, struct hdspm_status)
179674e95caSDavid Howells 
180ddcecf6bSTakashi Iwai /*
181674e95caSDavid Howells  * Get information about the card and its add-ons.
182ddcecf6bSTakashi Iwai  */
183674e95caSDavid Howells 
184674e95caSDavid Howells #define HDSPM_ADDON_TCO 1
185674e95caSDavid Howells 
186674e95caSDavid Howells struct hdspm_version {
187674e95caSDavid Howells 	uint8_t card_type; /* enum hdspm_io_type */
188674e95caSDavid Howells 	char cardname[20];
189674e95caSDavid Howells 	unsigned int serial;
190674e95caSDavid Howells 	unsigned short firmware_rev;
191674e95caSDavid Howells 	int addons;
192674e95caSDavid Howells };
193674e95caSDavid Howells 
194674e95caSDavid Howells #define SNDRV_HDSPM_IOCTL_GET_VERSION _IOR('H', 0x48, struct hdspm_version)
195674e95caSDavid Howells 
196674e95caSDavid Howells /* ------------- get Matrix Mixer IOCTL --------------- */
197674e95caSDavid Howells 
198674e95caSDavid Howells /* MADI mixer: 64inputs+64playback in 64outputs = 8192 => *4Byte =
199674e95caSDavid Howells  * 32768 Bytes
200674e95caSDavid Howells  */
201674e95caSDavid Howells 
202674e95caSDavid Howells /* organisation is 64 channelfader in a continuous memory block */
203674e95caSDavid Howells /* equivalent to hardware definition, maybe for future feature of mmap of
204674e95caSDavid Howells  * them
205674e95caSDavid Howells  */
206674e95caSDavid Howells /* each of 64 outputs has 64 infader and 64 outfader:
207674e95caSDavid Howells    Ins to Outs mixer[out].in[in], Outstreams to Outs mixer[out].pb[pb] */
208674e95caSDavid Howells 
209674e95caSDavid Howells #define HDSPM_MIXER_CHANNELS HDSPM_MAX_CHANNELS
210674e95caSDavid Howells 
211674e95caSDavid Howells struct hdspm_channelfader {
212674e95caSDavid Howells 	unsigned int in[HDSPM_MIXER_CHANNELS];
213674e95caSDavid Howells 	unsigned int pb[HDSPM_MIXER_CHANNELS];
214674e95caSDavid Howells };
215674e95caSDavid Howells 
216674e95caSDavid Howells struct hdspm_mixer {
217674e95caSDavid Howells 	struct hdspm_channelfader ch[HDSPM_MIXER_CHANNELS];
218674e95caSDavid Howells };
219674e95caSDavid Howells 
220674e95caSDavid Howells struct hdspm_mixer_ioctl {
221674e95caSDavid Howells 	struct hdspm_mixer *mixer;
222674e95caSDavid Howells };
223674e95caSDavid Howells 
224674e95caSDavid Howells /* use indirect access due to the limit of ioctl bit size */
225674e95caSDavid Howells #define SNDRV_HDSPM_IOCTL_GET_MIXER _IOR('H', 0x44, struct hdspm_mixer_ioctl)
226674e95caSDavid Howells 
227674e95caSDavid Howells /* typedefs for compatibility to user-space */
228674e95caSDavid Howells typedef struct hdspm_peak_rms hdspm_peak_rms_t;
229674e95caSDavid Howells typedef struct hdspm_config_info hdspm_config_info_t;
230674e95caSDavid Howells typedef struct hdspm_version hdspm_version_t;
231674e95caSDavid Howells typedef struct hdspm_channelfader snd_hdspm_channelfader_t;
232674e95caSDavid Howells typedef struct hdspm_mixer hdspm_mixer_t;
233674e95caSDavid Howells 
234674e95caSDavid Howells 
235674e95caSDavid Howells #endif
236