xref: /linux/include/uapi/sound/firewire.h (revision 55f261b73a7e1cb254577c3536cef8f415de220a)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _UAPI_SOUND_FIREWIRE_H_INCLUDED
3 #define _UAPI_SOUND_FIREWIRE_H_INCLUDED
4 
5 #include <linux/ioctl.h>
6 #include <linux/types.h>
7 
8 /* events can be read() from the hwdep device */
9 
10 #define SNDRV_FIREWIRE_EVENT_LOCK_STATUS	0x000010cc
11 #define SNDRV_FIREWIRE_EVENT_DICE_NOTIFICATION	0xd1ce004e
12 #define SNDRV_FIREWIRE_EVENT_EFW_RESPONSE	0x4e617475
13 #define SNDRV_FIREWIRE_EVENT_DIGI00X_MESSAGE	0x746e736c
14 #define SNDRV_FIREWIRE_EVENT_MOTU_NOTIFICATION	0x64776479
15 #define SNDRV_FIREWIRE_EVENT_TASCAM_CONTROL	0x7473636d
16 #define SNDRV_FIREWIRE_EVENT_MOTU_REGISTER_DSP_CHANGE	0x4d545244
17 
18 struct snd_firewire_event_common {
19 	unsigned int type; /* SNDRV_FIREWIRE_EVENT_xxx */
20 };
21 
22 struct snd_firewire_event_lock_status {
23 	unsigned int type;
24 	unsigned int status; /* 0/1 = unlocked/locked */
25 };
26 
27 struct snd_firewire_event_dice_notification {
28 	unsigned int type;
29 	unsigned int notification; /* DICE-specific bits */
30 };
31 
32 #define SND_EFW_TRANSACTION_USER_SEQNUM_MAX	((__u32)((__u16)~0) - 1)
33 /* each field should be in big endian */
34 struct snd_efw_transaction {
35 	__be32 length;
36 	__be32 version;
37 	__be32 seqnum;
38 	__be32 category;
39 	__be32 command;
40 	__be32 status;
41 	__be32 params[0];
42 };
43 struct snd_firewire_event_efw_response {
44 	unsigned int type;
45 	__be32 response[0];	/* some responses */
46 };
47 
48 struct snd_firewire_event_digi00x_message {
49 	unsigned int type;
50 	__u32 message;	/* Digi00x-specific message */
51 };
52 
53 struct snd_firewire_event_motu_notification {
54 	unsigned int type;
55 	__u32 message;	/* MOTU-specific bits. */
56 };
57 
58 struct snd_firewire_tascam_change {
59 	unsigned int index;
60 	__be32 before;
61 	__be32 after;
62 };
63 
64 struct snd_firewire_event_tascam_control {
65 	unsigned int type;
66 	struct snd_firewire_tascam_change changes[0];
67 };
68 
69 struct snd_firewire_event_motu_register_dsp_change {
70 	unsigned int type;
71 	__u32 count;		/* The number of changes. */
72 	__u32 changes[];	/* Encoded event for change of register DSP. */
73 };
74 
75 union snd_firewire_event {
76 	struct snd_firewire_event_common            common;
77 	struct snd_firewire_event_lock_status       lock_status;
78 	struct snd_firewire_event_dice_notification dice_notification;
79 	struct snd_firewire_event_efw_response      efw_response;
80 	struct snd_firewire_event_digi00x_message   digi00x_message;
81 	struct snd_firewire_event_tascam_control    tascam_control;
82 	struct snd_firewire_event_motu_notification motu_notification;
83 	struct snd_firewire_event_motu_register_dsp_change motu_register_dsp_change;
84 };
85 
86 
87 #define SNDRV_FIREWIRE_IOCTL_GET_INFO _IOR('H', 0xf8, struct snd_firewire_get_info)
88 #define SNDRV_FIREWIRE_IOCTL_LOCK      _IO('H', 0xf9)
89 #define SNDRV_FIREWIRE_IOCTL_UNLOCK    _IO('H', 0xfa)
90 #define SNDRV_FIREWIRE_IOCTL_TASCAM_STATE _IOR('H', 0xfb, struct snd_firewire_tascam_state)
91 #define SNDRV_FIREWIRE_IOCTL_MOTU_REGISTER_DSP_METER	_IOR('H', 0xfc, struct snd_firewire_motu_register_dsp_meter)
92 #define SNDRV_FIREWIRE_IOCTL_MOTU_COMMAND_DSP_METER	_IOR('H', 0xfd, struct snd_firewire_motu_command_dsp_meter)
93 #define SNDRV_FIREWIRE_IOCTL_MOTU_REGISTER_DSP_PARAMETER	_IOR('H', 0xfe, struct snd_firewire_motu_register_dsp_parameter)
94 
95 #define SNDRV_FIREWIRE_TYPE_DICE	1
96 #define SNDRV_FIREWIRE_TYPE_FIREWORKS	2
97 #define SNDRV_FIREWIRE_TYPE_BEBOB	3
98 #define SNDRV_FIREWIRE_TYPE_OXFW	4
99 #define SNDRV_FIREWIRE_TYPE_DIGI00X	5
100 #define SNDRV_FIREWIRE_TYPE_TASCAM	6
101 #define SNDRV_FIREWIRE_TYPE_MOTU	7
102 #define SNDRV_FIREWIRE_TYPE_FIREFACE	8
103 
104 struct snd_firewire_get_info {
105 	unsigned int type; /* SNDRV_FIREWIRE_TYPE_xxx */
106 	unsigned int card; /* same as fw_cdev_get_info.card */
107 	unsigned char guid[8];
108 	char device_name[16]; /* device node in /dev */
109 };
110 
111 /*
112  * SNDRV_FIREWIRE_IOCTL_LOCK prevents the driver from streaming.
113  * Returns -EBUSY if the driver is already streaming.
114  */
115 
116 #define SNDRV_FIREWIRE_TASCAM_STATE_COUNT	64
117 
118 struct snd_firewire_tascam_state {
119 	__be32 data[SNDRV_FIREWIRE_TASCAM_STATE_COUNT];
120 };
121 
122 /*
123  * In below MOTU models, software is allowed to control their DSP by accessing to registers.
124  *  - 828mk2
125  *  - 896hd
126  *  - Traveler
127  *  - 8 pre
128  *  - Ultralite
129  *  - 4 pre
130  *  - Audio Express
131  *
132  * On the other hand, the status of DSP is split into specific messages included in the sequence of
133  * isochronous packet. ALSA firewire-motu driver gathers the messages and allow userspace applications
134  * to read it via ioctl. In 828mk2, 896hd, and Traveler, hardware meter for all of physical inputs
135  * are put into the message, while one pair of physical outputs is selected. The selection is done by
136  * LSB one byte in asynchronous write quadlet transaction to 0x'ffff'f000'0b2c.
137  *
138  * I note that V3HD/V4HD uses asynchronous transaction for the purpose. The destination address is
139  * registered to 0x'ffff'f000'0b38 and '0b3c by asynchronous write quadlet request. The size of
140  * message differs between 23 and 51 quadlets. For the case, the number of mixer bus can be extended
141  * up to 12.
142  */
143 
144 #define SNDRV_FIREWIRE_MOTU_REGISTER_DSP_METER_COUNT	40
145 
146 /**
147  * struct snd_firewire_motu_register_dsp_meter - the container for meter information in DSP
148  *						 controlled by register access
149  * @data: Signal level meters. The mapping between position and input/output channel is
150  *	  model-dependent.
151  *
152  * The structure expresses the part of DSP status for hardware meter. The u8 storage includes linear
153  * value for audio signal level between 0x00 and 0x7f.
154  */
155 struct snd_firewire_motu_register_dsp_meter {
156 	__u8 data[SNDRV_FIREWIRE_MOTU_REGISTER_DSP_METER_COUNT];
157 };
158 
159 #define SNDRV_FIREWIRE_MOTU_REGISTER_DSP_MIXER_COUNT		4
160 #define SNDRV_FIREWIRE_MOTU_REGISTER_DSP_MIXER_SRC_COUNT	20
161 #define SNDRV_FIREWIRE_MOTU_REGISTER_DSP_INPUT_COUNT		10
162 #define SNDRV_FIREWIRE_MOTU_REGISTER_DSP_ALIGNED_INPUT_COUNT	(SNDRV_FIREWIRE_MOTU_REGISTER_DSP_INPUT_COUNT + 2)
163 
164 /**
165  * snd_firewire_motu_register_dsp_parameter - the container for parameters of DSP controlled
166  *					      by register access.
167  * @mixer.source.gain: The gain of source to mixer.
168  * @mixer.source.pan: The L/R balance of source to mixer.
169  * @mixer.source.flag: The flag of source to mixer, including mute, solo.
170  * @mixer.source.paired_balance: The L/R balance of paired source to mixer, only for 4 pre and
171  *				 Audio Express.
172  * @mixer.source.paired_width: The width of paired source to mixer, only for 4 pre and
173  *			       Audio Express.
174  * @mixer.output.paired_volume: The volume of paired output from mixer.
175  * @mixer.output.paired_flag: The flag of paired output from mixer.
176  * @output.main_paired_volume: The volume of paired main output.
177  * @output.hp_paired_volume: The volume of paired hp output.
178  * @output.hp_paired_assignment: The source assigned to paired hp output.
179  * @output.reserved: Padding for 32 bit alignment for future extension.
180  * @line_input.boost_flag: The flags of boost for line inputs, only for 828mk2 and Traveler.
181  * @line_input.nominal_level_flag: The flags of nominal level for line inputs, only for 828mk2 and
182  *				   Traveler.
183  * @line_input.reserved: Padding for 32 bit alignment for future extension.
184  * @input.gain_and_invert: The value including gain and invert for input, only for Ultralite, 4 pre
185  *			   and Audio Express.
186  * @input.flag: The flag of input; e.g. jack detection, phantom power, and pad, only for Ultralite,
187  *		4 pre and Audio express.
188  * @reserved: Padding so that the size of structure is kept to 512 byte, but for future extension.
189  *
190  * The structure expresses the set of parameters for DSP controlled by register access.
191  */
192 struct snd_firewire_motu_register_dsp_parameter {
193 	struct {
194 		struct {
195 			__u8 gain[SNDRV_FIREWIRE_MOTU_REGISTER_DSP_MIXER_SRC_COUNT];
196 			__u8 pan[SNDRV_FIREWIRE_MOTU_REGISTER_DSP_MIXER_SRC_COUNT];
197 			__u8 flag[SNDRV_FIREWIRE_MOTU_REGISTER_DSP_MIXER_SRC_COUNT];
198 			__u8 paired_balance[SNDRV_FIREWIRE_MOTU_REGISTER_DSP_MIXER_SRC_COUNT];
199 			__u8 paired_width[SNDRV_FIREWIRE_MOTU_REGISTER_DSP_MIXER_SRC_COUNT];
200 		} source[SNDRV_FIREWIRE_MOTU_REGISTER_DSP_MIXER_COUNT];
201 		struct {
202 			__u8 paired_volume[SNDRV_FIREWIRE_MOTU_REGISTER_DSP_MIXER_COUNT];
203 			__u8 paired_flag[SNDRV_FIREWIRE_MOTU_REGISTER_DSP_MIXER_COUNT];
204 		} output;
205 	} mixer;
206 	struct {
207 		__u8 main_paired_volume;
208 		__u8 hp_paired_volume;
209 		__u8 hp_paired_assignment;
210 		__u8 reserved[5];
211 	} output;
212 	struct {
213 		__u8 boost_flag;
214 		__u8 nominal_level_flag;
215 		__u8 reserved[6];
216 	} line_input;
217 	struct {
218 		__u8 gain_and_invert[SNDRV_FIREWIRE_MOTU_REGISTER_DSP_ALIGNED_INPUT_COUNT];
219 		__u8 flag[SNDRV_FIREWIRE_MOTU_REGISTER_DSP_ALIGNED_INPUT_COUNT];
220 	} input;
221 	__u8 reserved[64];
222 };
223 
224 /*
225  * In below MOTU models, software is allowed to control their DSP by command in frame of
226  * asynchronous transaction to 0x'ffff'0001'0000:
227  *
228  *  - 828 mk3 (FireWire only and Hybrid)
229  *  - 896 mk3 (FireWire only and Hybrid)
230  *  - Ultralite mk3 (FireWire only and Hybrid)
231  *  - Traveler mk3
232  *  - Track 16
233  *
234  * On the other hand, the states of hardware meter is split into specific messages included in the
235  * sequence of isochronous packet. ALSA firewire-motu driver gathers the message and allow userspace
236  * application to read it via ioctl.
237  */
238 
239 #define SNDRV_FIREWIRE_MOTU_COMMAND_DSP_METER_COUNT	400
240 
241 /**
242  * struct snd_firewire_motu_command_dsp_meter - the container for meter information in DSP
243  *						controlled by command
244  * @data: Signal level meters. The mapping between position and signal channel is model-dependent.
245  *
246  * The structure expresses the part of DSP status for hardware meter. The 32 bit storage is
247  * estimated to include IEEE 764 32 bit single precision floating point (binary32) value. It is
248  * expected to be linear value (not logarithm) for audio signal level between 0.0 and +1.0. However,
249  * the last two quadlets (data[398] and data[399]) are filled with 0xffffffff since they are the
250  * marker of one period.
251  */
252 struct snd_firewire_motu_command_dsp_meter {
253 	__u32 data[SNDRV_FIREWIRE_MOTU_COMMAND_DSP_METER_COUNT];
254 };
255 
256 #endif /* _UAPI_SOUND_FIREWIRE_H_INCLUDED */
257