Home | History | Annotate | Line # | Download | only in usb
      1  1.8  thorpej /*	$NetBSD: uirdavar.h,v 1.8 2021/09/26 15:08:29 thorpej 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  *
     19  1.1       is  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.1       is  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.1       is  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.1       is  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.1       is  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.1       is  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.1       is  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.1       is  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.1       is  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.1       is  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.1       is  * POSSIBILITY OF SUCH DAMAGE.
     30  1.1       is  */
     31  1.1       is /*
     32  1.1       is  * Protocol related definitions
     33  1.1       is  */
     34  1.1       is 
     35  1.1       is #define UIRDA_INPUT_HEADER_SIZE 1
     36  1.1       is /* Inbound header byte */
     37  1.1       is #define UIRDA_MEDIA_BUSY	0x80
     38  1.1       is #define UIRDA_SPEED_MASK	0x0f
     39  1.1       is #define UIRDA_NO_SPEED		0x00
     40  1.1       is #define UIRDA_2400		0x01
     41  1.1       is #define UIRDA_9600		0x02
     42  1.1       is #define UIRDA_19200		0x03
     43  1.1       is #define UIRDA_38400		0x04
     44  1.1       is #define UIRDA_57600		0x05
     45  1.1       is #define UIRDA_115200		0x06
     46  1.1       is #define UIRDA_576000		0x07
     47  1.1       is #define UIRDA_1152000		0x08
     48  1.1       is #define UIRDA_4000000		0x09
     49  1.1       is 
     50  1.1       is #define UIRDA_OUTPUT_HEADER_SIZE 1
     51  1.1       is /* Outbound header byte */
     52  1.1       is #define UIRDA_EB_NO_CHANGE	0x00
     53  1.1       is #define UIRDA_EB_48		0x10
     54  1.1       is #define UIRDA_EB_24		0x20
     55  1.1       is #define UIRDA_EB_12		0x30
     56  1.1       is #define UIRDA_EB_6		0x40
     57  1.1       is #define UIRDA_EB_3		0x50
     58  1.1       is #define UIRDA_EB_2		0x60
     59  1.1       is #define UIRDA_EB_1		0x70
     60  1.1       is #define UIRDA_EB_0		0x80
     61  1.1       is /* Speeds as above */
     62  1.1       is 
     63  1.1       is #define UIRDA_WR_TIMEOUT 200
     64  1.1       is 
     65  1.1       is typedef struct {
     66  1.1       is 	uByte		bLength;
     67  1.1       is 	uByte		bDescriptorType;
     68  1.1       is #define UDESC_IRDA	0x21
     69  1.1       is 	uWord		bcdSpecRevision;
     70  1.1       is 	uByte		bmDataSize;
     71  1.1       is #define UI_DS_2048	0x20
     72  1.1       is #define UI_DS_1024	0x10
     73  1.1       is #define UI_DS_512	0x08
     74  1.1       is #define UI_DS_256	0x04
     75  1.1       is #define UI_DS_128	0x02
     76  1.1       is #define UI_DS_64	0x01
     77  1.1       is 	uByte		bmWindowSize;
     78  1.1       is #define UI_WS_7		0x40
     79  1.1       is #define UI_WS_6		0x20
     80  1.1       is #define UI_WS_5		0x10
     81  1.1       is #define UI_WS_4		0x08
     82  1.1       is #define UI_WS_3		0x04
     83  1.1       is #define UI_WS_2		0x02
     84  1.1       is #define UI_WS_1		0x01
     85  1.1       is 	uByte		bmMinTurnaroundTime;
     86  1.1       is #define UI_TA_0		0x80
     87  1.1       is #define UI_TA_10	0x40
     88  1.1       is #define UI_TA_50	0x20
     89  1.1       is #define UI_TA_100	0x10
     90  1.1       is #define UI_TA_500	0x08
     91  1.1       is #define UI_TA_1000	0x04
     92  1.1       is #define UI_TA_5000	0x02
     93  1.1       is #define UI_TA_10000	0x01
     94  1.1       is 	uWord		wBaudRate;
     95  1.1       is #define UI_BR_4000000	0x0100
     96  1.1       is #define UI_BR_1152000	0x0080
     97  1.1       is #define UI_BR_576000	0x0040
     98  1.1       is #define UI_BR_115200	0x0020
     99  1.1       is #define UI_BR_57600	0x0010
    100  1.1       is #define UI_BR_38400	0x0008
    101  1.1       is #define UI_BR_19200	0x0004
    102  1.1       is #define UI_BR_9600	0x0002
    103  1.1       is #define UI_BR_2400	0x0001
    104  1.1       is 	uByte		bmAdditionalBOFs;
    105  1.1       is #define UI_EB_0		0x80
    106  1.1       is #define UI_EB_1		0x40
    107  1.1       is #define UI_EB_2		0x20
    108  1.1       is #define UI_EB_3		0x10
    109  1.1       is #define UI_EB_6		0x08
    110  1.1       is #define UI_EB_12	0x04
    111  1.1       is #define UI_EB_24	0x02
    112  1.1       is #define UI_EB_48	0x01
    113  1.1       is 	uByte		bIrdaSniff;
    114  1.1       is 	uByte		bMaxUnicastList;
    115  1.1       is } UPACKED usb_irda_descriptor_t;
    116  1.1       is #define USB_IRDA_DESCRIPTOR_SIZE 12
    117  1.1       is 
    118  1.1       is 
    119  1.1       is struct uirda_softc {
    120  1.7    skrll 	device_t		sc_dev;
    121  1.6    skrll 	struct usbd_device 	*sc_udev;
    122  1.6    skrll 	struct usbd_interface	*sc_iface;
    123  1.1       is 
    124  1.2       ad 	kmutex_t		sc_rd_buf_lk;
    125  1.6    skrll 	uint8_t			*sc_rd_buf;
    126  1.1       is 	int			sc_rd_addr;
    127  1.6    skrll 	struct usbd_pipe	*sc_rd_pipe;
    128  1.6    skrll 	struct usbd_xfer	*sc_rd_xfer;
    129  1.1       is 	struct selinfo		sc_rd_sel;
    130  1.1       is 	u_int			sc_rd_count;
    131  1.1       is 	u_char			sc_rd_err;
    132  1.1       is 
    133  1.2       ad 	kmutex_t		sc_wr_buf_lk;
    134  1.6    skrll 	uint8_t			*sc_wr_buf;
    135  1.1       is 	int			sc_wr_addr;
    136  1.6    skrll 	struct usbd_xfer	*sc_wr_xfer;
    137  1.6    skrll 	struct usbd_pipe	*sc_wr_pipe;
    138  1.1       is 	int			sc_wr_hdr;
    139  1.1       is 
    140  1.4     cube 	device_t		sc_child;
    141  1.1       is 	struct irda_params	sc_params;
    142  1.1       is 	usb_irda_descriptor_t	sc_irdadesc;
    143  1.1       is 
    144  1.1       is 	int			sc_refcnt;
    145  1.1       is 	char			sc_dying;
    146  1.6    skrll 	uint8_t		sc_hdszi; /* set to value if != 1 needed */
    147  1.1       is 
    148  1.1       is 	int			(*sc_loadfw)(struct uirda_softc *);
    149  1.1       is 	struct irframe_methods	*sc_irm;
    150  1.1       is };
    151  1.1       is 
    152  1.6    skrll usbd_status usbd_get_class_desc(struct usbd_device *, int, int, int, void *);
    153  1.1       is 
    154  1.6    skrll int uirda_open(void *, int, int, struct lwp *);
    155  1.6    skrll int uirda_close(void *, int, int, struct lwp *);
    156  1.6    skrll int uirda_read(void *, struct uio *, int);
    157  1.6    skrll int uirda_write(void *, struct uio *, int);
    158  1.6    skrll int uirda_set_params(void *, struct irda_params *);
    159  1.6    skrll int uirda_get_speeds(void *, int *);
    160  1.6    skrll int uirda_get_turnarounds(void *, int *);
    161  1.6    skrll int uirda_poll(void *, int, struct lwp *);
    162  1.6    skrll int uirda_kqfilter(void *, struct knote *);
    163