Ok. I didn't make 2.4.0 in 2000. Tough. I tried, but we had some
[davej-history.git] / include / net / irda / irda_device.h
blobac66f61bd492e49a6edf09a2ee0ce8c13c1a6ff4
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>
12 * Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved.
13 * Copyright (c) 1998 Thomas Davis, <ratbert@radiks.net>,
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 * MA 02111-1307 USA
30 ********************************************************************/
32 #ifndef IRDA_DEVICE_H
33 #define IRDA_DEVICE_H
35 #include <linux/tty.h>
36 #include <linux/netdevice.h>
37 #include <linux/spinlock.h>
38 #include <linux/irda.h>
40 #include <net/irda/irda.h>
41 #include <net/irda/qos.h>
42 #include <net/irda/irqueue.h>
43 #include <net/irda/irlap_frame.h>
45 /* Some non-standard interface flags (should not conflict with any in if.h) */
46 #define IFF_SIR 0x0001 /* Supports SIR speeds */
47 #define IFF_MIR 0x0002 /* Supports MIR speeds */
48 #define IFF_FIR 0x0004 /* Supports FIR speeds */
49 #define IFF_VFIR 0x0008 /* Supports VFIR speeds */
50 #define IFF_PIO 0x0010 /* Supports PIO transfer of data */
51 #define IFF_DMA 0x0020 /* Supports DMA transfer of data */
52 #define IFF_SHM 0x0040 /* Supports shared memory data transfers */
53 #define IFF_DONGLE 0x0080 /* Interface has a dongle attached */
54 #define IFF_AIR 0x0100 /* Supports Advanced IR (AIR) standards */
56 #define IO_XMIT 0x01
57 #define IO_RECV 0x02
59 typedef enum {
60 IRDA_IRLAP, /* IrDA mode, and deliver to IrLAP */
61 IRDA_RAW, /* IrDA mode */
62 SHARP_ASK,
63 TV_REMOTE, /* Also known as Consumer Electronics IR */
64 } INFRARED_MODE;
66 typedef enum {
67 IRDA_TASK_INIT, /* All tasks are initialized with this state */
68 IRDA_TASK_DONE, /* Signals that the task is finished */
69 IRDA_TASK_WAIT,
70 IRDA_TASK_WAIT1,
71 IRDA_TASK_WAIT2,
72 IRDA_TASK_WAIT3,
73 IRDA_TASK_CHILD_INIT, /* Initializing child task */
74 IRDA_TASK_CHILD_WAIT, /* Waiting for child task to finish */
75 IRDA_TASK_CHILD_DONE /* Child task is finished */
76 } IRDA_TASK_STATE;
78 struct irda_task;
79 typedef int (*IRDA_TASK_CALLBACK) (struct irda_task *task);
81 struct irda_task {
82 irda_queue_t q;
83 magic_t magic;
85 IRDA_TASK_STATE state;
86 IRDA_TASK_CALLBACK function;
87 IRDA_TASK_CALLBACK finished;
89 struct irda_task *parent;
90 struct timer_list timer;
92 void *instance; /* Instance being called */
93 void *param; /* Parameter to be used by instance */
96 /* Dongle info */
97 struct dongle_reg;
98 typedef struct {
99 struct dongle_reg *issue; /* Registration info */
100 struct net_device *dev; /* Device we are attached to */
101 struct irda_task *speed_task; /* Task handling speed change */
102 struct irda_task *reset_task; /* Task handling reset */
103 __u32 speed; /* Current speed */
105 /* Callbacks to the IrDA device driver */
106 int (*set_mode)(struct net_device *, int mode);
107 int (*read)(struct net_device *dev, __u8 *buf, int len);
108 int (*write)(struct net_device *dev, __u8 *buf, int len);
109 int (*set_dtr_rts)(struct net_device *dev, int dtr, int rts);
110 } dongle_t;
112 /* Dongle registration info */
113 struct dongle_reg {
114 irda_queue_t q; /* Must be first */
115 IRDA_DONGLE type;
117 void (*open)(dongle_t *dongle, struct qos_info *qos);
118 void (*close)(dongle_t *dongle);
119 int (*reset)(struct irda_task *task);
120 int (*change_speed)(struct irda_task *task);
123 /* Chip specific info */
124 typedef struct {
125 int cfg_base; /* Config register IO base */
126 int sir_base; /* SIR IO base */
127 int fir_base; /* FIR IO base */
128 int mem_base; /* Shared memory base */
129 int sir_ext; /* Length of SIR iobase */
130 int fir_ext; /* Length of FIR iobase */
131 int irq, irq2; /* Interrupts used */
132 int dma, dma2; /* DMA channel(s) used */
133 int fifo_size; /* FIFO size */
134 int irqflags; /* interrupt flags (ie, SA_SHIRQ|SA_INTERRUPT) */
135 int direction; /* Link direction, used by some FIR drivers */
136 int enabled; /* Powered on? */
137 int suspended; /* Suspended by APM */
138 __u32 speed; /* Currently used speed */
139 __u32 new_speed; /* Speed we must change to when Tx is finished */
140 int dongle_id; /* Dongle or transceiver currently used */
141 } chipio_t;
143 /* IO buffer specific info (inspired by struct sk_buff) */
144 typedef struct {
145 int state; /* Receiving state (transmit state not used) */
146 int in_frame; /* True if receiving frame */
148 __u8 *head; /* start of buffer */
149 __u8 *data; /* start of data in buffer */
150 __u8 *tail; /* end of data in buffer */
152 int len; /* length of data */
153 int truesize; /* total size of buffer */
154 __u16 fcs;
155 } iobuff_t;
157 /* Function prototypes */
158 int irda_device_init(void);
159 void irda_device_cleanup(void);
161 /* Interface to be uses by IrLAP */
162 void irda_device_set_media_busy(struct net_device *dev, int status);
163 int irda_device_is_media_busy(struct net_device *dev);
164 int irda_device_is_receiving(struct net_device *dev);
166 /* Interface for internal use */
167 int irda_device_txqueue_empty(struct net_device *dev);
168 int irda_device_set_raw_mode(struct net_device* self, int status);
169 int irda_device_set_dtr_rts(struct net_device *dev, int dtr, int rts);
170 int irda_device_change_speed(struct net_device *dev, __u32 speed);
171 int irda_device_setup(struct net_device *dev);
173 /* Dongle interface */
174 void irda_device_unregister_dongle(struct dongle_reg *dongle);
175 int irda_device_register_dongle(struct dongle_reg *dongle);
176 dongle_t *irda_device_dongle_init(struct net_device *dev, int type);
177 int irda_device_dongle_cleanup(dongle_t *dongle);
179 void setup_dma(int channel, char *buffer, int count, int mode);
181 void irda_task_delete(struct irda_task *task);
182 int irda_task_kick(struct irda_task *task);
183 struct irda_task *irda_task_execute(void *instance,
184 IRDA_TASK_CALLBACK function,
185 IRDA_TASK_CALLBACK finished,
186 struct irda_task *parent, void *param);
187 void irda_task_next_state(struct irda_task *task, IRDA_TASK_STATE state);
189 extern const char *infrared_mode[];
192 * Function irda_get_mtt (skb)
194 * Utility function for getting the minimum turnaround time out of
195 * the skb, where it has been hidden in the cb field.
197 #define irda_get_mtt(skb) ( \
198 IRDA_MIN(10000, \
199 (((struct irda_skb_cb *) skb->cb)->magic == LAP_MAGIC) ? \
200 ((struct irda_skb_cb *)(skb->cb))->mtt : 10000 \
204 #if 0
205 extern inline __u16 irda_get_mtt(struct sk_buff *skb)
207 __u16 mtt;
209 if (((struct irda_skb_cb *)(skb->cb))->magic != LAP_MAGIC)
210 mtt = 10000;
211 else
212 mtt = ((struct irda_skb_cb *)(skb->cb))->mtt;
214 ASSERT(mtt <= 10000, return 10000;);
216 return mtt;
218 #endif
221 * Function irda_get_speed (skb)
223 * Extact the speed this frame should be sent out with from the skb
226 #define irda_get_speed(skb) ( \
227 (((struct irda_skb_cb*) skb->cb)->magic == LAP_MAGIC) ? \
228 ((struct irda_skb_cb *)(skb->cb))->speed : 9600 \
231 #if 0
232 extern inline __u32 irda_get_speed(struct sk_buff *skb)
234 __u32 speed;
236 if (((struct irda_skb_cb *)(skb->cb))->magic != LAP_MAGIC)
237 speed = 9600;
238 else
239 speed = ((struct irda_skb_cb *)(skb->cb))->speed;
241 return speed;
243 #endif
245 #endif /* IRDA_DEVICE_H */