File: irda_device.h

package info (click to toggle)
kernel-source-2.2.1 2.2.1-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 61,788 kB
  • ctags: 188,316
  • sloc: ansic: 1,114,164; asm: 49,922; makefile: 8,185; sh: 1,745; perl: 856; tcl: 409; lisp: 218; cpp: 186; awk: 133; sed: 72
file content (153 lines) | stat: -rw-r--r-- 4,813 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*********************************************************************
 *                
 * Filename:      irda_device.h
 * Version:       
 * Description:   
 * Status:        Experimental.
 * Author:        Haris Zukanovic <haris@stud.cs.uit.no>
 * Created at:    Tue Apr 14 12:41:42 1998
 * Modified at:   Mon Jan 18 10:52:10 1999
 * Modified by:   Dag Brattli <dagb@cs.uit.no>
 * 
 *     Copyright (c) 1998 Haris Zukanovic, <haris@stud.cs.uit.no>
 *     Copyright (c) 1998 Dag Brattli, <dagb@cs.uit.no>
 *     Copyright (c) 1998 Thomas Davis, <ratbert@radiks.net>,
 *     All Rights Reserved.
 *      
 *     This program is free software; you can redistribute it and/or 
 *     modify it under the terms of the GNU General Public License as 
 *     published by the Free Software Foundation; either version 2 of 
 *     the License, or (at your option) any later version.
 *  
 *     Neither Haris Zukanovic nor University of Troms admit liability nor
 *     provide warranty for any of this software. This material is 
 *     provided "AS-IS" and at no charge.
 *     
 ********************************************************************/

#ifndef IRDA_DEVICE_H
#define IRDA_DEVICE_H

#include <linux/tty.h>
#include <linux/netdevice.h>

#include <net/irda/irda.h>
#include <net/irda/qos.h>
#include <net/irda/irqueue.h>

#define SIR_MODE 	0x01
#define MIR_MODE 	0x02
#define FIR_MODE 	0x04
#define IO_PIO   	0x08
#define IO_DMA		0x10

#define IO_XMIT 0x01
#define IO_RECV 0x02

/* Chip specific info */
struct chipio_t {
        int iobase, iobase2;  /* IO base */
        int io_ext, io_ext2;  /* Length of iobase */
        int irq, irq2;        /* Interrupts used */
        int fifo_size;        /* FIFO size */

        int dma, dma2;        /* DMA channel used */
        int irqflags;         /* interrupt flags (ie, SA_SHIRQ|SA_INTERRUPT) */
	int direction;        /* Used by some FIR drivers */

	int baudrate;         /* Currently used baudrate */
	int dongle_id;        /* Dongle or transceiver currently used */
};

/* Buffer specific info */
struct iobuff_t {
	int state;            /* Receiving state (transmit state not used) */
	int in_frame;         /* True if receiving frame */

	__u8 *data;	      /* the buffer */
	__u8 *head;	      /* start of data in buffer */
	__u8 *tail;           /* end of data in buffer */

	int offset;	      /* Usually data + offset = head */
	int len;	      /* currently used bytes in buffer */
	int truesize;	      /* total size of the data area */
	__u16 fcs;

	int flags;            /* Allocation flags (GFP_KERNEL | GFP_DMA ) */
};

/* 
 * This structure contains data that _we_ would have liked to be in the device
 * structure, but we don't want to mess it up more than it is already. Better 
 * to keep the data in separate structures! This structure abstracts common 
 * stuff from IrDA port implementations.
 */
struct irda_device {
	QUEUE q; /* Must be first */

        int  magic;	       /* Our magic bullet */
	char name[16];         /* Name of device "irda0" */
	char description[32];  /* Something like "irda0 <-> ttyS0" */

	struct irlap_cb *irlap; /* The link layer we are connected to  */
	struct device netdev;   /* Yes! we are some kind of netdevice */
	struct enet_statistics stats;

/* 	int flags; */

 	void *priv;           /* Pointer to low level implementation */

	struct qos_info qos;  /* QoS capabilities for this device */

	struct chipio_t io;
	struct iobuff_t tx_buff;
	struct iobuff_t rx_buff;

	int media_busy;
	
	/* Media busy stuff */
	struct timer_list media_busy_timer;
	struct timer_list todo_timer;

	int  (*hard_xmit)( struct sk_buff *skb, struct device *dev);
        void (*change_speed)( struct irda_device *driver, int baud);

 	int (*is_receiving)(struct irda_device *);     /* receiving? */
	/* int (*is_tbusy)(struct irda_device *); */   /* transmitting? */
	void (*wait_until_sent)(struct irda_device *);

	int new_speed; /* Will be removed in future */
};

extern hashbin_t *irda_device;

/* Function prototypes */
int  irda_device_init( void);
void irda_device_cleanup( void);

int  irda_device_open( struct irda_device *, char *name, void *priv);
void irda_device_close( struct irda_device *);

/* Interface to be uses by IrLAP */
inline void irda_device_set_media_busy( struct irda_device *, int status);
inline int  irda_device_is_media_busy( struct irda_device *);
inline int  irda_device_is_receiving( struct irda_device *);
inline void irda_device_change_speed( struct irda_device *, int);

inline struct qos_info *irda_device_get_qos( struct irda_device *self);
int irda_device_txqueue_empty( struct irda_device *self);

int irda_device_setup( struct device *dev);

__inline__ int irda_get_mtt( struct sk_buff *skb);

void setup_dma( int channel, char *buffer, int count, int mode);

#endif