Home | History | Annotate | Line # | Download | only in usb
usbdi_util.h revision 1.49.6.1
      1  1.49.6.1        ad /*	$NetBSD: usbdi_util.h,v 1.49.6.1 2020/02/29 20:19:17 ad Exp $	*/
      2       1.1  augustss 
      3       1.1  augustss /*
      4      1.32   mycroft  * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
      5       1.1  augustss  * All rights reserved.
      6       1.1  augustss  *
      7       1.5  augustss  * This code is derived from software contributed to The NetBSD Foundation
      8      1.20  augustss  * by Lennart Augustsson (lennart (at) augustsson.net) at
      9       1.5  augustss  * Carlstedt Research & Technology.
     10       1.1  augustss  *
     11       1.1  augustss  * Redistribution and use in source and binary forms, with or without
     12       1.1  augustss  * modification, are permitted provided that the following conditions
     13       1.1  augustss  * are met:
     14       1.1  augustss  * 1. Redistributions of source code must retain the above copyright
     15       1.1  augustss  *    notice, this list of conditions and the following disclaimer.
     16       1.1  augustss  * 2. Redistributions in binary form must reproduce the above copyright
     17       1.1  augustss  *    notice, this list of conditions and the following disclaimer in the
     18       1.1  augustss  *    documentation and/or other materials provided with the distribution.
     19       1.1  augustss  *
     20       1.1  augustss  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21       1.1  augustss  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22       1.1  augustss  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23       1.1  augustss  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24       1.1  augustss  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25       1.1  augustss  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26       1.1  augustss  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27       1.1  augustss  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28       1.1  augustss  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29       1.1  augustss  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30       1.1  augustss  * POSSIBILITY OF SUCH DAMAGE.
     31       1.1  augustss  */
     32       1.1  augustss 
     33      1.38     joerg #ifndef _USBDI_UTIL_H_
     34      1.38     joerg #define _USBDI_UTIL_H_
     35      1.38     joerg 
     36      1.39     joerg #include <dev/usb/usbhid.h>
     37      1.38     joerg 
     38  1.49.6.1        ad usbd_status	usbd_get_desc(struct usbd_device *, int, int, int, void *);
     39      1.47     skrll usbd_status	usbd_get_config_desc(struct usbd_device *, int,
     40  1.49.6.1        ad 		    usb_config_descriptor_t *);
     41  1.49.6.1        ad usbd_status	usbd_get_config_desc_full(struct usbd_device *, int, void *,
     42  1.49.6.1        ad 		    int);
     43      1.47     skrll usbd_status	usbd_get_bos_desc(struct usbd_device *, int,
     44  1.49.6.1        ad 		    usb_bos_descriptor_t *);
     45      1.47     skrll usbd_status	usbd_get_bos_desc_full(struct usbd_device *, int, void *, int);
     46      1.47     skrll usbd_status	usbd_get_device_desc(struct usbd_device *,
     47  1.49.6.1        ad 		    usb_device_descriptor_t *);
     48  1.49.6.1        ad usbd_status	usbd_get_initial_ddesc(struct usbd_device *,
     49  1.49.6.1        ad 		    usb_device_descriptor_t *);
     50  1.49.6.1        ad usbd_status	usbd_get_string_desc(struct usbd_device *, int, int,
     51  1.49.6.1        ad 		    usb_string_descriptor_t *, int *);
     52  1.49.6.1        ad 
     53  1.49.6.1        ad usbd_status	usbd_get_device_status(struct usbd_device *, usb_status_t *);
     54  1.49.6.1        ad usbd_status	usbd_get_hub_status(struct usbd_device *, usb_hub_status_t *);
     55  1.49.6.1        ad usbd_status	usbd_get_port_status(struct usbd_device *, int,
     56  1.49.6.1        ad 		    usb_port_status_t *);
     57  1.49.6.1        ad usbd_status	usbd_get_port_status_ext(struct usbd_device *, int,
     58  1.49.6.1        ad 		    usb_port_status_ext_t *);
     59  1.49.6.1        ad 
     60  1.49.6.1        ad usbd_status	usbd_get_desc_fake(struct usbd_device *, int, int, int, void *);
     61  1.49.6.1        ad 
     62      1.47     skrll usbd_status	usbd_clear_hub_feature(struct usbd_device *, int);
     63  1.49.6.1        ad usbd_status	usbd_set_hub_feature(struct usbd_device *, int);
     64      1.47     skrll usbd_status	usbd_clear_port_feature(struct usbd_device *, int, int);
     65  1.49.6.1        ad usbd_status	usbd_set_port_feature(struct usbd_device *, int, int);
     66      1.47     skrll usbd_status	usbd_set_port_u1_timeout(struct usbd_device *, int, int);
     67      1.47     skrll usbd_status	usbd_set_port_u2_timeout(struct usbd_device *, int, int);
     68  1.49.6.1        ad usbd_status	usbd_clear_endpoint_feature(struct usbd_device *, int, int);
     69  1.49.6.1        ad 
     70  1.49.6.1        ad usbd_status	usbd_get_config(struct usbd_device *, uint8_t *);
     71  1.49.6.1        ad usbd_status	usbd_set_config(struct usbd_device *, int);
     72  1.49.6.1        ad usbd_status	usbd_set_address(struct usbd_device *, int);
     73  1.49.6.1        ad usbd_status	usbd_set_idle(struct usbd_interface *, int, int);
     74  1.49.6.1        ad 
     75      1.47     skrll usbd_status	usbd_get_protocol(struct usbd_interface *, uint8_t *);
     76      1.47     skrll usbd_status	usbd_set_protocol(struct usbd_interface *, int);
     77      1.47     skrll 
     78  1.49.6.1        ad usbd_status	usbd_set_report(struct usbd_interface *, int, int, void *, int);
     79  1.49.6.1        ad usbd_status	usbd_get_report(struct usbd_interface *, int, int, void *, int);
     80  1.49.6.1        ad usbd_status	usbd_get_report_descriptor(struct usbd_device *, int, int,
     81  1.49.6.1        ad 		    void *);
     82  1.49.6.1        ad 
     83  1.49.6.1        ad usb_hid_descriptor_t *usbd_get_hid_descriptor(struct usbd_interface *);
     84  1.49.6.1        ad usbd_status	usbd_read_report_desc(struct usbd_interface *, void **, int *);
     85      1.47     skrll 
     86      1.47     skrll usbd_status	usbd_set_config_no(struct usbd_device *, int, int);
     87      1.47     skrll usbd_status	usbd_set_config_index(struct usbd_device *, int, int);
     88      1.47     skrll 
     89      1.47     skrll usbd_status	usbd_bulk_transfer(struct usbd_xfer *, struct usbd_pipe *,
     90  1.49.6.1        ad 		    uint16_t, uint32_t, void *, uint32_t *);
     91      1.47     skrll usbd_status	usbd_intr_transfer(struct usbd_xfer *, struct usbd_pipe *,
     92      1.47     skrll 		    uint16_t, uint32_t, void *, uint32_t *);
     93      1.31  augustss 
     94      1.42       mrg void usb_detach_waitold(device_t);
     95      1.42       mrg void usb_detach_wakeupold(device_t);
     96      1.25  augustss 
     97      1.36  drochner typedef struct {
     98      1.36  drochner 	uByte		bLength;
     99      1.36  drochner 	uByte		bDescriptorType;
    100      1.36  drochner 	uByte		bDescriptorSubtype;
    101      1.36  drochner } UPACKED usb_cdc_descriptor_t;
    102      1.36  drochner 
    103  1.49.6.1        ad /* An iterator for descriptors. */
    104  1.49.6.1        ad typedef struct {
    105  1.49.6.1        ad 	const uByte *cur;
    106  1.49.6.1        ad 	const uByte *end;
    107  1.49.6.1        ad } usbd_desc_iter_t;
    108  1.49.6.1        ad void usb_desc_iter_init(struct usbd_device *, usbd_desc_iter_t *);
    109  1.49.6.1        ad const usb_descriptor_t *usb_desc_iter_peek(usbd_desc_iter_t *);
    110  1.49.6.1        ad const usb_descriptor_t *usb_desc_iter_next(usbd_desc_iter_t *);
    111  1.49.6.1        ad const usb_interface_descriptor_t *usb_desc_iter_next_interface(usbd_desc_iter_t *);
    112  1.49.6.1        ad const usb_descriptor_t *usb_desc_iter_next_non_interface(usbd_desc_iter_t *);
    113  1.49.6.1        ad 
    114      1.47     skrll const usb_cdc_descriptor_t *usb_find_desc(struct usbd_device *, int,
    115      1.47     skrll 				      int);
    116      1.47     skrll const usb_cdc_descriptor_t *usb_find_desc_if(struct usbd_device *, int,
    117      1.47     skrll 					 int,
    118      1.47     skrll 					 usb_interface_descriptor_t *);
    119      1.36  drochner #define USBD_CDCSUBTYPE_ANY (~0)
    120      1.30  augustss 
    121      1.38     joerg #endif /* _USBDI_UTIL_H_ */
    122