Kristian Høgsberg | 4c5a443 | 2007-05-07 20:33:37 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Char device interface. |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 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 | |
Kristian Høgsberg | 4c5a443 | 2007-05-07 20:33:37 -0400 | [diff] [blame] | 21 | #ifndef _LINUX_FIREWIRE_CDEV_H |
| 22 | #define _LINUX_FIREWIRE_CDEV_H |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 23 | |
Kristian Høgsberg | 04dfb8d | 2007-05-07 20:33:36 -0400 | [diff] [blame] | 24 | #include <linux/ioctl.h> |
| 25 | #include <linux/types.h> |
Kristian Høgsberg | 4c5a443 | 2007-05-07 20:33:37 -0400 | [diff] [blame] | 26 | #include <linux/firewire-constants.h> |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 27 | |
Kristian Høgsberg | 97bd9ef | 2007-03-07 12:12:41 -0500 | [diff] [blame] | 28 | #define FW_CDEV_EVENT_BUS_RESET 0x00 |
| 29 | #define FW_CDEV_EVENT_RESPONSE 0x01 |
| 30 | #define FW_CDEV_EVENT_REQUEST 0x02 |
| 31 | #define FW_CDEV_EVENT_ISO_INTERRUPT 0x03 |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 32 | |
| 33 | /* The 'closure' fields are for user space to use. Data passed in the |
| 34 | * 'closure' field for a request will be returned in the corresponding |
| 35 | * event. It's a 64-bit type so that it's a fixed size type big |
| 36 | * enough to hold a pointer on all platforms. */ |
| 37 | |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 38 | struct fw_cdev_event_common { |
| 39 | __u64 closure; |
| 40 | __u32 type; |
| 41 | }; |
| 42 | |
Kristian Høgsberg | 97bd9ef | 2007-03-07 12:12:41 -0500 | [diff] [blame] | 43 | struct fw_cdev_event_bus_reset { |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 44 | __u64 closure; |
Kristian Høgsberg | 97bd9ef | 2007-03-07 12:12:41 -0500 | [diff] [blame] | 45 | __u32 type; |
| 46 | __u32 node_id; |
| 47 | __u32 local_node_id; |
| 48 | __u32 bm_node_id; |
| 49 | __u32 irm_node_id; |
| 50 | __u32 root_node_id; |
| 51 | __u32 generation; |
| 52 | }; |
| 53 | |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 54 | struct fw_cdev_event_response { |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 55 | __u64 closure; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 56 | __u32 type; |
| 57 | __u32 rcode; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 58 | __u32 length; |
| 59 | __u32 data[0]; |
| 60 | }; |
| 61 | |
| 62 | struct fw_cdev_event_request { |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 63 | __u64 closure; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 64 | __u32 type; |
| 65 | __u32 tcode; |
| 66 | __u64 offset; |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 67 | __u32 handle; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 68 | __u32 length; |
| 69 | __u32 data[0]; |
| 70 | }; |
| 71 | |
| 72 | struct fw_cdev_event_iso_interrupt { |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 73 | __u64 closure; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 74 | __u32 type; |
| 75 | __u32 cycle; |
Kristian Høgsberg | 9b32d5f | 2007-02-16 17:34:44 -0500 | [diff] [blame] | 76 | __u32 header_length; /* Length in bytes of following headers. */ |
| 77 | __u32 header[0]; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 78 | }; |
| 79 | |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 80 | union fw_cdev_event { |
| 81 | struct fw_cdev_event_common common; |
| 82 | struct fw_cdev_event_bus_reset bus_reset; |
| 83 | struct fw_cdev_event_response response; |
| 84 | struct fw_cdev_event_request request; |
| 85 | struct fw_cdev_event_iso_interrupt iso_interrupt; |
| 86 | }; |
| 87 | |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 88 | #define FW_CDEV_IOC_GET_INFO _IOWR('#', 0x00, struct fw_cdev_get_info) |
| 89 | #define FW_CDEV_IOC_SEND_REQUEST _IOW('#', 0x01, struct fw_cdev_send_request) |
| 90 | #define FW_CDEV_IOC_ALLOCATE _IOWR('#', 0x02, struct fw_cdev_allocate) |
| 91 | #define FW_CDEV_IOC_DEALLOCATE _IOW('#', 0x03, struct fw_cdev_deallocate) |
| 92 | #define FW_CDEV_IOC_SEND_RESPONSE _IOW('#', 0x04, struct fw_cdev_send_response) |
| 93 | #define FW_CDEV_IOC_INITIATE_BUS_RESET _IOW('#', 0x05, struct fw_cdev_initiate_bus_reset) |
| 94 | #define FW_CDEV_IOC_ADD_DESCRIPTOR _IOWR('#', 0x06, struct fw_cdev_add_descriptor) |
| 95 | #define FW_CDEV_IOC_REMOVE_DESCRIPTOR _IOW('#', 0x07, struct fw_cdev_remove_descriptor) |
Kristian Høgsberg | 66dea3e | 2007-03-28 21:26:42 +0200 | [diff] [blame] | 96 | |
Kristian Høgsberg | abaa574 | 2007-04-30 15:03:14 -0400 | [diff] [blame] | 97 | #define FW_CDEV_IOC_CREATE_ISO_CONTEXT _IOWR('#', 0x08, struct fw_cdev_create_iso_context) |
Kristian Høgsberg | 4f25922 | 2007-04-30 15:03:13 -0400 | [diff] [blame] | 98 | #define FW_CDEV_IOC_QUEUE_ISO _IOWR('#', 0x09, struct fw_cdev_queue_iso) |
| 99 | #define FW_CDEV_IOC_START_ISO _IOW('#', 0x0a, struct fw_cdev_start_iso) |
Kristian Høgsberg | abaa574 | 2007-04-30 15:03:14 -0400 | [diff] [blame] | 100 | #define FW_CDEV_IOC_STOP_ISO _IOW('#', 0x0b, struct fw_cdev_stop_iso) |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 101 | |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 102 | /* FW_CDEV_VERSION History |
| 103 | * |
| 104 | * 1 Feb 18, 2007: Initial version. |
| 105 | */ |
| 106 | #define FW_CDEV_VERSION 1 |
| 107 | |
| 108 | struct fw_cdev_get_info { |
| 109 | /* The version field is just a running serial number. We |
| 110 | * never break backwards compatibility. Userspace passes in |
| 111 | * the version it expects and the kernel passes back the |
| 112 | * highest version it can provide. Even if the structs in |
| 113 | * this interface are extended in a later version, the kernel |
| 114 | * will not copy back more data than what was present in the |
| 115 | * interface version userspace expects. */ |
| 116 | __u32 version; |
| 117 | |
| 118 | /* If non-zero, at most rom_length bytes of config rom will be |
| 119 | * copied into that user space address. In either case, |
| 120 | * rom_length is updated with the actual length of the config |
| 121 | * rom. */ |
| 122 | __u32 rom_length; |
| 123 | __u64 rom; |
| 124 | |
| 125 | /* If non-zero, a fw_cdev_event_bus_reset struct will be |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 126 | * copied here with the current state of the bus. This does |
| 127 | * not cause a bus reset to happen. The value of closure in |
| 128 | * this and sub-sequent bus reset events is set to |
| 129 | * bus_reset_closure. */ |
Kristian Høgsberg | 344bbc4 | 2007-03-07 12:12:43 -0500 | [diff] [blame] | 130 | __u64 bus_reset; |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 131 | __u64 bus_reset_closure; |
Kristian Høgsberg | e753350 | 2007-03-07 12:12:52 -0500 | [diff] [blame] | 132 | |
| 133 | /* The index of the card this devices belongs to. */ |
| 134 | __u32 card; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 135 | }; |
| 136 | |
| 137 | struct fw_cdev_send_request { |
| 138 | __u32 tcode; |
| 139 | __u32 length; |
| 140 | __u64 offset; |
| 141 | __u64 closure; |
| 142 | __u64 data; |
Kristian Høgsberg | 97e3527 | 2007-03-07 12:12:53 -0500 | [diff] [blame] | 143 | __u32 generation; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 144 | }; |
| 145 | |
| 146 | struct fw_cdev_send_response { |
| 147 | __u32 rcode; |
| 148 | __u32 length; |
| 149 | __u64 data; |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 150 | __u32 handle; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 151 | }; |
| 152 | |
| 153 | struct fw_cdev_allocate { |
| 154 | __u64 offset; |
| 155 | __u64 closure; |
| 156 | __u32 length; |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 157 | __u32 handle; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 158 | }; |
| 159 | |
Kristian Høgsberg | 9472316b | 2007-03-14 17:34:55 -0400 | [diff] [blame] | 160 | struct fw_cdev_deallocate { |
Kristian Høgsberg | 3964a44 | 2007-03-27 01:43:41 -0400 | [diff] [blame] | 161 | __u32 handle; |
Kristian Høgsberg | 9472316b | 2007-03-14 17:34:55 -0400 | [diff] [blame] | 162 | }; |
| 163 | |
Kristian Høgsberg | 5371842 | 2007-03-07 12:12:42 -0500 | [diff] [blame] | 164 | #define FW_CDEV_LONG_RESET 0 |
| 165 | #define FW_CDEV_SHORT_RESET 1 |
| 166 | |
| 167 | struct fw_cdev_initiate_bus_reset { |
| 168 | __u32 type; |
| 169 | }; |
| 170 | |
Kristian Høgsberg | 66dea3e | 2007-03-28 21:26:42 +0200 | [diff] [blame] | 171 | struct fw_cdev_add_descriptor { |
| 172 | __u32 immediate; |
| 173 | __u32 key; |
| 174 | __u64 data; |
| 175 | __u32 length; |
| 176 | __u32 handle; |
| 177 | }; |
| 178 | |
| 179 | struct fw_cdev_remove_descriptor { |
| 180 | __u32 handle; |
| 181 | }; |
| 182 | |
Kristian Høgsberg | 295e3fe | 2007-02-16 17:34:40 -0500 | [diff] [blame] | 183 | #define FW_CDEV_ISO_CONTEXT_TRANSMIT 0 |
| 184 | #define FW_CDEV_ISO_CONTEXT_RECEIVE 1 |
| 185 | |
Kristian Høgsberg | 98b6cbe | 2007-02-16 17:34:51 -0500 | [diff] [blame] | 186 | #define FW_CDEV_ISO_CONTEXT_MATCH_TAG0 1 |
| 187 | #define FW_CDEV_ISO_CONTEXT_MATCH_TAG1 2 |
| 188 | #define FW_CDEV_ISO_CONTEXT_MATCH_TAG2 4 |
| 189 | #define FW_CDEV_ISO_CONTEXT_MATCH_TAG3 8 |
| 190 | #define FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS 15 |
| 191 | |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 192 | struct fw_cdev_create_iso_context { |
Kristian Høgsberg | 295e3fe | 2007-02-16 17:34:40 -0500 | [diff] [blame] | 193 | __u32 type; |
| 194 | __u32 header_size; |
Kristian Høgsberg | 21efb3c | 2007-02-16 17:34:50 -0500 | [diff] [blame] | 195 | __u32 channel; |
| 196 | __u32 speed; |
Kristian Høgsberg | abaa574 | 2007-04-30 15:03:14 -0400 | [diff] [blame] | 197 | __u64 closure; |
| 198 | __u32 handle; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 199 | }; |
| 200 | |
Kristian Høgsberg | 1ca31ae | 2007-05-31 11:16:43 -0400 | [diff] [blame] | 201 | #define FW_CDEV_ISO_PAYLOAD_LENGTH(v) (v) |
| 202 | #define FW_CDEV_ISO_INTERRUPT (1 << 16) |
| 203 | #define FW_CDEV_ISO_SKIP (1 << 17) |
| 204 | #define FW_CDEV_ISO_TAG(v) ((v) << 18) |
| 205 | #define FW_CDEV_ISO_SY(v) ((v) << 20) |
| 206 | #define FW_CDEV_ISO_HEADER_LENGTH(v) ((v) << 24) |
| 207 | |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 208 | struct fw_cdev_iso_packet { |
Kristian Høgsberg | 1ca31ae | 2007-05-31 11:16:43 -0400 | [diff] [blame] | 209 | __u32 control; |
Stefan Richter | 5e20c28 | 2007-01-21 20:44:09 +0100 | [diff] [blame] | 210 | __u32 header[0]; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 211 | }; |
| 212 | |
| 213 | struct fw_cdev_queue_iso { |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 214 | __u64 packets; |
| 215 | __u64 data; |
Kristian Høgsberg | da8ecff | 2007-03-27 01:43:39 -0400 | [diff] [blame] | 216 | __u32 size; |
Kristian Høgsberg | abaa574 | 2007-04-30 15:03:14 -0400 | [diff] [blame] | 217 | __u32 handle; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 218 | }; |
| 219 | |
Kristian Høgsberg | 69cdb72 | 2007-02-16 17:34:41 -0500 | [diff] [blame] | 220 | struct fw_cdev_start_iso { |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 221 | __s32 cycle; |
Kristian Høgsberg | eb0306e | 2007-03-14 17:34:54 -0400 | [diff] [blame] | 222 | __u32 sync; |
| 223 | __u32 tags; |
Kristian Høgsberg | abaa574 | 2007-04-30 15:03:14 -0400 | [diff] [blame] | 224 | __u32 handle; |
| 225 | }; |
| 226 | |
| 227 | struct fw_cdev_stop_iso { |
| 228 | __u32 handle; |
Kristian Høgsberg | 19a15b9 | 2006-12-19 19:58:31 -0500 | [diff] [blame] | 229 | }; |
| 230 | |
Kristian Høgsberg | 4c5a443 | 2007-05-07 20:33:37 -0400 | [diff] [blame] | 231 | #endif /* _LINUX_FIREWIRE_CDEV_H */ |