aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ieee1394/iso.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/ieee1394/iso.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/ieee1394/iso.h')
-rw-r--r--drivers/ieee1394/iso.h201
1 files changed, 201 insertions, 0 deletions
diff --git a/drivers/ieee1394/iso.h b/drivers/ieee1394/iso.h
new file mode 100644
index 000000000000..fb654d9639a7
--- /dev/null
+++ b/drivers/ieee1394/iso.h
@@ -0,0 +1,201 @@
1/*
2 * IEEE 1394 for Linux
3 *
4 * kernel ISO transmission/reception
5 *
6 * Copyright (C) 2002 Maas Digital LLC
7 *
8 * This code is licensed under the GPL. See the file COPYING in the root
9 * directory of the kernel sources for details.
10 */
11
12#ifndef IEEE1394_ISO_H
13#define IEEE1394_ISO_H
14
15#include "hosts.h"
16#include "dma.h"
17
18/* high-level ISO interface */
19
20/* This API sends and receives isochronous packets on a large,
21 virtually-contiguous kernel memory buffer. The buffer may be mapped
22 into a user-space process for zero-copy transmission and reception.
23
24 There are no explicit boundaries between packets in the buffer. A
25 packet may be transmitted or received at any location. However,
26 low-level drivers may impose certain restrictions on alignment or
27 size of packets. (e.g. in OHCI no packet may cross a page boundary,
28 and packets should be quadlet-aligned)
29*/
30
31/* Packet descriptor - the API maintains a ring buffer of these packet
32 descriptors in kernel memory (hpsb_iso.infos[]). */
33
34struct hpsb_iso_packet_info {
35 /* offset of data payload relative to the first byte of the buffer */
36 __u32 offset;
37
38 /* length of the data payload, in bytes (not including the isochronous header) */
39 __u16 len;
40
41 /* (recv only) the cycle number (mod 8000) on which the packet was received */
42 __u16 cycle;
43
44 /* (recv only) channel on which the packet was received */
45 __u8 channel;
46
47 /* 2-bit 'tag' and 4-bit 'sy' fields of the isochronous header */
48 __u8 tag;
49 __u8 sy;
50};
51
52enum hpsb_iso_type { HPSB_ISO_RECV = 0, HPSB_ISO_XMIT = 1 };
53
54/* The mode of the dma when receiving iso data. Must be supported by chip */
55enum raw1394_iso_dma_recv_mode {
56 HPSB_ISO_DMA_DEFAULT = -1,
57 HPSB_ISO_DMA_OLD_ABI = 0,
58 HPSB_ISO_DMA_BUFFERFILL = 1,
59 HPSB_ISO_DMA_PACKET_PER_BUFFER = 2
60};
61
62struct hpsb_iso {
63 enum hpsb_iso_type type;
64
65 /* pointer to low-level driver and its private data */
66 struct hpsb_host *host;
67 void *hostdata;
68
69 /* a function to be called (from interrupt context) after
70 outgoing packets have been sent, or incoming packets have
71 arrived */
72 void (*callback)(struct hpsb_iso*);
73
74 /* wait for buffer space */
75 wait_queue_head_t waitq;
76
77 int speed; /* IEEE1394_SPEED_100, 200, or 400 */
78 int channel; /* -1 if multichannel */
79 int dma_mode; /* dma receive mode */
80
81
82 /* greatest # of packets between interrupts - controls
83 the maximum latency of the buffer */
84 int irq_interval;
85
86 /* the buffer for packet data payloads */
87 struct dma_region data_buf;
88
89 /* size of data_buf, in bytes (always a multiple of PAGE_SIZE) */
90 unsigned int buf_size;
91
92 /* # of packets in the ringbuffer */
93 unsigned int buf_packets;
94
95 /* protects packet cursors */
96 spinlock_t lock;
97
98 /* the index of the next packet that will be produced
99 or consumed by the user */
100 int first_packet;
101
102 /* the index of the next packet that will be transmitted
103 or received by the 1394 hardware */
104 int pkt_dma;
105
106 /* how many packets, starting at first_packet:
107 (transmit) are ready to be filled with data
108 (receive) contain received data */
109 int n_ready_packets;
110
111 /* how many times the buffer has overflowed or underflowed */
112 atomic_t overflows;
113
114 /* private flags to track initialization progress */
115#define HPSB_ISO_DRIVER_INIT (1<<0)
116#define HPSB_ISO_DRIVER_STARTED (1<<1)
117 unsigned int flags;
118
119 /* # of packets left to prebuffer (xmit only) */
120 int prebuffer;
121
122 /* starting cycle for DMA (xmit only) */
123 int start_cycle;
124
125 /* cycle at which next packet will be transmitted,
126 -1 if not known */
127 int xmit_cycle;
128
129 /* ringbuffer of packet descriptors in regular kernel memory
130 * XXX Keep this last, since we use over-allocated memory from
131 * this entry to fill this field. */
132 struct hpsb_iso_packet_info *infos;
133};
134
135/* functions available to high-level drivers (e.g. raw1394) */
136
137/* allocate the buffer and DMA context */
138
139struct hpsb_iso* hpsb_iso_xmit_init(struct hpsb_host *host,
140 unsigned int data_buf_size,
141 unsigned int buf_packets,
142 int channel,
143 int speed,
144 int irq_interval,
145 void (*callback)(struct hpsb_iso*));
146
147/* note: if channel = -1, multi-channel receive is enabled */
148struct hpsb_iso* hpsb_iso_recv_init(struct hpsb_host *host,
149 unsigned int data_buf_size,
150 unsigned int buf_packets,
151 int channel,
152 int dma_mode,
153 int irq_interval,
154 void (*callback)(struct hpsb_iso*));
155
156/* multi-channel only */
157int hpsb_iso_recv_listen_channel(struct hpsb_iso *iso, unsigned char channel);
158int hpsb_iso_recv_unlisten_channel(struct hpsb_iso *iso, unsigned char channel);
159int hpsb_iso_recv_set_channel_mask(struct hpsb_iso *iso, u64 mask);
160
161/* start/stop DMA */
162int hpsb_iso_xmit_start(struct hpsb_iso *iso, int start_on_cycle, int prebuffer);
163int hpsb_iso_recv_start(struct hpsb_iso *iso, int start_on_cycle, int tag_mask, int sync);
164void hpsb_iso_stop(struct hpsb_iso *iso);
165
166/* deallocate buffer and DMA context */
167void hpsb_iso_shutdown(struct hpsb_iso *iso);
168
169/* queue a packet for transmission. 'offset' is relative to the beginning of the
170 DMA buffer, where the packet's data payload should already have been placed */
171int hpsb_iso_xmit_queue_packet(struct hpsb_iso *iso, u32 offset, u16 len, u8 tag, u8 sy);
172
173/* wait until all queued packets have been transmitted to the bus */
174int hpsb_iso_xmit_sync(struct hpsb_iso *iso);
175
176/* N packets have been read out of the buffer, re-use the buffer space */
177int hpsb_iso_recv_release_packets(struct hpsb_iso *recv, unsigned int n_packets);
178
179/* check for arrival of new packets immediately (even if irq_interval
180 has not yet been reached) */
181int hpsb_iso_recv_flush(struct hpsb_iso *iso);
182
183/* returns # of packets ready to send or receive */
184int hpsb_iso_n_ready(struct hpsb_iso *iso);
185
186/* the following are callbacks available to low-level drivers */
187
188/* call after a packet has been transmitted to the bus (interrupt context is OK)
189 'cycle' is the _exact_ cycle the packet was sent on
190 'error' should be non-zero if some sort of error occurred when sending the packet
191*/
192void hpsb_iso_packet_sent(struct hpsb_iso *iso, int cycle, int error);
193
194/* call after a packet has been received (interrupt context OK) */
195void hpsb_iso_packet_received(struct hpsb_iso *iso, u32 offset, u16 len,
196 u16 cycle, u8 channel, u8 tag, u8 sy);
197
198/* call to wake waiting processes after buffer space has opened up. */
199void hpsb_iso_wake(struct hpsb_iso *iso);
200
201#endif /* IEEE1394_ISO_H */