firewire-cdev.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /*
  2. * Char device interface.
  3. *
  4. * Copyright (C) 2005-2006 Kristian Hoegsberg <krh@bitplanet.net>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. */
  20. #ifndef _LINUX_FIREWIRE_CDEV_H
  21. #define _LINUX_FIREWIRE_CDEV_H
  22. #include <linux/ioctl.h>
  23. #include <linux/types.h>
  24. #include <linux/firewire-constants.h>
  25. #define FW_CDEV_EVENT_BUS_RESET 0x00
  26. #define FW_CDEV_EVENT_RESPONSE 0x01
  27. #define FW_CDEV_EVENT_REQUEST 0x02
  28. #define FW_CDEV_EVENT_ISO_INTERRUPT 0x03
  29. /* The 'closure' fields are for user space to use. Data passed in the
  30. * 'closure' field for a request will be returned in the corresponding
  31. * event. It's a 64-bit type so that it's a fixed size type big
  32. * enough to hold a pointer on all platforms. */
  33. struct fw_cdev_event_common {
  34. __u64 closure;
  35. __u32 type;
  36. };
  37. struct fw_cdev_event_bus_reset {
  38. __u64 closure;
  39. __u32 type;
  40. __u32 node_id;
  41. __u32 local_node_id;
  42. __u32 bm_node_id;
  43. __u32 irm_node_id;
  44. __u32 root_node_id;
  45. __u32 generation;
  46. };
  47. struct fw_cdev_event_response {
  48. __u64 closure;
  49. __u32 type;
  50. __u32 rcode;
  51. __u32 length;
  52. __u32 data[0];
  53. };
  54. struct fw_cdev_event_request {
  55. __u64 closure;
  56. __u32 type;
  57. __u32 tcode;
  58. __u64 offset;
  59. __u32 handle;
  60. __u32 length;
  61. __u32 data[0];
  62. };
  63. struct fw_cdev_event_iso_interrupt {
  64. __u64 closure;
  65. __u32 type;
  66. __u32 cycle;
  67. __u32 header_length; /* Length in bytes of following headers. */
  68. __u32 header[0];
  69. };
  70. union fw_cdev_event {
  71. struct fw_cdev_event_common common;
  72. struct fw_cdev_event_bus_reset bus_reset;
  73. struct fw_cdev_event_response response;
  74. struct fw_cdev_event_request request;
  75. struct fw_cdev_event_iso_interrupt iso_interrupt;
  76. };
  77. #define FW_CDEV_IOC_GET_INFO _IOWR('#', 0x00, struct fw_cdev_get_info)
  78. #define FW_CDEV_IOC_SEND_REQUEST _IOW('#', 0x01, struct fw_cdev_send_request)
  79. #define FW_CDEV_IOC_ALLOCATE _IOWR('#', 0x02, struct fw_cdev_allocate)
  80. #define FW_CDEV_IOC_DEALLOCATE _IOW('#', 0x03, struct fw_cdev_deallocate)
  81. #define FW_CDEV_IOC_SEND_RESPONSE _IOW('#', 0x04, struct fw_cdev_send_response)
  82. #define FW_CDEV_IOC_INITIATE_BUS_RESET _IOW('#', 0x05, struct fw_cdev_initiate_bus_reset)
  83. #define FW_CDEV_IOC_ADD_DESCRIPTOR _IOWR('#', 0x06, struct fw_cdev_add_descriptor)
  84. #define FW_CDEV_IOC_REMOVE_DESCRIPTOR _IOW('#', 0x07, struct fw_cdev_remove_descriptor)
  85. #define FW_CDEV_IOC_CREATE_ISO_CONTEXT _IOWR('#', 0x08, struct fw_cdev_create_iso_context)
  86. #define FW_CDEV_IOC_QUEUE_ISO _IOWR('#', 0x09, struct fw_cdev_queue_iso)
  87. #define FW_CDEV_IOC_START_ISO _IOW('#', 0x0a, struct fw_cdev_start_iso)
  88. #define FW_CDEV_IOC_STOP_ISO _IOW('#', 0x0b, struct fw_cdev_stop_iso)
  89. /* FW_CDEV_VERSION History
  90. *
  91. * 1 Feb 18, 2007: Initial version.
  92. */
  93. #define FW_CDEV_VERSION 1
  94. struct fw_cdev_get_info {
  95. /* The version field is just a running serial number. We
  96. * never break backwards compatibility. Userspace passes in
  97. * the version it expects and the kernel passes back the
  98. * highest version it can provide. Even if the structs in
  99. * this interface are extended in a later version, the kernel
  100. * will not copy back more data than what was present in the
  101. * interface version userspace expects. */
  102. __u32 version;
  103. /* If non-zero, at most rom_length bytes of config rom will be
  104. * copied into that user space address. In either case,
  105. * rom_length is updated with the actual length of the config
  106. * rom. */
  107. __u32 rom_length;
  108. __u64 rom;
  109. /* If non-zero, a fw_cdev_event_bus_reset struct will be
  110. * copied here with the current state of the bus. This does
  111. * not cause a bus reset to happen. The value of closure in
  112. * this and sub-sequent bus reset events is set to
  113. * bus_reset_closure. */
  114. __u64 bus_reset;
  115. __u64 bus_reset_closure;
  116. /* The index of the card this devices belongs to. */
  117. __u32 card;
  118. };
  119. struct fw_cdev_send_request {
  120. __u32 tcode;
  121. __u32 length;
  122. __u64 offset;
  123. __u64 closure;
  124. __u64 data;
  125. __u32 generation;
  126. };
  127. struct fw_cdev_send_response {
  128. __u32 rcode;
  129. __u32 length;
  130. __u64 data;
  131. __u32 handle;
  132. };
  133. struct fw_cdev_allocate {
  134. __u64 offset;
  135. __u64 closure;
  136. __u32 length;
  137. __u32 handle;
  138. };
  139. struct fw_cdev_deallocate {
  140. __u32 handle;
  141. };
  142. #define FW_CDEV_LONG_RESET 0
  143. #define FW_CDEV_SHORT_RESET 1
  144. struct fw_cdev_initiate_bus_reset {
  145. __u32 type;
  146. };
  147. struct fw_cdev_add_descriptor {
  148. __u32 immediate;
  149. __u32 key;
  150. __u64 data;
  151. __u32 length;
  152. __u32 handle;
  153. };
  154. struct fw_cdev_remove_descriptor {
  155. __u32 handle;
  156. };
  157. #define FW_CDEV_ISO_CONTEXT_TRANSMIT 0
  158. #define FW_CDEV_ISO_CONTEXT_RECEIVE 1
  159. #define FW_CDEV_ISO_CONTEXT_MATCH_TAG0 1
  160. #define FW_CDEV_ISO_CONTEXT_MATCH_TAG1 2
  161. #define FW_CDEV_ISO_CONTEXT_MATCH_TAG2 4
  162. #define FW_CDEV_ISO_CONTEXT_MATCH_TAG3 8
  163. #define FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS 15
  164. struct fw_cdev_create_iso_context {
  165. __u32 type;
  166. __u32 header_size;
  167. __u32 channel;
  168. __u32 speed;
  169. __u64 closure;
  170. __u32 handle;
  171. };
  172. #define FW_CDEV_ISO_PAYLOAD_LENGTH(v) (v)
  173. #define FW_CDEV_ISO_INTERRUPT (1 << 16)
  174. #define FW_CDEV_ISO_SKIP (1 << 17)
  175. #define FW_CDEV_ISO_TAG(v) ((v) << 18)
  176. #define FW_CDEV_ISO_SY(v) ((v) << 20)
  177. #define FW_CDEV_ISO_HEADER_LENGTH(v) ((v) << 24)
  178. struct fw_cdev_iso_packet {
  179. __u32 control;
  180. __u32 header[0];
  181. };
  182. struct fw_cdev_queue_iso {
  183. __u64 packets;
  184. __u64 data;
  185. __u32 size;
  186. __u32 handle;
  187. };
  188. struct fw_cdev_start_iso {
  189. __s32 cycle;
  190. __u32 sync;
  191. __u32 tags;
  192. __u32 handle;
  193. };
  194. struct fw_cdev_stop_iso {
  195. __u32 handle;
  196. };
  197. #endif /* _LINUX_FIREWIRE_CDEV_H */