diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/firewire-cdev.h | 218 |
1 files changed, 185 insertions, 33 deletions
diff --git a/include/linux/firewire-cdev.h b/include/linux/firewire-cdev.h index 4d078e99c017..c6b3ca3af6df 100644 --- a/include/linux/firewire-cdev.h +++ b/include/linux/firewire-cdev.h | |||
@@ -25,10 +25,12 @@ | |||
25 | #include <linux/types.h> | 25 | #include <linux/types.h> |
26 | #include <linux/firewire-constants.h> | 26 | #include <linux/firewire-constants.h> |
27 | 27 | ||
28 | #define FW_CDEV_EVENT_BUS_RESET 0x00 | 28 | #define FW_CDEV_EVENT_BUS_RESET 0x00 |
29 | #define FW_CDEV_EVENT_RESPONSE 0x01 | 29 | #define FW_CDEV_EVENT_RESPONSE 0x01 |
30 | #define FW_CDEV_EVENT_REQUEST 0x02 | 30 | #define FW_CDEV_EVENT_REQUEST 0x02 |
31 | #define FW_CDEV_EVENT_ISO_INTERRUPT 0x03 | 31 | #define FW_CDEV_EVENT_ISO_INTERRUPT 0x03 |
32 | #define FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED 0x04 | ||
33 | #define FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED 0x05 | ||
32 | 34 | ||
33 | /** | 35 | /** |
34 | * struct fw_cdev_event_common - Common part of all fw_cdev_event_ types | 36 | * struct fw_cdev_event_common - Common part of all fw_cdev_event_ types |
@@ -136,7 +138,24 @@ struct fw_cdev_event_request { | |||
136 | * This event is sent when the controller has completed an &fw_cdev_iso_packet | 138 | * This event is sent when the controller has completed an &fw_cdev_iso_packet |
137 | * with the %FW_CDEV_ISO_INTERRUPT bit set. In the receive case, the headers | 139 | * with the %FW_CDEV_ISO_INTERRUPT bit set. In the receive case, the headers |
138 | * stripped of all packets up until and including the interrupt packet are | 140 | * stripped of all packets up until and including the interrupt packet are |
139 | * returned in the @header field. | 141 | * returned in the @header field. The amount of header data per packet is as |
142 | * specified at iso context creation by &fw_cdev_create_iso_context.header_size. | ||
143 | * | ||
144 | * In version 1 of this ABI, header data consisted of the 1394 isochronous | ||
145 | * packet header, followed by quadlets from the packet payload if | ||
146 | * &fw_cdev_create_iso_context.header_size > 4. | ||
147 | * | ||
148 | * In version 2 of this ABI, header data consist of the 1394 isochronous | ||
149 | * packet header, followed by a timestamp quadlet if | ||
150 | * &fw_cdev_create_iso_context.header_size > 4, followed by quadlets from the | ||
151 | * packet payload if &fw_cdev_create_iso_context.header_size > 8. | ||
152 | * | ||
153 | * Behaviour of ver. 1 of this ABI is no longer available since ABI ver. 2. | ||
154 | * | ||
155 | * Format of 1394 iso packet header: 16 bits len, 2 bits tag, 6 bits channel, | ||
156 | * 4 bits tcode, 4 bits sy, in big endian byte order. Format of timestamp: | ||
157 | * 16 bits invalid, 3 bits cycleSeconds, 13 bits cycleCount, in big endian byte | ||
158 | * order. | ||
140 | */ | 159 | */ |
141 | struct fw_cdev_event_iso_interrupt { | 160 | struct fw_cdev_event_iso_interrupt { |
142 | __u64 closure; | 161 | __u64 closure; |
@@ -147,12 +166,44 @@ struct fw_cdev_event_iso_interrupt { | |||
147 | }; | 166 | }; |
148 | 167 | ||
149 | /** | 168 | /** |
169 | * struct fw_cdev_event_iso_resource - Iso resources were allocated or freed | ||
170 | * @closure: See &fw_cdev_event_common; | ||
171 | * set by %FW_CDEV_IOC_(DE)ALLOCATE_ISO_RESOURCE(_ONCE) ioctl | ||
172 | * @type: %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED or | ||
173 | * %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED | ||
174 | * @handle: Reference by which an allocated resource can be deallocated | ||
175 | * @channel: Isochronous channel which was (de)allocated, if any | ||
176 | * @bandwidth: Bandwidth allocation units which were (de)allocated, if any | ||
177 | * | ||
178 | * An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED event is sent after an isochronous | ||
179 | * resource was allocated at the IRM. The client has to check @channel and | ||
180 | * @bandwidth for whether the allocation actually succeeded. | ||
181 | * | ||
182 | * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event is sent after an isochronous | ||
183 | * resource was deallocated at the IRM. It is also sent when automatic | ||
184 | * reallocation after a bus reset failed. | ||
185 | * | ||
186 | * @channel is <0 if no channel was (de)allocated or if reallocation failed. | ||
187 | * @bandwidth is 0 if no bandwidth was (de)allocated or if reallocation failed. | ||
188 | */ | ||
189 | struct fw_cdev_event_iso_resource { | ||
190 | __u64 closure; | ||
191 | __u32 type; | ||
192 | __u32 handle; | ||
193 | __s32 channel; | ||
194 | __s32 bandwidth; | ||
195 | }; | ||
196 | |||
197 | /** | ||
150 | * union fw_cdev_event - Convenience union of fw_cdev_event_ types | 198 | * union fw_cdev_event - Convenience union of fw_cdev_event_ types |
151 | * @common: Valid for all types | 199 | * @common: Valid for all types |
152 | * @bus_reset: Valid if @common.type == %FW_CDEV_EVENT_BUS_RESET | 200 | * @bus_reset: Valid if @common.type == %FW_CDEV_EVENT_BUS_RESET |
153 | * @response: Valid if @common.type == %FW_CDEV_EVENT_RESPONSE | 201 | * @response: Valid if @common.type == %FW_CDEV_EVENT_RESPONSE |
154 | * @request: Valid if @common.type == %FW_CDEV_EVENT_REQUEST | 202 | * @request: Valid if @common.type == %FW_CDEV_EVENT_REQUEST |
155 | * @iso_interrupt: Valid if @common.type == %FW_CDEV_EVENT_ISO_INTERRUPT | 203 | * @iso_interrupt: Valid if @common.type == %FW_CDEV_EVENT_ISO_INTERRUPT |
204 | * @iso_resource: Valid if @common.type == | ||
205 | * %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED or | ||
206 | * %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED | ||
156 | * | 207 | * |
157 | * Convenience union for userspace use. Events could be read(2) into an | 208 | * Convenience union for userspace use. Events could be read(2) into an |
158 | * appropriately aligned char buffer and then cast to this union for further | 209 | * appropriately aligned char buffer and then cast to this union for further |
@@ -163,33 +214,47 @@ struct fw_cdev_event_iso_interrupt { | |||
163 | * not fit will be discarded so that the next read(2) will return a new event. | 214 | * not fit will be discarded so that the next read(2) will return a new event. |
164 | */ | 215 | */ |
165 | union fw_cdev_event { | 216 | union fw_cdev_event { |
166 | struct fw_cdev_event_common common; | 217 | struct fw_cdev_event_common common; |
167 | struct fw_cdev_event_bus_reset bus_reset; | 218 | struct fw_cdev_event_bus_reset bus_reset; |
168 | struct fw_cdev_event_response response; | 219 | struct fw_cdev_event_response response; |
169 | struct fw_cdev_event_request request; | 220 | struct fw_cdev_event_request request; |
170 | struct fw_cdev_event_iso_interrupt iso_interrupt; | 221 | struct fw_cdev_event_iso_interrupt iso_interrupt; |
222 | struct fw_cdev_event_iso_resource iso_resource; | ||
171 | }; | 223 | }; |
172 | 224 | ||
173 | #define FW_CDEV_IOC_GET_INFO _IOWR('#', 0x00, struct fw_cdev_get_info) | 225 | /* available since kernel version 2.6.22 */ |
174 | #define FW_CDEV_IOC_SEND_REQUEST _IOW('#', 0x01, struct fw_cdev_send_request) | 226 | #define FW_CDEV_IOC_GET_INFO _IOWR('#', 0x00, struct fw_cdev_get_info) |
175 | #define FW_CDEV_IOC_ALLOCATE _IOWR('#', 0x02, struct fw_cdev_allocate) | 227 | #define FW_CDEV_IOC_SEND_REQUEST _IOW('#', 0x01, struct fw_cdev_send_request) |
176 | #define FW_CDEV_IOC_DEALLOCATE _IOW('#', 0x03, struct fw_cdev_deallocate) | 228 | #define FW_CDEV_IOC_ALLOCATE _IOWR('#', 0x02, struct fw_cdev_allocate) |
177 | #define FW_CDEV_IOC_SEND_RESPONSE _IOW('#', 0x04, struct fw_cdev_send_response) | 229 | #define FW_CDEV_IOC_DEALLOCATE _IOW('#', 0x03, struct fw_cdev_deallocate) |
178 | #define FW_CDEV_IOC_INITIATE_BUS_RESET _IOW('#', 0x05, struct fw_cdev_initiate_bus_reset) | 230 | #define FW_CDEV_IOC_SEND_RESPONSE _IOW('#', 0x04, struct fw_cdev_send_response) |
179 | #define FW_CDEV_IOC_ADD_DESCRIPTOR _IOWR('#', 0x06, struct fw_cdev_add_descriptor) | 231 | #define FW_CDEV_IOC_INITIATE_BUS_RESET _IOW('#', 0x05, struct fw_cdev_initiate_bus_reset) |
180 | #define FW_CDEV_IOC_REMOVE_DESCRIPTOR _IOW('#', 0x07, struct fw_cdev_remove_descriptor) | 232 | #define FW_CDEV_IOC_ADD_DESCRIPTOR _IOWR('#', 0x06, struct fw_cdev_add_descriptor) |
233 | #define FW_CDEV_IOC_REMOVE_DESCRIPTOR _IOW('#', 0x07, struct fw_cdev_remove_descriptor) | ||
234 | #define FW_CDEV_IOC_CREATE_ISO_CONTEXT _IOWR('#', 0x08, struct fw_cdev_create_iso_context) | ||
235 | #define FW_CDEV_IOC_QUEUE_ISO _IOWR('#', 0x09, struct fw_cdev_queue_iso) | ||
236 | #define FW_CDEV_IOC_START_ISO _IOW('#', 0x0a, struct fw_cdev_start_iso) | ||
237 | #define FW_CDEV_IOC_STOP_ISO _IOW('#', 0x0b, struct fw_cdev_stop_iso) | ||
181 | 238 | ||
182 | #define FW_CDEV_IOC_CREATE_ISO_CONTEXT _IOWR('#', 0x08, struct fw_cdev_create_iso_context) | 239 | /* available since kernel version 2.6.24 */ |
183 | #define FW_CDEV_IOC_QUEUE_ISO _IOWR('#', 0x09, struct fw_cdev_queue_iso) | 240 | #define FW_CDEV_IOC_GET_CYCLE_TIMER _IOR('#', 0x0c, struct fw_cdev_get_cycle_timer) |
184 | #define FW_CDEV_IOC_START_ISO _IOW('#', 0x0a, struct fw_cdev_start_iso) | ||
185 | #define FW_CDEV_IOC_STOP_ISO _IOW('#', 0x0b, struct fw_cdev_stop_iso) | ||
186 | #define FW_CDEV_IOC_GET_CYCLE_TIMER _IOR('#', 0x0c, struct fw_cdev_get_cycle_timer) | ||
187 | 241 | ||
188 | /* FW_CDEV_VERSION History | 242 | /* available since kernel version 2.6.30 */ |
189 | * | 243 | #define FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE _IOWR('#', 0x0d, struct fw_cdev_allocate_iso_resource) |
190 | * 1 Feb 18, 2007: Initial version. | 244 | #define FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE _IOW('#', 0x0e, struct fw_cdev_deallocate) |
245 | #define FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE _IOW('#', 0x0f, struct fw_cdev_allocate_iso_resource) | ||
246 | #define FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE_ONCE _IOW('#', 0x10, struct fw_cdev_allocate_iso_resource) | ||
247 | #define FW_CDEV_IOC_GET_SPEED _IO('#', 0x11) /* returns speed code */ | ||
248 | #define FW_CDEV_IOC_SEND_BROADCAST_REQUEST _IOW('#', 0x12, struct fw_cdev_send_request) | ||
249 | #define FW_CDEV_IOC_SEND_STREAM_PACKET _IOW('#', 0x13, struct fw_cdev_send_stream_packet) | ||
250 | |||
251 | /* | ||
252 | * FW_CDEV_VERSION History | ||
253 | * 1 (2.6.22) - initial version | ||
254 | * 2 (2.6.30) - changed &fw_cdev_event_iso_interrupt.header if | ||
255 | * &fw_cdev_create_iso_context.header_size is 8 or more | ||
191 | */ | 256 | */ |
192 | #define FW_CDEV_VERSION 1 | 257 | #define FW_CDEV_VERSION 2 |
193 | 258 | ||
194 | /** | 259 | /** |
195 | * struct fw_cdev_get_info - General purpose information ioctl | 260 | * struct fw_cdev_get_info - General purpose information ioctl |
@@ -201,7 +266,7 @@ union fw_cdev_event { | |||
201 | * case, @rom_length is updated with the actual length of the | 266 | * case, @rom_length is updated with the actual length of the |
202 | * configuration ROM. | 267 | * configuration ROM. |
203 | * @rom: If non-zero, address of a buffer to be filled by a copy of the | 268 | * @rom: If non-zero, address of a buffer to be filled by a copy of the |
204 | * local node's configuration ROM | 269 | * device's configuration ROM |
205 | * @bus_reset: If non-zero, address of a buffer to be filled by a | 270 | * @bus_reset: If non-zero, address of a buffer to be filled by a |
206 | * &struct fw_cdev_event_bus_reset with the current state | 271 | * &struct fw_cdev_event_bus_reset with the current state |
207 | * of the bus. This does not cause a bus reset to happen. | 272 | * of the bus. This does not cause a bus reset to happen. |
@@ -229,7 +294,7 @@ struct fw_cdev_get_info { | |||
229 | * Send a request to the device. This ioctl implements all outgoing requests. | 294 | * Send a request to the device. This ioctl implements all outgoing requests. |
230 | * Both quadlet and block request specify the payload as a pointer to the data | 295 | * Both quadlet and block request specify the payload as a pointer to the data |
231 | * in the @data field. Once the transaction completes, the kernel writes an | 296 | * in the @data field. Once the transaction completes, the kernel writes an |
232 | * &fw_cdev_event_request event back. The @closure field is passed back to | 297 | * &fw_cdev_event_response event back. The @closure field is passed back to |
233 | * user space in the response event. | 298 | * user space in the response event. |
234 | */ | 299 | */ |
235 | struct fw_cdev_send_request { | 300 | struct fw_cdev_send_request { |
@@ -284,9 +349,9 @@ struct fw_cdev_allocate { | |||
284 | }; | 349 | }; |
285 | 350 | ||
286 | /** | 351 | /** |
287 | * struct fw_cdev_deallocate - Free an address range allocation | 352 | * struct fw_cdev_deallocate - Free a CSR address range or isochronous resource |
288 | * @handle: Handle to the address range, as returned by the kernel when the | 353 | * @handle: Handle to the address range or iso resource, as returned by the |
289 | * range was allocated | 354 | * kernel when the range or resource was allocated |
290 | */ | 355 | */ |
291 | struct fw_cdev_deallocate { | 356 | struct fw_cdev_deallocate { |
292 | __u32 handle; | 357 | __u32 handle; |
@@ -329,6 +394,9 @@ struct fw_cdev_initiate_bus_reset { | |||
329 | * If successful, the kernel adds the descriptor and writes back a handle to the | 394 | * If successful, the kernel adds the descriptor and writes back a handle to the |
330 | * kernel-side object to be used for later removal of the descriptor block and | 395 | * kernel-side object to be used for later removal of the descriptor block and |
331 | * immediate key. | 396 | * immediate key. |
397 | * | ||
398 | * This ioctl affects the configuration ROMs of all local nodes. | ||
399 | * The ioctl only succeeds on device files which represent a local node. | ||
332 | */ | 400 | */ |
333 | struct fw_cdev_add_descriptor { | 401 | struct fw_cdev_add_descriptor { |
334 | __u32 immediate; | 402 | __u32 immediate; |
@@ -344,7 +412,7 @@ struct fw_cdev_add_descriptor { | |||
344 | * descriptor was added | 412 | * descriptor was added |
345 | * | 413 | * |
346 | * Remove a descriptor block and accompanying immediate key from the local | 414 | * Remove a descriptor block and accompanying immediate key from the local |
347 | * node's configuration ROM. | 415 | * nodes' configuration ROMs. |
348 | */ | 416 | */ |
349 | struct fw_cdev_remove_descriptor { | 417 | struct fw_cdev_remove_descriptor { |
350 | __u32 handle; | 418 | __u32 handle; |
@@ -370,6 +438,9 @@ struct fw_cdev_remove_descriptor { | |||
370 | * | 438 | * |
371 | * If a context was successfully created, the kernel writes back a handle to the | 439 | * If a context was successfully created, the kernel writes back a handle to the |
372 | * context, which must be passed in for subsequent operations on that context. | 440 | * context, which must be passed in for subsequent operations on that context. |
441 | * | ||
442 | * Note that the effect of a @header_size > 4 depends on | ||
443 | * &fw_cdev_get_info.version, as documented at &fw_cdev_event_iso_interrupt. | ||
373 | */ | 444 | */ |
374 | struct fw_cdev_create_iso_context { | 445 | struct fw_cdev_create_iso_context { |
375 | __u32 type; | 446 | __u32 type; |
@@ -473,10 +544,91 @@ struct fw_cdev_stop_iso { | |||
473 | * The %FW_CDEV_IOC_GET_CYCLE_TIMER ioctl reads the isochronous cycle timer | 544 | * The %FW_CDEV_IOC_GET_CYCLE_TIMER ioctl reads the isochronous cycle timer |
474 | * and also the system clock. This allows to express the receive time of an | 545 | * and also the system clock. This allows to express the receive time of an |
475 | * isochronous packet as a system time with microsecond accuracy. | 546 | * isochronous packet as a system time with microsecond accuracy. |
547 | * | ||
548 | * @cycle_timer consists of 7 bits cycleSeconds, 13 bits cycleCount, and | ||
549 | * 12 bits cycleOffset, in host byte order. | ||
476 | */ | 550 | */ |
477 | struct fw_cdev_get_cycle_timer { | 551 | struct fw_cdev_get_cycle_timer { |
478 | __u64 local_time; | 552 | __u64 local_time; |
479 | __u32 cycle_timer; | 553 | __u32 cycle_timer; |
480 | }; | 554 | }; |
481 | 555 | ||
556 | /** | ||
557 | * struct fw_cdev_allocate_iso_resource - (De)allocate a channel or bandwidth | ||
558 | * @closure: Passed back to userspace in correponding iso resource events | ||
559 | * @channels: Isochronous channels of which one is to be (de)allocated | ||
560 | * @bandwidth: Isochronous bandwidth units to be (de)allocated | ||
561 | * @handle: Handle to the allocation, written by the kernel (only valid in | ||
562 | * case of %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE ioctls) | ||
563 | * | ||
564 | * The %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE ioctl initiates allocation of an | ||
565 | * isochronous channel and/or of isochronous bandwidth at the isochronous | ||
566 | * resource manager (IRM). Only one of the channels specified in @channels is | ||
567 | * allocated. An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED is sent after | ||
568 | * communication with the IRM, indicating success or failure in the event data. | ||
569 | * The kernel will automatically reallocate the resources after bus resets. | ||
570 | * Should a reallocation fail, an %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event | ||
571 | * will be sent. The kernel will also automatically deallocate the resources | ||
572 | * when the file descriptor is closed. | ||
573 | * | ||
574 | * The %FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE ioctl can be used to initiate | ||
575 | * deallocation of resources which were allocated as described above. | ||
576 | * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event concludes this operation. | ||
577 | * | ||
578 | * The %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE ioctl is a variant of allocation | ||
579 | * without automatic re- or deallocation. | ||
580 | * An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED event concludes this operation, | ||
581 | * indicating success or failure in its data. | ||
582 | * | ||
583 | * The %FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE_ONCE ioctl works like | ||
584 | * %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE except that resources are freed | ||
585 | * instead of allocated. | ||
586 | * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event concludes this operation. | ||
587 | * | ||
588 | * To summarize, %FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE allocates iso resources | ||
589 | * for the lifetime of the fd or handle. | ||
590 | * In contrast, %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE allocates iso resources | ||
591 | * for the duration of a bus generation. | ||
592 | * | ||
593 | * @channels is a host-endian bitfield with the least significant bit | ||
594 | * representing channel 0 and the most significant bit representing channel 63: | ||
595 | * 1ULL << c for each channel c that is a candidate for (de)allocation. | ||
596 | * | ||
597 | * @bandwidth is expressed in bandwidth allocation units, i.e. the time to send | ||
598 | * one quadlet of data (payload or header data) at speed S1600. | ||
599 | */ | ||
600 | struct fw_cdev_allocate_iso_resource { | ||
601 | __u64 closure; | ||
602 | __u64 channels; | ||
603 | __u32 bandwidth; | ||
604 | __u32 handle; | ||
605 | }; | ||
606 | |||
607 | /** | ||
608 | * struct fw_cdev_send_stream_packet - send an asynchronous stream packet | ||
609 | * @length: Length of outgoing payload, in bytes | ||
610 | * @tag: Data format tag | ||
611 | * @channel: Isochronous channel to transmit to | ||
612 | * @sy: Synchronization code | ||
613 | * @closure: Passed back to userspace in the response event | ||
614 | * @data: Userspace pointer to payload | ||
615 | * @generation: The bus generation where packet is valid | ||
616 | * @speed: Speed to transmit at | ||
617 | * | ||
618 | * The %FW_CDEV_IOC_SEND_STREAM_PACKET ioctl sends an asynchronous stream packet | ||
619 | * to every device which is listening to the specified channel. The kernel | ||
620 | * writes an &fw_cdev_event_response event which indicates success or failure of | ||
621 | * the transmission. | ||
622 | */ | ||
623 | struct fw_cdev_send_stream_packet { | ||
624 | __u32 length; | ||
625 | __u32 tag; | ||
626 | __u32 channel; | ||
627 | __u32 sy; | ||
628 | __u64 closure; | ||
629 | __u64 data; | ||
630 | __u32 generation; | ||
631 | __u32 speed; | ||
632 | }; | ||
633 | |||
482 | #endif /* _LINUX_FIREWIRE_CDEV_H */ | 634 | #endif /* _LINUX_FIREWIRE_CDEV_H */ |