1 /* $NetBSD: uirdavar.h,v 1.3 2008/04/28 20:23:59 martin Exp $ */
4 * Copyright (c) 2001,2007 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart@augustsson.net).
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 * Protocol related definitions
35 #define UIRDA_INPUT_HEADER_SIZE 1
36 /* Inbound header byte */
37 #define UIRDA_MEDIA_BUSY 0x80
38 #define UIRDA_SPEED_MASK 0x0f
39 #define UIRDA_NO_SPEED 0x00
40 #define UIRDA_2400 0x01
41 #define UIRDA_9600 0x02
42 #define UIRDA_19200 0x03
43 #define UIRDA_38400 0x04
44 #define UIRDA_57600 0x05
45 #define UIRDA_115200 0x06
46 #define UIRDA_576000 0x07
47 #define UIRDA_1152000 0x08
48 #define UIRDA_4000000 0x09
50 #define UIRDA_OUTPUT_HEADER_SIZE 1
51 /* Outbound header byte */
52 #define UIRDA_EB_NO_CHANGE 0x00
53 #define UIRDA_EB_48 0x10
54 #define UIRDA_EB_24 0x20
55 #define UIRDA_EB_12 0x30
56 #define UIRDA_EB_6 0x40
57 #define UIRDA_EB_3 0x50
58 #define UIRDA_EB_2 0x60
59 #define UIRDA_EB_1 0x70
60 #define UIRDA_EB_0 0x80
63 #define UIRDA_WR_TIMEOUT 200
67 uByte bDescriptorType
;
68 #define UDESC_IRDA 0x21
69 uWord bcdSpecRevision
;
71 #define UI_DS_2048 0x20
72 #define UI_DS_1024 0x10
73 #define UI_DS_512 0x08
74 #define UI_DS_256 0x04
75 #define UI_DS_128 0x02
85 uByte bmMinTurnaroundTime
;
89 #define UI_TA_100 0x10
90 #define UI_TA_500 0x08
91 #define UI_TA_1000 0x04
92 #define UI_TA_5000 0x02
93 #define UI_TA_10000 0x01
95 #define UI_BR_4000000 0x0100
96 #define UI_BR_1152000 0x0080
97 #define UI_BR_576000 0x0040
98 #define UI_BR_115200 0x0020
99 #define UI_BR_57600 0x0010
100 #define UI_BR_38400 0x0008
101 #define UI_BR_19200 0x0004
102 #define UI_BR_9600 0x0002
103 #define UI_BR_2400 0x0001
104 uByte bmAdditionalBOFs
;
110 #define UI_EB_12 0x04
111 #define UI_EB_24 0x02
112 #define UI_EB_48 0x01
114 uByte bMaxUnicastList
;
115 } UPACKED usb_irda_descriptor_t
;
116 #define USB_IRDA_DESCRIPTOR_SIZE 12
120 USBBASEDEVICE sc_dev
;
121 usbd_device_handle sc_udev
;
122 usbd_interface_handle sc_iface
;
124 kmutex_t sc_rd_buf_lk
;
127 usbd_pipe_handle sc_rd_pipe
;
128 usbd_xfer_handle sc_rd_xfer
;
129 struct selinfo sc_rd_sel
;
133 kmutex_t sc_wr_buf_lk
;
136 usbd_xfer_handle sc_wr_xfer
;
137 usbd_pipe_handle sc_wr_pipe
;
139 struct selinfo sc_wr_sel
;
142 struct irda_params sc_params
;
143 usb_irda_descriptor_t sc_irdadesc
;
147 u_int8_t sc_hdszi
; /* set to value if != 1 needed */
149 int (*sc_loadfw
)(struct uirda_softc
*);
150 struct irframe_methods
*sc_irm
;
153 usbd_status
usbd_get_class_desc(usbd_device_handle
, int type
, int index
,
154 int len
, void *desc
);
156 int uirda_open(void *h
, int flag
, int mode
, struct lwp
*l
);
157 int uirda_close(void *h
, int flag
, int mode
, struct lwp
*l
);
158 int uirda_read(void *h
, struct uio
*uio
, int flag
);
159 int uirda_write(void *h
, struct uio
*uio
, int flag
);
160 int uirda_set_params(void *h
, struct irda_params
*params
);
161 int uirda_get_speeds(void *h
, int *speeds
);
162 int uirda_get_turnarounds(void *h
, int *times
);
163 int uirda_poll(void *h
, int events
, struct lwp
*l
);
164 int uirda_kqfilter(void *h
, struct knote
*kn
);