checkpatch: if should not continue a preceeding brace
[linux-2.6/mini2440.git] / drivers / ieee1394 / iso.h
blobb5de5f21ef78a57e45032500867fdb24538de00e
1 /*
2 * IEEE 1394 for Linux
4 * kernel ISO transmission/reception
6 * Copyright (C) 2002 Maas Digital LLC
8 * This code is licensed under the GPL. See the file COPYING in the root
9 * directory of the kernel sources for details.
12 #ifndef IEEE1394_ISO_H
13 #define IEEE1394_ISO_H
15 #include <linux/spinlock_types.h>
16 #include <asm/atomic.h>
17 #include <asm/types.h>
19 #include "dma.h"
21 struct hpsb_host;
23 /* high-level ISO interface */
26 * This API sends and receives isochronous packets on a large,
27 * virtually-contiguous kernel memory buffer. The buffer may be mapped
28 * into a user-space process for zero-copy transmission and reception.
30 * There are no explicit boundaries between packets in the buffer. A
31 * packet may be transmitted or received at any location. However,
32 * low-level drivers may impose certain restrictions on alignment or
33 * size of packets. (e.g. in OHCI no packet may cross a page boundary,
34 * and packets should be quadlet-aligned)
37 /* Packet descriptor - the API maintains a ring buffer of these packet
38 * descriptors in kernel memory (hpsb_iso.infos[]). */
39 struct hpsb_iso_packet_info {
40 /* offset of data payload relative to the first byte of the buffer */
41 __u32 offset;
43 /* length of the data payload, in bytes (not including the isochronous
44 * header) */
45 __u16 len;
47 /* (recv only) the cycle number (mod 8000) on which the packet was
48 * received */
49 __u16 cycle;
51 /* (recv only) channel on which the packet was received */
52 __u8 channel;
54 /* 2-bit 'tag' and 4-bit 'sy' fields of the isochronous header */
55 __u8 tag;
56 __u8 sy;
58 /* length in bytes of the packet including header/trailer.
59 * MUST be at structure end, since the first part of this structure is
60 * also defined in raw1394.h (i.e. struct raw1394_iso_packet_info), is
61 * copied to userspace and is accessed there through libraw1394. */
62 __u16 total_len;
65 enum hpsb_iso_type { HPSB_ISO_RECV = 0, HPSB_ISO_XMIT = 1 };
67 /* The mode of the dma when receiving iso data. Must be supported by chip */
68 enum raw1394_iso_dma_recv_mode {
69 HPSB_ISO_DMA_DEFAULT = -1,
70 HPSB_ISO_DMA_OLD_ABI = 0,
71 HPSB_ISO_DMA_BUFFERFILL = 1,
72 HPSB_ISO_DMA_PACKET_PER_BUFFER = 2
75 struct hpsb_iso {
76 enum hpsb_iso_type type;
78 /* pointer to low-level driver and its private data */
79 struct hpsb_host *host;
80 void *hostdata;
82 /* a function to be called (from interrupt context) after
83 * outgoing packets have been sent, or incoming packets have
84 * arrived */
85 void (*callback)(struct hpsb_iso*);
87 /* wait for buffer space */
88 wait_queue_head_t waitq;
90 int speed; /* IEEE1394_SPEED_100, 200, or 400 */
91 int channel; /* -1 if multichannel */
92 int dma_mode; /* dma receive mode */
95 /* greatest # of packets between interrupts - controls
96 * the maximum latency of the buffer */
97 int irq_interval;
99 /* the buffer for packet data payloads */
100 struct dma_region data_buf;
102 /* size of data_buf, in bytes (always a multiple of PAGE_SIZE) */
103 unsigned int buf_size;
105 /* # of packets in the ringbuffer */
106 unsigned int buf_packets;
108 /* protects packet cursors */
109 spinlock_t lock;
111 /* the index of the next packet that will be produced
112 or consumed by the user */
113 int first_packet;
115 /* the index of the next packet that will be transmitted
116 or received by the 1394 hardware */
117 int pkt_dma;
119 /* how many packets, starting at first_packet:
120 * (transmit) are ready to be filled with data
121 * (receive) contain received data */
122 int n_ready_packets;
124 /* how many times the buffer has overflowed or underflowed */
125 atomic_t overflows;
126 /* how many cycles were skipped for a given context */
127 atomic_t skips;
129 /* Current number of bytes lost in discarded packets */
130 int bytes_discarded;
132 /* private flags to track initialization progress */
133 #define HPSB_ISO_DRIVER_INIT (1<<0)
134 #define HPSB_ISO_DRIVER_STARTED (1<<1)
135 unsigned int flags;
137 /* # of packets left to prebuffer (xmit only) */
138 int prebuffer;
140 /* starting cycle for DMA (xmit only) */
141 int start_cycle;
143 /* cycle at which next packet will be transmitted,
144 * -1 if not known */
145 int xmit_cycle;
147 /* ringbuffer of packet descriptors in regular kernel memory
148 * XXX Keep this last, since we use over-allocated memory from
149 * this entry to fill this field. */
150 struct hpsb_iso_packet_info *infos;
153 /* functions available to high-level drivers (e.g. raw1394) */
155 struct hpsb_iso* hpsb_iso_xmit_init(struct hpsb_host *host,
156 unsigned int data_buf_size,
157 unsigned int buf_packets,
158 int channel,
159 int speed,
160 int irq_interval,
161 void (*callback)(struct hpsb_iso*));
162 struct hpsb_iso* hpsb_iso_recv_init(struct hpsb_host *host,
163 unsigned int data_buf_size,
164 unsigned int buf_packets,
165 int channel,
166 int dma_mode,
167 int irq_interval,
168 void (*callback)(struct hpsb_iso*));
169 int hpsb_iso_recv_listen_channel(struct hpsb_iso *iso, unsigned char channel);
170 int hpsb_iso_recv_unlisten_channel(struct hpsb_iso *iso, unsigned char channel);
171 int hpsb_iso_recv_set_channel_mask(struct hpsb_iso *iso, u64 mask);
172 int hpsb_iso_xmit_start(struct hpsb_iso *iso, int start_on_cycle,
173 int prebuffer);
174 int hpsb_iso_recv_start(struct hpsb_iso *iso, int start_on_cycle,
175 int tag_mask, int sync);
176 void hpsb_iso_stop(struct hpsb_iso *iso);
177 void hpsb_iso_shutdown(struct hpsb_iso *iso);
178 int hpsb_iso_xmit_queue_packet(struct hpsb_iso *iso, u32 offset, u16 len,
179 u8 tag, u8 sy);
180 int hpsb_iso_xmit_sync(struct hpsb_iso *iso);
181 int hpsb_iso_recv_release_packets(struct hpsb_iso *recv,
182 unsigned int n_packets);
183 int hpsb_iso_recv_flush(struct hpsb_iso *iso);
184 int hpsb_iso_n_ready(struct hpsb_iso *iso);
186 /* the following are callbacks available to low-level drivers */
188 void hpsb_iso_packet_sent(struct hpsb_iso *iso, int cycle, int error);
189 void hpsb_iso_packet_received(struct hpsb_iso *iso, u32 offset, u16 len,
190 u16 total_len, u16 cycle, u8 channel, u8 tag,
191 u8 sy);
192 void hpsb_iso_wake(struct hpsb_iso *iso);
194 #endif /* IEEE1394_ISO_H */