00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef IRDA_DEVICE_H
00033 #define IRDA_DEVICE_H
00034
00035 #include <linux/tty.h>
00036 #include <linux/netdevice.h>
00037 #include <asm/spinlock.h>
00038 #include <linux/irda.h>
00039
00040 #include <net/irda/irda.h>
00041 #include <net/irda/qos.h>
00042 #include <net/irda/irqueue.h>
00043 #include <net/irda/irlap_frame.h>
00044
00045
00046 #define IFF_SIR 0x0001
00047 #define IFF_MIR 0x0002
00048 #define IFF_FIR 0x0004
00049 #define IFF_VFIR 0x0008
00050 #define IFF_PIO 0x0010
00051 #define IFF_DMA 0x0020
00052 #define IFF_SHM 0x0040
00053 #define IFF_DONGLE 0x0080
00054 #define IFF_AIR 0x0100
00055
00056 #define IO_XMIT 0x01
00057 #define IO_RECV 0x02
00058
00059 typedef enum {
00060 IRDA_IRLAP,
00061 IRDA_RAW,
00062 SHARP_ASK,
00063 TV_REMOTE,
00064 } INFRARED_MODE;
00065
00066 typedef enum {
00067 IRDA_TASK_INIT,
00068 IRDA_TASK_DONE,
00069 IRDA_TASK_WAIT,
00070 IRDA_TASK_WAIT1,
00071 IRDA_TASK_WAIT2,
00072 IRDA_TASK_WAIT3,
00073 IRDA_TASK_CHILD_INIT,
00074 IRDA_TASK_CHILD_WAIT,
00075 IRDA_TASK_CHILD_DONE
00076 } TASK_STATE;
00077
00078 struct irda_task;
00079 typedef int (*TASK_CALLBACK) (struct irda_task *task);
00080
00081 struct irda_task {
00082 queue_t q;
00083 magic_t magic;
00084
00085 TASK_STATE state;
00086 TASK_CALLBACK function;
00087 TASK_CALLBACK finished;
00088
00089 struct irda_task *parent;
00090 struct timer_list timer;
00091
00092 void *instance;
00093 void *param;
00094 };
00095
00096
00097 struct dongle_reg;
00098 typedef struct {
00099 struct dongle_reg *issue;
00100 struct device *dev;
00101 struct irda_task *speed_task;
00102 struct irda_task *reset_task;
00103 __u32 speed;
00104
00105
00106 int (*set_mode)(struct device *, int mode);
00107 int (*read)(struct device *dev, __u8 *buf, int len);
00108 int (*write)(struct device *dev, __u8 *buf, int len);
00109 int (*set_dtr_rts)(struct device *dev, int dtr, int rts);
00110 } dongle_t;
00111
00112
00113 struct dongle_reg {
00114 queue_t q;
00115 IRDA_DONGLE type;
00116
00117 void (*open)(dongle_t *dongle, struct qos_info *qos);
00118 void (*close)(dongle_t *dongle);
00119 int (*reset)(struct irda_task *task);
00120 int (*change_speed)(struct irda_task *task);
00121 };
00122
00123
00124 typedef struct {
00125 int cfg_base;
00126 int sir_base;
00127 int fir_base;
00128 int mem_base;
00129 int sir_ext;
00130 int fir_ext;
00131 int irq, irq2;
00132 int dma, dma2;
00133 int fifo_size;
00134 int irqflags;
00135 int direction;
00136 int enabled;
00137 int suspended;
00138 __u32 speed;
00139 __u32 new_speed;
00140 int dongle_id;
00141 } chipio_t;
00142
00143
00144 typedef struct {
00145 int state;
00146 int in_frame;
00147
00148 __u8 *head;
00149 __u8 *data;
00150 __u8 *tail;
00151
00152 int len;
00153 int truesize;
00154 __u16 fcs;
00155 } iobuff_t;
00156
00157
00158 int irda_device_init(void);
00159 void irda_device_cleanup(void);
00160
00161
00162 void irda_device_set_media_busy(struct device *dev, int status);
00163 int irda_device_is_media_busy(struct device *dev);
00164 int irda_device_is_receiving(struct device *dev);
00165
00166
00167 int irda_device_txqueue_empty(struct device *dev);
00168 int irda_device_set_raw_mode(struct device* self, int status);
00169 int irda_device_set_dtr_rts(struct device *dev, int dtr, int rts);
00170 int irda_device_change_speed(struct device *dev, __u32 speed);
00171 int irda_device_setup(struct device *dev);
00172
00173
00174 void irda_device_unregister_dongle(struct dongle_reg *dongle);
00175 int irda_device_register_dongle(struct dongle_reg *dongle);
00176 dongle_t *irda_device_dongle_init(struct device *dev, int type);
00177 int irda_device_dongle_cleanup(dongle_t *dongle);
00178
00179 void setup_dma(int channel, char *buffer, int count, int mode);
00180
00181 void irda_task_delete(struct irda_task *task);
00182 int irda_task_kick(struct irda_task *task);
00183 struct irda_task *irda_task_execute(void *instance, TASK_CALLBACK function,
00184 TASK_CALLBACK finished,
00185 struct irda_task *parent, void *param);
00186 void irda_task_next_state(struct irda_task *task, TASK_STATE state);
00187
00188 extern const char *infrared_mode[];
00189
00190
00191
00192
00193
00194
00195
00196 #define irda_get_mtt(skb) ( \
00197 IRDA_MIN(10000, \
00198 (((struct irda_skb_cb *) skb->cb)->magic == LAP_MAGIC) ? \
00199 ((struct irda_skb_cb *)(skb->cb))->mtt : 10000 \
00200 ) \
00201 )
00202
00203 #if 0
00204 extern inline __u16 irda_get_mtt(struct sk_buff *skb)
00205 {
00206 __u16 mtt;
00207
00208 if (((struct irda_skb_cb *)(skb->cb))->magic != LAP_MAGIC)
00209 mtt = 10000;
00210 else
00211 mtt = ((struct irda_skb_cb *)(skb->cb))->mtt;
00212
00213 ASSERT(mtt <= 10000, return 10000;);
00214
00215 return mtt;
00216 }
00217 #endif
00218
00219
00220
00221
00222
00223
00224
00225 #define irda_get_speed(skb) ( \
00226 (((struct irda_skb_cb*) skb->cb)->magic == LAP_MAGIC) ? \
00227 ((struct irda_skb_cb *)(skb->cb))->speed : 9600 \
00228 )
00229
00230 #if 0
00231 extern inline __u32 irda_get_speed(struct sk_buff *skb)
00232 {
00233 __u32 speed;
00234
00235 if (((struct irda_skb_cb *)(skb->cb))->magic != LAP_MAGIC)
00236 speed = 9600;
00237 else
00238 speed = ((struct irda_skb_cb *)(skb->cb))->speed;
00239
00240 return speed;
00241 }
00242 #endif
00243
00244 #endif
00245
00246