diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/net/irda/irda_device.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 'include/net/irda/irda_device.h')
-rw-r--r-- | include/net/irda/irda_device.h | 301 |
1 files changed, 301 insertions, 0 deletions
diff --git a/include/net/irda/irda_device.h b/include/net/irda/irda_device.h new file mode 100644 index 000000000000..3b216f186f18 --- /dev/null +++ b/include/net/irda/irda_device.h | |||
@@ -0,0 +1,301 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * Filename: irda_device.h | ||
4 | * Version: 0.9 | ||
5 | * Description: Contains various declarations used by the drivers | ||
6 | * Status: Experimental. | ||
7 | * Author: Dag Brattli <dagb@cs.uit.no> | ||
8 | * Created at: Tue Apr 14 12:41:42 1998 | ||
9 | * Modified at: Mon Mar 20 09:08:57 2000 | ||
10 | * Modified by: Dag Brattli <dagb@cs.uit.no> | ||
11 | * | ||
12 | * Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved. | ||
13 | * Copyright (c) 1998 Thomas Davis, <ratbert@radiks.net>, | ||
14 | * Copyright (c) 2000-2002 Jean Tourrilhes <jt@hpl.hp.com> | ||
15 | * | ||
16 | * This program is free software; you can redistribute it and/or | ||
17 | * modify it under the terms of the GNU General Public License as | ||
18 | * published by the Free Software Foundation; either version 2 of | ||
19 | * the License, or (at your option) any later version. | ||
20 | * | ||
21 | * This program is distributed in the hope that it will be useful, | ||
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
24 | * GNU General Public License for more details. | ||
25 | * | ||
26 | * You should have received a copy of the GNU General Public License | ||
27 | * along with this program; if not, write to the Free Software | ||
28 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
29 | * MA 02111-1307 USA | ||
30 | * | ||
31 | ********************************************************************/ | ||
32 | |||
33 | /* | ||
34 | * This header contains all the IrDA definitions a driver really | ||
35 | * needs, and therefore the driver should not need to include | ||
36 | * any other IrDA headers - Jean II | ||
37 | */ | ||
38 | |||
39 | #ifndef IRDA_DEVICE_H | ||
40 | #define IRDA_DEVICE_H | ||
41 | |||
42 | #include <linux/config.h> | ||
43 | #include <linux/tty.h> | ||
44 | #include <linux/netdevice.h> | ||
45 | #include <linux/spinlock.h> | ||
46 | #include <linux/skbuff.h> /* struct sk_buff */ | ||
47 | #include <linux/irda.h> | ||
48 | #include <linux/types.h> | ||
49 | |||
50 | #include <net/pkt_sched.h> | ||
51 | #include <net/irda/irda.h> | ||
52 | #include <net/irda/qos.h> /* struct qos_info */ | ||
53 | #include <net/irda/irqueue.h> /* irda_queue_t */ | ||
54 | |||
55 | /* A few forward declarations (to make compiler happy) */ | ||
56 | struct irlap_cb; | ||
57 | |||
58 | /* Some non-standard interface flags (should not conflict with any in if.h) */ | ||
59 | #define IFF_SIR 0x0001 /* Supports SIR speeds */ | ||
60 | #define IFF_MIR 0x0002 /* Supports MIR speeds */ | ||
61 | #define IFF_FIR 0x0004 /* Supports FIR speeds */ | ||
62 | #define IFF_VFIR 0x0008 /* Supports VFIR speeds */ | ||
63 | #define IFF_PIO 0x0010 /* Supports PIO transfer of data */ | ||
64 | #define IFF_DMA 0x0020 /* Supports DMA transfer of data */ | ||
65 | #define IFF_SHM 0x0040 /* Supports shared memory data transfers */ | ||
66 | #define IFF_DONGLE 0x0080 /* Interface has a dongle attached */ | ||
67 | #define IFF_AIR 0x0100 /* Supports Advanced IR (AIR) standards */ | ||
68 | |||
69 | #define IO_XMIT 0x01 | ||
70 | #define IO_RECV 0x02 | ||
71 | |||
72 | typedef enum { | ||
73 | IRDA_IRLAP, /* IrDA mode, and deliver to IrLAP */ | ||
74 | IRDA_RAW, /* IrDA mode */ | ||
75 | SHARP_ASK, | ||
76 | TV_REMOTE, /* Also known as Consumer Electronics IR */ | ||
77 | } INFRARED_MODE; | ||
78 | |||
79 | typedef enum { | ||
80 | IRDA_TASK_INIT, /* All tasks are initialized with this state */ | ||
81 | IRDA_TASK_DONE, /* Signals that the task is finished */ | ||
82 | IRDA_TASK_WAIT, | ||
83 | IRDA_TASK_WAIT1, | ||
84 | IRDA_TASK_WAIT2, | ||
85 | IRDA_TASK_WAIT3, | ||
86 | IRDA_TASK_CHILD_INIT, /* Initializing child task */ | ||
87 | IRDA_TASK_CHILD_WAIT, /* Waiting for child task to finish */ | ||
88 | IRDA_TASK_CHILD_DONE /* Child task is finished */ | ||
89 | } IRDA_TASK_STATE; | ||
90 | |||
91 | struct irda_task; | ||
92 | typedef int (*IRDA_TASK_CALLBACK) (struct irda_task *task); | ||
93 | |||
94 | struct irda_task { | ||
95 | irda_queue_t q; | ||
96 | magic_t magic; | ||
97 | |||
98 | IRDA_TASK_STATE state; | ||
99 | IRDA_TASK_CALLBACK function; | ||
100 | IRDA_TASK_CALLBACK finished; | ||
101 | |||
102 | struct irda_task *parent; | ||
103 | struct timer_list timer; | ||
104 | |||
105 | void *instance; /* Instance being called */ | ||
106 | void *param; /* Parameter to be used by instance */ | ||
107 | }; | ||
108 | |||
109 | /* Dongle info */ | ||
110 | struct dongle_reg; | ||
111 | typedef struct { | ||
112 | struct dongle_reg *issue; /* Registration info */ | ||
113 | struct net_device *dev; /* Device we are attached to */ | ||
114 | struct irda_task *speed_task; /* Task handling speed change */ | ||
115 | struct irda_task *reset_task; /* Task handling reset */ | ||
116 | __u32 speed; /* Current speed */ | ||
117 | |||
118 | /* Callbacks to the IrDA device driver */ | ||
119 | int (*set_mode)(struct net_device *, int mode); | ||
120 | int (*read)(struct net_device *dev, __u8 *buf, int len); | ||
121 | int (*write)(struct net_device *dev, __u8 *buf, int len); | ||
122 | int (*set_dtr_rts)(struct net_device *dev, int dtr, int rts); | ||
123 | } dongle_t; | ||
124 | |||
125 | /* Dongle registration info */ | ||
126 | struct dongle_reg { | ||
127 | irda_queue_t q; /* Must be first */ | ||
128 | IRDA_DONGLE type; | ||
129 | |||
130 | void (*open)(dongle_t *dongle, struct qos_info *qos); | ||
131 | void (*close)(dongle_t *dongle); | ||
132 | int (*reset)(struct irda_task *task); | ||
133 | int (*change_speed)(struct irda_task *task); | ||
134 | struct module *owner; | ||
135 | }; | ||
136 | |||
137 | /* | ||
138 | * Per-packet information we need to hide inside sk_buff | ||
139 | * (must not exceed 48 bytes, check with struct sk_buff) | ||
140 | */ | ||
141 | struct irda_skb_cb { | ||
142 | magic_t magic; /* Be sure that we can trust the information */ | ||
143 | __u32 next_speed; /* The Speed to be set *after* this frame */ | ||
144 | __u16 mtt; /* Minimum turn around time */ | ||
145 | __u16 xbofs; /* Number of xbofs required, used by SIR mode */ | ||
146 | __u16 next_xbofs; /* Number of xbofs required *after* this frame */ | ||
147 | void *context; /* May be used by drivers */ | ||
148 | void (*destructor)(struct sk_buff *skb); /* Used for flow control */ | ||
149 | __u16 xbofs_delay; /* Number of xbofs used for generating the mtt */ | ||
150 | __u8 line; /* Used by IrCOMM in IrLPT mode */ | ||
151 | }; | ||
152 | |||
153 | /* Chip specific info */ | ||
154 | typedef struct { | ||
155 | int cfg_base; /* Config register IO base */ | ||
156 | int sir_base; /* SIR IO base */ | ||
157 | int fir_base; /* FIR IO base */ | ||
158 | int mem_base; /* Shared memory base */ | ||
159 | int sir_ext; /* Length of SIR iobase */ | ||
160 | int fir_ext; /* Length of FIR iobase */ | ||
161 | int irq, irq2; /* Interrupts used */ | ||
162 | int dma, dma2; /* DMA channel(s) used */ | ||
163 | int fifo_size; /* FIFO size */ | ||
164 | int irqflags; /* interrupt flags (ie, SA_SHIRQ|SA_INTERRUPT) */ | ||
165 | int direction; /* Link direction, used by some FIR drivers */ | ||
166 | int enabled; /* Powered on? */ | ||
167 | int suspended; /* Suspended by APM */ | ||
168 | __u32 speed; /* Currently used speed */ | ||
169 | __u32 new_speed; /* Speed we must change to when Tx is finished */ | ||
170 | int dongle_id; /* Dongle or transceiver currently used */ | ||
171 | } chipio_t; | ||
172 | |||
173 | /* IO buffer specific info (inspired by struct sk_buff) */ | ||
174 | typedef struct { | ||
175 | int state; /* Receiving state (transmit state not used) */ | ||
176 | int in_frame; /* True if receiving frame */ | ||
177 | |||
178 | __u8 *head; /* start of buffer */ | ||
179 | __u8 *data; /* start of data in buffer */ | ||
180 | |||
181 | int len; /* current length of data */ | ||
182 | int truesize; /* total allocated size of buffer */ | ||
183 | __u16 fcs; | ||
184 | |||
185 | struct sk_buff *skb; /* ZeroCopy Rx in async_unwrap_char() */ | ||
186 | } iobuff_t; | ||
187 | |||
188 | /* Maximum SIR frame (skb) that we expect to receive *unwrapped*. | ||
189 | * Max LAP MTU (I field) is 2048 bytes max (IrLAP 1.1, chapt 6.6.5, p40). | ||
190 | * Max LAP header is 2 bytes (for now). | ||
191 | * Max CRC is 2 bytes at SIR, 4 bytes at FIR. | ||
192 | * Need 1 byte for skb_reserve() to align IP header for IrLAN. | ||
193 | * Add a few extra bytes just to be safe (buffer is power of two anyway) | ||
194 | * Jean II */ | ||
195 | #define IRDA_SKB_MAX_MTU 2064 | ||
196 | /* Maximum SIR frame that we expect to send, wrapped (i.e. with XBOFS | ||
197 | * and escaped characters on top of above). */ | ||
198 | #define IRDA_SIR_MAX_FRAME 4269 | ||
199 | |||
200 | /* The SIR unwrapper async_unwrap_char() will use a Rx-copy-break mechanism | ||
201 | * when using the optional ZeroCopy Rx, where only small frames are memcpy | ||
202 | * to a smaller skb to save memory. This is the threshold under which copy | ||
203 | * will happen (and over which it won't happen). | ||
204 | * Some FIR drivers may use this #define as well... | ||
205 | * This is the same value as various Ethernet drivers. - Jean II */ | ||
206 | #define IRDA_RX_COPY_THRESHOLD 256 | ||
207 | |||
208 | /* Function prototypes */ | ||
209 | int irda_device_init(void); | ||
210 | void irda_device_cleanup(void); | ||
211 | |||
212 | /* IrLAP entry points used by the drivers. | ||
213 | * We declare them here to avoid the driver pulling a whole bunch stack | ||
214 | * headers they don't really need - Jean II */ | ||
215 | struct irlap_cb *irlap_open(struct net_device *dev, struct qos_info *qos, | ||
216 | const char *hw_name); | ||
217 | void irlap_close(struct irlap_cb *self); | ||
218 | |||
219 | /* Interface to be uses by IrLAP */ | ||
220 | void irda_device_set_media_busy(struct net_device *dev, int status); | ||
221 | int irda_device_is_media_busy(struct net_device *dev); | ||
222 | int irda_device_is_receiving(struct net_device *dev); | ||
223 | |||
224 | /* Interface for internal use */ | ||
225 | static inline int irda_device_txqueue_empty(const struct net_device *dev) | ||
226 | { | ||
227 | return (skb_queue_len(&dev->qdisc->q) == 0); | ||
228 | } | ||
229 | int irda_device_set_raw_mode(struct net_device* self, int status); | ||
230 | struct net_device *alloc_irdadev(int sizeof_priv); | ||
231 | |||
232 | /* Dongle interface */ | ||
233 | void irda_device_unregister_dongle(struct dongle_reg *dongle); | ||
234 | int irda_device_register_dongle(struct dongle_reg *dongle); | ||
235 | dongle_t *irda_device_dongle_init(struct net_device *dev, int type); | ||
236 | int irda_device_dongle_cleanup(dongle_t *dongle); | ||
237 | |||
238 | #ifdef CONFIG_ISA | ||
239 | void irda_setup_dma(int channel, dma_addr_t buffer, int count, int mode); | ||
240 | #endif | ||
241 | |||
242 | void irda_task_delete(struct irda_task *task); | ||
243 | struct irda_task *irda_task_execute(void *instance, | ||
244 | IRDA_TASK_CALLBACK function, | ||
245 | IRDA_TASK_CALLBACK finished, | ||
246 | struct irda_task *parent, void *param); | ||
247 | void irda_task_next_state(struct irda_task *task, IRDA_TASK_STATE state); | ||
248 | |||
249 | /* | ||
250 | * Function irda_get_mtt (skb) | ||
251 | * | ||
252 | * Utility function for getting the minimum turnaround time out of | ||
253 | * the skb, where it has been hidden in the cb field. | ||
254 | */ | ||
255 | static inline __u16 irda_get_mtt(const struct sk_buff *skb) | ||
256 | { | ||
257 | const struct irda_skb_cb *cb = (const struct irda_skb_cb *) skb->cb; | ||
258 | return (cb->magic == LAP_MAGIC) ? cb->mtt : 10000; | ||
259 | } | ||
260 | |||
261 | /* | ||
262 | * Function irda_get_next_speed (skb) | ||
263 | * | ||
264 | * Extract the speed that should be set *after* this frame from the skb | ||
265 | * | ||
266 | * Note : return -1 for user space frames | ||
267 | */ | ||
268 | static inline __u32 irda_get_next_speed(const struct sk_buff *skb) | ||
269 | { | ||
270 | const struct irda_skb_cb *cb = (const struct irda_skb_cb *) skb->cb; | ||
271 | return (cb->magic == LAP_MAGIC) ? cb->next_speed : -1; | ||
272 | } | ||
273 | |||
274 | /* | ||
275 | * Function irda_get_next_xbofs (skb) | ||
276 | * | ||
277 | * Extract the xbofs that should be set for this frame from the skb | ||
278 | * | ||
279 | * Note : default to 10 for user space frames | ||
280 | */ | ||
281 | static inline __u16 irda_get_xbofs(const struct sk_buff *skb) | ||
282 | { | ||
283 | const struct irda_skb_cb *cb = (const struct irda_skb_cb *) skb->cb; | ||
284 | return (cb->magic == LAP_MAGIC) ? cb->xbofs : 10; | ||
285 | } | ||
286 | |||
287 | /* | ||
288 | * Function irda_get_next_xbofs (skb) | ||
289 | * | ||
290 | * Extract the xbofs that should be set *after* this frame from the skb | ||
291 | * | ||
292 | * Note : return -1 for user space frames | ||
293 | */ | ||
294 | static inline __u16 irda_get_next_xbofs(const struct sk_buff *skb) | ||
295 | { | ||
296 | const struct irda_skb_cb *cb = (const struct irda_skb_cb *) skb->cb; | ||
297 | return (cb->magic == LAP_MAGIC) ? cb->next_xbofs : -1; | ||
298 | } | ||
299 | #endif /* IRDA_DEVICE_H */ | ||
300 | |||
301 | |||