firewire-cdev.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. /*
  2. * Char device interface.
  3. *
  4. * Copyright (C) 2005-2007 Kristian Hoegsberg <krh@bitplanet.net>
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice (including the next
  14. * paragraph) shall be included in all copies or substantial portions of the
  15. * Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  20. * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  21. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  22. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. * DEALINGS IN THE SOFTWARE.
  24. */
  25. #ifndef _LINUX_FIREWIRE_CDEV_H
  26. #define _LINUX_FIREWIRE_CDEV_H
  27. #include <linux/ioctl.h>
  28. #include <linux/types.h>
  29. #include <linux/firewire-constants.h>
  30. #define FW_CDEV_EVENT_BUS_RESET 0x00
  31. #define FW_CDEV_EVENT_RESPONSE 0x01
  32. #define FW_CDEV_EVENT_REQUEST 0x02
  33. #define FW_CDEV_EVENT_ISO_INTERRUPT 0x03
  34. #define FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED 0x04
  35. #define FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED 0x05
  36. /**
  37. * struct fw_cdev_event_common - Common part of all fw_cdev_event_ types
  38. * @closure: For arbitrary use by userspace
  39. * @type: Discriminates the fw_cdev_event_ types
  40. *
  41. * This struct may be used to access generic members of all fw_cdev_event_
  42. * types regardless of the specific type.
  43. *
  44. * Data passed in the @closure field for a request will be returned in the
  45. * corresponding event. It is big enough to hold a pointer on all platforms.
  46. * The ioctl used to set @closure depends on the @type of event.
  47. */
  48. struct fw_cdev_event_common {
  49. __u64 closure;
  50. __u32 type;
  51. };
  52. /**
  53. * struct fw_cdev_event_bus_reset - Sent when a bus reset occurred
  54. * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_GET_INFO ioctl
  55. * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_BUS_RESET
  56. * @node_id: New node ID of this node
  57. * @local_node_id: Node ID of the local node, i.e. of the controller
  58. * @bm_node_id: Node ID of the bus manager
  59. * @irm_node_id: Node ID of the iso resource manager
  60. * @root_node_id: Node ID of the root node
  61. * @generation: New bus generation
  62. *
  63. * This event is sent when the bus the device belongs to goes through a bus
  64. * reset. It provides information about the new bus configuration, such as
  65. * new node ID for this device, new root ID, and others.
  66. */
  67. struct fw_cdev_event_bus_reset {
  68. __u64 closure;
  69. __u32 type;
  70. __u32 node_id;
  71. __u32 local_node_id;
  72. __u32 bm_node_id;
  73. __u32 irm_node_id;
  74. __u32 root_node_id;
  75. __u32 generation;
  76. };
  77. /**
  78. * struct fw_cdev_event_response - Sent when a response packet was received
  79. * @closure: See &fw_cdev_event_common;
  80. * set by %FW_CDEV_IOC_SEND_REQUEST ioctl
  81. * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_RESPONSE
  82. * @rcode: Response code returned by the remote node
  83. * @length: Data length, i.e. the response's payload size in bytes
  84. * @data: Payload data, if any
  85. *
  86. * This event is sent when the stack receives a response to an outgoing request
  87. * sent by %FW_CDEV_IOC_SEND_REQUEST ioctl. The payload data for responses
  88. * carrying data (read and lock responses) follows immediately and can be
  89. * accessed through the @data field.
  90. */
  91. struct fw_cdev_event_response {
  92. __u64 closure;
  93. __u32 type;
  94. __u32 rcode;
  95. __u32 length;
  96. __u32 data[0];
  97. };
  98. /**
  99. * struct fw_cdev_event_request - Sent on incoming request to an address region
  100. * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl
  101. * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST
  102. * @tcode: Transaction code of the incoming request
  103. * @offset: The offset into the 48-bit per-node address space
  104. * @handle: Reference to the kernel-side pending request
  105. * @length: Data length, i.e. the request's payload size in bytes
  106. * @data: Incoming data, if any
  107. *
  108. * This event is sent when the stack receives an incoming request to an address
  109. * region registered using the %FW_CDEV_IOC_ALLOCATE ioctl. The request is
  110. * guaranteed to be completely contained in the specified region. Userspace is
  111. * responsible for sending the response by %FW_CDEV_IOC_SEND_RESPONSE ioctl,
  112. * using the same @handle.
  113. *
  114. * The payload data for requests carrying data (write and lock requests)
  115. * follows immediately and can be accessed through the @data field.
  116. */
  117. struct fw_cdev_event_request {
  118. __u64 closure;
  119. __u32 type;
  120. __u32 tcode;
  121. __u64 offset;
  122. __u32 handle;
  123. __u32 length;
  124. __u32 data[0];
  125. };
  126. /**
  127. * struct fw_cdev_event_iso_interrupt - Sent when an iso packet was completed
  128. * @closure: See &fw_cdev_event_common;
  129. * set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl
  130. * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_ISO_INTERRUPT
  131. * @cycle: Cycle counter of the interrupt packet
  132. * @header_length: Total length of following headers, in bytes
  133. * @header: Stripped headers, if any
  134. *
  135. * This event is sent when the controller has completed an &fw_cdev_iso_packet
  136. * with the %FW_CDEV_ISO_INTERRUPT bit set. In the receive case, the headers
  137. * stripped of all packets up until and including the interrupt packet are
  138. * returned in the @header field. The amount of header data per packet is as
  139. * specified at iso context creation by &fw_cdev_create_iso_context.header_size.
  140. *
  141. * In version 1 of this ABI, header data consisted of the 1394 isochronous
  142. * packet header, followed by quadlets from the packet payload if
  143. * &fw_cdev_create_iso_context.header_size > 4.
  144. *
  145. * In version 2 of this ABI, header data consist of the 1394 isochronous
  146. * packet header, followed by a timestamp quadlet if
  147. * &fw_cdev_create_iso_context.header_size > 4, followed by quadlets from the
  148. * packet payload if &fw_cdev_create_iso_context.header_size > 8.
  149. *
  150. * Behaviour of ver. 1 of this ABI is no longer available since ABI ver. 2.
  151. *
  152. * Format of 1394 iso packet header: 16 bits len, 2 bits tag, 6 bits channel,
  153. * 4 bits tcode, 4 bits sy, in big endian byte order. Format of timestamp:
  154. * 16 bits invalid, 3 bits cycleSeconds, 13 bits cycleCount, in big endian byte
  155. * order.
  156. */
  157. struct fw_cdev_event_iso_interrupt {
  158. __u64 closure;
  159. __u32 type;
  160. __u32 cycle;
  161. __u32 header_length;
  162. __u32 header[0];
  163. };
  164. /**
  165. * struct fw_cdev_event_iso_resource - Iso resources were allocated or freed
  166. * @closure: See &fw_cdev_event_common;
  167. * set by %FW_CDEV_IOC_(DE)ALLOCATE_ISO_RESOURCE(_ONCE) ioctl
  168. * @type: %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED or
  169. * %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED
  170. * @handle: Reference by which an allocated resource can be deallocated
  171. * @channel: Isochronous channel which was (de)allocated, if any
  172. * @bandwidth: Bandwidth allocation units which were (de)allocated, if any
  173. *
  174. * An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED event is sent after an isochronous
  175. * resource was allocated at the IRM. The client has to check @channel and
  176. * @bandwidth for whether the allocation actually succeeded.
  177. *
  178. * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event is sent after an isochronous
  179. * resource was deallocated at the IRM. It is also sent when automatic
  180. * reallocation after a bus reset failed.
  181. *
  182. * @channel is <0 if no channel was (de)allocated or if reallocation failed.
  183. * @bandwidth is 0 if no bandwidth was (de)allocated or if reallocation failed.
  184. */
  185. struct fw_cdev_event_iso_resource {
  186. __u64 closure;
  187. __u32 type;
  188. __u32 handle;
  189. __s32 channel;
  190. __s32 bandwidth;
  191. };
  192. /**
  193. * union fw_cdev_event - Convenience union of fw_cdev_event_ types
  194. * @common: Valid for all types
  195. * @bus_reset: Valid if @common.type == %FW_CDEV_EVENT_BUS_RESET
  196. * @response: Valid if @common.type == %FW_CDEV_EVENT_RESPONSE
  197. * @request: Valid if @common.type == %FW_CDEV_EVENT_REQUEST
  198. * @iso_interrupt: Valid if @common.type == %FW_CDEV_EVENT_ISO_INTERRUPT
  199. * @iso_resource: Valid if @common.type ==
  200. * %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED or
  201. * %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED
  202. *
  203. * Convenience union for userspace use. Events could be read(2) into an
  204. * appropriately aligned char buffer and then cast to this union for further
  205. * processing. Note that for a request, response or iso_interrupt event,
  206. * the data[] or header[] may make the size of the full event larger than
  207. * sizeof(union fw_cdev_event). Also note that if you attempt to read(2)
  208. * an event into a buffer that is not large enough for it, the data that does
  209. * not fit will be discarded so that the next read(2) will return a new event.
  210. */
  211. union fw_cdev_event {
  212. struct fw_cdev_event_common common;
  213. struct fw_cdev_event_bus_reset bus_reset;
  214. struct fw_cdev_event_response response;
  215. struct fw_cdev_event_request request;
  216. struct fw_cdev_event_iso_interrupt iso_interrupt;
  217. struct fw_cdev_event_iso_resource iso_resource;
  218. };
  219. /* available since kernel version 2.6.22 */
  220. #define FW_CDEV_IOC_GET_INFO _IOWR('#', 0x00, struct fw_cdev_get_info)
  221. #define FW_CDEV_IOC_SEND_REQUEST _IOW('#', 0x01, struct fw_cdev_send_request)
  222. #define FW_CDEV_IOC_ALLOCATE _IOWR('#', 0x02, struct fw_cdev_allocate)
  223. #define FW_CDEV_IOC_DEALLOCATE _IOW('#', 0x03, struct fw_cdev_deallocate)
  224. #define FW_CDEV_IOC_SEND_RESPONSE _IOW('#', 0x04, struct fw_cdev_send_response)
  225. #define FW_CDEV_IOC_INITIATE_BUS_RESET _IOW('#', 0x05, struct fw_cdev_initiate_bus_reset)
  226. #define FW_CDEV_IOC_ADD_DESCRIPTOR _IOWR('#', 0x06, struct fw_cdev_add_descriptor)
  227. #define FW_CDEV_IOC_REMOVE_DESCRIPTOR _IOW('#', 0x07, struct fw_cdev_remove_descriptor)
  228. #define FW_CDEV_IOC_CREATE_ISO_CONTEXT _IOWR('#', 0x08, struct fw_cdev_create_iso_context)
  229. #define FW_CDEV_IOC_QUEUE_ISO _IOWR('#', 0x09, struct fw_cdev_queue_iso)
  230. #define FW_CDEV_IOC_START_ISO _IOW('#', 0x0a, struct fw_cdev_start_iso)
  231. #define FW_CDEV_IOC_STOP_ISO _IOW('#', 0x0b, struct fw_cdev_stop_iso)
  232. /* available since kernel version 2.6.24 */
  233. #define FW_CDEV_IOC_GET_CYCLE_TIMER _IOR('#', 0x0c, struct fw_cdev_get_cycle_timer)
  234. /* available since kernel version 2.6.30 */
  235. #define FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE _IOWR('#', 0x0d, struct fw_cdev_allocate_iso_resource)
  236. #define FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE _IOW('#', 0x0e, struct fw_cdev_deallocate)
  237. #define FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE _IOW('#', 0x0f, struct fw_cdev_allocate_iso_resource)
  238. #define FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE_ONCE _IOW('#', 0x10, struct fw_cdev_allocate_iso_resource)
  239. #define FW_CDEV_IOC_GET_SPEED _IO('#', 0x11) /* returns speed code */
  240. #define FW_CDEV_IOC_SEND_BROADCAST_REQUEST _IOW('#', 0x12, struct fw_cdev_send_request)
  241. #define FW_CDEV_IOC_SEND_STREAM_PACKET _IOW('#', 0x13, struct fw_cdev_send_stream_packet)
  242. /* available since kernel version 2.6.34 */
  243. #define FW_CDEV_IOC_GET_CYCLE_TIMER2 _IOWR('#', 0x14, struct fw_cdev_get_cycle_timer2)
  244. /*
  245. * FW_CDEV_VERSION History
  246. * 1 (2.6.22) - initial version
  247. * 2 (2.6.30) - changed &fw_cdev_event_iso_interrupt.header if
  248. * &fw_cdev_create_iso_context.header_size is 8 or more
  249. * (2.6.32) - added time stamp to xmit &fw_cdev_event_iso_interrupt
  250. * (2.6.33) - IR has always packet-per-buffer semantics now, not one of
  251. * dual-buffer or packet-per-buffer depending on hardware
  252. * 3 (2.6.34) - made &fw_cdev_get_cycle_timer reliable
  253. */
  254. #define FW_CDEV_VERSION 3
  255. /**
  256. * struct fw_cdev_get_info - General purpose information ioctl
  257. * @version: The version field is just a running serial number.
  258. * We never break backwards compatibility, but may add more
  259. * structs and ioctls in later revisions.
  260. * @rom_length: If @rom is non-zero, at most rom_length bytes of configuration
  261. * ROM will be copied into that user space address. In either
  262. * case, @rom_length is updated with the actual length of the
  263. * configuration ROM.
  264. * @rom: If non-zero, address of a buffer to be filled by a copy of the
  265. * device's configuration ROM
  266. * @bus_reset: If non-zero, address of a buffer to be filled by a
  267. * &struct fw_cdev_event_bus_reset with the current state
  268. * of the bus. This does not cause a bus reset to happen.
  269. * @bus_reset_closure: Value of &closure in this and subsequent bus reset events
  270. * @card: The index of the card this device belongs to
  271. */
  272. struct fw_cdev_get_info {
  273. __u32 version;
  274. __u32 rom_length;
  275. __u64 rom;
  276. __u64 bus_reset;
  277. __u64 bus_reset_closure;
  278. __u32 card;
  279. };
  280. /**
  281. * struct fw_cdev_send_request - Send an asynchronous request packet
  282. * @tcode: Transaction code of the request
  283. * @length: Length of outgoing payload, in bytes
  284. * @offset: 48-bit offset at destination node
  285. * @closure: Passed back to userspace in the response event
  286. * @data: Userspace pointer to payload
  287. * @generation: The bus generation where packet is valid
  288. *
  289. * Send a request to the device. This ioctl implements all outgoing requests.
  290. * Both quadlet and block request specify the payload as a pointer to the data
  291. * in the @data field. Once the transaction completes, the kernel writes an
  292. * &fw_cdev_event_response event back. The @closure field is passed back to
  293. * user space in the response event.
  294. */
  295. struct fw_cdev_send_request {
  296. __u32 tcode;
  297. __u32 length;
  298. __u64 offset;
  299. __u64 closure;
  300. __u64 data;
  301. __u32 generation;
  302. };
  303. /**
  304. * struct fw_cdev_send_response - Send an asynchronous response packet
  305. * @rcode: Response code as determined by the userspace handler
  306. * @length: Length of outgoing payload, in bytes
  307. * @data: Userspace pointer to payload
  308. * @handle: The handle from the &fw_cdev_event_request
  309. *
  310. * Send a response to an incoming request. By setting up an address range using
  311. * the %FW_CDEV_IOC_ALLOCATE ioctl, userspace can listen for incoming requests. An
  312. * incoming request will generate an %FW_CDEV_EVENT_REQUEST, and userspace must
  313. * send a reply using this ioctl. The event has a handle to the kernel-side
  314. * pending transaction, which should be used with this ioctl.
  315. */
  316. struct fw_cdev_send_response {
  317. __u32 rcode;
  318. __u32 length;
  319. __u64 data;
  320. __u32 handle;
  321. };
  322. /**
  323. * struct fw_cdev_allocate - Allocate a CSR address range
  324. * @offset: Start offset of the address range
  325. * @closure: To be passed back to userspace in request events
  326. * @length: Length of the address range, in bytes
  327. * @handle: Handle to the allocation, written by the kernel
  328. *
  329. * Allocate an address range in the 48-bit address space on the local node
  330. * (the controller). This allows userspace to listen for requests with an
  331. * offset within that address range. When the kernel receives a request
  332. * within the range, an &fw_cdev_event_request event will be written back.
  333. * The @closure field is passed back to userspace in the response event.
  334. * The @handle field is an out parameter, returning a handle to the allocated
  335. * range to be used for later deallocation of the range.
  336. *
  337. * The address range is allocated on all local nodes. The address allocation
  338. * is exclusive except for the FCP command and response registers.
  339. */
  340. struct fw_cdev_allocate {
  341. __u64 offset;
  342. __u64 closure;
  343. __u32 length;
  344. __u32 handle;
  345. };
  346. /**
  347. * struct fw_cdev_deallocate - Free a CSR address range or isochronous resource
  348. * @handle: Handle to the address range or iso resource, as returned by the
  349. * kernel when the range or resource was allocated
  350. */
  351. struct fw_cdev_deallocate {
  352. __u32 handle;
  353. };
  354. #define FW_CDEV_LONG_RESET 0
  355. #define FW_CDEV_SHORT_RESET 1
  356. /**
  357. * struct fw_cdev_initiate_bus_reset - Initiate a bus reset
  358. * @type: %FW_CDEV_SHORT_RESET or %FW_CDEV_LONG_RESET
  359. *
  360. * Initiate a bus reset for the bus this device is on. The bus reset can be
  361. * either the original (long) bus reset or the arbitrated (short) bus reset
  362. * introduced in 1394a-2000.
  363. */
  364. struct fw_cdev_initiate_bus_reset {
  365. __u32 type; /* FW_CDEV_SHORT_RESET or FW_CDEV_LONG_RESET */
  366. };
  367. /**
  368. * struct fw_cdev_add_descriptor - Add contents to the local node's config ROM
  369. * @immediate: If non-zero, immediate key to insert before pointer
  370. * @key: Upper 8 bits of root directory pointer
  371. * @data: Userspace pointer to contents of descriptor block
  372. * @length: Length of descriptor block data, in quadlets
  373. * @handle: Handle to the descriptor, written by the kernel
  374. *
  375. * Add a descriptor block and optionally a preceding immediate key to the local
  376. * node's configuration ROM.
  377. *
  378. * The @key field specifies the upper 8 bits of the descriptor root directory
  379. * pointer and the @data and @length fields specify the contents. The @key
  380. * should be of the form 0xXX000000. The offset part of the root directory entry
  381. * will be filled in by the kernel.
  382. *
  383. * If not 0, the @immediate field specifies an immediate key which will be
  384. * inserted before the root directory pointer.
  385. *
  386. * @immediate, @key, and @data array elements are CPU-endian quadlets.
  387. *
  388. * If successful, the kernel adds the descriptor and writes back a handle to the
  389. * kernel-side object to be used for later removal of the descriptor block and
  390. * immediate key.
  391. *
  392. * This ioctl affects the configuration ROMs of all local nodes.
  393. * The ioctl only succeeds on device files which represent a local node.
  394. */
  395. struct fw_cdev_add_descriptor {
  396. __u32 immediate;
  397. __u32 key;
  398. __u64 data;
  399. __u32 length;
  400. __u32 handle;
  401. };
  402. /**
  403. * struct fw_cdev_remove_descriptor - Remove contents from the configuration ROM
  404. * @handle: Handle to the descriptor, as returned by the kernel when the
  405. * descriptor was added
  406. *
  407. * Remove a descriptor block and accompanying immediate key from the local
  408. * nodes' configuration ROMs.
  409. */
  410. struct fw_cdev_remove_descriptor {
  411. __u32 handle;
  412. };
  413. #define FW_CDEV_ISO_CONTEXT_TRANSMIT 0
  414. #define FW_CDEV_ISO_CONTEXT_RECEIVE 1
  415. /**
  416. * struct fw_cdev_create_iso_context - Create a context for isochronous IO
  417. * @type: %FW_CDEV_ISO_CONTEXT_TRANSMIT or %FW_CDEV_ISO_CONTEXT_RECEIVE
  418. * @header_size: Header size to strip for receive contexts
  419. * @channel: Channel to bind to
  420. * @speed: Speed for transmit contexts
  421. * @closure: To be returned in &fw_cdev_event_iso_interrupt
  422. * @handle: Handle to context, written back by kernel
  423. *
  424. * Prior to sending or receiving isochronous I/O, a context must be created.
  425. * The context records information about the transmit or receive configuration
  426. * and typically maps to an underlying hardware resource. A context is set up
  427. * for either sending or receiving. It is bound to a specific isochronous
  428. * channel.
  429. *
  430. * If a context was successfully created, the kernel writes back a handle to the
  431. * context, which must be passed in for subsequent operations on that context.
  432. *
  433. * For receive contexts, @header_size must be at least 4 and must be a multiple
  434. * of 4.
  435. *
  436. * Note that the effect of a @header_size > 4 depends on
  437. * &fw_cdev_get_info.version, as documented at &fw_cdev_event_iso_interrupt.
  438. */
  439. struct fw_cdev_create_iso_context {
  440. __u32 type;
  441. __u32 header_size;
  442. __u32 channel;
  443. __u32 speed;
  444. __u64 closure;
  445. __u32 handle;
  446. };
  447. #define FW_CDEV_ISO_PAYLOAD_LENGTH(v) (v)
  448. #define FW_CDEV_ISO_INTERRUPT (1 << 16)
  449. #define FW_CDEV_ISO_SKIP (1 << 17)
  450. #define FW_CDEV_ISO_SYNC (1 << 17)
  451. #define FW_CDEV_ISO_TAG(v) ((v) << 18)
  452. #define FW_CDEV_ISO_SY(v) ((v) << 20)
  453. #define FW_CDEV_ISO_HEADER_LENGTH(v) ((v) << 24)
  454. /**
  455. * struct fw_cdev_iso_packet - Isochronous packet
  456. * @control: Contains the header length (8 uppermost bits), the sy field
  457. * (4 bits), the tag field (2 bits), a sync flag (1 bit),
  458. * a skip flag (1 bit), an interrupt flag (1 bit), and the
  459. * payload length (16 lowermost bits)
  460. * @header: Header and payload
  461. *
  462. * &struct fw_cdev_iso_packet is used to describe isochronous packet queues.
  463. *
  464. * Use the FW_CDEV_ISO_ macros to fill in @control.
  465. *
  466. * For transmit packets, the header length must be a multiple of 4 and specifies
  467. * the numbers of bytes in @header that will be prepended to the packet's
  468. * payload; these bytes are copied into the kernel and will not be accessed
  469. * after the ioctl has returned. The sy and tag fields are copied to the iso
  470. * packet header (these fields are specified by IEEE 1394a and IEC 61883-1).
  471. * The skip flag specifies that no packet is to be sent in a frame; when using
  472. * this, all other fields except the interrupt flag must be zero.
  473. *
  474. * For receive packets, the header length must be a multiple of the context's
  475. * header size; if the header length is larger than the context's header size,
  476. * multiple packets are queued for this entry. The sy and tag fields are
  477. * ignored. If the sync flag is set, the context drops all packets until
  478. * a packet with a matching sy field is received (the sync value to wait for is
  479. * specified in the &fw_cdev_start_iso structure). The payload length defines
  480. * how many payload bytes can be received for one packet (in addition to payload
  481. * quadlets that have been defined as headers and are stripped and returned in
  482. * the &fw_cdev_event_iso_interrupt structure). If more bytes are received, the
  483. * additional bytes are dropped. If less bytes are received, the remaining
  484. * bytes in this part of the payload buffer will not be written to, not even by
  485. * the next packet, i.e., packets received in consecutive frames will not
  486. * necessarily be consecutive in memory. If an entry has queued multiple
  487. * packets, the payload length is divided equally among them.
  488. *
  489. * When a packet with the interrupt flag set has been completed, the
  490. * &fw_cdev_event_iso_interrupt event will be sent. An entry that has queued
  491. * multiple receive packets is completed when its last packet is completed.
  492. */
  493. struct fw_cdev_iso_packet {
  494. __u32 control;
  495. __u32 header[0];
  496. };
  497. /**
  498. * struct fw_cdev_queue_iso - Queue isochronous packets for I/O
  499. * @packets: Userspace pointer to packet data
  500. * @data: Pointer into mmap()'ed payload buffer
  501. * @size: Size of packet data in bytes
  502. * @handle: Isochronous context handle
  503. *
  504. * Queue a number of isochronous packets for reception or transmission.
  505. * This ioctl takes a pointer to an array of &fw_cdev_iso_packet structs,
  506. * which describe how to transmit from or receive into a contiguous region
  507. * of a mmap()'ed payload buffer. As part of transmit packet descriptors,
  508. * a series of headers can be supplied, which will be prepended to the
  509. * payload during DMA.
  510. *
  511. * The kernel may or may not queue all packets, but will write back updated
  512. * values of the @packets, @data and @size fields, so the ioctl can be
  513. * resubmitted easily.
  514. */
  515. struct fw_cdev_queue_iso {
  516. __u64 packets;
  517. __u64 data;
  518. __u32 size;
  519. __u32 handle;
  520. };
  521. #define FW_CDEV_ISO_CONTEXT_MATCH_TAG0 1
  522. #define FW_CDEV_ISO_CONTEXT_MATCH_TAG1 2
  523. #define FW_CDEV_ISO_CONTEXT_MATCH_TAG2 4
  524. #define FW_CDEV_ISO_CONTEXT_MATCH_TAG3 8
  525. #define FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS 15
  526. /**
  527. * struct fw_cdev_start_iso - Start an isochronous transmission or reception
  528. * @cycle: Cycle in which to start I/O. If @cycle is greater than or
  529. * equal to 0, the I/O will start on that cycle.
  530. * @sync: Determines the value to wait for for receive packets that have
  531. * the %FW_CDEV_ISO_SYNC bit set
  532. * @tags: Tag filter bit mask. Only valid for isochronous reception.
  533. * Determines the tag values for which packets will be accepted.
  534. * Use FW_CDEV_ISO_CONTEXT_MATCH_ macros to set @tags.
  535. * @handle: Isochronous context handle within which to transmit or receive
  536. */
  537. struct fw_cdev_start_iso {
  538. __s32 cycle;
  539. __u32 sync;
  540. __u32 tags;
  541. __u32 handle;
  542. };
  543. /**
  544. * struct fw_cdev_stop_iso - Stop an isochronous transmission or reception
  545. * @handle: Handle of isochronous context to stop
  546. */
  547. struct fw_cdev_stop_iso {
  548. __u32 handle;
  549. };
  550. /**
  551. * struct fw_cdev_get_cycle_timer - read cycle timer register
  552. * @local_time: system time, in microseconds since the Epoch
  553. * @cycle_timer: Cycle Time register contents
  554. *
  555. * The %FW_CDEV_IOC_GET_CYCLE_TIMER ioctl reads the isochronous cycle timer
  556. * and also the system clock (%CLOCK_REALTIME). This allows to express the
  557. * receive time of an isochronous packet as a system time.
  558. *
  559. * @cycle_timer consists of 7 bits cycleSeconds, 13 bits cycleCount, and
  560. * 12 bits cycleOffset, in host byte order. Cf. the Cycle Time register
  561. * per IEEE 1394 or Isochronous Cycle Timer register per OHCI-1394.
  562. *
  563. * In version 1 and 2 of the ABI, this ioctl returned unreliable (non-
  564. * monotonic) @cycle_timer values on certain controllers.
  565. */
  566. struct fw_cdev_get_cycle_timer {
  567. __u64 local_time;
  568. __u32 cycle_timer;
  569. };
  570. /**
  571. * struct fw_cdev_get_cycle_timer2 - read cycle timer register
  572. * @tv_sec: system time, seconds
  573. * @tv_nsec: system time, sub-seconds part in nanoseconds
  574. * @clk_id: input parameter, clock from which to get the system time
  575. * @cycle_timer: Cycle Time register contents
  576. *
  577. * The %FW_CDEV_IOC_GET_CYCLE_TIMER2 works like
  578. * %FW_CDEV_IOC_GET_CYCLE_TIMER but lets you choose a clock like with POSIX'
  579. * clock_gettime function. Supported @clk_id values are POSIX' %CLOCK_REALTIME
  580. * and %CLOCK_MONOTONIC and Linux' %CLOCK_MONOTONIC_RAW.
  581. */
  582. struct fw_cdev_get_cycle_timer2 {
  583. __s64 tv_sec;
  584. __s32 tv_nsec;
  585. __s32 clk_id;
  586. __u32 cycle_timer;
  587. };
  588. /**
  589. * struct fw_cdev_allocate_iso_resource - (De)allocate a channel or bandwidth
  590. * @closure: Passed back to userspace in correponding iso resource events
  591. * @channels: Isochronous channels of which one is to be (de)allocated
  592. * @bandwidth: Isochronous bandwidth units to be (de)allocated
  593. * @handle: Handle to the allocation, written by the kernel (only valid in
  594. * case of %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE ioctls)
  595. *
  596. * The %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE ioctl initiates allocation of an
  597. * isochronous channel and/or of isochronous bandwidth at the isochronous
  598. * resource manager (IRM). Only one of the channels specified in @channels is
  599. * allocated. An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED is sent after
  600. * communication with the IRM, indicating success or failure in the event data.
  601. * The kernel will automatically reallocate the resources after bus resets.
  602. * Should a reallocation fail, an %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event
  603. * will be sent. The kernel will also automatically deallocate the resources
  604. * when the file descriptor is closed.
  605. *
  606. * The %FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE ioctl can be used to initiate
  607. * deallocation of resources which were allocated as described above.
  608. * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event concludes this operation.
  609. *
  610. * The %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE ioctl is a variant of allocation
  611. * without automatic re- or deallocation.
  612. * An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED event concludes this operation,
  613. * indicating success or failure in its data.
  614. *
  615. * The %FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE_ONCE ioctl works like
  616. * %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE except that resources are freed
  617. * instead of allocated.
  618. * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event concludes this operation.
  619. *
  620. * To summarize, %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE allocates iso resources
  621. * for the lifetime of the fd or @handle.
  622. * In contrast, %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE allocates iso resources
  623. * for the duration of a bus generation.
  624. *
  625. * @channels is a host-endian bitfield with the least significant bit
  626. * representing channel 0 and the most significant bit representing channel 63:
  627. * 1ULL << c for each channel c that is a candidate for (de)allocation.
  628. *
  629. * @bandwidth is expressed in bandwidth allocation units, i.e. the time to send
  630. * one quadlet of data (payload or header data) at speed S1600.
  631. */
  632. struct fw_cdev_allocate_iso_resource {
  633. __u64 closure;
  634. __u64 channels;
  635. __u32 bandwidth;
  636. __u32 handle;
  637. };
  638. /**
  639. * struct fw_cdev_send_stream_packet - send an asynchronous stream packet
  640. * @length: Length of outgoing payload, in bytes
  641. * @tag: Data format tag
  642. * @channel: Isochronous channel to transmit to
  643. * @sy: Synchronization code
  644. * @closure: Passed back to userspace in the response event
  645. * @data: Userspace pointer to payload
  646. * @generation: The bus generation where packet is valid
  647. * @speed: Speed to transmit at
  648. *
  649. * The %FW_CDEV_IOC_SEND_STREAM_PACKET ioctl sends an asynchronous stream packet
  650. * to every device which is listening to the specified channel. The kernel
  651. * writes an &fw_cdev_event_response event which indicates success or failure of
  652. * the transmission.
  653. */
  654. struct fw_cdev_send_stream_packet {
  655. __u32 length;
  656. __u32 tag;
  657. __u32 channel;
  658. __u32 sy;
  659. __u64 closure;
  660. __u64 data;
  661. __u32 generation;
  662. __u32 speed;
  663. };
  664. #endif /* _LINUX_FIREWIRE_CDEV_H */