uirdavar.h revision 1.1 1 1.1 is /* $NetBSD: uirdavar.h,v 1.1 2007/04/27 14:42:49 is Exp $ */
2 1.1 is
3 1.1 is /*
4 1.1 is * Copyright (c) 2001,2007 The NetBSD Foundation, Inc.
5 1.1 is * All rights reserved.
6 1.1 is *
7 1.1 is * This code is derived from software contributed to The NetBSD Foundation
8 1.1 is * by Lennart Augustsson (lennart (at) augustsson.net).
9 1.1 is *
10 1.1 is * Redistribution and use in source and binary forms, with or without
11 1.1 is * modification, are permitted provided that the following conditions
12 1.1 is * are met:
13 1.1 is * 1. Redistributions of source code must retain the above copyright
14 1.1 is * notice, this list of conditions and the following disclaimer.
15 1.1 is * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 is * notice, this list of conditions and the following disclaimer in the
17 1.1 is * documentation and/or other materials provided with the distribution.
18 1.1 is * 3. All advertising materials mentioning features or use of this software
19 1.1 is * must display the following acknowledgement:
20 1.1 is * This product includes software developed by the NetBSD
21 1.1 is * Foundation, Inc. and its contributors.
22 1.1 is * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 is * contributors may be used to endorse or promote products derived
24 1.1 is * from this software without specific prior written permission.
25 1.1 is *
26 1.1 is * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 is * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 is * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 is * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 is * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 is * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 is * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 is * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 is * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 is * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 is * POSSIBILITY OF SUCH DAMAGE.
37 1.1 is */
38 1.1 is /*
39 1.1 is * Protocol related definitions
40 1.1 is */
41 1.1 is
42 1.1 is #define UIRDA_INPUT_HEADER_SIZE 1
43 1.1 is /* Inbound header byte */
44 1.1 is #define UIRDA_MEDIA_BUSY 0x80
45 1.1 is #define UIRDA_SPEED_MASK 0x0f
46 1.1 is #define UIRDA_NO_SPEED 0x00
47 1.1 is #define UIRDA_2400 0x01
48 1.1 is #define UIRDA_9600 0x02
49 1.1 is #define UIRDA_19200 0x03
50 1.1 is #define UIRDA_38400 0x04
51 1.1 is #define UIRDA_57600 0x05
52 1.1 is #define UIRDA_115200 0x06
53 1.1 is #define UIRDA_576000 0x07
54 1.1 is #define UIRDA_1152000 0x08
55 1.1 is #define UIRDA_4000000 0x09
56 1.1 is
57 1.1 is #define UIRDA_OUTPUT_HEADER_SIZE 1
58 1.1 is /* Outbound header byte */
59 1.1 is #define UIRDA_EB_NO_CHANGE 0x00
60 1.1 is #define UIRDA_EB_48 0x10
61 1.1 is #define UIRDA_EB_24 0x20
62 1.1 is #define UIRDA_EB_12 0x30
63 1.1 is #define UIRDA_EB_6 0x40
64 1.1 is #define UIRDA_EB_3 0x50
65 1.1 is #define UIRDA_EB_2 0x60
66 1.1 is #define UIRDA_EB_1 0x70
67 1.1 is #define UIRDA_EB_0 0x80
68 1.1 is /* Speeds as above */
69 1.1 is
70 1.1 is #define UIRDA_WR_TIMEOUT 200
71 1.1 is
72 1.1 is typedef struct {
73 1.1 is uByte bLength;
74 1.1 is uByte bDescriptorType;
75 1.1 is #define UDESC_IRDA 0x21
76 1.1 is uWord bcdSpecRevision;
77 1.1 is uByte bmDataSize;
78 1.1 is #define UI_DS_2048 0x20
79 1.1 is #define UI_DS_1024 0x10
80 1.1 is #define UI_DS_512 0x08
81 1.1 is #define UI_DS_256 0x04
82 1.1 is #define UI_DS_128 0x02
83 1.1 is #define UI_DS_64 0x01
84 1.1 is uByte bmWindowSize;
85 1.1 is #define UI_WS_7 0x40
86 1.1 is #define UI_WS_6 0x20
87 1.1 is #define UI_WS_5 0x10
88 1.1 is #define UI_WS_4 0x08
89 1.1 is #define UI_WS_3 0x04
90 1.1 is #define UI_WS_2 0x02
91 1.1 is #define UI_WS_1 0x01
92 1.1 is uByte bmMinTurnaroundTime;
93 1.1 is #define UI_TA_0 0x80
94 1.1 is #define UI_TA_10 0x40
95 1.1 is #define UI_TA_50 0x20
96 1.1 is #define UI_TA_100 0x10
97 1.1 is #define UI_TA_500 0x08
98 1.1 is #define UI_TA_1000 0x04
99 1.1 is #define UI_TA_5000 0x02
100 1.1 is #define UI_TA_10000 0x01
101 1.1 is uWord wBaudRate;
102 1.1 is #define UI_BR_4000000 0x0100
103 1.1 is #define UI_BR_1152000 0x0080
104 1.1 is #define UI_BR_576000 0x0040
105 1.1 is #define UI_BR_115200 0x0020
106 1.1 is #define UI_BR_57600 0x0010
107 1.1 is #define UI_BR_38400 0x0008
108 1.1 is #define UI_BR_19200 0x0004
109 1.1 is #define UI_BR_9600 0x0002
110 1.1 is #define UI_BR_2400 0x0001
111 1.1 is uByte bmAdditionalBOFs;
112 1.1 is #define UI_EB_0 0x80
113 1.1 is #define UI_EB_1 0x40
114 1.1 is #define UI_EB_2 0x20
115 1.1 is #define UI_EB_3 0x10
116 1.1 is #define UI_EB_6 0x08
117 1.1 is #define UI_EB_12 0x04
118 1.1 is #define UI_EB_24 0x02
119 1.1 is #define UI_EB_48 0x01
120 1.1 is uByte bIrdaSniff;
121 1.1 is uByte bMaxUnicastList;
122 1.1 is } UPACKED usb_irda_descriptor_t;
123 1.1 is #define USB_IRDA_DESCRIPTOR_SIZE 12
124 1.1 is
125 1.1 is
126 1.1 is struct uirda_softc {
127 1.1 is USBBASEDEVICE sc_dev;
128 1.1 is usbd_device_handle sc_udev;
129 1.1 is usbd_interface_handle sc_iface;
130 1.1 is
131 1.1 is struct lock sc_rd_buf_lk;
132 1.1 is u_int8_t *sc_rd_buf;
133 1.1 is int sc_rd_addr;
134 1.1 is usbd_pipe_handle sc_rd_pipe;
135 1.1 is usbd_xfer_handle sc_rd_xfer;
136 1.1 is struct selinfo sc_rd_sel;
137 1.1 is u_int sc_rd_count;
138 1.1 is u_char sc_rd_err;
139 1.1 is
140 1.1 is struct lock sc_wr_buf_lk;
141 1.1 is u_int8_t *sc_wr_buf;
142 1.1 is int sc_wr_addr;
143 1.1 is usbd_xfer_handle sc_wr_xfer;
144 1.1 is usbd_pipe_handle sc_wr_pipe;
145 1.1 is int sc_wr_hdr;
146 1.1 is struct selinfo sc_wr_sel;
147 1.1 is
148 1.1 is struct device *sc_child;
149 1.1 is struct irda_params sc_params;
150 1.1 is usb_irda_descriptor_t sc_irdadesc;
151 1.1 is
152 1.1 is int sc_refcnt;
153 1.1 is char sc_dying;
154 1.1 is u_int8_t sc_hdszi; /* set to value if != 1 needed */
155 1.1 is
156 1.1 is int (*sc_loadfw)(struct uirda_softc *);
157 1.1 is struct irframe_methods *sc_irm;
158 1.1 is };
159 1.1 is
160 1.1 is usbd_status usbd_get_class_desc(usbd_device_handle, int type, int index,
161 1.1 is int len, void *desc);
162 1.1 is
163 1.1 is int uirda_open(void *h, int flag, int mode, struct lwp *l);
164 1.1 is int uirda_close(void *h, int flag, int mode, struct lwp *l);
165 1.1 is int uirda_read(void *h, struct uio *uio, int flag);
166 1.1 is int uirda_write(void *h, struct uio *uio, int flag);
167 1.1 is int uirda_set_params(void *h, struct irda_params *params);
168 1.1 is int uirda_get_speeds(void *h, int *speeds);
169 1.1 is int uirda_get_turnarounds(void *h, int *times);
170 1.1 is int uirda_poll(void *h, int events, struct lwp *l);
171 1.1 is int uirda_kqfilter(void *h, struct knote *kn);
172