1 /*********************************************************************
3 * Filename: irda_device.h
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,
30 ********************************************************************/
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 */
60 IRDA_IRLAP, /* IrDA mode, and deliver to IrLAP */
61 IRDA_RAW, /* IrDA mode */
63 TV_REMOTE, /* Also known as Consumer Electronics IR */
67 IRDA_TASK_INIT, /* All tasks are initialized with this state */
68 IRDA_TASK_DONE, /* Signals that the task is finished */
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 */
79 typedef int (*IRDA_TASK_CALLBACK) (struct irda_task *task);
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 */
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);
112 /* Dongle registration info */
114 irda_queue_t q; /* Must be first */
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 */
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 */
143 /* IO buffer specific info (inspired by struct sk_buff) */
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 */
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) ( \
199 (((struct irda_skb_cb *) skb->cb)->magic == LAP_MAGIC) ? \
200 ((struct irda_skb_cb *)(skb->cb))->mtt : 10000 \
205 extern inline __u16 irda_get_mtt(struct sk_buff *skb)
209 if (((struct irda_skb_cb *)(skb->cb))->magic != LAP_MAGIC)
212 mtt = ((struct irda_skb_cb *)(skb->cb))->mtt;
214 ASSERT(mtt <= 10000, return 10000;);
221 * Function irda_get_next_speed (skb)
223 * Extract the speed that should be set *after* this frame from the skb
225 * Note : return -1 for user space frames
227 #define irda_get_next_speed(skb) ( \
228 (((struct irda_skb_cb*) skb->cb)->magic == LAP_MAGIC) ? \
229 ((struct irda_skb_cb *)(skb->cb))->next_speed : -1 \
233 extern inline __u32 irda_get_next_speed(struct sk_buff *skb)
237 if (((struct irda_skb_cb *)(skb->cb))->magic != LAP_MAGIC)
240 speed = ((struct irda_skb_cb *)(skb->cb))->next_speed;
247 * Function irda_get_next_xbofs (skb)
249 * Extract the xbofs that should be set for this frame from the skb
251 * Note : default to 10 for user space frames
253 #define irda_get_xbofs(skb) ( \
254 (((struct irda_skb_cb*) skb->cb)->magic == LAP_MAGIC) ? \
255 ((struct irda_skb_cb *)(skb->cb))->xbofs : 10 \
259 * Function irda_get_next_xbofs (skb)
261 * Extract the xbofs that should be set *after* this frame from the skb
263 * Note : return -1 for user space frames
265 #define irda_get_next_xbofs(skb) ( \
266 (((struct irda_skb_cb*) skb->cb)->magic == LAP_MAGIC) ? \
267 ((struct irda_skb_cb *)(skb->cb))->next_xbofs : -1 \
270 #endif /* IRDA_DEVICE_H */