]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - include/net/irda/irda_device.h
Merge branch 'irq-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[mirror_ubuntu-zesty-kernel.git] / include / net / irda / irda_device.h
CommitLineData
1da177e4
LT
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
a6227e26 27 * along with this program; if not, see <http://www.gnu.org/licenses/>.
1da177e4
LT
28 *
29 ********************************************************************/
30
31/*
32 * This header contains all the IrDA definitions a driver really
33 * needs, and therefore the driver should not need to include
34 * any other IrDA headers - Jean II
35 */
36
37#ifndef IRDA_DEVICE_H
38#define IRDA_DEVICE_H
39
1da177e4
LT
40#include <linux/tty.h>
41#include <linux/netdevice.h>
42#include <linux/spinlock.h>
43#include <linux/skbuff.h> /* struct sk_buff */
44#include <linux/irda.h>
45#include <linux/types.h>
46
47#include <net/pkt_sched.h>
48#include <net/irda/irda.h>
49#include <net/irda/qos.h> /* struct qos_info */
50#include <net/irda/irqueue.h> /* irda_queue_t */
51
52/* A few forward declarations (to make compiler happy) */
53struct irlap_cb;
54
55/* Some non-standard interface flags (should not conflict with any in if.h) */
56#define IFF_SIR 0x0001 /* Supports SIR speeds */
57#define IFF_MIR 0x0002 /* Supports MIR speeds */
58#define IFF_FIR 0x0004 /* Supports FIR speeds */
59#define IFF_VFIR 0x0008 /* Supports VFIR speeds */
60#define IFF_PIO 0x0010 /* Supports PIO transfer of data */
61#define IFF_DMA 0x0020 /* Supports DMA transfer of data */
62#define IFF_SHM 0x0040 /* Supports shared memory data transfers */
63#define IFF_DONGLE 0x0080 /* Interface has a dongle attached */
64#define IFF_AIR 0x0100 /* Supports Advanced IR (AIR) standards */
65
66#define IO_XMIT 0x01
67#define IO_RECV 0x02
68
69typedef enum {
70 IRDA_IRLAP, /* IrDA mode, and deliver to IrLAP */
71 IRDA_RAW, /* IrDA mode */
72 SHARP_ASK,
73 TV_REMOTE, /* Also known as Consumer Electronics IR */
74} INFRARED_MODE;
75
76typedef enum {
77 IRDA_TASK_INIT, /* All tasks are initialized with this state */
78 IRDA_TASK_DONE, /* Signals that the task is finished */
79 IRDA_TASK_WAIT,
80 IRDA_TASK_WAIT1,
81 IRDA_TASK_WAIT2,
82 IRDA_TASK_WAIT3,
83 IRDA_TASK_CHILD_INIT, /* Initializing child task */
84 IRDA_TASK_CHILD_WAIT, /* Waiting for child task to finish */
85 IRDA_TASK_CHILD_DONE /* Child task is finished */
86} IRDA_TASK_STATE;
87
88struct irda_task;
89typedef int (*IRDA_TASK_CALLBACK) (struct irda_task *task);
90
91struct irda_task {
92 irda_queue_t q;
93 magic_t magic;
94
95 IRDA_TASK_STATE state;
96 IRDA_TASK_CALLBACK function;
97 IRDA_TASK_CALLBACK finished;
98
99 struct irda_task *parent;
100 struct timer_list timer;
101
102 void *instance; /* Instance being called */
103 void *param; /* Parameter to be used by instance */
104};
105
106/* Dongle info */
107struct dongle_reg;
108typedef struct {
109 struct dongle_reg *issue; /* Registration info */
110 struct net_device *dev; /* Device we are attached to */
111 struct irda_task *speed_task; /* Task handling speed change */
112 struct irda_task *reset_task; /* Task handling reset */
113 __u32 speed; /* Current speed */
114
115 /* Callbacks to the IrDA device driver */
116 int (*set_mode)(struct net_device *, int mode);
117 int (*read)(struct net_device *dev, __u8 *buf, int len);
118 int (*write)(struct net_device *dev, __u8 *buf, int len);
119 int (*set_dtr_rts)(struct net_device *dev, int dtr, int rts);
120} dongle_t;
121
122/* Dongle registration info */
123struct dongle_reg {
124 irda_queue_t q; /* Must be first */
125 IRDA_DONGLE type;
126
127 void (*open)(dongle_t *dongle, struct qos_info *qos);
128 void (*close)(dongle_t *dongle);
129 int (*reset)(struct irda_task *task);
130 int (*change_speed)(struct irda_task *task);
131 struct module *owner;
132};
133
134/*
135 * Per-packet information we need to hide inside sk_buff
69c30e1e
SO
136 * (must not exceed 48 bytes, check with struct sk_buff)
137 * The default_qdisc_pad field is a temporary hack.
1da177e4
LT
138 */
139struct irda_skb_cb {
69c30e1e 140 unsigned int default_qdisc_pad;
1da177e4
LT
141 magic_t magic; /* Be sure that we can trust the information */
142 __u32 next_speed; /* The Speed to be set *after* this frame */
143 __u16 mtt; /* Minimum turn around time */
144 __u16 xbofs; /* Number of xbofs required, used by SIR mode */
145 __u16 next_xbofs; /* Number of xbofs required *after* this frame */
146 void *context; /* May be used by drivers */
147 void (*destructor)(struct sk_buff *skb); /* Used for flow control */
148 __u16 xbofs_delay; /* Number of xbofs used for generating the mtt */
149 __u8 line; /* Used by IrCOMM in IrLPT mode */
150};
151
152/* Chip specific info */
153typedef struct {
154 int cfg_base; /* Config register IO base */
155 int sir_base; /* SIR IO base */
156 int fir_base; /* FIR IO base */
157 int mem_base; /* Shared memory base */
158 int sir_ext; /* Length of SIR iobase */
159 int fir_ext; /* Length of FIR iobase */
160 int irq, irq2; /* Interrupts used */
161 int dma, dma2; /* DMA channel(s) used */
162 int fifo_size; /* FIFO size */
78dea8cc 163 int irqflags; /* interrupt flags (ie, IRQF_SHARED) */
1da177e4
LT
164 int direction; /* Link direction, used by some FIR drivers */
165 int enabled; /* Powered on? */
166 int suspended; /* Suspended by APM */
167 __u32 speed; /* Currently used speed */
168 __u32 new_speed; /* Speed we must change to when Tx is finished */
169 int dongle_id; /* Dongle or transceiver currently used */
170} chipio_t;
171
172/* IO buffer specific info (inspired by struct sk_buff) */
173typedef struct {
174 int state; /* Receiving state (transmit state not used) */
175 int in_frame; /* True if receiving frame */
176
177 __u8 *head; /* start of buffer */
178 __u8 *data; /* start of data in buffer */
179
180 int len; /* current length of data */
181 int truesize; /* total allocated size of buffer */
182 __u16 fcs;
183
184 struct sk_buff *skb; /* ZeroCopy Rx in async_unwrap_char() */
185} iobuff_t;
186
187/* Maximum SIR frame (skb) that we expect to receive *unwrapped*.
188 * Max LAP MTU (I field) is 2048 bytes max (IrLAP 1.1, chapt 6.6.5, p40).
189 * Max LAP header is 2 bytes (for now).
190 * Max CRC is 2 bytes at SIR, 4 bytes at FIR.
191 * Need 1 byte for skb_reserve() to align IP header for IrLAN.
192 * Add a few extra bytes just to be safe (buffer is power of two anyway)
193 * Jean II */
194#define IRDA_SKB_MAX_MTU 2064
195/* Maximum SIR frame that we expect to send, wrapped (i.e. with XBOFS
196 * and escaped characters on top of above). */
197#define IRDA_SIR_MAX_FRAME 4269
198
199/* The SIR unwrapper async_unwrap_char() will use a Rx-copy-break mechanism
200 * when using the optional ZeroCopy Rx, where only small frames are memcpy
201 * to a smaller skb to save memory. This is the threshold under which copy
202 * will happen (and over which it won't happen).
203 * Some FIR drivers may use this #define as well...
204 * This is the same value as various Ethernet drivers. - Jean II */
205#define IRDA_RX_COPY_THRESHOLD 256
206
207/* Function prototypes */
208int irda_device_init(void);
209void irda_device_cleanup(void);
210
211/* IrLAP entry points used by the drivers.
212 * We declare them here to avoid the driver pulling a whole bunch stack
213 * headers they don't really need - Jean II */
214struct irlap_cb *irlap_open(struct net_device *dev, struct qos_info *qos,
215 const char *hw_name);
216void irlap_close(struct irlap_cb *self);
217
218/* Interface to be uses by IrLAP */
219void irda_device_set_media_busy(struct net_device *dev, int status);
220int irda_device_is_media_busy(struct net_device *dev);
221int irda_device_is_receiving(struct net_device *dev);
222
223/* Interface for internal use */
224static inline int irda_device_txqueue_empty(const struct net_device *dev)
225{
3e745dd6 226 return qdisc_all_tx_empty(dev);
1da177e4
LT
227}
228int irda_device_set_raw_mode(struct net_device* self, int status);
229struct net_device *alloc_irdadev(int sizeof_priv);
230
1da177e4 231void irda_setup_dma(int channel, dma_addr_t buffer, int count, int mode);
1da177e4 232
1da177e4
LT
233/*
234 * Function irda_get_mtt (skb)
235 *
236 * Utility function for getting the minimum turnaround time out of
237 * the skb, where it has been hidden in the cb field.
238 */
239static inline __u16 irda_get_mtt(const struct sk_buff *skb)
240{
241 const struct irda_skb_cb *cb = (const struct irda_skb_cb *) skb->cb;
242 return (cb->magic == LAP_MAGIC) ? cb->mtt : 10000;
243}
244
245/*
246 * Function irda_get_next_speed (skb)
247 *
248 * Extract the speed that should be set *after* this frame from the skb
249 *
250 * Note : return -1 for user space frames
251 */
252static inline __u32 irda_get_next_speed(const struct sk_buff *skb)
253{
254 const struct irda_skb_cb *cb = (const struct irda_skb_cb *) skb->cb;
255 return (cb->magic == LAP_MAGIC) ? cb->next_speed : -1;
256}
257
258/*
259 * Function irda_get_next_xbofs (skb)
260 *
261 * Extract the xbofs that should be set for this frame from the skb
262 *
263 * Note : default to 10 for user space frames
264 */
265static inline __u16 irda_get_xbofs(const struct sk_buff *skb)
266{
267 const struct irda_skb_cb *cb = (const struct irda_skb_cb *) skb->cb;
268 return (cb->magic == LAP_MAGIC) ? cb->xbofs : 10;
269}
270
271/*
272 * Function irda_get_next_xbofs (skb)
273 *
274 * Extract the xbofs that should be set *after* this frame from the skb
275 *
276 * Note : return -1 for user space frames
277 */
278static inline __u16 irda_get_next_xbofs(const struct sk_buff *skb)
279{
280 const struct irda_skb_cb *cb = (const struct irda_skb_cb *) skb->cb;
281 return (cb->magic == LAP_MAGIC) ? cb->next_xbofs : -1;
282}
283#endif /* IRDA_DEVICE_H */
284
285