xref: /freebsd/sys/dev/usb/usb_request.h (revision 71625ec9ad2a9bc8c09784fbd23b759830e0ee5f)
102ac6454SAndrew Thompson /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3718cf2ccSPedro F. Giffuni  *
402ac6454SAndrew Thompson  * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
502ac6454SAndrew Thompson  *
602ac6454SAndrew Thompson  * Redistribution and use in source and binary forms, with or without
702ac6454SAndrew Thompson  * modification, are permitted provided that the following conditions
802ac6454SAndrew Thompson  * are met:
902ac6454SAndrew Thompson  * 1. Redistributions of source code must retain the above copyright
1002ac6454SAndrew Thompson  *    notice, this list of conditions and the following disclaimer.
1102ac6454SAndrew Thompson  * 2. Redistributions in binary form must reproduce the above copyright
1202ac6454SAndrew Thompson  *    notice, this list of conditions and the following disclaimer in the
1302ac6454SAndrew Thompson  *    documentation and/or other materials provided with the distribution.
1402ac6454SAndrew Thompson  *
1502ac6454SAndrew Thompson  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1602ac6454SAndrew Thompson  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1702ac6454SAndrew Thompson  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1802ac6454SAndrew Thompson  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1902ac6454SAndrew Thompson  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2002ac6454SAndrew Thompson  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2102ac6454SAndrew Thompson  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2202ac6454SAndrew Thompson  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2302ac6454SAndrew Thompson  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2402ac6454SAndrew Thompson  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2502ac6454SAndrew Thompson  * SUCH DAMAGE.
2602ac6454SAndrew Thompson  */
2702ac6454SAndrew Thompson 
2875973647SAndrew Thompson #ifndef _USB_REQUEST_H_
2975973647SAndrew Thompson #define	_USB_REQUEST_H_
3002ac6454SAndrew Thompson 
31760bc48eSAndrew Thompson struct usb_process;
3202ac6454SAndrew Thompson 
33a593f6b8SAndrew Thompson usb_error_t usbd_req_clear_hub_feature(struct usb_device *udev,
3402ac6454SAndrew Thompson 		    struct mtx *mtx, uint16_t sel);
35a593f6b8SAndrew Thompson usb_error_t usbd_req_clear_port_feature(struct usb_device *udev,
3602ac6454SAndrew Thompson 		    struct mtx *mtx, uint8_t port, uint16_t sel);
37a593f6b8SAndrew Thompson usb_error_t usbd_req_get_alt_interface_no(struct usb_device *udev,
3802ac6454SAndrew Thompson 		    struct mtx *mtx, uint8_t *alt_iface_no,
3902ac6454SAndrew Thompson 		    uint8_t iface_index);
40a593f6b8SAndrew Thompson usb_error_t usbd_req_get_config(struct usb_device *udev, struct mtx *mtx,
4102ac6454SAndrew Thompson 		    uint8_t *pconf);
42a593f6b8SAndrew Thompson usb_error_t usbd_req_get_descriptor_ptr(struct usb_device *udev,
43760bc48eSAndrew Thompson 		    struct usb_config_descriptor **ppcd, uint16_t wValue);
44a593f6b8SAndrew Thompson usb_error_t usbd_req_get_config_desc(struct usb_device *udev, struct mtx *mtx,
45760bc48eSAndrew Thompson 		    struct usb_config_descriptor *d, uint8_t conf_index);
46a593f6b8SAndrew Thompson usb_error_t usbd_req_get_config_desc_full(struct usb_device *udev,
47760bc48eSAndrew Thompson 		    struct mtx *mtx, struct usb_config_descriptor **ppcd,
482c79a775SHans Petter Selasky 		    uint8_t conf_index);
49a593f6b8SAndrew Thompson usb_error_t usbd_req_get_desc(struct usb_device *udev, struct mtx *mtx,
5016589beaSAndrew Thompson 		    uint16_t *actlen, void *desc, uint16_t min_len,
5116589beaSAndrew Thompson 		    uint16_t max_len, uint16_t id, uint8_t type,
5216589beaSAndrew Thompson 		    uint8_t index, uint8_t retries);
53a593f6b8SAndrew Thompson usb_error_t usbd_req_get_device_desc(struct usb_device *udev, struct mtx *mtx,
54760bc48eSAndrew Thompson 		    struct usb_device_descriptor *d);
55a593f6b8SAndrew Thompson usb_error_t usbd_req_get_device_status(struct usb_device *udev,
56760bc48eSAndrew Thompson 		    struct mtx *mtx, struct usb_status *st);
57a593f6b8SAndrew Thompson usb_error_t usbd_req_get_hub_descriptor(struct usb_device *udev,
58760bc48eSAndrew Thompson 		    struct mtx *mtx, struct usb_hub_descriptor *hd,
5902ac6454SAndrew Thompson 		    uint8_t nports);
60963169b4SHans Petter Selasky usb_error_t usbd_req_get_ss_hub_descriptor(struct usb_device *udev,
61963169b4SHans Petter Selasky 		    struct mtx *mtx, struct usb_hub_ss_descriptor *hd,
62963169b4SHans Petter Selasky 		    uint8_t nports);
63a593f6b8SAndrew Thompson usb_error_t usbd_req_get_hub_status(struct usb_device *udev, struct mtx *mtx,
64760bc48eSAndrew Thompson 		    struct usb_hub_status *st);
65a593f6b8SAndrew Thompson usb_error_t usbd_req_get_port_status(struct usb_device *udev, struct mtx *mtx,
66760bc48eSAndrew Thompson 		    struct usb_port_status *ps, uint8_t port);
67a593f6b8SAndrew Thompson usb_error_t usbd_req_reset_port(struct usb_device *udev, struct mtx *mtx,
6802ac6454SAndrew Thompson 		    uint8_t port);
69cbb75751SHans Petter Selasky usb_error_t usbd_req_warm_reset_port(struct usb_device *udev,
70cbb75751SHans Petter Selasky 		    struct mtx *mtx, uint8_t port);
71a593f6b8SAndrew Thompson usb_error_t usbd_req_set_address(struct usb_device *udev, struct mtx *mtx,
7202ac6454SAndrew Thompson 		    uint16_t addr);
73a593f6b8SAndrew Thompson usb_error_t usbd_req_set_hub_feature(struct usb_device *udev, struct mtx *mtx,
7402ac6454SAndrew Thompson 		    uint16_t sel);
75a593f6b8SAndrew Thompson usb_error_t usbd_req_set_port_feature(struct usb_device *udev,
7602ac6454SAndrew Thompson 		    struct mtx *mtx, uint8_t port, uint16_t sel);
77963169b4SHans Petter Selasky usb_error_t usbd_setup_device_desc(struct usb_device *udev, struct mtx *mtx);
78a593f6b8SAndrew Thompson usb_error_t usbd_req_re_enumerate(struct usb_device *udev, struct mtx *mtx);
79963169b4SHans Petter Selasky usb_error_t usbd_req_clear_device_feature(struct usb_device *udev,
80963169b4SHans Petter Selasky 		    struct mtx *mtx, uint16_t sel);
81963169b4SHans Petter Selasky usb_error_t usbd_req_set_device_feature(struct usb_device *udev,
82963169b4SHans Petter Selasky 		    struct mtx *mtx, uint16_t sel);
83963169b4SHans Petter Selasky usb_error_t usbd_req_set_hub_u1_timeout(struct usb_device *udev,
84963169b4SHans Petter Selasky 		    struct mtx *mtx, uint8_t port, uint8_t timeout);
85963169b4SHans Petter Selasky usb_error_t usbd_req_set_hub_u2_timeout(struct usb_device *udev,
86963169b4SHans Petter Selasky 		    struct mtx *mtx, uint8_t port, uint8_t timeout);
87963169b4SHans Petter Selasky usb_error_t usbd_req_set_hub_depth(struct usb_device *udev,
88963169b4SHans Petter Selasky 		    struct mtx *mtx, uint16_t depth);
899eb0d702SHans Petter Selasky usb_error_t usbd_req_reset_tt(struct usb_device *udev, struct mtx *mtx,
909eb0d702SHans Petter Selasky 		    uint8_t port);
919eb0d702SHans Petter Selasky usb_error_t usbd_req_clear_tt_buffer(struct usb_device *udev, struct mtx *mtx,
929eb0d702SHans Petter Selasky 		    uint8_t port, uint8_t addr, uint8_t type, uint8_t endpoint);
934131f6fbSHans Petter Selasky usb_error_t usbd_req_set_port_link_state(struct usb_device *udev,
944131f6fbSHans Petter Selasky 		    struct mtx *mtx, uint8_t port, uint8_t link_state);
954563ba7aSHans Petter Selasky usb_error_t usbd_req_set_lpm_info(struct usb_device *udev, struct mtx *mtx,
964563ba7aSHans Petter Selasky 		    uint8_t port, uint8_t besl, uint8_t addr, uint8_t rwe);
9702ac6454SAndrew Thompson 
982c79a775SHans Petter Selasky void *	usbd_alloc_config_desc(struct usb_device *, uint32_t);
992c79a775SHans Petter Selasky void	usbd_free_config_desc(struct usb_device *, void *);
1002c79a775SHans Petter Selasky 
10175973647SAndrew Thompson #endif					/* _USB_REQUEST_H_ */
102