firewire.h 11 KB

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